025-frame-locals.M1pp (811B)
1 # %frame / %endframe + %local(name): set a single-slot "current frame"; 2 # %local(name) looks up <frame>_FRAME.<name> (typically a %struct- 3 # generated zero-arg macro) and emits its body. 4 # 5 # Frames are independent of (now-removed) scope handling. They drive 6 # only the %local lookup. A %frame must be closed by %endframe before 7 # end-of-input; nesting is forbidden. 8 # 9 # Also exercises %local as an expression atom: composes inside %( ... ) 10 # arithmetic. 11 12 %struct foo_FRAME { a b c } 13 14 %frame foo 15 %local(a) 16 %local(b) 17 %local(c) 18 19 # %local inside an arithmetic expression — yields offset+100. 20 %((+ %local(b) 100)) 21 22 %endframe 23 24 # A second frame after the first is closed — confirms that frame state 25 # is properly reset and a fresh frame can be opened. 26 %struct bar_FRAME { x y } 27 %frame bar 28 %local(y) 29 %endframe 30 31 END