Ejemplo n.º 1
0
 public Specializer(Module targetModule, TypeNodeList pars, TypeNodeList args){
   Debug.Assert(pars != null && pars.Count > 0);
   Debug.Assert(args != null && args.Count > 0);
   this.pars = pars;
   this.args = args;
   this.TargetModule = targetModule;
 }
Ejemplo n.º 2
0
 /// <param name="module">The module into which the duplicate IR will be grafted.</param>
 /// <param name="type">The type into which the duplicate Member will be grafted. Ignored if entire type, or larger unit is duplicated.</param>
 public Duplicator(Module/*!*/ module, TypeNode type) {
   this.TargetModule = module;
   this.TargetType = this.OriginalTargetType = type;
   this.DuplicateFor = new TrivialHashtable();
   this.TypesToBeDuplicated = new TrivialHashtable();
   //^ base();
 }
Ejemplo n.º 3
0
 public SnippetParser(IParserFactory/*!*/ defaultParserFactory, Module symbolTable, ErrorNodeList errorNodes, CompilerParameters options) {
   this.DefaultParserFactory = defaultParserFactory;
   this.ErrorNodes = errorNodes;
   this.SymbolTable = symbolTable;
   this.Options = options;
   this.CurrentStatementList = new StatementList(0);
   //^ base();
 }
Ejemplo n.º 4
0
 public virtual Module VisitModule(Module module){
   if (module == null) return null;
   module.Attributes = this.VisitAttributeList(module.Attributes);
   module.Types = this.VisitTypeNodeList(module.Types);
   return module;
 }
Ejemplo n.º 5
0
 public MethodBodySpecializer(Module module, TypeNodeList pars, TypeNodeList args)
   : base(module, pars, args){
   //^ base;
 }
Ejemplo n.º 6
0
 public virtual void VisitModule(Module module)
 {
   if (module == null) return;
   this.VisitAttributeList(module.Attributes);
   this.VisitTypeNodeList(module.Types);
 }
Ejemplo n.º 7
0
 public virtual Module VisitModuleReference(Module module)
 {
     if (module == null) return null;
     Module dup = (Module)this.DuplicateFor[module.UniqueKey];
     if (dup != null) return dup;
     for (int i = 0, n = this.TargetModule.ModuleReferences == null ? 0 : this.TargetModule.ModuleReferences.Count; i < n; i++)
     {
         //^ assert this.TargetModule.ModuleReferences != null;
         ModuleReference modRef = this.TargetModule.ModuleReferences[i];
         if (modRef == null) continue;
         if (string.Compare(module.Name, modRef.Name, true, System.Globalization.CultureInfo.InvariantCulture) != 0) continue;
         this.DuplicateFor[module.UniqueKey] = modRef.Module; return modRef.Module;
     }
     if (this.TargetModule.ModuleReferences == null)
         this.TargetModule.ModuleReferences = new ModuleReferenceList();
     this.TargetModule.ModuleReferences.Add(new ModuleReference(module.Name, module));
     this.DuplicateFor[module.UniqueKey] = module;
     return module;
 }
Ejemplo n.º 8
0
 public override Module VisitModule(Module module)
 {
     if (module == null) return null;
     Module dup = (Module)module.Clone();
     if (this.TargetModule == null) this.TargetModule = dup;
     this.FindTypesToBeDuplicated(module.Types);
     return base.VisitModule(dup);
 }
Ejemplo n.º 9
0
 private void ProvideTypeMembers(TypeNode/*!*/ dup, object/*!*/ handle)
 {
     TypeNode template = (TypeNode)handle;
     Debug.Assert(!template.membersBeingPopulated);
     TypeNode savedTargetType = this.TargetType;
     Module savedTargetModule = this.TargetModule;
     this.TargetType = dup;
     //^ assume dup.DeclaringModule != null;
     this.TargetModule = dup.DeclaringModule;
     this.FindTypesToBeDuplicated(template.NestedTypes);
     dup.Members = this.VisitMemberList(template.Members);
     DelegateNode delegateNode = dup as DelegateNode;
     if (delegateNode != null && delegateNode.IsNormalized)
     {
         Debug.Assert(dup.Members != null && dup.Members.Count > 0 && dup.Members[0] != null);
         delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters);
         delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType);
     }
     this.TargetModule = savedTargetModule;
     this.TargetType = savedTargetType;
 }
Ejemplo n.º 10
0
 private void ProvideNestedTypes(TypeNode/*!*/ dup, object/*!*/ handle)
 {
     TypeNode template = (TypeNode)handle;
     TypeNode savedTargetType = this.TargetType;
     Module savedTargetModule = this.TargetModule;
     this.TargetType = dup;
     //^ assume dup.DeclaringModule != null;
     this.TargetModule = dup.DeclaringModule;
     this.FindTypesToBeDuplicated(template.NestedTypes);
     dup.NestedTypes = this.VisitNestedTypes(dup, template.NestedTypes);
     this.TargetModule = savedTargetModule;
     this.TargetType = savedTargetType;
 }
Ejemplo n.º 11
0
 public static void Initialize(bool doNotLockFile, bool getDebugInfo, Module.AssemblyReferenceResolver initialResolver)
 {
     if (CoreSystemTypes.Initialized)
         CoreSystemTypes.Clear();
     if (SystemAssembly == null)
         SystemAssembly = CoreSystemTypes.GetSystemAssembly(doNotLockFile, getDebugInfo);
     if (initialResolver != null)
         SystemAssembly.AssemblyReferenceResolution += initialResolver;
     if (SystemAssembly == null)
         throw new InvalidOperationException(ExceptionStrings.InternalCompilerError);
     if (TargetPlatform.TargetVersion == null)
     {
         TargetPlatform.TargetVersion = SystemAssembly.Version;
         if (TargetPlatform.TargetVersion == null)
             TargetPlatform.TargetVersion = typeof(object).Module.Assembly.GetName().Version;
     }
     if (TargetPlatform.TargetVersion != null)
     {
         if (TargetPlatform.TargetVersion.Major > 1 || TargetPlatform.TargetVersion.Minor > 1 ||
           (TargetPlatform.TargetVersion.Minor == 1 && TargetPlatform.TargetVersion.Build == 9999))
         {
             if (SystemAssembly.IsValidTypeName(StandardIds.System, Identifier.For("Nullable`1")))
                 TargetPlatform.GenericTypeNamesMangleChar = '`';
             else if (SystemAssembly.IsValidTypeName(StandardIds.System, Identifier.For("Nullable!1")))
                 TargetPlatform.GenericTypeNamesMangleChar = '!';
             else if (TargetPlatform.TargetVersion.Major == 1 && TargetPlatform.TargetVersion.Minor == 2)
                 TargetPlatform.GenericTypeNamesMangleChar = (char)0;
         }
     }
     InitializeSystemTypes();
 }
Ejemplo n.º 12
0
    public static void Initialize(bool doNotLockFile, bool getDebugInfo, Module.AssemblyReferenceResolver initialResolver){
      if (SystemTypes.Initialized){
        SystemTypes.Clear();
        CoreSystemTypes.Initialize(doNotLockFile, getDebugInfo, initialResolver);
#if ExtendedRuntime
        ExtendedRuntimeTypes.Initialize(doNotLockFile, getDebugInfo);
#endif
      }else if (!CoreSystemTypes.Initialized){
        CoreSystemTypes.Initialize(doNotLockFile, getDebugInfo, initialResolver);
#if ExtendedRuntime
        ExtendedRuntimeTypes.Clear();
        ExtendedRuntimeTypes.Initialize(doNotLockFile, getDebugInfo);
#endif
      }

      if (TargetPlatform.TargetVersion == null){
        TargetPlatform.TargetVersion = SystemAssembly.Version;
        if (TargetPlatform.TargetVersion == null)
          TargetPlatform.TargetVersion = typeof(object).Module.Assembly.GetName().Version;
      }

      InitializeSystemTypes(SystemAssembly);
    }
Ejemplo n.º 13
0
 /// <param name="module">The module into which the duplicate IR will be grafted.</param>
 /// <param name="type">The type into which the duplicate Member will be grafted. Ignored if entire type, or larger unit is duplicated.</param>
 public Duplicator(Module/*!*/ module, TypeNode type)
   : this(module, type, 4)
 {
   
 }
Ejemplo n.º 14
0
    private void ProvideTypeMembers(TypeNode/*!*/ dup, object/*!*/ handle) {
      TypeNode template = (TypeNode)handle;
      Debug.Assert(!template.membersBeingPopulated);
      TypeNode savedTargetType = this.TargetType;
      Module savedTargetModule = this.TargetModule;
      this.TargetType = dup;
      //^ assume dup.DeclaringModule != null;
      this.TargetModule = dup.DeclaringModule;
      //if (!this.RecordOriginalAsTemplate) this.FindTypesToBeDuplicated(template.NestedTypes);
      dup.Members = this.VisitMemberList(template.Members);
      DelegateNode delegateNode = dup as DelegateNode;
      if (delegateNode != null && delegateNode.IsNormalized){
        Debug.Assert(dup.Members != null && dup.Members.Count > 0 && dup.Members[0] != null);
        DelegateNode templateDelegateNode = template as DelegateNode;
        delegateNode.Parameters = this.VisitParameterList(templateDelegateNode.Parameters);
        delegateNode.ReturnType = this.VisitTypeReference(templateDelegateNode.ReturnType);
      }
#if ExtendedRuntime || CodeContracts
      dup.Contract = this.VisitTypeContract(template.Contract);
#endif

      this.TargetModule = savedTargetModule;
      this.TargetType = savedTargetType;
    }
Ejemplo n.º 15
0
    private void ProvideTypeSignature(TypeNode/*!*/ dup, object/*!*/ handle)
    {
      TypeNode type = (TypeNode)handle;
      TypeNode savedTargetType = this.TargetType;
      this.TargetType = dup;
      this.TargetModule = dup.DeclaringModule;
      
      // There could be type instantiations of this thing during the following visits.
      // They need to know what type parameters we have.
      // Null check is here so if someone copies a type and then immediately updates the template parameters
      //  we don't override it
      if (!this.RecordOriginalAsTemplate && dup.templateParameters == null)
      {
        dup.TemplateParameters = this.VisitTypeReferenceList(type.TemplateParameters);
      }
      if (dup.DeclaringType == null && !(dup is ITypeParameter))
      {
        var originalDeclaringType = type.DeclaringType;
        var declaringType = this.VisitTypeReference(originalDeclaringType);
        if (originalDeclaringType != null && (declaringType == null || declaringType == originalDeclaringType))
        {
          dup.DeclaringType = this.OriginalTargetType;
        }
        else
        {
          dup.DeclaringType = declaringType;
        }
      }
      Class c = dup as Class;
      if (c != null && c.baseClass == null)
      {
        Class templateClass = (Class)type;
        c.BaseClass = (Class)this.VisitTypeReference(templateClass.BaseClass);
      }
      dup.Interfaces = this.VisitInterfaceReferenceList(type.Interfaces);

      this.TargetType = savedTargetType;
    }