It worksgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit statusgit status!
This commit is contained in:
@ -130,20 +130,11 @@ prototype:
|
||||
definition:
|
||||
TYPE ID COLON
|
||||
{
|
||||
|
||||
printdebug("Currently see a record definition for %s", $2);
|
||||
tn = CreateEntry(getAncestor(cur),TYPE_RECORD_TYPE, recprime, $2, CreateRecordInfo(0, cur = CreateScope(cur, 0, 0)));
|
||||
printdebug("Created a new scope");
|
||||
//if (look_up(cur, $2) == undefined) {
|
||||
// printdebug("rec not found");
|
||||
//}
|
||||
}
|
||||
dblock
|
||||
{
|
||||
//We are scanning through the dblock scope to get the length of the dblock (num of elements) from getRecSize
|
||||
//and then putting it in the entry that we created above.
|
||||
} dblock {
|
||||
setRecSize(look_up(getParent(cur), $2), getRecSize(cur));
|
||||
//putting in all the offsets
|
||||
setRecOffsetInfo(cur, look_up(getParent(cur),$2));
|
||||
printdebug("Moving up a scope after seeing a record definition");
|
||||
cur = getParent(cur);
|
||||
@ -155,9 +146,7 @@ definition:
|
||||
CreateEntry(cur,TYPE_ARRAY_TYPE, arrayprim, $2, CreateArrayInfo($4, (TableNode*)$6));
|
||||
printdebug("%sID: %s, dimensions: %d, typeOfArray: %s", COLOR_GREEN, $2, $4, getName((TableNode*)$6));
|
||||
}
|
||||
|
||||
| function_declaration
|
||||
|
||||
| TYPE ID COLON id_or_types ARROW id_or_types
|
||||
{
|
||||
printdebug("Currently see a function type definition of name %s,parameter type %s, of return type %s", $2, getName((TableNode*)$4), getName((TableNode*)$6));
|
||||
@ -655,7 +644,11 @@ rec_op:
|
||||
|
||||
ablock:
|
||||
L_PAREN{
|
||||
emit_push_all(S_Pop(stack));
|
||||
if (stack == NULL){
|
||||
stack = S_Init();
|
||||
}
|
||||
Stack * t = S_Init();
|
||||
S_Push(stack, t, 0);
|
||||
}
|
||||
argument_list {
|
||||
} R_PAREN
|
||||
@ -675,13 +668,10 @@ argument_list:
|
||||
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL);
|
||||
// this emits params for function and arrays TODO: fix
|
||||
Stack * t = S_Peek(stack);
|
||||
if (stack == NULL){
|
||||
stack = S_Init();
|
||||
}
|
||||
if(t == NULL){
|
||||
t = S_Init();
|
||||
S_Push(stack, t, 0);
|
||||
}
|
||||
if(t==NULL){
|
||||
t = S_Init();
|
||||
S_Push(stack, t, 1);
|
||||
}
|
||||
emit_parameter(tn_or_const(NODE,arg));
|
||||
S_Push(t, current, 1);
|
||||
emit_detach();
|
||||
@ -694,17 +684,7 @@ argument_list:
|
||||
|
||||
{
|
||||
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL);
|
||||
Stack * t = S_Peek(stack);
|
||||
if (stack == NULL){
|
||||
stack = S_Init();
|
||||
}
|
||||
if(t == NULL){
|
||||
t = S_Init();
|
||||
S_Push(stack, t, 0);
|
||||
}
|
||||
emit_parameter(tn_or_const(NODE,arg));
|
||||
S_Push(t, current, 1);
|
||||
emit_detach();
|
||||
$$ = 1;
|
||||
printdebug("[ARGUMENT_LIST] argument list is %d", $$);
|
||||
}
|
||||
@ -940,7 +920,6 @@ assignable:
|
||||
$$ = pass;
|
||||
printdebug("[ASSIGNABLE - RULE 1] assignable = type: %s | ID = %s", getType(pass), getName(pass));
|
||||
}
|
||||
|
||||
| assignable
|
||||
{
|
||||
printdebug("%sBeginning rule 2 of assignable.", COLOR_CYAN);
|
||||
@ -1035,7 +1014,8 @@ assignable:
|
||||
int a = S_Size(S_Peek(stack));
|
||||
}
|
||||
*/
|
||||
emit_push_all(S_Pop(stack));
|
||||
emit_push_all(S_Peek(stack));
|
||||
S_Pop(stack);
|
||||
emit_function_call(node, a, tn_or_const(NODE, $1));
|
||||
$$ = node;
|
||||
//NOTE ADD ASSIGNMENT EMIT HERE (MIGHT NEED TO PUSH TO STACK for function call)
|
||||
|
Reference in New Issue
Block a user