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()); }
void genLoad(Var e) { int id = e.getClassId(); if (e == null) io.ICE("load instruction with no variable ptr"); if (e.getLocalToken() != null) { // LocalToken lt = (LocalToken) e.getLocalToken(); LocalBuilder lt = (LocalBuilder) e.getLocalToken(); il.Emit(OpCodes.Ldloc, lt); } else { if (e.getFieldBuilder() != null) { FieldBuilder fb = (FieldBuilder) e.getFieldBuilder(); if (id == Tok.T_STATIC) il.Emit(OpCodes.Ldsfld, fb); else il.Emit(OpCodes.Ldfld, fb); } else { int index = e.getIndex(); if (id == Tok.T_PARAM) { if (index <= 256) il.Emit(OpCodes.Ldarg_S, index); else il.Emit(OpCodes.Ldarg, index); } else { if (id == Tok.T_AUTO || id == Tok.T_DEFCLASS) { if (index <= 256) il.Emit(OpCodes.Ldloc_S, e.getIndex()); else il.Emit(OpCodes.Ldloc, e.getIndex()); } else { io.ICE("instruction load of unknown class (" + e.getClassId()+")"); } } } } }
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() + ")"); } } } } }
void genLoad(Var e) { int id = e.getClassId(); if (e == null) { io.ICE("load instruction with no variable ptr"); } if (e.getLocalToken() != null) { // LocalToken lt = (LocalToken) e.getLocalToken(); LocalBuilder lt = (LocalBuilder)e.getLocalToken(); il.Emit(OpCodes.Ldloc, lt); } else { if (e.getFieldBuilder() != null) { FieldBuilder fb = (FieldBuilder)e.getFieldBuilder(); if (id == Tok.T_STATIC) { il.Emit(OpCodes.Ldsfld, fb); } else { il.Emit(OpCodes.Ldfld, fb); } } else { int index = e.getIndex(); if (id == Tok.T_PARAM) { if (index <= 256) { il.Emit(OpCodes.Ldarg_S, index); } else { il.Emit(OpCodes.Ldarg, index); } } else { if (id == Tok.T_AUTO || id == Tok.T_DEFCLASS) { if (index <= 256) { il.Emit(OpCodes.Ldloc_S, e.getIndex()); } else { il.Emit(OpCodes.Ldloc, e.getIndex()); } } else { io.ICE("instruction load of unknown class (" + e.getClassId() + ")"); } } } } }