public static IRubyObject INTERPRET_BLOCK(Ruby runtime, ThreadContext context, String file, int line, Node node, String name, IRubyObject self, Block block) { try { ThreadContext.pushBacktrace(context, name, file, line); blockPreTrace(runtime, context, name, self.getType()); return node.interpret(runtime, context, self, block); } finally { blockPostTrace(runtime, context, name, self.getType()); ThreadContext.popBacktrace(context); } } public static IRubyObject INTERPRET_ROOT(Ruby runtime, ThreadContext context, Node node, IRubyObject self, Block block) {
@JRubyMethod(name = "==", required = 1) @Override public IRubyObject op_equal(ThreadContext context, IRubyObject other) { if (this == other) return context.tru; if (!(other instanceof RubyStruct)) return context.fals; if (getType() != other.getType()) { return context.fals; } if (other == this) return context.tru; // recursion guard return context.safeRecurse(EqualRecursive.INSTANCE, other, this, "==", true); }
private String formatMessage(final IRubyObject msg) { if (getRuntime().getString().equals(msg.getType())) { return msg.asJavaString(); } else if (getRuntime().getHash().equals(msg.getType())) { final RubyHash hash = (RubyHash) msg; return Objects.toString(hash.get(getRuntime().newSymbol(LOG_PROPERTY_TEXT))); } throw new IllegalArgumentException(Objects.toString(msg)); }
private String formatMessage(final IRubyObject msg) { if (getRuntime().getString().equals(msg.getType())) { return msg.asJavaString(); } else if (getRuntime().getHash().equals(msg.getType())) { final RubyHash hash = (RubyHash) msg; return Objects.toString(hash.get(getRuntime().newSymbol(LOG_PROPERTY_TEXT))); } throw new IllegalArgumentException(Objects.toString(msg)); }
public static IRubyObject[] toAry(ThreadContext context, IRubyObject[] args) { IRubyObject ary; if (args.length == 1 && (ary = Helpers.aryOrToAry(context, args[0])) != context.nil) { if (ary instanceof RubyArray) { args = ((RubyArray) ary).toJavaArray(); } else { throw context.runtime.newTypeError(args[0].getType().getName() + "#to_ary should return Array"); } } return args; }
private IRubyObject[] toAry(ThreadContext context, IRubyObject value) { final IRubyObject ary = Helpers.aryToAry(context, value); if (ary == context.nil) return new IRubyObject[] { value }; if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArray(); throw context.runtime.newTypeError(value.getType().getName() + "#to_ary should return Array"); }
/** rb_cmperr * */ public static IRubyObject cmperr(IRubyObject recv, IRubyObject other) { IRubyObject target; if (other.isImmediate() || !(other.isNil() || other.isTrue() || other == recv.getRuntime().getFalse())) { target = other.inspect(); } else { target = other.getType(); } throw recv.getRuntime().newArgumentError("comparison of " + recv.getType() + " with " + target + " failed"); }
private IRubyObject[] toAry(ThreadContext context, IRubyObject value) { final IRubyObject ary = Helpers.aryToAry(context, value); if (ary == context.nil) return new IRubyObject[] { value }; if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArray(); throw context.runtime.newTypeError(value.getType().getName() + "#to_ary should return Array"); }
public static IRubyObject[] toAry(ThreadContext context, IRubyObject[] args) { IRubyObject ary; if (args.length == 1 && (ary = Helpers.aryOrToAry(context, args[0])) != context.nil) { if (ary instanceof RubyArray) { args = ((RubyArray) ary).toJavaArray(); } else { throw context.runtime.newTypeError(args[0].getType().getName() + "#to_ary should return Array"); } } return args; }
@Override @JRubyMethod(name = "==", required = 1) public IRubyObject op_equal(ThreadContext context, IRubyObject obj) { if (!getType().equals(obj.getType())) { return context.fals; } return context.runtime.newBoolean(random.equals(((RubyRandom) obj).random)); }
/** num_sadded * */ @JRubyMethod(name = "singleton_method_added") public static IRubyObject singleton_method_added(ThreadContext context, IRubyObject self, IRubyObject name) { Ruby runtime = context.runtime; throw runtime.newTypeError(str(runtime, "can't define singleton method \"", ids(runtime, name), "\" for ", types(runtime, self.getType()))); }
@Override @JRubyMethod(name = "==", required = 1) public IRubyObject op_equal(ThreadContext context, IRubyObject obj) { if (!getType().equals(obj.getType())) { return context.fals; } return context.runtime.newBoolean(random.equals(((RubyRandom) obj).random)); }
@Override @JRubyMethod(name = "==", required = 1, compat = RUBY1_9) public IRubyObject op_equal_19(ThreadContext context, IRubyObject obj) { if (!getType().equals(obj.getType())) { return context.runtime.getFalse(); } return context.runtime.newBoolean(random.equals(((RubyRandom) obj).random)); }
private Cursor getSourceLocation(IRubyObject msg) { if (getRuntime().getHash().equals(msg.getType())) { final RubyHash hash = (RubyHash) msg; final Object sourceLocation = hash.get(getRuntime().newSymbol(LOG_PROPERTY_SOURCE_LOCATION)); return new CursorImpl((IRubyObject) sourceLocation); } return null; } }
private Cursor getSourceLocation(IRubyObject msg) { if (getRuntime().getHash().equals(msg.getType())) { final RubyHash hash = (RubyHash) msg; final Object sourceLocation = hash.get(getRuntime().newSymbol(LOG_PROPERTY_SOURCE_LOCATION)); return new CursorImpl((IRubyObject) sourceLocation); } return null; } }
@Override public IRubyObject set(IRubyObject value) { if (value == get()) { return value; } if (!value.respondsTo("write") && !value.respondsToMissing("write")) { throw runtime.newTypeError(name() + " must have write method, " + value.getType().getName() + " given"); } return super.set(value); } }
@Override public IRubyObject set(IRubyObject value) { if (value == get()) { return value; } if (!value.respondsTo("write") && !value.respondsToMissing("write")) { throw runtime.newTypeError(name() + " must have write method, " + value.getType().getName() + " given"); } return super.set(value); } }
@JRubyMethod(name = "assignable_from?", required = 1) public RubyBoolean assignable_from_p(IRubyObject other) { if ( ! (other instanceof JavaClass) ) { throw getRuntime().newTypeError("assignable_from requires JavaClass (" + other.getType() + " given)"); } Class<?> otherClass = ((JavaClass) other).javaClass(); return isAssignableFrom(otherClass) ? getRuntime().getTrue() : getRuntime().getFalse(); }
@JRubyMethod(name = "assignable_from?", required = 1) public RubyBoolean assignable_from_p(IRubyObject other) { if ( ! (other instanceof JavaClass) ) { throw getRuntime().newTypeError("assignable_from requires JavaClass (" + other.getType() + " given)"); } Class<?> otherClass = ((JavaClass) other).javaClass(); return isAssignableFrom(otherClass) ? getRuntime().getTrue() : getRuntime().getFalse(); }
@JRubyMethod(name = "assignable_from?", required = 1) public RubyBoolean assignable_from_p(IRubyObject other) { if (! (other instanceof JavaClass)) { throw getRuntime().newTypeError("assignable_from requires JavaClass (" + other.getType() + " given)"); } Class<?> otherClass = ((JavaClass) other).javaClass(); return assignable(javaClass(), otherClass) ? getRuntime().getTrue() : getRuntime().getFalse(); }