duskos

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

commit 9981267a324c3523d22aeb0f87de5171b9977f26
parent c5c622ead3273e110a08353e5f2500c0aba379f5
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed, 26 Oct 2022 09:08:39 -0400

cc: code consolidation

Diffstat:
Mfs/cc/ast.fs | 18+++++++++---------
Mfs/cc/cc.fs | 3+--
2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/fs/cc/ast.fs b/fs/cc/ast.fs @@ -506,26 +506,26 @@ alias noop parseStatement ( funcnode -- ) \ forward declaration current to parseStatement \ returntype, name and '(' have already been parsed, parse the rest -: parseFuncDef ( unitnode type name -- ) +: parseFuncDef ( unitnode type name -- fnode ) Function :new ( unode type fnode ) dup dup Function name addSymbol swap parseFuncArgs over Node :add ( unode fnode ) - dup rot Node :add ( fnode ) parseStatement ; + dup rot Node :add ( fnode ) dup parseStatement ; -: parseGlobalDecl ( unitnode ctype -- ) +: parseGlobalDecl ( unitnode ctype -- dnode ) Declare :new ( unode dnode ) dup rot Node :add ( dnode ) dup dup Declare :name addSymbol - STORAGE_MEM over Declare ctype to CType storage - nextt parseDeclareInit read; ; + STORAGE_MEM over Declare ctype to CType storage ( dnode ) + dup nextt parseDeclareInit read; ; \\ Parse the next element in a Unit node -: parseUnit ( unitnode tok -- ) - dup S" #[" s= if drop #[0 drop exit then +: parseUnit ( unitnode tok -- node-or-0 ) + dup S" #[" s= if drop #[0 drop 0 exit then 0 to curstatic dup S" static" s= if drop nextt 1 to curstatic then parseType _assert ( unode type ) nextt dup ';' isChar? if \ Only a type on a line is fine, carry on - 2drop drop exit then + 2drop drop 0 exit then to nexttputback parseVariable ( unode ctype ) nextt dup S" (" s= if drop dup CType type swap CType name parseFuncDef else to nexttputback parseGlobalDecl then ; @@ -533,5 +533,5 @@ current to parseStatement : newparseunit ( -- unit ) AST_UNIT ASTNode :new dup to curunit ; : parseast ( -- ) newparseunit - begin ( unode ) nextt? ?dup while over swap parseUnit repeat drop + begin ( unode ) nextt? ?dup while over swap parseUnit drop repeat drop _ccdebug if nl> ." used pad space for AST: " _pad :usedsz .x nl> then ; diff --git a/fs/cc/cc.fs b/fs/cc/cc.fs @@ -16,8 +16,7 @@ curunit gennode ; : :c - newparseunit nextt parseUnit - curunit Node firstchild ?dup if + newparseunit nextt parseUnit ?dup if _ccdebug if dup printast nl> then dup trnode _ccdebug if dup printast nl> then gennode then ;