I think it was broken so I fixed it
This commit is contained in:
@ -550,21 +550,6 @@ compound_statement:
|
||||
emit_label(*l);
|
||||
S_Push(stack, l, 2);
|
||||
} expression R_PAREN {
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
emit_conditional_jump(E_IF_X_TRUE, 0, tn_or_const(NODE, $4));
|
||||
Stack * t = S_Peek(TrueList);
|
||||
if(t==NULL){
|
||||
t = S_Init();
|
||||
S_Push(TrueList, t, 1);
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
emit_goto(0);
|
||||
t = S_Peek(FalseList);
|
||||
if(t==NULL){
|
||||
t = S_Init();
|
||||
S_Push(FalseList, t, 1);
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
} sblock {
|
||||
@ -854,40 +839,40 @@ expression:
|
||||
| expression AND expression
|
||||
{
|
||||
// ----------------------------------------------------------------------------
|
||||
emit_conditional_jump(E_IF_X_TRUE, 0, tn_or_const(NODE, $1));
|
||||
Stack * t1 = S_Peek(TrueList);
|
||||
if(t1==NULL){
|
||||
t1 = S_Init();
|
||||
S_Push(TrueList, t1, 1);
|
||||
}
|
||||
S_Push(t1, current, 1);
|
||||
emit_goto(0);
|
||||
t1 = S_Peek(FalseList);
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
emit_conditional_jump(E_IF_X_FALSE, 0, tn_or_const(NODE, $1));
|
||||
Stack * t1 = S_Peek(FalseList);
|
||||
if(t1==NULL){
|
||||
t1 = S_Init();
|
||||
S_Push(FalseList, t1, 1);
|
||||
}
|
||||
S_Push(t1, current, 1);
|
||||
emit_goto(0);
|
||||
t1 = S_Peek(TrueList);
|
||||
if(t1==NULL){
|
||||
t1 = S_Init();
|
||||
S_Push(TrueList, t1, 1);
|
||||
}
|
||||
S_Push(t1, current, 1);
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
|
||||
emit_conditional_jump(E_IF_X_TRUE, 0, tn_or_const(NODE, $3));
|
||||
Stack * t = S_Peek(TrueList);
|
||||
if(t==NULL){
|
||||
t = S_Init();
|
||||
S_Push(TrueList, t, 1);
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
emit_goto(0);
|
||||
t = S_Peek(FalseList);
|
||||
emit_conditional_jump(E_IF_X_FALSE, 0, tn_or_const(NODE, $3));
|
||||
Stack * t = S_Peek(FalseList);
|
||||
if(t==NULL){
|
||||
t = S_Init();
|
||||
S_Push(FalseList, t, 1);
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
|
||||
emit_goto(0);
|
||||
t = S_Peek(TrueList);
|
||||
if(t==NULL){
|
||||
t = S_Init();
|
||||
S_Push(TrueList, t, 1);
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
S_Merge(FalseList);
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
// ----------------------------------------------------------------------------
|
||||
printdebug("AND");
|
||||
char* temp = temp_var_gen();
|
||||
@ -904,6 +889,8 @@ expression:
|
||||
| expression OR expression
|
||||
{
|
||||
// ----------------------------------------------------------------------------
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
emit_conditional_jump(E_IF_X_TRUE, 0, tn_or_const(NODE, $1));
|
||||
Stack * t1 = S_Peek(TrueList);
|
||||
if(t1==NULL){
|
||||
@ -920,7 +907,6 @@ expression:
|
||||
S_Push(t1, current, 1);
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(FalseList), getLabel(current));
|
||||
|
||||
emit_conditional_jump(E_IF_X_TRUE, 0, tn_or_const(NODE, $3));
|
||||
Stack * t = S_Peek(TrueList);
|
||||
if(t==NULL){
|
||||
@ -936,14 +922,11 @@ expression:
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
S_Merge(TrueList);
|
||||
// This is very inportant.
|
||||
// With OR W DO NOT BP THE TRUELIST Only with AND
|
||||
// ----------------------------------------------------------------------------
|
||||
printdebug("OR");
|
||||
if((getTypeEntry((TableNode*)$1)==getTypeEntry((TableNode*)$3)) && getTypeEntry((TableNode*)$1) == boo) {
|
||||
char* temp = temp_var_gen();
|
||||
TableNode* node = CreateEntry(cur,TYPE_PRIMITIVE, boo, temp, NULL);
|
||||
// emit_binary_op(E_OR,node,tn_or_const(NODE,$1),tn_or_const(NODE,$3));
|
||||
$$ = node;
|
||||
} else {
|
||||
$$=undefined;
|
||||
@ -956,6 +939,8 @@ expression:
|
||||
char* temp = temp_var_gen();
|
||||
TableNode* node = CreateEntry(cur,TYPE_PRIMITIVE, boo, temp, NULL);
|
||||
// ----------------------------------------------------------------------------
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
emit_binary_op(E_LESS_THAN, node, tn_or_const(NODE,$1), tn_or_const(NODE,$3));
|
||||
emit_conditional_jump(E_IF_X_TRUE, 0, tn_or_const(NODE, node));
|
||||
Stack * t = S_Peek(TrueList);
|
||||
@ -971,10 +956,6 @@ expression:
|
||||
S_Push(FalseList, t, 1);
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
// emit_label(label_gen());
|
||||
// emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
/*
|
||||
*/
|
||||
// ----------------------------------------------------------------------------
|
||||
printdebug("less than expression");
|
||||
if(getTypeEntry((TableNode*)$1) == getTypeEntry((TableNode*)$3) && getTypeEntry((TableNode*)$1)==integ) {
|
||||
@ -992,6 +973,8 @@ expression:
|
||||
char* temp = temp_var_gen();
|
||||
TableNode* node = CreateEntry(cur,TYPE_PRIMITIVE, boo, temp, NULL);
|
||||
// ----------------------------------------------------------------------------
|
||||
emit_label(label_gen());
|
||||
emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
emit_binary_op(E_EQUAL_TO, node, tn_or_const(NODE,$1), tn_or_const(NODE,$3));
|
||||
emit_conditional_jump(E_IF_X_TRUE, 0, tn_or_const(NODE, node));
|
||||
Stack * t = S_Peek(TrueList);
|
||||
@ -1007,8 +990,6 @@ expression:
|
||||
S_Push(FalseList, t, 1);
|
||||
}
|
||||
S_Push(t, current, 1);
|
||||
// emit_label(label_gen());
|
||||
// emit_backpatch(S_Pop(TrueList), getLabel(current));
|
||||
// ----------------------------------------------------------------------------
|
||||
printdebug("equals check expression");
|
||||
if(getTypeEntry((TableNode*)$1) == getTypeEntry((TableNode*)$3) && getTypeEntry((TableNode*)$1) != undefined) {
|
||||
|
Reference in New Issue
Block a user