aboutsummaryrefslogtreecommitdiff
path: root/src/move.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/move.c')
-rw-r--r--src/move.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/move.c b/src/move.c
index 9e8cfa0..2a55d3d 100644
--- a/src/move.c
+++ b/src/move.c
@@ -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;
}