internal void GenerateCall(MethodStructure method) { var m = method.GainMethod(); if (m.IsVirtual) { Generator.Emit(OpCodes.Callvirt, m); } else { Generator.Emit(OpCodes.Call, m); } }
public RootStructure(string name, string dir = null) { Name = name; FileName = name + ".exe"; Assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(Name), AssemblyBuilderAccess.RunAndSave, dir); Module = Assembly.DefineDynamicModule(Name, FileName, true); var attr = MethodAttributes.PrivateScope | MethodAttributes.SpecialName | MethodAttributes.Static; var arg = new List<ParameterStructure>(); var gnr = new List<GenericParameterStructure>(); EntryContext = new MethodStructure(); EntryContext.Initialize("@@entry", false, attr, gnr, arg, null); AppendChild(EntryContext); }
public GlobalContextStructure(string name, BlockStructure block) { Name = name; Block = block; var tattr = TypeAttributes.Class | TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.SpecialName; var gnr = new List<GenericParameterStructure>(); var imp = new List<TypeStructure>(); GlobalField = new PureTypeStructure(); GlobalField.Initialize(Name + ".@@Global", tattr, gnr, null, imp); AppendChild(GlobalField); var mattr = MethodAttributes.PrivateScope | MethodAttributes.SpecialName | MethodAttributes.Static; var arg = new List<ParameterStructure>(); var gnr2 = new List<GenericParameterStructure>(); GlobalContext = new MethodStructure(); GlobalContext.Initialize("@@global", false, mattr, gnr2, arg, null); GlobalField.AppendChild(GlobalContext); AppendChild(Block); }
internal MethodInfo RenewMethod(MethodStructure method) { if (Info.GetType().Name == "TypeBuilderInstantiation") { return TypeBuilder.GetMethod(Info, method.GainMethod()); } else { var m = method.GainMethod(); var types = Info.RenewTypes(m.GetParameters().ToTypes()); var ret = Info.GetMethod(m.Name, types); if (ret == null) { throw new InvalidOperationException(); } return ret; } }
internal override BuilderStructure RenewInstance(TypeStructure type) { var ret = new MethodStructure(); ret.Info = type.RenewMethod(this); return ret; }