aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-11-19 18:41:55 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2023-11-19 18:41:55 +0200
commit8f754f8b13e55e4bb92d72f105c5aaaba1754b7d (patch)
treeb70b813c091691d6645f8cb82295f41f24f3be93 /src/ast.c
parent5304dbcf4df1fc211b5099f4d6eb7f23dfa8c454 (diff)
downloadek-8f754f8b13e55e4bb92d72f105c5aaaba1754b7d.tar.gz
ek-8f754f8b13e55e4bb92d72f105c5aaaba1754b7d.zip
start working on instruction lowering
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/ast.c b/src/ast.c
index 5187066..0fc7c8c 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -453,14 +453,14 @@ struct ast_node *gen_var(struct ast_node *id, struct ast_node *type,
}
struct ast_node *gen_proc(struct ast_node *id, struct ast_node *sign,
- struct ast_node *body)
+ struct ast_node *body, struct src_loc loc)
{
ALLOC_NODE(n, "proc");
n->node_type = AST_PROC;
- n->_proc.id = id;
- n->_proc.sign = sign;
- n->_proc.body = body;
- n->loc = id->loc;
+ AST_PROC(n).id = id;
+ AST_PROC(n).sign = sign;
+ AST_PROC(n).body = body;
+ n->loc = loc;
return n;
}
@@ -1215,7 +1215,8 @@ struct ast_node *clone_ast_node(struct ast_node *node)
case AST_PROC: new = gen_proc(clone_ast_node(node->_proc.id),
clone_ast_node(node->_proc.sign),
- clone_ast_node(node->_proc.body));
+ clone_ast_node(node->_proc.body),
+ node->loc);
break;
case AST_VAR: {
@@ -1307,9 +1308,10 @@ struct ast_node *clone_ast_node(struct ast_node *node)
break;
case AST_TYPE_SIGN:
- new = gen_type(AST_TYPE_SIGN, NULL,
+ new = gen_type(AST_TYPE_SIGN,
clone_ast_node(AST_SIGN_TYPE(node).params),
- clone_ast_node(AST_SIGN_TYPE(node).ret));
+ clone_ast_node(AST_SIGN_TYPE(node).ret),
+ NULL);
break;
}