// elt = buildCall([], arr, arg)
// val = build(n) <-- val
// val = buildCall(METH, elt, val)
// val = buildCall([]=, arr, arg, val)
public Operand buildOpElementAsgnWithMethod(Node node, IRScope s) {
final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
Operand array = build(opElementAsgnNode.getReceiverNode(), s);
List<Operand> args = setupCallArgs(opElementAsgnNode.getArgsNode(), s);
// SSS FIXME: Verify with Tom that I am not missing something here
assert args.size() == 1;
Operand index = args.get(0);
Variable elt = s.getNewTemporaryVariable();
s.addInstr(new CallInstr(elt, new MethAddr("[]"), array, new Operand[] { index }, null)); // elt = a[index]
Operand value = build(opElementAsgnNode.getValueNode(), s); // Load 'value'
String operation = opElementAsgnNode.getOperatorName();
s.addInstr(new CallInstr(elt, new MethAddr(operation), elt, new Operand[] { value }, null)); // elt = elt.OPERATION(value)
// SSS: do not load the call result into 'elt' to eliminate the RAW dependency on the call
// We already know what the result is going be .. we are just storing it back into the array
Variable tmp = s.getNewTemporaryVariable();
s.addInstr(new CallInstr(tmp, new MethAddr("[]="), array, new Operand[] { index, elt }, null)); // a[index] = elt