compileMultipleAsgn19Assignment(multipleAsgn19Node, context, expr);
}
public void compileMultipleAsgn19Assignment(Node node, BodyCompiler context, boolean expr) {
final MultipleAsgn19Node multipleAsgn19Node = (MultipleAsgn19Node) node;
// normal items at the front or back of the masgn
ArrayCallback prePostAssignCallback = new ArrayCallback() {
public void nextValue(BodyCompiler context, Object sourceArray,
int index) {
ListNode nodes = (ListNode) sourceArray;
Node assignNode = nodes.get(index);
// perform assignment for the next node
compileAssignment(assignNode, context, false);
}
};
CompilerCallback restCallback = new CompilerCallback() {
public void call(BodyCompiler context) {
Node argsNode = multipleAsgn19Node.getRest();
if (argsNode instanceof StarNode) {
// done processing args
context.consumeCurrentValue();
} else {
// assign to appropriate variable
compileAssignment(argsNode, context, false);
}
}
};
if (multipleAsgn19Node.getPreCount() == 0 && multipleAsgn19Node.getPostCount() == 0) {
if (multipleAsgn19Node.getRest() == null) {
throw new NotCompilableException("Something's wrong, multiple assignment with no head or args at: " + multipleAsgn19Node.getPosition());
} else {
if (multipleAsgn19Node.getRest() instanceof StarNode) {
// do nothing
} else {
context.ensureMultipleAssignableRubyArray(multipleAsgn19Node.getPreCount() != 0 || multipleAsgn19Node.getPostCount() != 0);
context.forEachInValueArray(0, 0, null, null, restCallback);
}
}
} else {
context.ensureMultipleAssignableRubyArray(multipleAsgn19Node.getPreCount() != 0 || multipleAsgn19Node.getPostCount() != 0);
if (multipleAsgn19Node.getRest() == null) {
context.forEachInValueArray(0, multipleAsgn19Node.getPreCount(), multipleAsgn19Node.getPre(), multipleAsgn19Node.getPostCount(), multipleAsgn19Node.getPost(), prePostAssignCallback, null);
} else {
context.forEachInValueArray(0, multipleAsgn19Node.getPreCount(), multipleAsgn19Node.getPre(), multipleAsgn19Node.getPostCount(), multipleAsgn19Node.getPost(), prePostAssignCallback, restCallback);
}
}
// TODO: don't require pop
if (!expr) context.consumeCurrentValue();
}