public void Call(IAsm a) { Var func = a.getVar(); LibFunc lfunc; String funcsig = genDataTypeSig(a.getVar()); VarList x = func.getParams(); String paramsig = ""; if (x.Length() > 0) { int max = x.Length(); StringBuilder t = new StringBuilder(Io.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(Io.MAXSTR); sb.Append("\tcall "); sb.Append(funcsig); sb.Append(" "); lfunc = lib.lookup_func(a.getVar().getName()); if (lfunc != null) { sb.Append(lfunc.nameFull); } else { sb.Append(io.GetClassname()); sb.Append("::"); sb.Append(func.getName()); sb.Append("("); sb.Append(paramsig); sb.Append(")"); } sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append("\r\n"); io.Out(sb.ToString()); }
public void FieldDef(IAsm a) { Var e = a.getVar(); String prefix = ""; switch (e.getClassId()) { case Tok.T_STATIC: prefix = "\t.field "; break; case Tok.T_AUTO: case Tok.T_DEFCLASS: prefix = "\t.field "; break; default: io.Abort("PL0407: unhandled field def type"); break; } StringBuilder sb = new StringBuilder(Io.MAXSTR); sb.Append(prefix); sb.Append(genDataTypeSig(e)); sb.Append(" "); sb.Append(e.getName()); sb.Append("\r\n"); io.Out(sb.ToString()); }
public void Call(IAsm a) { Var func = a.getVar(); LibFunc lfunc; String funcsig = genDataTypeSig(a.getVar()); VarList x = func.getParams(); String paramsig = ""; if (x.Length() > 0) { int max = x.Length(); StringBuilder t = new StringBuilder(Io.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(Io.MAXSTR); sb.Append("\tcall "); sb.Append(funcsig); sb.Append(" "); lfunc = lib.lookup_func(a.getVar().getName()); if (lfunc != null) { sb.Append(lfunc.nameFull); } else { sb.Append(io.GetClassname()); sb.Append("::"); sb.Append(func.getName()); sb.Append("("); sb.Append(paramsig); sb.Append(")"); } sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append("\r\n"); io.Out(sb.ToString()); }
public void Call(IAsm a) { Var func = a.getVar(); Object o = func.getMethodBuilder(); LibFunc lfunc = lib.lookup_func(a.getVar().getName()); if (lfunc != null) { il.Emit(OpCodes.Call, lfunc.methodInfo); } else { if (o == null) { io.ICE("no previous extern for (" + func.getName() + ")"); } MethodBuilder mb = (MethodBuilder)o; il.Emit(OpCodes.Call, mb); } }
public void FuncBegin(IAsm a) { Var func = a.getVar(); String funcsig = genDataTypeSig(a.getVar()); VarList x = func.getParams(); String paramsig = ""; if (x.Length() > 0) { int max = x.Length(); StringBuilder t = new StringBuilder(Io.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(Io.MAXSTR); sb.Append("\t.method public "); sb.Append("static "); 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().ToLower().Equals("main")) { io.Out("\t.entrypoint\r\n"); } }
public void FuncBegin(IAsm a) { Var func = a.getVar(); Type funcsig = genDataTypeSig(a.getVar()); VarList paramlist = func.getParams(); Type[] paramTypes = null; 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); for (int i = 0; i < paramlist.Length(); i++) { emethod.DefineParameter(i + 1, 0, paramlist.FindByIndex(i).getName()); } il = emethod.GetILGenerator(); if (func.getName().ToLower().Equals("main")) { appbuild.SetEntryPoint(emethod); } // emodule.SetUserEntryPoint(emethod); labelhash = new Hashtable(); }
public void Call(IAsm a) { Var func = a.getVar(); Object o = func.getMethodBuilder(); LibFunc lfunc = lib.lookup_func(a.getVar().getName()); if (lfunc != null) { il.Emit(OpCodes.Call, lfunc.methodInfo); } else { if (o == null) io.ICE("no previous extern for (" + func.getName() + ")"); MethodBuilder mb = (MethodBuilder) o; il.Emit(OpCodes.Call, mb); } }
public void Load(IAsm a) { StringBuilder sb = new StringBuilder(Io.MAXSTR); Var e = a.getVar(); if (e == null) { io.Abort("PL0402: load instruction with no variable ptr"); } switch (e.getClassId()) { case Tok.T_STATIC: sb.Append("\tldsfld "); sb.Append(genFieldRef(e)); sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append(", "); sb.Append(e.getName()); sb.Append("\r\n"); break; case Tok.T_AUTO: case Tok.T_DEFCLASS: sb.Append("\tldloc "); sb.Append(e.getIndex()); sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append(", "); sb.Append(e.getName()); sb.Append("\r\n"); break; case Tok.T_PARAM: sb.Append("\tldarg "); sb.Append(e.getIndex()); sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append(", "); sb.Append(e.getName()); sb.Append("\r\n"); break; default: io.Abort("PL0403: instruction load of unknown class (" + e.getClassId() + ")"); break; } io.Out(sb.ToString()); }
public void FieldDef(IAsm a) { Var e = a.getVar(); FieldAttributes attr = FieldAttributes.Private; if (e.getClassId() == Tok.T_STATIC) { attr |= FieldAttributes.Static; } Type t = genDataTypeSig(e); /* gen type info */ FieldBuilder f = eclass.DefineField(e.getName(), t, attr); e.setFieldBuilder((Object)f); }
public void Store(IAsm a) { StringBuilder sb = new StringBuilder(Io.MAXSTR); Var e = a.getVar(); if (e == null) { io.Abort("PL0404: store instruction with no variable ptr"); } switch (e.getClassId()) { case Tok.T_STATIC: sb.Append("\tstsfld "); sb.Append(genFieldRef(e)); sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append(", "); sb.Append(e.getName()); sb.Append("\r\n"); break; case Tok.T_AUTO: case Tok.T_DEFCLASS: sb.Append("\tstloc "); sb.Append(e.getIndex()); sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append(", "); sb.Append(e.getName()); sb.Append("\r\n"); break; case Tok.T_PARAM: sb.Append("\tstarg "); sb.Append(e.getIndex()); sb.Append("\t\t\t\t\t//"); sb.Append(a.getICount()); sb.Append(", "); sb.Append(e.getName()); sb.Append("\r\n"); break; default: io.Abort("PL0405: instruction load of unknown class (" + e.getClassId() + ")"); break; } io.Out(sb.ToString()); }
public void FuncBegin(IAsm a) { Var func = a.getVar(); String funcsig = genDataTypeSig(a.getVar()); VarList x = func.getParams(); String paramsig = ""; if (x.Length() > 0) { int max = x.Length(); StringBuilder t = new StringBuilder(Io.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(Io.MAXSTR); sb.Append("\t.method public "); sb.Append("static "); 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().ToLower().Equals("main")) io.Out("\t.entrypoint\r\n"); }
public void Store(IAsm a) { if (a.getVar() == null) io.ICE("store instruction with no variable ptr"); Var e = localvars.FindByName(a.getVar().getName()); if (e == null) e = a.getVar(); int id = e.getClassId(); if (e.getLocalToken() != null) { LocalBuilder lt = (LocalBuilder) e.getLocalToken(); il.Emit(OpCodes.Stloc, lt); } else { if (e.getFieldBuilder() != null) { FieldBuilder fb = (FieldBuilder) e.getFieldBuilder(); if (id == Tok.T_STATIC) il.Emit(OpCodes.Stsfld, fb); else il.Emit(OpCodes.Stfld, fb); } else { int index = e.getIndex(); if (id == Tok.T_PARAM) { if (index <= 256) il.Emit(OpCodes.Starg_S, index); else il.Emit(OpCodes.Starg, index); } else { if (id == Tok.T_AUTO || id == Tok.T_DEFCLASS) il.Emit(OpCodes.Stloc, index); else io.ICE("instruction load of unknown class (" + e.getClassId()+")"); } } } }
public void Load(IAsm a) { Var e = a.getVar(); genLoad(e); }
public void FuncBegin(IAsm a) { Var func = a.getVar(); Type funcsig = genDataTypeSig(a.getVar()); VarList paramlist = func.getParams(); Type[] paramTypes = null; 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); for (int i = 0; i < paramlist.Length(); i++) emethod.DefineParameter(i+1, 0, paramlist.FindByIndex(i).getName()); il = emethod.GetILGenerator(); if (func.getName().ToLower().Equals("main")) appbuild.SetEntryPoint(emethod); // emodule.SetUserEntryPoint(emethod); labelhash = new Hashtable(); }
public void Store(IAsm a) { if (a.getVar() == null) { io.ICE("store instruction with no variable ptr"); } Var e = localvars.FindByName(a.getVar().getName()); if (e == null) { e = a.getVar(); } int id = e.getClassId(); if (e.getLocalToken() != null) { LocalBuilder lt = (LocalBuilder)e.getLocalToken(); il.Emit(OpCodes.Stloc, lt); } else { if (e.getFieldBuilder() != null) { FieldBuilder fb = (FieldBuilder)e.getFieldBuilder(); if (id == Tok.T_STATIC) { il.Emit(OpCodes.Stsfld, fb); } else { il.Emit(OpCodes.Stfld, fb); } } else { int index = e.getIndex(); if (id == Tok.T_PARAM) { if (index <= 256) { il.Emit(OpCodes.Starg_S, index); } else { il.Emit(OpCodes.Starg, index); } } else { if (id == Tok.T_AUTO || id == Tok.T_DEFCLASS) { il.Emit(OpCodes.Stloc, index); } else { io.ICE("instruction load of unknown class (" + e.getClassId() + ")"); } } } } }
public void FieldDef(IAsm a) { Var e = a.getVar(); FieldAttributes attr = FieldAttributes.Private; if (e.getClassId() == Tok.T_STATIC) attr |= FieldAttributes.Static; Type t = genDataTypeSig(e); /* gen type info */ FieldBuilder f = eclass.DefineField(e.getName(), t, attr); e.setFieldBuilder((Object) f); }