// FIXME: Charlie added this to test something?
if (a instanceof TypedArgumentNode) {
TypedArgumentNode t = (TypedArgumentNode)a;
s.addInstr(new DECLARE_LOCAL_TYPE_Instr(argIndex, buildType(t.getTypeNode())));
}
s.addInstr(new ReceiveArgumentInstruction(s.getLocalVariable(a.getName()), argIndex));
}
// IMPORTANT: Receive the block argument before the opt and splat args
// This is so that the *arg can be encoded as 'rest of the array'. This
// won't work if the block argument hasn't been received yet!
if (argsNode.getBlock() != null)
s.addInstr(new ReceiveClosureInstr(s.getLocalVariable(argsNode.getBlock().getName())));
// Now for the rest
if (opt > 0) {
ListNode optArgs = argsNode.getOptArgs();
for (int j = 0; j < opt; j++, argIndex++) {
// Jump to 'l' if this arg is not null. If null, fall through and build the default value!
Label l = s.getNewLabel();
LocalAsgnNode n = (LocalAsgnNode)optArgs.get(j);
Variable av = s.getLocalVariable(n.getName());
s.addInstr(new ReceiveOptionalArgumentInstr(av, argIndex));
s.addInstr(new BNEInstr(av, Nil.NIL, l)); // if 'av' is not null, go to default
build(n, s);
s.addInstr(new LABEL_Instr(l));
}
}
if (rest > -1) {
s.addInstr(new ReceiveArgumentInstruction(s.getLocalVariable(argsNode.getRestArgNode().getName()), argIndex, true));
}
// FIXME: Ruby 1.9 post args code needs to come here
}