}
protected void assignKwargs(IRubyObject[] args, Ruby runtime, ThreadContext context, DynamicScope scope, IRubyObject self) {
if (args.length > 0) {
if (args[args.length - 1] instanceof RubyHash) {
RubyHash keyValues = (RubyHash)args[args.length - 1];
if (keywords != null) {
for (Node knode : keywords.childNodes()) {
KeywordArgNode kwarg = (KeywordArgNode)knode;
LocalAsgnNode kasgn = (LocalAsgnNode)kwarg.getAssignable();
String name = kasgn.getName();
RubySymbol sym = runtime.newSymbol(name);
if (keyValues.op_aref(context, sym).isNil()) {
kasgn.interpret(runtime, context, self, Block.NULL_BLOCK);
} else {
IRubyObject value = keyValues.delete(context, sym, Block.NULL_BLOCK);
scope.setValue(kasgn.getIndex(), value, kasgn.getDepth());
}
}
}
if (keyRest == null && !keyValues.isEmpty()) {
throw runtime.newArgumentError("unknown keyword: " + keyValues.directKeySet().iterator().next());
}
if (keyRest != null) {
LocalAsgnNode krestAsgn = (LocalAsgnNode)keyRest.getVariable();
scope.setValue(krestAsgn.getIndex(), keyValues, krestAsgn.getDepth());