/////////////////////////////////////////////////////////////////////////////////
// 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));
}