예제 #1
0
 private string GetFullTypeNameForSymbol(Symbol forSymbol) {
     Scope declIn = forSymbol.getDeclaredIn();
     return declIn.GetFullyQualifiedNameForSymbol(forSymbol.getSymbolName());
 }
예제 #2
0
 private Type GetTypeFromRefAssemblies(Symbol forSymbol) {
     string fullName = GetFullTypeNameForSymbol(forSymbol);          
     String repId = 
         forSymbol.getDeclaredIn().getRepositoryIdFor(forSymbol.getSymbolName());
     return m_refAsmTypes.GetTypeFromRefAssemblies(fullName, repId);
 }
예제 #3
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;            
        }    
예제 #4
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>
 public TypeBuilder StartTypeDefinition(Symbol typeSymbol,
                                        TypeAttributes typeAttributes, Type parent, Type[] interfaces,
                                        bool isForwardDeclaration) {
     Scope enclosingScope = typeSymbol.getDeclaredIn();
     String fullyQualName = enclosingScope.GetFullyQualifiedNameForSymbol(typeSymbol.getSymbolName());
     return StartTypeDefinition(typeSymbol, fullyQualName, 
                                typeAttributes, parent, interfaces, isForwardDeclaration);
 }
예제 #5
0
 /// <summary>finds the repository id attribute for the symbol starting the search in startInScope</summary>
 private string FindRepositoryId(Symbol forSymbol) {
     Scope startInScope = forSymbol.getDeclaredIn();
     string forName = forSymbol.getSymbolName();
     string result = startInScope.getRepositoryIdFor(forName);
     if (result == null) {
         // try inside scope to find it
         Scope innerScope = startInScope.getChildScope(forName);
         if (innerScope != null) {
             result = innerScope.getRepositoryIdFor(forName);
         }
     }
     return result;
 }
 /** handles the declaration for the value definition / fwd declaration
  * @return the TypeBuilder for this interface
  */
 private TypeBuilder CreateOrGetValueDcl(Symbol forSymbol,
                                         System.Type parent, System.Type[] interfaces,
                                         bool isAbstract, bool isForwardDecl) {
     TypeBuilder valueToBuild;
     if (!m_typeManager.IsFwdDeclared(forSymbol)) {
         Trace.WriteLine("generating code for value type: " + forSymbol.getSymbolName());
         TypeAttributes attrs = TypeAttributes.Public | TypeAttributes.Abstract;
         if (isAbstract) {
             attrs |= TypeAttributes.Interface;
             if (parent != null) { 
                 // classes are considered as concrete value types
                 throw new InvalidIdlException("not possible for an abstract value type " +
                                               forSymbol.getDeclaredIn().GetFullyQualifiedNameForSymbol(forSymbol.getSymbolName()) + 
                                               " to inherit from a concrete one " +
                                               parent.FullName);
             }
         } else {
             attrs |= TypeAttributes.Class;
         }
         valueToBuild = m_typeManager.StartTypeDefinition(forSymbol, attrs, parent, interfaces, 
                                                          isForwardDecl);            
         if (isAbstract) {
             // add InterfaceTypeAttribute
             IdlTypeInterface ifType = IdlTypeInterface.AbstractValueType;
             CustomAttributeBuilder interfaceTypeAttrBuilder = new InterfaceTypeAttribute(ifType).CreateAttributeBuilder();
             valueToBuild.SetCustomAttribute(interfaceTypeAttrBuilder);
         }
         valueToBuild.AddInterfaceImplementation(typeof(IIdlEntity)); // implement IDLEntity
     } else {
         // get incomplete type
         Trace.WriteLine("complete valuetype: " + forSymbol.getSymbolName());
         valueToBuild = m_typeManager.GetIncompleteForwardDeclaration(forSymbol);
         // add inheritance relationship:
         for (int i = 0; i < interfaces.Length; i++) {
             valueToBuild.AddInterfaceImplementation(interfaces[i]);
         }
         if (parent != null) { 
             valueToBuild.SetParent(parent);
         }
     }
     // add abstract methods for all interface methods, a class inherit from (only if valueToBuild is a class an not an interface)
     // add property to abstract class for all properties defined in an interface (only if valueToBuild is a class an not an interface)
     AddInheritedMembersAbstractDeclToClassForIf(valueToBuild, interfaces);
     return valueToBuild;
 }
 /** handles the declaration for the interface definition / fwd declaration
  * @return the TypeBuilder for this interface
  */
 private TypeBuilder CreateOrGetInterfaceDcl(Symbol forSymbol, System.Type[] interfaces, 
                                             bool isAbstract, bool isLocal, bool isForward) {
     TypeBuilder interfaceToBuild = null;
     if (!m_typeManager.IsFwdDeclared(forSymbol)) {
         Trace.WriteLine("generating code for interface: " + forSymbol.getSymbolName());
         interfaceToBuild = m_typeManager.StartTypeDefinition(forSymbol, 
                                                              TypeAttributes.Interface | TypeAttributes.Public | TypeAttributes.Abstract,
                                                              null, interfaces, isForward);
         // add InterfaceTypeAttribute
         IdlTypeInterface ifType = IdlTypeInterface.ConcreteInterface;
         if (isAbstract) { 
             ifType = IdlTypeInterface.AbstractInterface; 
         }
         if (isLocal) {
             ifType = IdlTypeInterface.LocalInterface;
         }
         if ((isLocal) && (isAbstract)) {
             throw new InternalCompilerException("internal error: iftype precondition");
         }
         // add interface type
         CustomAttributeBuilder interfaceTypeAttrBuilder = new InterfaceTypeAttribute(ifType).CreateAttributeBuilder();
         interfaceToBuild.SetCustomAttribute(interfaceTypeAttrBuilder);
         interfaceToBuild.AddInterfaceImplementation(typeof(IIdlEntity));
     } else {
         // get incomplete type
         Trace.WriteLine("complete interface: " + forSymbol.getSymbolName());
         interfaceToBuild = m_typeManager.GetIncompleteForwardDeclaration(forSymbol);
         // add inheritance relationship:
         for (int i = 0; i < interfaces.Length; i++) {
             interfaceToBuild.AddInterfaceImplementation(interfaces[i]);
         }
     }
     return interfaceToBuild;
 }