aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fwd/ast.h61
1 files changed, 33 insertions, 28 deletions
diff --git a/include/fwd/ast.h b/include/fwd/ast.h
index 044a27e..4c8d412 100644
--- a/include/fwd/ast.h
+++ b/include/fwd/ast.h
@@ -32,10 +32,11 @@ struct src_loc {
struct ast;
enum type_kind {
- TYPE_ID = 1, TYPE_REF, TYPE_PTR, TYPE_ARR, TYPE_CLOSURE,
+ TYPE_ID = 1, TYPE_REF, TYPE_PTR, TYPE_CLOSURE,
TYPE_PURE_CLOSURE, TYPE_FUNC_PTR, TYPE_VOID, TYPE_NIL,
TYPE_I8, TYPE_I16, TYPE_I32, TYPE_I64,
- TYPE_U8, TYPE_U16, TYPE_U32, TYPE_U64
+ TYPE_U8, TYPE_U16, TYPE_U32, TYPE_U64,
+ TYPE_BOOL
};
static inline bool is_int_type(enum type_kind k)
@@ -104,6 +105,8 @@ enum ast_kind {
AST_IMPORT,
/** Creating new variable */
AST_LET,
+ AST_PUT,
+ AST_WRITE,
/** If statement */
AST_IF,
/** Nil check */
@@ -116,8 +119,6 @@ enum ast_kind {
AST_PROC_DEF,
/** Variable declaration/definition. */
AST_VAR_DEF,
- /** Dot. \c a.b; */
- AST_DOT,
/* Closure */
AST_CLOSURE,
/** Construct new type, something!{} */
@@ -171,10 +172,11 @@ enum ast_kind {
/** Sizeof */
AST_SIZEOF,
AST_AS,
- AST_ARR,
- AST_ASSIGN,
AST_CONSTRUCTION,
AST_CONSTRUCT,
+ AST_DECONSTRUCTION,
+ AST_DECONSTRUCT,
+ AST_EXPLODE,
AST_SELF,
AST_FORGET,
AST_PASTE,
@@ -202,6 +204,7 @@ enum ast_flag {
AST_FLAG_NOMOVES = (1 << 2),
AST_FLAG_PUBLIC = (1 << 3),
AST_REQ_FRAME = (1 << 4),
+ AST_FLAG_LOWERED = (1 << 5)
};
struct ast {
@@ -323,9 +326,7 @@ static inline bool is_const(struct ast *x)
static inline bool is_lvalue(struct ast *node)
{
switch (node->k) {
- case AST_ARR:
case AST_DEREF:
- case AST_DOT:
case AST_ID:
return true;
@@ -398,10 +399,6 @@ static inline bool is_trivially_copyable(struct type *type)
#define tgen_nil(loc) \
tgen_type(TYPE_NIL, NULL, NULL, loc)
-#define tarr_base(x) return_t0(x, TYPE_ARR)
-#define tgen_arr(base, len, loc) \
- tgen_type(TYPE_ARR, base, len, loc)
-
#define tptr_base(x) return_t0(x, TYPE_PTR)
#define tgen_ptr(base, loc) \
tgen_type(TYPE_PTR, base, NULL, loc)
@@ -414,7 +411,7 @@ static inline bool is_trivially_copyable(struct type *type)
#define tgen_closure(args, loc) \
tgen_type(TYPE_CLOSURE, args, NULL, loc)
-#define tpure_closure_args(x) return_t0(x, TYPE_CLOSURE)
+#define tpure_closure_args(x) return_t0(x, TYPE_PURE_CLOSURE)
#define tgen_pure_closure(args, loc) \
tgen_type(TYPE_PURE_CLOSURE, args, NULL, loc)
@@ -447,6 +444,15 @@ static inline bool is_trivially_copyable(struct type *type)
#define gen_construct(id, members, loc) \
gen_str1(AST_CONSTRUCT, id, members, loc)
+#define deconstruction_id(x) return_s(x, AST_DECONSTRUCTION)
+#define deconstruction_var(x) return_a0(x, AST_DECONSTRUCTION)
+#define gen_deconstruction(id, expr, loc) \
+ gen_str1(AST_DECONSTRUCTION, id, expr, loc)
+
+#define deconstruct_members(x) return_a0(x, AST_DECONSTRUCT)
+#define gen_deconstruct(members, loc) \
+ gen1(AST_DECONSTRUCT, members, loc)
+
#define gen_paste(l, r, loc) \
gen2(AST_PASTE, l, r, loc)
@@ -481,16 +487,6 @@ static inline bool is_trivially_copyable(struct type *type)
#define gen_sizeof(type, loc) \
gen_ast(AST_SIZEOF, NULL, NULL, NULL, NULL, type, NULL, 0, 0., loc)
-#define assign_expr(x) return_a1(x, AST_ASSIGN)
-#define assign_target(x) return_a0(x, AST_ASSIGN)
-#define gen_assign(l, r, loc) \
- gen2(AST_ASSIGN, l, r, loc)
-
-#define arr_base(x) return_a0(x, AST_ARR)
-#define arr_idx(x) return_a1(x, AST_ARR)
-#define gen_arr(base, idx, loc) \
- gen2(AST_ARR, base, idx, loc)
-
#define unop_expr(x) ({assert(is_unop(x)); x->a0;})
#define gen_unop(op, expr, loc) \
gen1(op, expr, loc)
@@ -507,11 +503,6 @@ static inline bool is_trivially_copyable(struct type *type)
#define gen_proc(id, params, rtype, body, loc) \
gen_ast(AST_PROC_DEF, params, body, NULL, NULL, rtype, id, 0, 0., loc)
-#define dot_id(x) return_s(x, AST_DOT)
-#define dot_expr(x) return_a0(x, AST_DOT)
-#define gen_dot(id, expr, loc) \
- gen_str1(AST_DOT, id, expr, loc)
-
#define var_id(x) return_s(x, AST_VAR_DEF)
#define var_type(x) return_t2(x, AST_VAR_DEF)
#define gen_var(id, type, loc) \
@@ -570,6 +561,20 @@ static inline bool is_trivially_copyable(struct type *type)
#define gen_let(var, from, loc) \
gen2(AST_LET, var, from, loc)
+#define put_dst(x) return_a0(x, AST_PUT)
+#define gen_put(dst, loc) \
+ gen1(AST_PUT, dst, loc)
+
+#define write_dst(x) return_a0(x, AST_WRITE)
+#define write_src(x) return_a1(x, AST_WRITE)
+#define gen_write(dst, src, loc) \
+ gen2(AST_WRITE, dst, src, loc)
+
+#define explode_deconstruct(x) return_a0(x, AST_EXPLODE)
+#define explode_expr(x) return_a1(x, AST_EXPLODE)
+#define gen_explode(deconstruct, expr, loc) \
+ gen2(AST_EXPLODE, deconstruct, expr, loc)
+
#define init_args(x) return_t2(x, AST_INIT)
#define init_body(x) return_a0(x, AST_INIT)
#define init_id(x) return_s(x, AST_INIT)