// this loop handles nested, complex assignments, such as:
// class(x) <- "foo"
// x$a[3] <- 4
// class(x$a[3]) <- "foo"
SEXP lhs = assignment.getArgument(0);
while(lhs instanceof FunctionCall) {
FunctionCall call = (FunctionCall) lhs;
rhs = builder.translateSetterCall(context, call, rhs);
lhs = call.getArgument(0);
}
LValue target;
if( lhs instanceof Symbol) {
target = new EnvironmentVariable((Symbol) lhs);
} else if(lhs instanceof StringVector) {
target = new EnvironmentVariable( Symbol.get(((StringVector) lhs).getElementAsString(0)) );
} else {
throw new EvalException("cannot assign to value of type " + lhs.getTypeName());
}
doAssignment(builder, target, rhs);
}