CreatePropertyInfo() public method

public CreatePropertyInfo ( Microsoft.CSharp.RuntimeBinder.Semantics.PropertySymbol prop, AggregateType propertyType ) : Microsoft.CSharp.RuntimeBinder.Semantics.EXPRPropertyInfo
prop Microsoft.CSharp.RuntimeBinder.Semantics.PropertySymbol
propertyType AggregateType
return Microsoft.CSharp.RuntimeBinder.Semantics.EXPRPropertyInfo
Example #1
0
        /////////////////////////////////////////////////////////////////////////////////
        // Statement types.
        protected override Expr VisitASSIGNMENT(ExprAssignment assignment)
        {
            Debug.Assert(assignment != null);

            // For assignments, we either have a member assignment or an indexed assignment.
            //Debug.Assert(assignment.GetLHS().isPROP() || assignment.GetLHS().isFIELD() || assignment.GetLHS().isARRAYINDEX() || assignment.GetLHS().isLOCAL());
            Expr lhs;

            if (assignment.LHS is ExprProperty prop)
            {
                if (prop.OptionalArguments == null)
                {
                    // Regular property.
                    lhs = Visit(prop);
                }
                else
                {
                    // Indexed assignment. Here we need to find the instance of the object, create the
                    // PropInfo for the thing, and get the array of expressions that make up the index arguments.
                    //
                    // The LHS becomes Expression.Property(instance, indexerInfo, arguments).
                    Expr instance  = Visit(prop.MemberGroup.OptionalObject);
                    Expr propInfo  = ExprFactory.CreatePropertyInfo(prop.PropWithTypeSlot.Prop(), prop.PropWithTypeSlot.Ats);
                    Expr arguments = GenerateParamsArray(
                        GenerateArgsList(prop.OptionalArguments),
                        PredefinedType.PT_EXPRESSION);

                    lhs = GenerateCall(PREDEFMETH.PM_EXPRESSION_PROPERTY, instance, propInfo, arguments);
                }
            }
            else
            {
                lhs = Visit(assignment.LHS);
            }

            Expr rhs = Visit(assignment.RHS);

            return(GenerateCall(PREDEFMETH.PM_EXPRESSION_ASSIGN, lhs, rhs));
        }
Example #2
0
        protected override Expr VisitPROP(ExprProperty expr)
        {
            Debug.Assert(expr != null);
            Expr pObject;

            if (expr.PropWithTypeSlot.Prop().isStatic || expr.MemberGroup.OptionalObject == null)
            {
                pObject = ExprFactory.CreateNull();
            }
            else
            {
                pObject = Visit(expr.MemberGroup.OptionalObject);
            }
            Expr propInfo = ExprFactory.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));
        }