示例#1
0
        /// <summary>
        /// Start a type definition for a boxed value type
        /// Adds also repository id and IIdlEntity inheritance.
        /// </summary>
        public TypeBuilder StartBoxedValueTypeDefinition(Symbol typeSymbol, Type boxedType,
                                                         CustomAttributeBuilder[] boxedTypeAttributes)
        {
            if (IsTypeDeclarded(typeSymbol))
            {
                // was not skipped, tried to redeclare -> internal error
                throw new InternalCompilerException("A type with the name " +
                                                    GetKnownType(typeSymbol).GetCompactClsType().FullName +
                                                    " is already declared for symbol: " + typeSymbol);
            }

            Scope  enclosingScope = typeSymbol.getDeclaredIn();
            String fullyQualName  = enclosingScope.GetFullyQualifiedNameForSymbol(typeSymbol.getSymbolName());

            Trace.WriteLine("generating code for boxed value type: " + fullyQualName);

            TypeBuilder result =
                m_boxedValueTypeGenerator.CreateBoxedType(boxedType, m_modBuilder,
                                                          fullyQualName, boxedTypeAttributes);

            // book-keeping
            TypeContainer container = new CompileTimeTypeContainer(this, result);

            m_typesInCreation[typeSymbol] = container;

            // repository and iidlentiry inheritance
            result.AddInterfaceImplementation(typeof(IIdlEntity));
            AddRepositoryIdAttribute(result, typeSymbol);

            return(result);
        }
示例#2
0
        /// <summary>
        /// start a type definition for a type
        /// </summary>
        /// <param name="isForwardDeclaration">specifies, if this type is created from an idl forward declaration</param>
        private TypeBuilder StartTypeDefinition(Symbol typeSymbol, string fullyQualName,
                                                TypeAttributes typeAttributes, Type parent, Type[] interfaces,
                                                bool isForwardDeclaration)
        {
            if (IsTypeDeclarded(typeSymbol))
            {
                // was not skipped, tried to redeclare -> internal error
                throw new InternalCompilerException("A type with the name " +
                                                    GetKnownType(typeSymbol).GetCompactClsType().FullName +
                                                    " is already declared for symbol: " + typeSymbol);
            }

            TypeBuilder result = m_modBuilder.DefineType(fullyQualName, typeAttributes, parent, interfaces);

            AddRepositoryIdAttribute(result, typeSymbol); // every constructed type should have a rep-id.
            // book-keeping
            TypeContainer container = new CompileTimeTypeContainer(this, result);

            m_typesInCreation[typeSymbol] = container;

            if (isForwardDeclaration)
            {
                // store type-fwd declaration in a special place, to allow searching only those when trying to complete a fwd declaration.
                m_fwdDeclaredTypes[typeSymbol] = container;
            }

            return(result);
        }
示例#3
0
 /// <summary>
 /// allows sequence recursion for unions/struct. Don't forget to call
 /// UnpublishTypeForSequenceRecursion after sequence elem type is identified
 /// </summary>
 public void PublishTypeForSequenceRecursion(Symbol typeSym, TypeBuilder type)
 {
     if (!IsTypeDeclarded(typeSym))
     {
         TypeContainer container =
             new CompileTimeTypeContainer(this, type);
         m_sequenceRecursionAllowedType = new TypeSymbolPair(typeSym, container);
     }
 }
示例#4
0
        public UnionGenerationHelper StartUnionTypeDefinition(Symbol typeSymbol, string fullyQualName)
        {
            if (IsTypeDeclarded(typeSymbol))
            {
                // was not skipped, tried to redeclare -> internal error
                throw new InternalCompilerException("A type with the name " +
                                                    GetKnownType(typeSymbol).GetCompactClsType().FullName +
                                                    " is already declared for symbol: " + typeSymbol);
            }

            UnionGenerationHelper genHelper = new UnionGenerationHelper(m_modBuilder, fullyQualName,
                                                                        TypeAttributes.Public);

            AddRepositoryIdAttribute(genHelper.Builder, typeSymbol);
            // book-keeping
            TypeContainer container = new CompileTimeTypeContainer(this, genHelper.Builder);

            m_typesInCreation[typeSymbol] = container;

            return(genHelper);
        }
示例#5
0
        /// <summary>
        /// get the full defined Type or the fwd decl
        /// </summary>
        public TypeContainer GetKnownType(Symbol forSymbol)
        {
            // search in all complete types from this run, also typesdefs, ...
            TypeContainer result = (TypeContainer)m_completeTypeTable[forSymbol];

            if (result == null)
            {
                result = (TypeContainer)m_typesInCreation[forSymbol];
            }
            if (result == null)
            {
                // search in build-module to get also types from a run over a previous root idl-file (one specified on the command line)
                Type fromBuildMod = GetTypeFromBuildModule(forSymbol);
                if (fromBuildMod != null)
                {
                    result = new CompileTimeTypeContainer(this, fromBuildMod);
                }
            }
            if (result == null)
            {
                // check in types, which are defined in referenced assemblies

                Type fromAsm = GetTypeFromRefAssemblies(forSymbol);
                if (fromAsm != null)
                {
                    // remark: all types in ref assemblies are fully completed -> no need for compileTimeTypeContainer
                    result = new TypeContainer(fromAsm);
                }
            }
            if ((result == null) && (m_sequenceRecursionAllowedType != null) &&
                m_sequenceRecursionAllowedType.SymbolPart.Equals(forSymbol))
            {
                result = m_sequenceRecursionAllowedType.TypePart;
            }
            return(result);
        }
示例#6
0
 /// <summary>
 /// allows sequence recursion for unions/struct. Don't forget to call
 /// UnpublishTypeForSequenceRecursion after sequence elem type is identified
 /// </summary>
 public void PublishTypeForSequenceRecursion(Symbol typeSym, TypeBuilder type) {
     if (!IsTypeDeclarded(typeSym)) {
         TypeContainer container =
             new CompileTimeTypeContainer(this, type);
         m_sequenceRecursionAllowedType = new TypeSymbolPair(typeSym, container);
     }            
 }
示例#7
0
        /// <summary> 
        /// get the full defined Type or the fwd decl
        /// </summary>
        public TypeContainer GetKnownType(Symbol forSymbol) {
            // search in all complete types from this run, also typesdefs, ...
            TypeContainer result = (TypeContainer)m_completeTypeTable[forSymbol];
            if (result == null) {
                result = (TypeContainer)m_typesInCreation[forSymbol];
            }
            if (result == null) {
                // search in build-module to get also types from a run over a previous root idl-file (one specified on the command line)
                Type fromBuildMod = GetTypeFromBuildModule(forSymbol);
                if (fromBuildMod != null) {
                    result = new CompileTimeTypeContainer(this, fromBuildMod);
                }        
            }
            if (result == null) { 
                // check in types, which are defined in referenced assemblies

                Type fromAsm = GetTypeFromRefAssemblies(forSymbol);
                if (fromAsm != null) {
                    // remark: all types in ref assemblies are fully completed -> no need for compileTimeTypeContainer
                    result = new TypeContainer(fromAsm);
                }
            }
            if ((result == null) && (m_sequenceRecursionAllowedType != null) &&
                m_sequenceRecursionAllowedType.SymbolPart.Equals(forSymbol)) {
                result = m_sequenceRecursionAllowedType.TypePart;
            }
            return result;
        }
示例#8
0
        public UnionGenerationHelper StartUnionTypeDefinition(Symbol typeSymbol, string fullyQualName) {            
            
            if (IsTypeDeclarded(typeSymbol)) {
                // was not skipped, tried to redeclare -> internal error
                throw new InternalCompilerException("A type with the name " + 
                                                    GetKnownType(typeSymbol).GetCompactClsType().FullName +
                                                    " is already declared for symbol: " + typeSymbol);
            }            
            
            UnionGenerationHelper genHelper = new UnionGenerationHelper(m_modBuilder, fullyQualName,
                                                                        TypeAttributes.Public);
            AddRepositoryIdAttribute(genHelper.Builder, typeSymbol);
            // book-keeping
            TypeContainer container = new CompileTimeTypeContainer(this, genHelper.Builder);
            m_typesInCreation[typeSymbol] = container;

            return genHelper;
        }
示例#9
0
        /// <summary>
        /// Start a type definition for a boxed value type
        /// Adds also repository id and IIdlEntity inheritance.
        /// </summary>
        public TypeBuilder StartBoxedValueTypeDefinition(Symbol typeSymbol, Type boxedType, 
                                                         CustomAttributeBuilder[] boxedTypeAttributes) {            

            if (IsTypeDeclarded(typeSymbol)) {
                // was not skipped, tried to redeclare -> internal error
                throw new InternalCompilerException("A type with the name " + 
                                                    GetKnownType(typeSymbol).GetCompactClsType().FullName +
                                                    " is already declared for symbol: " + typeSymbol);
            }

            Scope enclosingScope = typeSymbol.getDeclaredIn();
            String fullyQualName = enclosingScope.GetFullyQualifiedNameForSymbol(typeSymbol.getSymbolName());
                                                    
            Trace.WriteLine("generating code for boxed value type: " + fullyQualName);
            
            TypeBuilder result =
                m_boxedValueTypeGenerator.CreateBoxedType(boxedType, m_modBuilder,
                                                          fullyQualName, boxedTypeAttributes);
                                                            
            // book-keeping
            TypeContainer container = new CompileTimeTypeContainer(this, result);
            m_typesInCreation[typeSymbol] = container;
            
            // repository and iidlentiry inheritance
            result.AddInterfaceImplementation(typeof(IIdlEntity));
            AddRepositoryIdAttribute(result, typeSymbol);            
            
            return result;            
        }    
示例#10
0
 /// <summary>
 /// start a type definition for a type
 /// </summary>        
 /// <param name="isForwardDeclaration">specifies, if this type is created from an idl forward declaration</param>
 private TypeBuilder StartTypeDefinition(Symbol typeSymbol, string fullyQualName,
                                        TypeAttributes typeAttributes, Type parent, Type[] interfaces,
                                        bool isForwardDeclaration) {                                   
                                       
      if (IsTypeDeclarded(typeSymbol)) {
          // was not skipped, tried to redeclare -> internal error
          throw new InternalCompilerException("A type with the name " + 
                                              GetKnownType(typeSymbol).GetCompactClsType().FullName +
                                              " is already declared for symbol: " + typeSymbol);
      }            
     
     TypeBuilder result = m_modBuilder.DefineType(fullyQualName, typeAttributes, parent, interfaces);
     AddRepositoryIdAttribute(result, typeSymbol); // every constructed type should have a rep-id.
     // book-keeping
     TypeContainer container = new CompileTimeTypeContainer(this, result);
     m_typesInCreation[typeSymbol] = container;
                                                                                  
     if (isForwardDeclaration) {
         // store type-fwd declaration in a special place, to allow searching only those when trying to complete a fwd declaration.
         m_fwdDeclaredTypes[typeSymbol] = container;
     }
                                            
     return result;
 }