aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gen_code.c3
-rw-r--r--node.h1
-rw-r--r--pc.h2
-rw-r--r--pc.y2
-rw-r--r--scope.c2
-rw-r--r--scope.h1
6 files changed, 10 insertions, 1 deletions
diff --git a/gen_code.c b/gen_code.c
index 9f13a2d..be56e83 100644
--- a/gen_code.c
+++ b/gen_code.c
@@ -123,7 +123,8 @@ ptree *t;
switch (t->type){
case ASSIGNOP:
if (t->l->ret_type == INT) {
- fprintf(stderr, "ASSIGN (INT) %s\n", t->l->attr.nval->name);
+ GEN_EXPR(t->r);
+ fprintf(stdout, "mov %s, ADDR\n", *reg_ptr);
} else {
fprintf(stderr, "ASSIGN (REAL) %s\n", t->l->attr.nval->name);
}
diff --git a/node.h b/node.h
index e59cb86..8bafcc0 100644
--- a/node.h
+++ b/node.h
@@ -17,6 +17,7 @@ typedef struct node_s {
char *name;
struct node_s *next;
int var_type;
+ int offset;
struct fi* func_info;
struct ai* array_info;
diff --git a/pc.h b/pc.h
index 04f8bfe..e49d665 100644
--- a/pc.h
+++ b/pc.h
@@ -13,5 +13,7 @@ int yyerror(char*);
int count_args(ptree*);
int set_func_types(ptree*, int*, int);
int get_call_types(ptree*, int*, int);
+
+#define OFFSET_SIZE 8
#endif
diff --git a/pc.y b/pc.y
index 23b3b24..3753cdf 100644
--- a/pc.y
+++ b/pc.y
@@ -133,6 +133,7 @@ id_list
check_id(cur_scope, $1);
tmp = scope_insert(cur_scope, $1);
+ tmp->offset = cur_scope->offset++;
$$ = mkid(tmp);
}
|id_list ',' ID
@@ -141,6 +142,7 @@ id_list
check_id(cur_scope, $3);
tmp = scope_insert(cur_scope, $3);
+ tmp->offset = cur_scope->offset++;
$$ = mktree(LIST, $1, mkid(tmp));
}
;
diff --git a/scope.c b/scope.c
index d7d50fc..47e5943 100644
--- a/scope.c
+++ b/scope.c
@@ -21,6 +21,8 @@ scope* mkscope()
p->prev = NULL;
p->ret_var= NULL;
+ p->offset = 2;
+
return p;
}
diff --git a/scope.h b/scope.h
index 4fbe9ca..e3af747 100644
--- a/scope.h
+++ b/scope.h
@@ -9,6 +9,7 @@ typedef struct hash {
node* table[HASH_SIZE];
struct hash *prev;
node* ret_var;
+ int offset;
} scope;
scope* mkscope();