Ejemplo n.º 1
0
 internal void GenerateCall(MethodStructure method)
 {
     var m = method.GainMethod();
     if (m.IsVirtual)
     {
         Generator.Emit(OpCodes.Callvirt, m);
     }
     else
     {
         Generator.Emit(OpCodes.Call, m);
     }
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 4
0
 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;
     }
 }
Ejemplo n.º 5
0
 internal override BuilderStructure RenewInstance(TypeStructure type)
 {
     var ret = new MethodStructure();
     ret.Info = type.RenewMethod(this);
     return ret;
 }