예제 #1
0
        public BSYMMGR()
        {
            this.tableGlobal = new SYMTBL();
            _symFactory      = new SymFactory(this.tableGlobal);

            this.tableTypeArrays = new Dictionary <TypeArrayKey, TypeArray>();
            _rootNS = _symFactory.CreateNamespace(NameManager.Lookup(""), null);

            ////////////////////////////////////////////////////////////////////////////////
            // Build the data structures needed to make FPreLoad fast. Make sure the
            // namespaces are created. Compute and sort hashes of the NamespaceSymbol * value and type
            // name (sans arity indicator).

            for (int i = 0; i < (int)PredefinedType.PT_COUNT; ++i)
            {
                NamespaceSymbol ns    = GetRootNS();
                string          name  = PredefinedTypeFacts.GetName((PredefinedType)i);
                int             start = 0;
                while (start < name.Length)
                {
                    int iDot = name.IndexOf('.', start);
                    if (iDot == -1)
                    {
                        break;
                    }
                    string sub = (iDot > start) ? name.Substring(start, iDot - start) : name.Substring(start);
                    Name   nm  = NameManager.Add(sub);
                    ns     = LookupGlobalSymCore(nm, ns, symbmask_t.MASK_NamespaceSymbol) as NamespaceSymbol ?? _symFactory.CreateNamespace(nm, ns);
                    start += sub.Length + 1;
                }
            }
        }
        public bool Init(ErrorHandling errorContext, SymbolTable symtable)
        {
            _runtimeBinderSymbolTable = symtable;
            Debug.Assert(_pBSymmgr != null);

#if !CSEE
            Debug.Assert(_predefSyms == null);
#else // CSEE
            Debug.Assert(predefSyms == null || aidMsCorLib != KAID.kaidNil);
#endif // CSEE

            if (_aidMsCorLib == KAID.kaidNil)
            {
                // If we haven't found mscorlib yet, first look for System.Object. Then use its assembly as
                // the location for all other pre-defined types.
                AggregateSymbol aggObj = FindPredefinedType(errorContext, PredefinedTypeFacts.GetName(PredefinedType.PT_OBJECT), KAID.kaidGlobal, AggKindEnum.Class, 0, true);
                if (aggObj == null)
                {
                    return(false);
                }
                _aidMsCorLib = aggObj.GetAssemblyID();
            }

            _predefSyms = new AggregateSymbol[(int)PredefinedType.PT_COUNT];
            Debug.Assert(_predefSyms != null);

            return(true);
        }
예제 #3
0
        ////////////////////////////////////////////////////////////////////////////////
        // Build the data structures needed to make FPreLoad fast. Make sure the
        // namespaces are created. Compute and sort hashes of the NamespaceSymbol * value and type
        // name (sans arity indicator).

        private void InitPreLoad()
        {
            for (int i = 0; i < (int)PredefinedType.PT_COUNT; ++i)
            {
                NamespaceSymbol ns    = GetRootNS();
                string          name  = PredefinedTypeFacts.GetName((PredefinedType)i);
                int             start = 0;
                while (start < name.Length)
                {
                    int iDot = name.IndexOf('.', start);
                    if (iDot == -1)
                    {
                        break;
                    }
                    string          sub = (iDot > start) ? name.Substring(start, iDot - start) : name.Substring(start);
                    Name            nm  = this.GetNameManager().Add(sub);
                    NamespaceSymbol sym = this.LookupGlobalSymCore(nm, ns, symbmask_t.MASK_NamespaceSymbol).AsNamespaceSymbol();
                    if (sym == null)
                    {
                        ns = _symFactory.CreateNamespace(nm, ns);
                    }
                    else
                    {
                        ns = sym;
                    }
                    start += sub.Length + 1;
                }
            }
        }
예제 #4
0
        // We want to delay load the predefined symbols as needed.
        private AggregateSymbol DelayLoadPredefSym(PredefinedType pt)
        {
            CType           type = _runtimeBinderSymbolTable.GetCTypeFromType(PredefinedTypeFacts.GetAssociatedSystemType(pt));
            AggregateSymbol sym  = type.getAggregate();

            return(InitializePredefinedType(sym, pt));
        }
예제 #5
0
        // We want to delay load the predefined symbols as needed.
        private static AggregateSymbol DelayLoadPredefSym(PredefinedType pt)
        {
            AggregateType   type = (AggregateType)SymbolTable.GetCTypeFromType(PredefinedTypeFacts.GetAssociatedSystemType(pt));
            AggregateSymbol sym  = type.OwningAggregate;

            return(InitializePredefinedType(sym, pt));
        }
        // We want to delay load the predef syms as needed.
        private AggregateSymbol DelayLoadPredefSym(PredefinedType pt)
        {
            CType           type = _runtimeBinderSymbolTable.GetCTypeFromType(PredefinedTypeFacts.GetAssociatedSystemType(pt));
            AggregateSymbol sym  = type.getAggregate();

            // If we failed to load this thing, we have problems.
            if (sym == null)
            {
                return(null);
            }
            return(InitializePredefinedType(sym, pt));
        }
        public void ReportMissingPredefTypeError(ErrorHandling errorContext, PredefinedType pt)
        {
            Debug.Assert(_pBSymmgr != null);
            Debug.Assert(_predefSyms != null);
            Debug.Assert((PredefinedType)0 <= pt && pt < PredefinedType.PT_COUNT && _predefSyms[(int)pt] == null);

            // We do not assert that !predefTypeInfo[pt].isRequired because if the user is defining
            // their own MSCorLib and is defining a required PredefType, they'll run into this error
            // and we need to allow it to go through.

            errorContext.Error(ErrorCode.ERR_PredefinedTypeNotFound, PredefinedTypeFacts.GetName(pt));
        }
 public AggregateSymbol GetReqPredefAgg(PredefinedType pt)
 {
     if (!PredefinedTypeFacts.IsRequired(pt))
     {
         throw Error.InternalCompilerError();
     }
     if (_predefSyms[(int)pt] == null)
     {
         // Delay load this thing.
         _predefSyms[(int)pt] = DelayLoadPredefSym(pt);
     }
     return(_predefSyms[(int)pt]);
 }
예제 #9
0
파일: Type.cs 프로젝트: wenchaoli/corefx
        ////////////////////////////////////////////////////////////////////////////////
        // Given a symbol, determine its fundamental type. This is the type that
        // indicate how the item is stored and what instructions are used to reference
        // if. The fundamental types are:
        // one of the integral/float types (includes enums with that underlying type)
        // reference type
        // struct/value type
        public FUNDTYPE fundType()
        {
            switch (GetTypeKind())
            {
            case TypeKind.TK_AggregateType:
            {
                AggregateSymbol sym = ((AggregateType)this).getAggregate();

                // Treat enums like their underlying types.
                if (sym.IsEnum())
                {
                    sym = sym.GetUnderlyingType().getAggregate();
                }

                if (sym.IsStruct())
                {
                    // Struct type could be predefined (int, long, etc.) or some other struct.
                    if (sym.IsPredefined())
                    {
                        return(PredefinedTypeFacts.GetFundType(sym.GetPredefType()));
                    }
                    return(FUNDTYPE.FT_STRUCT);
                }
                return(FUNDTYPE.FT_REF);         // Interfaces, classes, delegates are reference types.
            }

            case TypeKind.TK_TypeParameterType:
                return(FUNDTYPE.FT_VAR);

            case TypeKind.TK_ArrayType:
            case TypeKind.TK_NullType:
                return(FUNDTYPE.FT_REF);

            case TypeKind.TK_PointerType:
                return(FUNDTYPE.FT_PTR);

            case TypeKind.TK_NullableType:
                return(FUNDTYPE.FT_STRUCT);

            default:
                return(FUNDTYPE.FT_NONE);
            }
        }
예제 #10
0
파일: Type.cs 프로젝트: wenchaoli/corefx
 ////////////////////////////////////////////////////////////////////////////////
 // A few types are considered "numeric" types. They are the fundamental number
 // types the compiler knows about for operators and conversions.
 public bool isNumericType()
 {
     return(isPredefined() &&
            PredefinedTypeFacts.IsNumericType(getPredefType()));
 }
예제 #11
0
파일: Type.cs 프로젝트: wenchaoli/corefx
 ////////////////////////////////////////////////////////////////////////////////
 // A few types are considered "simple" types for purposes of conversions and so
 // on. They are the fundamental types the compiler knows about for operators and
 // conversions.
 public bool isSimpleType()
 {
     return(isPredefined() &&
            PredefinedTypeFacts.IsSimpleType(getPredefType()));
 }
 public static bool isRequired(PredefinedType pt)
 {
     return(PredefinedTypeFacts.IsRequired(pt));
 }
 public static string GetFullName(PredefinedType pt)
 {
     return(PredefinedTypeFacts.GetName(pt));
 }
예제 #14
0
        ////////////////////////////////////////////////////////////////////////////////
        // Some of the predefined types have built-in names, like "int" or "string" or
        // "object". This return the nice name if one exists; otherwise null is
        // returned.

        private static string GetNiceName(PredefinedType pt)
        {
            return(PredefinedTypeFacts.GetNiceName(pt));
        }
예제 #15
0
 public static string GetFullName(PredefinedType pt) => PredefinedTypeFacts.GetName(pt);
예제 #16
0
        ////////////////////////////////////////////////////////////////////////////////
        // Some of the predefined types have built-in names, like "int" or "string" or
        // "object". This return the nice name if one exists; otherwise null is
        // returned.

        private static string GetNiceName(PredefinedType pt) => PredefinedTypeFacts.GetNiceName(pt);