aboutsummaryrefslogtreecommitdiff
path: root/compiler/ast.cup
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/ast.cup')
-rw-r--r--compiler/ast.cup11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/ast.cup b/compiler/ast.cup
index 82e8477..2ba677b 100644
--- a/compiler/ast.cup
+++ b/compiler/ast.cup
@@ -1,5 +1,6 @@
-import "std/vector.cup"
+import "compiler/tokens.cup"
import "compiler/types.cup"
+import "std/vector.cup"
enum NodeType {
// Unary
@@ -149,6 +150,14 @@ fn node_from_int_literal(val: int): Node* {
return node;
}
+fn variable_new(name: char*, typ: Type*, offset: int): Variable* {
+ let v: Variable* = malloc(sizeof(Variable));
+ v.name = name;
+ v.typ = typ;
+ v.offset = offset;
+ return v;
+}
+
fn block_add_child(block: Node*, child: Node*) {
if (block.d.block.children == null)
block.d.block.children = vector_new();