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 Load(IAsm a) { StringBuilder sb = new StringBuilder(MyC.MAXSTR); Var e = a.getVar(); if (e == null) { Console.WriteLine("?Load instruction with no variable ptr"); Environment.Exit(1); } switch (e.getClassId()) { case Tok.T_STATIC: { sb.Append("\tldsfld "); sb.Append(genFieldRef(e)); sb.Append("\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//"); 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//"); sb.Append(a.getICount()); sb.Append(", "); sb.Append(e.getName()); sb.Append("\r\n"); break; default: Console.Write("?Instruction load of unknown class ("); Console.Write(e.getClassId()); Console.WriteLine(")"); Environment.Exit(1); break; } io.Out(sb.ToString()); }
public void Store(IAsm a) { Var e = a.getVar(); int id = e.getClassId(); if (e == null) { Io.ICE("Store instruction with no variable ptr"); } if (e.getLocalToken() != null) { // LocalToken lt = (LocalToken) e.getLocalToken(); 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()+")"); } }