public EXPRASSIGNMENT CreateAssignment(EXPR pLHS, EXPR pRHS)
        {
            EXPRASSIGNMENT pAssignment = new EXPRASSIGNMENT();

            pAssignment.kind  = ExpressionKind.EK_ASSIGNMENT;
            pAssignment.type  = pLHS.type;
            pAssignment.flags = EXPRFLAG.EXF_ASSGOP;
            pAssignment.SetLHS(pLHS);
            pAssignment.SetRHS(pRHS);
            return(pAssignment);
        }
        /////////////////////////////////////////////////////////////////////////////////
        // Statement types.
        protected override EXPR VisitASSIGNMENT(EXPRASSIGNMENT assignment)
        {
            Debug.Assert(assignment != null);
            Debug.Assert(alwaysRewrite || currentAnonMeth != 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.GetLHS().isPROP())
            {
                EXPRPROP prop = assignment.GetLHS().asPROP();

                if (prop.GetOptionalArguments() == 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.GetMemberGroup().GetOptionalObject());
                    EXPR propInfo = GetExprFactory().CreatePropertyInfo(prop.pwtSlot.Prop(), prop.pwtSlot.Ats);
                    EXPR arguments = GenerateParamsArray(
                        GenerateArgsList(prop.GetOptionalArguments()),
                        PredefinedType.PT_EXPRESSION);

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

            EXPR rhs = Visit(assignment.GetRHS());
            return GenerateCall(PREDEFMETH.PM_EXPRESSION_ASSIGN, lhs, rhs);
        }
Example #3
0
 protected virtual EXPR VisitASSIGNMENT(EXPRASSIGNMENT pExpr)
 {
     return(VisitEXPR(pExpr));
 }
Example #4
0
 protected virtual EXPR VisitASSIGNMENT(EXPRASSIGNMENT pExpr)
 {
     return VisitEXPR(pExpr);
 }
Example #5
0
 public EXPRASSIGNMENT CreateAssignment(EXPR pLHS, EXPR pRHS)
 {
     EXPRASSIGNMENT pAssignment = new EXPRASSIGNMENT();
     pAssignment.kind = ExpressionKind.EK_ASSIGNMENT;
     pAssignment.type = pLHS.type;
     pAssignment.flags = EXPRFLAG.EXF_ASSGOP;
     pAssignment.SetLHS(pLHS);
     pAssignment.SetRHS(pRHS);
     return pAssignment;
 }