public Procedures(Type returnedType, int noParameters, string predefined, List <dynamic> parametersOrder, SymbolTable localSymbolTable) { this.returnedType = returnedType; this.noParameters = noParameters; this.predefined = predefined; this.localSymbolTable = localSymbolTable; this.parametersOrder = parametersOrder; }
//Constant declaration missing public string Visit(ProcDeclaration node) { localscope = node[0].AnchorToken.Lexeme; currentLocalConstTable = localConstTables[localscope]; currentLocalSymbolTable = localSymbolTables[localscope]; currentFunctionParamTable = functionParamTables[localscope]; localSymbolAssAssign = new Dictionary <string, string>(); localSymbolAssLoad = new Dictionary <string, string>(); Visit((dynamic)node[3]); //Constants var functionLoad = new StringBuilder(); functionLoad.Append("call "); functionLoad.Append(CILTypes[globalSymbolTable[localscope]]); functionLoad.Append(" class ChimeraProgram::"); functionLoad.Append(localscope); functionLoad.Append("("); var sb = new StringBuilder(); //sb.Append("instance default "); sb.Append(".method public static hidebysig default "); sb.Append(CILTypes[globalSymbolTable[localscope]]); sb.Append(" "); sb.Append(localscope); sb.Append(" ("); var flag = false; int count = 0; foreach (KeyValuePair <string, Type> kvp in currentFunctionParamTable) { if (flag) { sb.Append(", "); functionLoad.Append(", "); } else { flag = true; } sb.Append(CILTypes[kvp.Value]); functionLoad.Append(CILTypes[kvp.Value]); sb.Append(" "); sb.Append(kvp.Key); try { currentLocalVar.Add(kvp.Key, count); localSymbolAssLoad.Add(kvp.Key, "ldarg." + count + "\n"); }catch { } count++; } sb.Append(") cil managed\n{"); sb.Append("\n.locals init (\n"); count = 0; flag = false; foreach (KeyValuePair <string, Type> kvp in currentLocalSymbolTable) { if (flag) { sb.Append(",\n"); } else { flag = true; } sb.Append(CILTypes[kvp.Value]); sb.Append(" "); /*sb.Append("V_"); * sb.Append(count);*/ sb.Append("'" + kvp.Key + "'"); try{ currentLocalVar.Add(kvp.Key, count); localSymbolAssAssign.Add(kvp.Key, "\tstloc." + count + "\n"); localSymbolAssLoad.Add(kvp.Key, "\tldloc." + count + "\n"); }catch { } count++; } sb.Append(")\n"); foreach (KeyValuePair <string, Type> kvp in currentLocalSymbolTable) { sb.Append(String.Format( "\t\t{0}\n" + localSymbolAssAssign[kvp.Key] + "\n", getInitVal(CILTypes[kvp.Value]) )); } sb.Append(Visit((dynamic)node[5])); sb.Append("\nret\n} // end of method ChimeraProgram::"); sb.Append(localscope); globalSymbolAssLoad.Add(localscope, functionLoad.ToString()); localscope = null; sb.Append("\n"); return(sb.ToString()); }