}
});
}
public void compileMethodArgs(Node node, BodyCompiler context, boolean expr) {
final ArgsNode argsNode = (ArgsNode) node;
final int required = argsNode.getRequiredArgsCount();
final int opt = argsNode.getOptionalArgsCount();
final int rest = argsNode.getRestArg();
ArrayCallback requiredAssignment = null;
ArrayCallback optionalGiven = null;
ArrayCallback optionalNotGiven = null;
CompilerCallback restAssignment = null;
CompilerCallback blockAssignment = null;
if (required > 0) {
requiredAssignment = new ArrayCallback() {
public void nextValue(BodyCompiler context, Object object, int index) {
ArrayNode arguments = (ArrayNode)object;
Node argNode = arguments.get(index);
switch (argNode.getNodeType()) {
case ARGUMENTNODE:
int varIndex = ((ArgumentNode)argNode).getIndex();
context.getVariableCompiler().assignLocalVariable(varIndex, false);
break;
case MULTIPLEASGN19NODE:
compileMultipleAsgn19Assignment(argNode, context, false);
break;
default:
throw new NotCompilableException("unknown argument type: " + argNode);
}
}
};
}
if (opt > 0) {
optionalGiven = new ArrayCallback() {
public void nextValue(BodyCompiler context, Object object, int index) {
OptArgNode optArg = (OptArgNode)((ListNode) object).get(index);
compileAssignment(optArg.getValue(), context, false);
}
};
optionalNotGiven = new ArrayCallback() {
public void nextValue(BodyCompiler context, Object object, int index) {
OptArgNode optArg = (OptArgNode)((ListNode) object).get(index);
compile(optArg.getValue(), context, false);
}
};
}
if (rest > -1) {
restAssignment = new CompilerCallback() {
public void call(BodyCompiler context) {
context.getVariableCompiler().assignLocalVariable(argsNode.getRestArg(), false);
}
};
}
if (argsNode.getBlock() != null) {
blockAssignment = new CompilerCallback() {
public void call(BodyCompiler context) {
context.getVariableCompiler().assignLocalVariable(argsNode.getBlock().getCount(), false);
}
};
}
context.getVariableCompiler().assignMethodArguments19(
argsNode.getPre(),
argsNode.getPreCount(),
argsNode.getPost(),
argsNode.getPostCount(),
argsNode.getPostIndex(),
argsNode.getOptArgs(),
argsNode.getOptionalArgsCount(),
requiredAssignment,
optionalGiven,
optionalNotGiven,
restAssignment,
blockAssignment);