diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-12-29 00:07:16 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-01-06 17:19:52 +0200 |
| commit | c7b41b47d038fd4973da05224b7aa29efaae1784 (patch) | |
| tree | ad439ff996aa5121bced46bdb7e42eb419702be0 /src/move.c | |
| parent | d501b2c9ebab6f5b90c808ea0e5fde912818707d (diff) | |
| download | fwd-c7b41b47d038fd4973da05224b7aa29efaae1784.tar.gz fwd-c7b41b47d038fd4973da05224b7aa29efaae1784.zip | |
work towards a simple integer vector implementation
+ Hopefully shows that useful programs can be implemented with
the rules present
+ Still missing at least external functions with non-void returns
Diffstat (limited to 'src/move.c')
| -rw-r--r-- | src/move.c | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -418,6 +418,7 @@ static int mvcheck_if(struct state *state, struct ast *node) return -1; } + if (if_else(node)) if (mvcheck(&else_state, if_else(node))) { destroy_state(&body_state); destroy_state(&else_state); @@ -480,6 +481,46 @@ static int mvcheck_statements(struct state *state, struct ast *nodes) return 0; } +static int mvcheck_construct(struct state *state, struct ast *node) +{ + foreach_node(expr, construct_members(node)) { + if (mvcheck(state, expr)) + return -1; + } + + return 0; +} + +static int mvcheck_construction(struct state *state, struct ast *node) +{ + return mvcheck(state, construction_expr(node)); +} + +static int mvcheck_as(struct state *state, struct ast *as) +{ + return mvcheck(state, as_expr(as)); +} + +static int mvcheck_forget(struct state *state, struct ast *node) +{ + struct ast *def = file_scope_find_symbol(node->scope, forget_id(node)); + assert(def); + + /* act as if a move has happened */ + insert_move(state, def, node); + return 0; +} + +static int mvcheck_explode(struct state *state, struct ast *node) +{ + return mvcheck(state, explode_expr(node)); +} + +static int mvcheck_write(struct state *state, struct ast *node) +{ + return mvcheck(state, write_src(node)); +} + static int mvcheck(struct state *state, struct ast *node) { if (is_unop(node)) @@ -502,12 +543,22 @@ static int mvcheck(struct state *state, struct ast *node) case AST_IF: return mvcheck_if (state, node); case AST_REF: return mvcheck_ref (state, node); case AST_DEREF: return mvcheck_deref (state, node); + case AST_CONSTRUCT: return mvcheck_construct (state, node); + case AST_AS: return mvcheck_as (state, node); + case AST_FORGET: return mvcheck_forget (state, node); + case AST_EXPLODE: return mvcheck_explode (state, node); + case AST_WRITE: return mvcheck_write (state, node); + case AST_CONSTRUCTION: return mvcheck_construction(state, node); + case AST_NIL_CHECK: + case AST_SIZEOF: + case AST_STRUCT_DEF: case AST_EMPTY: case AST_IMPORT: case AST_CONST_INT: case AST_CONST_STR: case AST_CONST_FLOAT: case AST_CONST_CHAR: + case AST_NIL: return 0; default: break; } |
