@RubyLevelMethod(name = "trace_var", module = true) public static RubyValue trace_var(RubyValue receiver, RubyArray args, RubyBlock block) { if (null == args || args.size() < 1) { int actual_argc = (null == args) ? 0 : args.size(); throw new RubyException( RubyRuntime.ArgumentErrorClass, "in `trace_var': wrong number of arguments (" + actual_argc + " for 1)"); } if (!(args.get(0) instanceof RubySymbol)) { throw new RubyException( RubyRuntime.ArgumentErrorClass, args.get(0).toString() + " is not a symbol"); } String name = ((RubySymbol) args.get(0)).toString(); RubyValue v = args.get(1); if (v instanceof RubyProc) { GlobalVariables.addTraceProc(name, (RubyProc) v); } else if (null != block) { GlobalVariables.addTraceProc(name, ObjectFactory.createProc(block)); } else { throw new RubyException( RubyRuntime.ArgumentErrorClass, "tried to create Proc object without a block"); } return RubyConstant.QNIL; }
@RubyLevelMethod(name = "at_exit", module = true) public static RubyValue atExit(RubyValue receiver, RubyBlock block) { if (null == block) { throw new RubyException(RubyRuntime.ArgumentErrorClass, "called without a block"); } AtExitBlocks.registerBlock(block); return ObjectFactory.createProc(block); }
@RubyLevelMethod(name = "lambda", alias = "proc", module = true) public static RubyValue lambda(RubyValue receiver, RubyBlock block) { block.setCreatedByLambda(); return ObjectFactory.createProc(block); }