duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 997c5cba462045157a695102fc6d2d7e0cc2b2ed
parent 362ef3986cce1109bb8f4a81cbdc8f2973d72085
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed, 10 Aug 2022 12:07:14 -0400

In structs, move the field code into the fields themselves

Previously, the struct compiler would dereference the field's method (either a
"val" or a ":method") and compile it. Now, we have the field directly hold its
word. This makes referencing fields faster and it also opens the door to further
simplifications.

Diffstat:
Mfs/xcomp/bootlo.fs | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -180,16 +180,18 @@ alias noop [then] : _getinst' ( 'struct -- ''inst ) CELLSZ + ; : _getinst ( 'struct -- 'inst ) _getinst' @ ; : (struct()) ( off 'struct -- a ) _getinst + ; -: (struct) ( off 'struct ) _getinst + ?toexec ; -: (struct:) ( off 'struct ) - _getinst + to? ?dup if execute else @ execute then ; +: (struct) ( 'struct off ) swap _getinst + ?toexec ; +: (struct:) ( 'struct off ) + swap _getinst + to? ?dup if execute else @ execute then ; : _parens ( 'struct off ) compiling if litn litn compile (struct()) else swap (struct()) then ; : 'structsz ( 'struct -- sz ) @ llcnt CELLSZ * ; : structsz ( w -- sz ) does' 'structsz ; : struct ( cnt -- ) doer >r here 0 , 0 , 0 begin ( 'dict off ) - over word entry ( 'dict off ) dup , CELLSZ + next ( 'dict off ) + over word entry ( 'dict off ) dup litn + curword 1+ c@ ':' = if compile (struct:) else compile (struct) then exit, + CELLSZ + next ( 'dict off ) 2drop immediate does> ( ??? 'struct -- ??? *to* ) word case ( 'struct R:str ) @@ -198,9 +200,7 @@ does> ( ??? 'struct -- ??? *to* ) \ find field in list curword over @ ( 'struct str 'dict ) find ( 'struct 'field ) ?dup not if curword stype abort" field doesn't exist!" then - @ ( 'struct off ) - curword 1+ c@ ':' = if ['] (struct:) else ['] (struct) then >r - compiling if litn litn r> execute, else swap r> execute then + compiling if swap litn execute, else execute then endcase ; : _inst! ( 'inst -- ) dup CELLSZ + swap @ ( 'inst w ) does' _getinst' ! ;