commit cfaeeaab9bbeb78382b6ce65526c002f6e4a75c8
parent 29e4eff849ad3bc03f17cb356d01e6e0b8d43bf0
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Mon, 13 Jun 2022 10:04:53 -0400
cc: remove "name" data from AST_ASSIGN node
It is redundant with its parent (AST_DECLARE) data.
Diffstat:
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/cc/ast.fs b/fs/cc/ast.fs
@@ -51,7 +51,7 @@ create bopsprectbl 1 c, 1 c, 0 c, 0 c, 2 c, 2 c, 2 c, 2 c,
8 value AST_UNARYOP \ data1=uopid
\ 9 = unused
10 value AST_BINARYOP \ data1=bopid
-11 value AST_ASSIGN \ data1=name
+11 value AST_ASSIGN
\ 12 = unused
13 value AST_VARIABLE \ data1=name
14 value AST_FUNCALL \ data1=name data2=MAP_FUNCTION
@@ -85,7 +85,7 @@ ASTIDCNT wordtbl astdatatbl ( node -- node )
:w ( UnaryOp ) _[ dup data1 uopchar emit _] ;
'w noop ( Unused )
:w ( BinaryOp ) _[ dup data1 boptoken stype _] ;
-'w _s ( Assign )
+'w noop ( Assign )
'w noop ( Unused )
'w _s ( Variable )
'w _s ( FunCall )
@@ -182,9 +182,7 @@ ASTIDCNT wordtbl astdatatbl ( node -- node )
then ;
: parseAssign ( parentnode tok -- )
- '=' expectChar
- AST_ASSIGN createnode ( pnode anode ) over data1 ( name ) ,
- dup rot addnode ( anode )
+ '=' expectChar AST_ASSIGN newnode ( anode )
_nextt parseExpression read; ( anode expr ) swap addnode ;
: parseDeclarationList ( stmtsnode -- )
diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs
@@ -62,6 +62,10 @@ alias noop gennode ( node -- ) \ forward declaration
: spit ( a u -- ) A>r >r >A begin Ac@+ .x1 spc> next r>A ;
: getfuncmap ( node -- funcentry ) AST_FUNCTION parentnodeid data2 ;
+\ get SF offset of AST_DECLARE node
+: declsfoff ( dnode -- off )
+ dup data1 swap getfuncmap ( name funcentry ) findvarinmap ( varentry )
+ vmap.sfoff ;
ASTIDCNT wordtbl gentbl ( node -- )
'w genchildren ( Declare )
@@ -94,9 +98,7 @@ ASTIDCNT wordtbl gentbl ( node -- )
gennode bopgentblmiddle r@ data1 wexec eax push,
gennode ebx pop, bopgentblpost r> data1 wexec ;
:w ( Assign )
- dup genchildren ( node )
- dup data1 ( node name )
- swap getfuncmap findvarinmap ( varnode ) vmap.sfoff
+ dup genchildren ( node ) parentnode ( declnode ) declsfoff ( off )
[ebp]+ eax mov, ;
'w genchildren ( DeclarationList )
:w ( Variable )