From f0214ff61b5a94b9629db6f43d7a5b010bd4ffbc Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 18 Aug 2022 09:47:54 +0200 Subject: fix bodyarg --- src/cffc.hff | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/cffc.hff') diff --git a/src/cffc.hff b/src/cffc.hff index aad2ee4..ad6a8aa 100644 --- a/src/cffc.hff +++ b/src/cffc.hff @@ -119,11 +119,13 @@ struct Parser { curenv *Env, curloop int, loopid int, + targty *const Type, tokloc Loc, curloc Loc, eof bool, is_header bool, peekchr Option, + peektok Option, } @@ -152,6 +154,8 @@ struct Expr { BinOp struct { op TokT, lhs *Expr, rhs *Expr }, UnOp struct { op UnOp, ex *Expr }, Cond struct { test *Expr, t *Expr, f *Expr }, + Cast *Expr, + Dot struct { lhs *Expr, fld *const AggField }, Index struct { lhs *Expr, rhs *Expr }, Slice struct { lhs *Expr, begin *Expr, end *Expr }, Call struct { lhs *Expr, args [#]Expr }, @@ -200,6 +204,7 @@ struct Var { struct MacroCase { variadic bool, + bodyarg bool, params [#]*const u8, body [#]Tok, } @@ -220,6 +225,7 @@ struct Decl { Macro Macro, Ty *const Type, }, + myenv *Env, } struct DeclList { @@ -311,12 +317,8 @@ fn mkptrtype(child *const Type) *const Type { .u: :Ptr(child) }); } -fn mkslicetype(child *const Type) *const Type { - return interntype({ - g_targ.ptrsize, - .u: :Ptr(child) - }); -} +extern fn mkslicetype(child *const Type) *const Type; + fn childtype(ty *const Type) *const Type { switch ty.u { case Ptr t; return t; @@ -326,7 +328,9 @@ fn childtype(ty *const Type) *const Type { return #null; } extern fn completetype(ty *const Type) bool; -extern fn isnumtype(ty *const Type) bool; +fn isnumtype(ty *const Type) bool { + return ty->is(:Int) or ty->is(:Flo); +} extern fn typeof2(a *const Type, b *const Type) *const Type; // env.cff -- cgit v1.2.3