commit 336a34a9ce67e938a64a545a5f75c7385886dfc3
parent 1ee9e9acde1a53eb333374092c5e6641b5a88ce6
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 23 Jun 2022 13:32:26 -0400
cc: make vmap into a struct
Diffstat:
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs
@@ -55,8 +55,8 @@ alias noop gennode ( node -- ) \ forward declaration
: spit ( a u -- ) A>r >r >A begin Ac@+ .x1 next r>A ;
: getfuncmap ( node -- funcentry ) AST_FUNCTION parentnodeid data2 ;
-: lvvar ( lvnode -- varentry )
- dup data1 swap getfuncmap ( name funcentry ) findvarinmap ;
+: lvvar ( lvnode -- ) \ sets Varmap
+ dup data1 swap getfuncmap ( name funcentry ) findvarinmap to Varmap ;
\ Multiply the value of "node" by a factor of "n"
\ TODO: support lvalues and expressions
@@ -152,7 +152,7 @@ ASTIDCNT wordtbl gentbl ( node -- )
firstchild ?dup if begin dup gennode ops$ nextsibling ?dup not until then ;
'w genchildren ( ArgSpecs )
:w ( LValue )
- lvvar dup vmap.sfoff sf+>op ( vmap )
+ lvvar vmap.sfoff sf+>op ( )
vmap.decl data3 ( nbelem ) 1 > if &op>op then ;
:w ( UnaryOp )
_debug if ." unaryop: " dup printast nl> .ops then
diff --git a/fs/cc/map.fs b/fs/cc/map.fs
@@ -28,8 +28,10 @@ newxdict curmap
: fmap.address 12 + @ ;
: fmap.address! 12 + ! ;
: fmap.vmap 16 + ;
-: vmap.sfoff @ ;
-: vmap.decl 4 + @ ;
+
+struct Varmap
+ field vmap.sfoff
+ field vmap.decl
: _err ( -- ) abort" mapping error" ;
\ print curmap in reverse order of parsing
@@ -37,9 +39,9 @@ newxdict curmap
curmap @ ?dup not if exit then begin ( w )
dup wordname[] rtype spc>
dup fmap.sfsize .x spc> dup fmap.argsize .x nl>
- dup fmap.vmap @ ?dup if begin ( w vmap )
- spc> spc> dup wordname[] rtype spc> dup vmap.sfoff .x nl>
- prevword ?dup not until then ( w )
+ dup fmap.vmap @ ?dup if begin ( w vmap ) to Varmap
+ spc> spc> Varmap wordname[] rtype spc> vmap.sfoff .x nl>
+ Varmap prevword ?dup not until then ( w )
prevword ?dup not until ;
: Function ( astnode -- entry )