Esempio n. 1
0
        // Value
        public EXPR BindValue(EXPR exprSrc)
        {
            Debug.Assert(exprSrc != null && exprSrc.type.IsNullableType());

            // For new T?(x), the answer is x.
            if (CNullable.IsNullableConstructor(exprSrc))
            {
                Debug.Assert(exprSrc.asCALL().GetOptionalArguments() != null && !exprSrc.asCALL().GetOptionalArguments().isLIST());
                return(exprSrc.asCALL().GetOptionalArguments());
            }

            CType         typeBase = exprSrc.type.AsNullableType().GetUnderlyingType();
            AggregateType ats      = exprSrc.type.AsNullableType().GetAts(GetErrorContext());

            if (ats == null)
            {
                EXPRPROP rval = GetExprFactory().CreateProperty(typeBase, exprSrc);
                rval.SetError();
                return(rval);
            }

            // UNDONE: move this to transform pass ...
            PropertySymbol prop = GetSymbolLoader().getBSymmgr().propNubValue;

            if (prop == null)
            {
                prop = GetSymbolLoader().getPredefinedMembers().GetProperty(PREDEFPROP.PP_G_OPTIONAL_VALUE);
                GetSymbolLoader().getBSymmgr().propNubValue = prop;
            }

            PropWithType     pwt       = new PropWithType(prop, ats);
            MethWithType     mwt       = new MethWithType(prop != null ? prop.methGet : null, ats);
            MethPropWithInst mpwi      = new MethPropWithInst(prop, ats);
            EXPRMEMGRP       pMemGroup = GetExprFactory().CreateMemGroup(exprSrc, mpwi);
            EXPRPROP         exprRes   = GetExprFactory().CreateProperty(typeBase, null, null, pMemGroup, pwt, mwt, null);

            if (prop == null)
            {
                exprRes.SetError();
            }

            return(exprRes);
        }
        public EXPRPROP CreateProperty(CType pType, EXPR pOptionalObjectThrough, EXPR pOptionalArguments, EXPRMEMGRP pMemberGroup, PropWithType pwtSlot, MethWithType mwtGet, MethWithType mwtSet)
        {
            EXPRPROP rval = new EXPRPROP();

            rval.kind  = ExpressionKind.EK_PROP;
            rval.type  = pType;
            rval.flags = 0;
            rval.SetOptionalObjectThrough(pOptionalObjectThrough);
            rval.SetOptionalArguments(pOptionalArguments);
            rval.SetMemberGroup(pMemberGroup);

            if (pwtSlot != null)
            {
                rval.pwtSlot = pwtSlot;
            }
            if (mwtSet != null)
            {
                rval.mwtSet = mwtSet;
            }
            Debug.Assert(rval != null);
            return(rval);
        }
Esempio n. 3
0
 protected override EXPR VisitPROP(EXPRPROP expr)
 {
     Debug.Assert(expr != null);
     Debug.Assert(alwaysRewrite || currentAnonMeth != null);
     EXPR pObject;
     if (expr.pwtSlot.Prop().isStatic || expr.GetMemberGroup().GetOptionalObject() == null)
     {
         pObject = GetExprFactory().CreateNull();
     }
     else
     {
         pObject = Visit(expr.GetMemberGroup().GetOptionalObject());
     }
     EXPR propInfo = GetExprFactory().CreatePropertyInfo(expr.pwtSlot.Prop(), expr.pwtSlot.GetType());
     if (expr.GetOptionalArguments() != null)
     {
         // It is an indexer property.  Turn it into a virtual method call.
         EXPR args = GenerateArgsList(expr.GetOptionalArguments());
         EXPR Params = GenerateParamsArray(args, PredefinedType.PT_EXPRESSION);
         return GenerateCall(PREDEFMETH.PM_EXPRESSION_PROPERTY, pObject, propInfo, Params);
     }
     return GenerateCall(PREDEFMETH.PM_EXPRESSION_PROPERTY, pObject, propInfo);
 }
Esempio n. 4
0
        protected void CheckLvalueProp(EXPRPROP prop)
        {
            Debug.Assert(prop != null);
            Debug.Assert(prop.isLvalue());

            // We have an lvalue property.  Give an error if this is an abstract property
            // or an inaccessible property.

            if (prop.isBaseCall() && prop.mwtSet.Meth().isAbstract)
            {
                ErrorContext.Error(ErrorCode.ERR_AbstractBaseCall, prop.mwtSet);
            }
            else
            {
                CType type = null;
                if (prop.GetOptionalObjectThrough() != null)
                {
                    type = prop.GetOptionalObjectThrough().type;
                }

                CheckPropertyAccess(prop.mwtSet, prop.pwtSlot, type);
            }
        }
Esempio n. 5
0
 protected virtual EXPR VisitPROP(EXPRPROP pExpr)
 {
     return VisitEXPR(pExpr);
 }
Esempio n. 6
0
 protected virtual EXPR VisitPROP(EXPRPROP pExpr)
 {
     return(VisitEXPR(pExpr));
 }
Esempio n. 7
0
        public EXPRPROP CreateProperty(CType pType, EXPR pOptionalObjectThrough, EXPR pOptionalArguments, EXPRMEMGRP pMemberGroup, PropWithType pwtSlot, MethWithType mwtGet, MethWithType mwtSet)
        {
            EXPRPROP rval = new EXPRPROP();
            rval.kind = ExpressionKind.EK_PROP;
            rval.type = pType;
            rval.flags = 0;
            rval.SetOptionalObjectThrough(pOptionalObjectThrough);
            rval.SetOptionalArguments(pOptionalArguments);
            rval.SetMemberGroup(pMemberGroup);

            if (pwtSlot != null)
            {
                rval.pwtSlot = pwtSlot;
            }
            if (mwtSet != null)
            {
                rval.mwtSet = mwtSet;
            }
            Debug.Assert(rval != null);
            return (rval);
        }