diff --git a/transpiler/main/c_code_gen.c b/transpiler/main/c_code_gen.c index be7341dca..6a50bb4d7 100644 --- a/transpiler/main/c_code_gen.c +++ b/transpiler/main/c_code_gen.c @@ -401,7 +401,11 @@ void transpileAssignStmt(struct AssignStmt* as, struct Ctx* ctx){ //find type via local variable symbol table assert(ctx->tables->lvst != NULL); - struct LVSTLine* line = lvst_get(ctx->tables->lvst, as->var->simpleVar->name); + struct LVSTLine* line = lvst_get( + ctx->tables->lvst, + as->var->simpleVar->name, + ctx->flags->debug + ); assert(line != NULL); diff --git a/transpiler/main/tables/localvarsymtable.c b/transpiler/main/tables/localvarsymtable.c index 022cabb63..eb2b3c6c1 100644 --- a/transpiler/main/tables/localvarsymtable.c +++ b/transpiler/main/tables/localvarsymtable.c @@ -50,7 +50,7 @@ void discoverLVAssignStmt( // -------------------------------------------------------- //to add a row to the local variable symbol table //the lvst works as a set regarding the 'name' of the local variable -void lvst_add(struct LVST* lvst, struct LVSTLine* line); +void lvst_add(struct LVST* lvst, struct LVSTLine* line, bool debug); // -------------------------------------------------------- struct LVST* makeLocalVarSymTable(bool debug){ @@ -90,7 +90,7 @@ void fillLocalVarSymTable( line->isArg = true; line->firstOccur = NULL; - lvst_add(st->lvst, line); + lvst_add(st->lvst, line, debug); } if(debug){ @@ -130,10 +130,14 @@ void freeLVSTLine(struct LVSTLine* l){ free(l); } -void lvst_add(struct LVST* lvst, struct LVSTLine* line){ - - //no debug param, so we print - printf("lvst_add(%p, %p)\n", lvst, line); +void lvst_add( + struct LVST* lvst, + struct LVSTLine* line, + bool debug +){ + if(debug){ + printf("lvst_add(%p, %p)\n", lvst, line); + } //the local var symbol table works as a set //with 'name' as the key @@ -168,10 +172,15 @@ void lvst_add(struct LVST* lvst, struct LVSTLine* line){ lvst->count += 1; } -struct LVSTLine* lvst_get(struct LVST* lvst, char* name){ +struct LVSTLine* lvst_get( + struct LVST* lvst, + char* name, + bool debug +){ - //no debug param, so we print - printf("lvst_get(%p, %s)\n", lvst, name); + if(debug){ + printf("lvst_get(%p, %s)\n", lvst, name); + } for(int i = 0; i < lvst->count; i++){ @@ -273,7 +282,7 @@ void discoverLVAssignStmt( line->firstOccur = a; line->isArg = false;; - lvst_add(st->lvst, line); + lvst_add(st->lvst, line, debug); } void lvst_print(struct LVST* lvst){ diff --git a/transpiler/main/tables/localvarsymtable.h b/transpiler/main/tables/localvarsymtable.h index 3ab73f8b6..c1172fed6 100644 --- a/transpiler/main/tables/localvarsymtable.h +++ b/transpiler/main/tables/localvarsymtable.h @@ -56,7 +56,9 @@ void fillLocalVarSymTable( void freeLocalVarSymTable(struct LVST* lvst); //obtain a reference to the line for that identifier -struct LVSTLine* lvst_get(struct LVST* lvst, char* name); +struct LVSTLine* lvst_get( + struct LVST* lvst, char* name, bool debug +); void lvst_print(struct LVST* lvst); #endif diff --git a/transpiler/main/tables/subrsymtable.c b/transpiler/main/tables/subrsymtable.c index db92dccfc..be038d4c7 100644 --- a/transpiler/main/tables/subrsymtable.c +++ b/transpiler/main/tables/subrsymtable.c @@ -27,7 +27,9 @@ struct SST* makeSubrSymTable(struct Namespace* ns, bool debug){ line->isLibC = false; line->returnType = m->returnType; - printf("\tadding '%s' to subroutine symbol table\n", line->name); + if(debug){ + printf("\tadding '%s' to subroutine symbol table\n", line->name); + } sst_add(sst, line); } diff --git a/transpiler/main/typeinference.c b/transpiler/main/typeinference.c index 9d60a5b00..42a2cc6b4 100644 --- a/transpiler/main/typeinference.c +++ b/transpiler/main/typeinference.c @@ -149,7 +149,9 @@ struct Type* inferTypeSimpleVar(struct ST* st, struct SimpleVar* v){ //of another variable, it should have been initialized //before. so we can pull it's type from the LSVT - struct LVSTLine* line = lvst_get(st->lvst, v->name); + //debug=true as param because + //we do not get debug param here + struct LVSTLine* line = lvst_get(st->lvst, v->name, true); //if it has an index, we unwrap the type if(v->optIndex != NULL){