Language: yield/signal/coroutine become keywords, start is contextual. Coroutine methods (func Name() coroutine) with start and yield / wait / frames / fixed / await; signals with Emit/Connect and Connection handles; ScriptRef<T> and node.GetScript<T>() for fields, plain methods and signals of other scripts. Diagnostics AES2050-AES2059. Bytecode v3: ScriptRefs, XFields, XMethods and Connects tables resolved by name in vm.Link, per-script signals, coroutine flag on functions; new opcodes START/YIELD/EMIT/CONNECT/DISCONNECT/CONNECTED/COSTOP/CORUN/ SELFREF/GETSCRIPT/GETXF/SETXF/CALLR, checked by verify. Runtime: script/coroutine scheduler (frames/fixed counters, time heap, await lists; only due coroutines are visited) and script/signal registry (snapshot per Emit, deferred removal, no allocations in steady state). Hot reload cancels coroutines of changed scripts, rebinds connections by name and signature, then runs Reloaded. Tooling: script/build removed, aego check/test/dump run on the workspace (test builds include _test.aes); langsvc completion, hover, signatures and semantic tokens for the new syntax; editor highlighting, snippets with placeholders, coroutine/signal profiler graphs and stats. Docs (script.md sections 16-19, editor.md, ARCHITECTURE), test fixtures and golden files, platformer enemies wired to the player, scriptreload demo, and run.Config.FrameTime for deterministic headless fixed steps. Modules (6.5): engine/module registry and ComponentBuilder are the one registration path for engine subsystems and native code; render2d, render3d and script/engine are modules over scene/frame, the script component moved to scene/scriptcomp, and scene/components and scene/systems are gone. Editor inspector, templates, picking shapes and extension hooks are driven by descriptors and editor/builtins; sdk gains Component/EditorHook; depcheck checks the module graph and the aego_runtime graph. Also: stop tracking built tool binaries; gl33 activates the scratch unit before binding for texture updates. Verification: typed component method adapters (Method0..2, Proc0..2) with direct field access and no allocations; app.Build as the single construction path for run and the editor; modules attach per scene document; depcheck aego_editor pass; diagnostic codes in one place and every code covered by a test; indexed coroutine heaps with eager cancel; dead component references and nil intrinsics fault with AES6004, host faults keep their code; GC roots of struct fields checked in verify and vm.Link; 255-field limit; AES4010 for script packages shadowing host modules; architecture registry D111-D147. Golden: the harness renders on the thread that owns the GL context, ReadPixels returns rows in memory order (render targets are top-down per D17), and the first rendering references are committed.
84 lines
1.5 KiB
Go
84 lines
1.5 KiB
Go
package vm
|
|
|
|
const staticBit = uint64(1) << 63
|
|
|
|
type object struct {
|
|
gen uint32
|
|
live bool
|
|
mark bool
|
|
str bool
|
|
s string
|
|
elems []Value
|
|
width int
|
|
mask uint32
|
|
size int
|
|
}
|
|
|
|
type Heap struct {
|
|
objs []object
|
|
free []uint32
|
|
live int
|
|
bytes int
|
|
since int
|
|
}
|
|
|
|
func heapHandle(idx, gen uint32) uint64 {
|
|
return uint64(idx)<<32 | uint64(gen)
|
|
}
|
|
|
|
func (h *Heap) alloc(size int) (uint32, *object) {
|
|
var idx uint32
|
|
if n := len(h.free); n > 0 {
|
|
idx = h.free[n-1]
|
|
h.free = h.free[:n-1]
|
|
} else {
|
|
h.objs = append(h.objs, object{})
|
|
idx = uint32(len(h.objs) - 1)
|
|
}
|
|
o := &h.objs[idx]
|
|
o.gen++
|
|
if o.gen == 0 {
|
|
o.gen = 1
|
|
}
|
|
o.live, o.mark, o.size = true, false, size
|
|
h.live++
|
|
h.bytes += size
|
|
h.since += size
|
|
return idx, o
|
|
}
|
|
|
|
func (h *Heap) get(a uint64) *object {
|
|
if a == 0 || a&staticBit != 0 {
|
|
return nil
|
|
}
|
|
idx := uint32(a >> 32)
|
|
if int(idx) >= len(h.objs) {
|
|
return nil
|
|
}
|
|
o := &h.objs[idx]
|
|
if !o.live || o.gen != uint32(a) {
|
|
return nil
|
|
}
|
|
return o
|
|
}
|
|
|
|
func (h *Heap) newString(s string) Value {
|
|
idx, o := h.alloc(len(s) + 32)
|
|
o.str, o.s, o.elems, o.width, o.mask = true, s, nil, 0, 0
|
|
return Value{A: heapHandle(idx, o.gen)}
|
|
}
|
|
|
|
func (h *Heap) newSlice(width int, mask uint32, capacity int) Value {
|
|
idx, o := h.alloc(capacity*width*16 + 48)
|
|
o.str, o.s = false, ""
|
|
o.elems = make([]Value, 0, capacity*width)
|
|
o.width, o.mask = width, mask
|
|
return Value{A: heapHandle(idx, o.gen)}
|
|
}
|
|
|
|
func (h *Heap) grow(o *object, delta int) {
|
|
o.size += delta
|
|
h.bytes += delta
|
|
h.since += delta
|
|
}
|