fixing still
This commit is contained in:
@ -615,6 +615,7 @@ expression:
|
||||
if(getTypeEntry((TableNode*)$2) == integ) {
|
||||
char* temp = temp_var_gen();
|
||||
TableNode* node = CreateEntry(cur,TYPE_PRIMITIVE, integ, temp, NULL);
|
||||
emit_unary_op(E_NEG,node,tn_or_const(NODE,$2));
|
||||
//NOTE ADD ASSIGNMENT EMIT HERE (MIGHT NEED TO PUSH TO STACK)
|
||||
//result of unary operation
|
||||
$$ = node;
|
||||
@ -630,6 +631,7 @@ expression:
|
||||
if(getTypeEntry((TableNode*)$2) == boo) {
|
||||
char* temp = temp_var_gen();
|
||||
TableNode* node = CreateEntry(cur,TYPE_PRIMITIVE, boo, temp, NULL);
|
||||
emit_unary_op(E_NOT,node,tn_or_const(NODE,$2));
|
||||
//NOTE ADD ASSIGNMENT EMIT HERE (MIGHT NEED TO PUSH TO STACK)
|
||||
//result of unary operation
|
||||
$$ = node;
|
||||
|
@ -121,7 +121,7 @@ int run(FILE *alpha) {
|
||||
|
||||
if (st_flag != NULL) {
|
||||
print_symbol_table(top, st_flag);
|
||||
//emit_as_file(stdout, begin);
|
||||
emit_as_file(stdout, begin);
|
||||
fclose(st_flag);
|
||||
}
|
||||
|
||||
|
@ -1601,6 +1601,7 @@ bool isConst(TNodeOrConst * tnc) {
|
||||
TNodeOrConst * tn_or_const(Discriminant d, void * tnc) {
|
||||
TNodeOrConst * count = calloc(1, sizeof(*count));
|
||||
count->d = d;
|
||||
count->tnc_union = calloc(1, sizeof(*count->tnc_union));
|
||||
switch (d) {
|
||||
case NODE:
|
||||
count->tnc_union->node = tnc;
|
||||
@ -1632,7 +1633,7 @@ static void emit_helper(void){
|
||||
} else {
|
||||
current->next = inst;
|
||||
inst->prev = current;
|
||||
inst->index = current->index++;
|
||||
inst->index = current->index+1;
|
||||
current = inst;
|
||||
}
|
||||
}
|
||||
@ -1661,6 +1662,7 @@ void emit_assignment(TableNode * target, TNodeOrConst * source){
|
||||
}
|
||||
|
||||
char * get_string(TNodeOrConst * tc){
|
||||
|
||||
char * s;
|
||||
switch (tc->d) {
|
||||
case NODE:
|
||||
@ -1670,10 +1672,12 @@ char * get_string(TNodeOrConst * tc){
|
||||
case STRING:
|
||||
return tc->tnc_union->string;
|
||||
case INTEGER:
|
||||
return getName(integ);
|
||||
s = calloc(10, sizeof(char));
|
||||
sprintf(s, "%d", tc->tnc_union->integer);
|
||||
return s;
|
||||
case CHARACTER:
|
||||
return getName(chara);
|
||||
s = calloc(2, sizeof(char));
|
||||
sprintf(s, "%c", tc->tnc_union->character);
|
||||
return s;
|
||||
|
Reference in New Issue
Block a user