public override void EmitNewEnvironment(CodeGen cg) { ConstructorInfo ctor = EnvironmentType.GetConstructor( ScriptDomainManager.Options.DebugMode ? new Type[] { StorageType, typeof(SymbolId[]), } : new Type[] { StorageType, }); // emit: dict.Tuple[.Item000...].Item000 = dict, and then leave dict on the stack cg.EmitNew(ctor); cg.Emit(OpCodes.Dup); Slot tmp = cg.GetLocalTmp(EnvironmentType); tmp.EmitSet(cg); cg.EmitPropertyGet(EnvironmentType, "TupleData"); PropertyInfo last = null; foreach (PropertyInfo pi in Tuple.GetAccessPath(StorageType, 0)) { if (last != null) { cg.EmitPropertyGet(last); } last = pi; } tmp.EmitGet(cg); cg.EmitPropertySet(last); cg.FreeLocalTmp(tmp); }
public override void EmitNewEnvironment(CodeGen cg) { ConstructorInfo ctor = EnvironmentType.GetConstructor(new Type[] { StorageType }); // emit: dict.Tuple[.Item000...].Item000 = dict, and then leave dict on the stack cg.EmitNew(ctor); cg.Emit(OpCodes.Dup); Slot tmp = cg.GetLocalTmp(EnvironmentType); tmp.EmitSet(cg); cg.EmitPropertyGet(EnvironmentType, "Data"); var fld = StorageType.GetField("$parent$"); //cg.EmitFieldGet(fld); tmp.EmitGet(cg); cg.EmitFieldSet(fld); cg.FreeLocalTmp(tmp); }