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