public ExprProperty CreateProperty(CType pType, Expr pOptionalObjectThrough, Expr pOptionalArguments, ExprMemberGroup pMemberGroup, PropWithType pwtSlot, MethWithType mwtGet, MethWithType mwtSet) { ExprProperty rval = new ExprProperty(pType); rval.OptionalObjectThrough = pOptionalObjectThrough; rval.OptionalArguments = pOptionalArguments; rval.MemberGroup = pMemberGroup; if (pwtSlot != null) { rval.PropWithTypeSlot = pwtSlot; } if (mwtSet != null) { rval.MethWithTypeSet = mwtSet; } return(rval); }
// Value public Expr BindValue(Expr exprSrc) { Debug.Assert(exprSrc != null && exprSrc.Type is NullableType); // For new T?(x), the answer is x. if (IsNullableConstructor(exprSrc, out ExprCall call)) { var args = call.OptionalArguments; Debug.Assert(args != null && !(args is ExprList)); return(args); } NullableType nubSrc = (NullableType)exprSrc.Type; CType typeBase = nubSrc.GetUnderlyingType(); AggregateType ats = nubSrc.GetAts(GetErrorContext()); if (ats == null) { ExprProperty rval = GetExprFactory().CreateProperty(typeBase, exprSrc); rval.SetError(); return(rval); } 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); MethPropWithInst mpwi = new MethPropWithInst(prop, ats); ExprMemberGroup pMemGroup = GetExprFactory().CreateMemGroup(exprSrc, mpwi); ExprProperty exprRes = GetExprFactory().CreateProperty(typeBase, null, null, pMemGroup, pwt, null); if (prop == null) { exprRes.SetError(); } return(exprRes); }
// Value public Expr BindValue(Expr exprSrc) { Debug.Assert(exprSrc != null && exprSrc.Type.IsNullableType()); // For new T?(x), the answer is x. if (IsNullableConstructor(exprSrc)) { Debug.Assert(exprSrc.asCALL().OptionalArguments != null && !exprSrc.asCALL().OptionalArguments.isLIST()); return(exprSrc.asCALL().OptionalArguments); } CType typeBase = exprSrc.Type.AsNullableType().GetUnderlyingType(); AggregateType ats = exprSrc.Type.AsNullableType().GetAts(GetErrorContext()); if (ats == null) { ExprProperty rval = GetExprFactory().CreateProperty(typeBase, exprSrc); rval.SetError(); return(rval); } 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?.methGet, ats); MethPropWithInst mpwi = new MethPropWithInst(prop, ats); ExprMemberGroup pMemGroup = GetExprFactory().CreateMemGroup(exprSrc, mpwi); ExprProperty exprRes = GetExprFactory().CreateProperty(typeBase, null, null, pMemGroup, pwt, mwt, null); if (prop == null) { exprRes.SetError(); } return(exprRes); }
public ExprProperty CreateProperty(CType pType, Expr pOptionalObjectThrough, Expr pOptionalArguments, ExprMemberGroup pMemberGroup, PropWithType pwtSlot, MethWithType mwtGet, MethWithType mwtSet) { ExprProperty rval = new ExprProperty(); rval.Kind = ExpressionKind.EK_PROP; rval.Type = pType; rval.Flags = 0; rval.OptionalObjectThrough = pOptionalObjectThrough; rval.OptionalArguments = pOptionalArguments; rval.MemberGroup = pMemberGroup; if (pwtSlot != null) { rval.PropWithTypeSlot = pwtSlot; } if (mwtSet != null) { rval.MethWithTypeSet = mwtSet; } Debug.Assert(rval != null); return(rval); }
protected override Expr VisitPROP(ExprProperty expr) { Debug.Assert(expr != null); Expr pObject; if (expr.PropWithTypeSlot.Prop().isStatic || expr.MemberGroup.OptionalObject == null) { pObject = GetExprFactory().CreateNull(); } else { pObject = Visit(expr.MemberGroup.OptionalObject); } Expr propInfo = GetExprFactory().CreatePropertyInfo(expr.PropWithTypeSlot.Prop(), expr.PropWithTypeSlot.GetType()); if (expr.OptionalArguments != null) { // It is an indexer property. Turn it into a virtual method call. Expr args = GenerateArgsList(expr.OptionalArguments); Expr Params = GenerateParamsArray(args, PredefinedType.PT_EXPRESSION); return(GenerateCall(PREDEFMETH.PM_EXPRESSION_PROPERTY, pObject, propInfo, Params)); } return(GenerateCall(PREDEFMETH.PM_EXPRESSION_PROPERTY, pObject, propInfo)); }
protected virtual Expr VisitPROP(ExprProperty pExpr) { return(VisitEXPR(pExpr)); }