using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; namespace Sunweaver.DataPrototypes { public class Locals { private Dictionary> locals; private ILGenerator il; public Locals(ILGenerator ilGen) { locals = new Dictionary>(); il = ilGen; } public LocalBuilder this[Type t, int i] { get { LocalBuilder retval; if (locals.ContainsKey(t)) { if (locals[t].ContainsKey(i)) { return locals[t][i]; } else { retval = il.DeclareLocal(t); locals[t][i] = retval; return retval; } } else { retval = il.DeclareLocal(t); locals[t] = new Dictionary(); locals[t][i] = retval; return retval; } } } public LocalBuilder this[Type t] { get { return this[t, 0]; } } } }