aboutsummaryrefslogtreecommitdiff
path: root/src/cffc.hff
diff options
context:
space:
mode:
Diffstat (limited to 'src/cffc.hff')
-rw-r--r--src/cffc.hff48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/cffc.hff b/src/cffc.hff
index 1c80b3a..d327766 100644
--- a/src/cffc.hff
+++ b/src/cffc.hff
@@ -119,6 +119,7 @@ struct Type {
struct Fn;
struct Expan;
struct IRCtx;
+struct Block;
struct Parser {
fp *FILE,
irctx *IRCtx,
@@ -128,6 +129,7 @@ struct Parser {
curfn *Fn,
curenv *Env,
curloop int,
+ curblock *Block,
curexpan *Expan,
expanno int,
loopid int,
@@ -154,6 +156,13 @@ enum UnOp {
}
struct Stmt;
+struct Defers;
+struct Block {
+ sts [#]Stmt,
+ defers *Defers,
+ id int,
+}
+
struct Expr {
loc Loc,
ty *const Type,
@@ -180,13 +189,21 @@ struct Expr {
EUnionIni struct { var *const AggField, ex *Expr },
AggIni struct { flds [#]*const AggField, exs [#]Expr },
ArrIni struct { idxs [#]u32, exs [#]Expr, maxn i64 },
- Stmt [#]Stmt,
+ Stmt Block,
}
}
+
+struct Defers {
+ next *Defers,
+ blockid int,
+ age int,
+ ex Expr
+}
+
struct ISwitchCase {
es [#]Expr,
- t [#]Stmt
+ t Block
}
struct EUSwitchCase {
@@ -196,35 +213,36 @@ struct EUSwitchCase {
variant int,
captty *const Type,
fld *AggField,
- t [#]Stmt
+ t Block
}
struct CSwitchCase {
test Expr,
- t [#]Stmt,
+ t Block,
}
struct Stmt {
loc Loc,
u enum union {
- Block [#]Stmt,
- If struct { test Expr, t [#]Stmt, f [#]Stmt },
- While struct { test Expr, body [#]Stmt, id int },
+ Block Block,
+ If struct { test Expr, t Block, f Block },
+ While struct { test Expr, body Block, id int },
+ DoWhile struct { test Expr, body Block, id int },
For struct {
- ini [#]Stmt,
+ ini Block,
test Expr,
next Option<Expr>,
- body [#]Stmt,
+ body Block,
id int,
},
Break #{loopid} int,
Continue #{loopid} int,
- Return Option<Expr>,
+ Return struct { ex Option<Expr>, deferage int },
Expr Expr,
Decl *Decl,
- ISwitch struct { ex Expr, cs [#]ISwitchCase, f [#]Stmt },
- EUSwitch struct { ex Expr, cs [#]EUSwitchCase, f [#]Stmt },
- CSwitch struct { cs [#]CSwitchCase, f [#]Stmt }
+ ISwitch struct { ex Expr, cs [#]ISwitchCase, f Block },
+ EUSwitch struct { ex Expr, cs [#]EUSwitchCase, f Block },
+ CSwitch struct { cs [#]CSwitchCase, f Block }
}
}
@@ -233,7 +251,7 @@ struct Fn {
paramnames [#]*const u8,
variadic bool,
id int,
- body Option<[#]Stmt>
+ body Option<Block>
}
struct Var {
@@ -340,6 +358,7 @@ struct Targ {
sizesize u8,
f64align u8,
valistsize u8, valistalign u8,
+ valistllvmty *const u8,
charsigned bool,
shortenum bool,
@@ -443,6 +462,7 @@ extern fn types_to_llvm() void;
extern fn mkenv(parent *Env, alloc *Allocator) *Env;
extern fn envparent(*Env) *Env;
extern fn envput(*Env, Decl, **const Decl) *Decl;
+extern fn envput_alloc(*Env, *Allocator, Decl, **const Decl) *Decl;
extern fn envfind(*Env, *const u8) *Decl;
extern fn envfind_noparent(*Env, *const u8) *Decl;
extern fn envfree(*Env) void;