Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
~/NetBeansProjects/rubinius ➔ ruby -r shotgun/lib/primitives.rb -r shotgun/lib/jprimitives.rb -e "ShotgunPrimitives.new.generate_select(STDOUT)" ## RubiniusPrimitives.java public static IRubyObject cpu_primitive_add(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) { ARITY(1); GUARD(FIXNUM_P(msg->recv)); OBJECT t1 = stack_pop(); if(FIXNUM_P(t1)) { RET(fixnum_add(state, msg->recv, t1)); } else if(BIGNUM_P(t1)) { RET(bignum_add(state, bignum_new(state, N2I(msg->recv)), t1)); } else if(FLOAT_P(t1)) { OBJECT t2 = float_coerce(state, msg->recv); RET(float_new(state, FLOAT_TO_DOUBLE(t2) + FLOAT_TO_DOUBLE(t1))); } else { FAIL(); } } public static IRubyObject cpu_primitive_bignum_add(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) { ARITY(1); GUARD(BIGNUM_P(msg->recv)); OBJECT t1 = stack_pop(); if(BIGNUM_P(t1) || FIXNUM_P(t1)) { RET(bignum_add(state, msg->recv, t1)); } else if(FLOAT_P(t1)) { double a = bignum_to_double(state, msg->recv); RET(float_new(state, a + FLOAT_TO_DOUBLE(t1))); } else { FAIL(); } } public static IRubyObject cpu_primitive_sub(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) { ARITY(1); GUARD(FIXNUM_P(msg->recv)); OBJECT t1 = stack_pop(); if(FIXNUM_P(t1)) { RET(fixnum_sub(state, msg->recv, t1)); } else if(BIGNUM_P(t1)) { RET(bignum_sub(state, bignum_new(state, N2I(msg->recv)), t1)); } else if(FLOAT_P(t1)) { OBJECT t2 = float_coerce(state, msg->recv); RET(float_new(state, FLOAT_TO_DOUBLE(t2) - FLOAT_TO_DOUBLE(t1))); } else { FAIL(); ...
Pasted April 27, 2008 6:35PM EDT
by headius
Channel #rubinius on irc.freenode.com
Embed