public void Call(IAsm a) { Var func = a.getVar(); String funcsig = genDataTypeSig(a.getVar()); /* gen type info */ VarList x = func.getParams(); /* get any params */ String paramsig = ""; if (x.Length() > 0) { int max = x.Length(); StringBuilder t = new StringBuilder(MyC.MAXSTR); for (int i = 0; i < max; i++) { Var e = x.FindByIndex(i); t.Append(genDataTypeSig(e)); if (i < max - 1) { t.Append(","); } } paramsig = t.ToString(); } StringBuilder sb = new StringBuilder(MyC.MAXSTR); sb.Append("\tcall "); sb.Append(funcsig); sb.Append("("); sb.Append(paramsig); sb.Append(")\t//"); sb.Append(a.getICount()); sb.Append("\r\n"); io.Out(sb.ToString()); }
public void FuncBegin(IAsm a) { Var func = a.getVar(); Type funcsig = genDataTypeSig(a.getVar()); /* gen return type info */ VarList paramlist = func.getParams(); /* get any params */ Type[] paramTypes = null; // in case no params if (paramlist.Length() > 0) { int max = paramlist.Length(); paramTypes = new Type[max]; for (int i = 0; i < max; i++) { Var e = paramlist.FindByIndex(i); paramTypes[i] = genDataTypeSig(e); } } emethod = eclass.DefineMethod(func.getName(), MethodAttributes.Static | MethodAttributes.Public, funcsig, paramTypes); func.setMethodBuilder(emethod); // save the method ref /* * set the argument symbol info */ for (int i = 0; i < paramlist.Length(); i++) { emethod.DefineParameter(i + 1, 0, paramlist.FindByIndex(i).getName()); } il = emethod.GetILGenerator(); // create new il generator if (func.getName().Equals("main")) /* special entry point for main */ { appbuild.SetEntryPoint(emethod); } // emodule.SetUserEntryPoint(emethod); /* * must also re-init the label hashtable for each function */ labelhash = new Hashtable(); localsdone = false; }
public void LocalVars(VarList v) { int max = v.Length(); for (int i = 0; i < max; i++) // loop thru the local params { Var e = v.FindByIndex(i); // indexed by number Type et = genDataTypeSig(e); // LocalToken t = emethod.DeclareLocal(et); LocalBuilder t = il.DeclareLocal(et); if (Io.gendebug) { t.SetLocalSymInfo(e.getName()); } e.setLocalToken(t); } localsdone = true; }
public void LocalVars(VarList v) { StringBuilder sb = new StringBuilder(MyC.MAXSTR); sb.Append("\t.locals ("); int max = v.Length(); for (int i = 0; i < max; i++) // loop thru the local params { Var e = v.FindByIndex(i); // indexed by number String stype = ""; switch (e.getTypeId()) { case Tok.T_CHAR: stype = "char"; break; case Tok.T_SHORT: stype = "int16"; break; case Tok.T_INT: case Tok.T_LONG: stype = "int32"; break; case Tok.T_FLOAT: stype = "float"; break; case Tok.T_DOUBLE: stype = "double float"; break; default: Console.WriteLine("?Could not find type for local\n"); Environment.Exit(1); break; } sb.Append(stype); // append it now if (i < max - 1) { sb.Append(","); // if not last, seperate with comma } } sb.Append(")\r\n"); io.Out(sb.ToString()); }
public void FuncBegin(IAsm a) { Var func = a.getVar(); String funcsig = genDataTypeSig(a.getVar()); /* gen type info */ VarList x = func.getParams(); /* get any params */ String paramsig = ""; if (x.Length() > 0) { int max = x.Length(); StringBuilder t = new StringBuilder(MyC.MAXSTR); for (int i = 0; i < max; i++) { Var e = x.FindByIndex(i); t.Append(genDataTypeSig(e)); if (i < max - 1) { t.Append(","); } } paramsig = t.ToString(); } StringBuilder sb = new StringBuilder(MyC.MAXSTR); sb.Append("\t.method "); sb.Append(funcsig); sb.Append(" "); sb.Append(func.getName()); sb.Append("("); sb.Append(paramsig); sb.Append("){\r\n"); io.Out(sb.ToString()); if (func.getName().Equals("main")) /* special entry point for main */ { io.Out("\t.entrypoint\r\n"); } }
public void LocalVars(VarList v) { StringBuilder sb = new StringBuilder(MyC.MAXSTR); sb.Append("\t.locals ("); int max = v.Length(); for (int i = 0; i < max; i++) // loop thru the local params { Var e = v.FindByIndex(i); // indexed by number String stype = ""; switch (e.getTypeId()) { case Tok.T_CHAR: stype = "char"; break; case Tok.T_SHORT: stype = "int16"; break; case Tok.T_INT: case Tok.T_LONG: stype = "int32"; break; case Tok.T_FLOAT: stype = "float"; break; case Tok.T_DOUBLE: stype = "double float"; break; default: Console.WriteLine("?Could not find type for local\n"); Environment.Exit(1); break; } sb.Append(stype); // append it now if (i < max-1) sb.Append(","); // if not last, seperate with comma } sb.Append(")\r\n"); io.Out(sb.ToString()); }
public void LocalVars(VarList v) { int max = v.Length(); for (int i = 0; i < max; i++) // loop thru the local params { Var e = v.FindByIndex(i); // indexed by number Type et = genDataTypeSig(e); // LocalToken t = emethod.DeclareLocal(et); LocalBuilder t = il.DeclareLocal(et); if (Io.gendebug) t.SetLocalSymInfo(e.getName()); e.setLocalToken(t); } localsdone = true; }