// kdyz vlezu do smeru dolu tak level zvetsim asi a kdyz se vyleze tam zmensit public override int VisitDef_one_function([NotNull] GrammarParser.Def_one_functionContext context) { inFunction = true; localSymbolTable = new SymbolTable(); if (!jmpToMainDone) { DoMainJmp(0); } FuncItem newItem = createFunction(context); if (!globalSymbolTable.ContainsFuncItem(newItem.GetName())) { globalSymbolTable.AddFuncItem(newItem); } else { //Console.WriteLine("Funkce s timhle jmenem uz existuje!\n"); errors.Add("Funkce " + newItem.GetName() + " už existuje!\n"); } AddINT(3 + newItem.GetParameters().Count); level += 1; //inFunctionAddress = 3 + newItem.GetParameters().Count; inFunctionAddress = 3; for (int i = 0; i < newItem.GetParameters().Count; i++) { VarConstItem parItem = new VarConstItem(newItem.GetParameters()[i].getName(), "neni potreba", VarConstType.Var, newItem.GetParameters()[i].getDataType(), inFunctionAddress, 0); localSymbolTable.AddVarConstItem(parItem); inFunctionAddress += 1; } base.VisitDef_one_function(context); level -= 1; Console.WriteLine(localSymbolTable.VarConstToString()); AddRET(0, 0); inFunction = false; localSymbolTable = null; return(456); }
public void AddFuncItem(FuncItem item) { funcTable[item.GetName()] = item; }