Пример #1
0
        public SymbolLoader()
        {
            GlobalSymbolContext globalSymbols = new GlobalSymbolContext();

            PredefinedMembers   = new PredefinedMembers(this);
            ErrorContext        = new ErrorHandling(globalSymbols);
            GlobalSymbolContext = globalSymbols;
            Debug.Assert(GlobalSymbolContext != null);
        }
Пример #2
0
 public SymbolLoader(
     GlobalSymbolContext globalSymbols,
     ErrorHandling errorContext
     )
 {
     _nameManager        = globalSymbols.GetNameManager();
     PredefinedMembers   = new PredefinedMembers(this);
     ErrorContext        = errorContext;
     GlobalSymbolContext = globalSymbols;
     Debug.Assert(GlobalSymbolContext != null);
 }
Пример #3
0
        // Create an expr for new T?(exprSrc) where T is exprSrc.type.
        private static ExprCall BindNubNew(Expr exprSrc)
        {
            Debug.Assert(exprSrc != null);

            NullableType    pNubSourceType = TypeManager.GetNullable(exprSrc.Type);
            AggregateType   pSourceType    = pNubSourceType.GetAts();
            MethodSymbol    meth           = PredefinedMembers.GetMethod(PREDEFMETH.PM_G_OPTIONAL_CTOR);
            MethWithInst    methwithinst   = new MethWithInst(meth, pSourceType, TypeArray.Empty);
            ExprMemberGroup memgroup       = ExprFactory.CreateMemGroup(null, methwithinst);

            return(ExprFactory.CreateCall(EXPRFLAG.EXF_NEWOBJCALL | EXPRFLAG.EXF_CANTBENULL, pNubSourceType, exprSrc, memgroup, methwithinst));
        }
Пример #4
0
 public SymbolLoader(
     GlobalSymbolContext globalSymbols,
     UserStringBuilder userStringBuilder,
     ErrorHandling errorContext
 )
 {
     _nameManager = globalSymbols.GetNameManager();
     PredefinedMembers = new PredefinedMembers(this);
     ErrorContext = errorContext;
     GlobalSymbolContext = globalSymbols;
     Debug.Assert(GlobalSymbolContext != null);
 }
Пример #5
0
        // Create an expr for exprSrc.Value where exprSrc.type is a NullableType.
        private static Expr BindNubValue(Expr exprSrc)
        {
            Debug.Assert(exprSrc != null && exprSrc.Type is NullableType);

            // For new T?(x), the answer is x.
            if (IsNullableConstructor(exprSrc, out ExprCall call))
            {
                Expr args = call.OptionalArguments;
                Debug.Assert(args != null && !(args is ExprList));
                return(args);
            }

            NullableType     nubSrc    = (NullableType)exprSrc.Type;
            CType            typeBase  = nubSrc.UnderlyingType;
            AggregateType    ats       = nubSrc.GetAts();
            PropertySymbol   prop      = PredefinedMembers.GetProperty(PREDEFPROP.PP_G_OPTIONAL_VALUE);
            PropWithType     pwt       = new PropWithType(prop, ats);
            MethPropWithInst mpwi      = new MethPropWithInst(prop, ats);
            ExprMemberGroup  pMemGroup = ExprFactory.CreateMemGroup(exprSrc, mpwi);

            return(ExprFactory.CreateProperty(typeBase, null, null, pMemGroup, pwt, null));
        }
Пример #6
0
 private static MethodSymbol GetPreDefMethod(PREDEFMETH pdm) => PredefinedMembers.GetMethod(pdm);