org.jruby
Class RubyFixnum

java.lang.Object
  extended by org.jruby.RubyObject
      extended by org.jruby.RubyNumeric
          extended by org.jruby.RubyInteger
              extended by org.jruby.RubyFixnum
All Implemented Interfaces:
java.lang.Cloneable, IRubyObject

public class RubyFixnum
extends RubyInteger

Implementation of the Fixnum class.

Author:
jpetersen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.RubyNumeric
RubyNumeric.InvalidIntegerException, RubyNumeric.NumberTooLargeException
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Finalizer
 
Field Summary
static byte EQUALEQUAL_SWITCHVALUE
           
static byte HASH_SWITCHVALUE
           
static byte INSPECT_SWITCHVALUE
           
static long MAX
           
static long MAX_MARSHAL_FIXNUM
           
static long MIN
           
static long MIN_MARSHAL_FIXNUM
           
static byte OP_GT_SWITCHVALUE
           
static byte OP_LE_SWITCHVALUE
           
static byte OP_LT_SWITCHVALUE
           
static byte OP_MINUS_SWITCHVALUE
           
static byte OP_PLUS_SWITCHVALUE
           
static byte OP_SPACESHIP_SWITCHVALUE
           
static byte OP_TIMES_SWITCHVALUE
           
static byte TO_I_SWITCHVALUE
           
static byte TO_INT_SWITCHVALUE
           
static byte TO_S_SWITCHVALUE
           
 
Fields inherited from class org.jruby.RubyNumeric
DBL_EPSILON, NUMERIC_ALLOCATOR
 
Fields inherited from class org.jruby.RubyObject
instanceVariables, isTrue, metaClass, NEVER, OBJECT_ALLOCATOR
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyFixnum(Ruby runtime)
           
RubyFixnum(Ruby runtime, long value)
           
 
Method Summary
 IRubyObject abs()
          fix_abs
 IRubyObject and(IRubyObject other)
          fix_and
 IRubyObject aref(IRubyObject other)
          fix_aref
 IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, int methodIndex, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject cmp(IRubyObject other)
          fix_cmp
static RubyClass createFixnumClass(Ruby runtime)
           
 IRubyObject div_div(IRubyObject other)
          fix_div here is terrible MRI gotcha: 1.div 3.0 -> 0 1 / 3.0 -> 0.3333333333333333 MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: rb_funcall(x, ruby_frame->orig_func, 1, y); also note that RubyFloat doesn't override Numeric.div
 IRubyObject div_slash(IRubyObject other)
           
 IRubyObject divmod(IRubyObject other)
          fix_divmod
 boolean eql(IRubyObject other)
          short circuit for Fixnum key comparison
 IRubyObject equal(IRubyObject other)
          fix_equal
 boolean equals(java.lang.Object other)
          This method is just a wrapper around the Ruby "==" method, provided so that RubyObjects can be used as keys in the Java HashMap object underlying RubyHash.
 IRubyObject freeze()
          Freeze an object.
 IRubyObject ge(IRubyObject other)
          fix_ge
 double getDoubleValue()
           
 java.lang.Class getJavaClass()
          RubyMethod getJavaClass.
 long getLongValue()
           
 int getNativeTypeIndex()
          This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.
 IRubyObject gt(IRubyObject other)
          fix_gt
 RubyFixnum hash()
           
 int hashCode()
           
 RubyFixnum id()
          Return the internal id of an object.
 IRubyObject id2name()
          fix_id2name
 IRubyObject idiv(IRubyObject other, java.lang.String method)
           
static IRubyObject induced_from(IRubyObject recv, IRubyObject other)
          rb_fix_induced_from
 boolean isImmediate()
           
 IRubyObject le(IRubyObject other)
          fix_le
 IRubyObject lshift(IRubyObject other)
          fix_lshift
 IRubyObject lt(IRubyObject other)
          fix_lt
static RubyFixnum minus_one(Ruby runtime)
           
 IRubyObject minus(IRubyObject other)
          fix_minus
 IRubyObject mod(IRubyObject other)
          fix_mod
 IRubyObject mul(IRubyObject other)
          fix_mul
 RubyFixnum newFixnum(long newValue)
           
static RubyFixnum newFixnum(Ruby runtime, long value)
           
static RubyFixnum one(Ruby runtime)
           
 IRubyObject or(IRubyObject other)
          fix_or
 IRubyObject plus(IRubyObject other)
          fix_plus
 IRubyObject pow(IRubyObject other)
          fix_pow
 IRubyObject quo(IRubyObject other)
          fix_quo
 IRubyObject rev()
          fix_rev
 IRubyObject rshift(IRubyObject other)
          fix_rshift
 IRubyObject size()
          fix_size
 IRubyObject taint()
          rb_obj_taint
 IRubyObject to_f()
          fix_to_f
 RubyString to_s(IRubyObject[] args)
          fix_to_s
 IRubyObject to_sym()
          fix_to_sym
 IRubyObject uminus()
          fix_uminus
static RubyFixnum unmarshalFrom(UnmarshalStream input)
           
 IRubyObject xor(IRubyObject other)
          fix_xor
 IRubyObject zero_p()
          fix_zero_p
static RubyFixnum zero(Ruby runtime)
           
 
Methods inherited from class org.jruby.RubyInteger
chr, convertToInteger, createIntegerClass, downto, int_p, succ, times, to_i, toFloat, upto
 
Methods inherited from class org.jruby.RubyNumeric
asNumeric, callCoerced, callCoerced, ceil, checkInt, coerce, coerceBin, coerceBody, coerceCmp, coerceRelOp, createNumericClass, dbl_cmp, dbl2num, div, doCoerce, eql_p, fix2int, fix2long, floor, getCoerced, init_copy, int2fix, modulo, newNumeric, nonzero_p, num2dbl, num2fix, num2int, num2long, remainder, round, sadded, step, str2fnum, str2fnum, str2inum, str2inum, to_int, truncate, uplus
 
Methods inherited from class org.jruby.RubyObject
addFinalizer, anyToString, asString, asSymbol, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethodMissing, callMethodMissing, callSuper, checkArrayType, checkFrozen, checkStringType, compilerCallMethod, compilerCallMethodWithIndex, convertToArray, convertToFloat, convertToHash, convertToString, convertToType, convertToType, convertToType, convertToTypeWithCheck, createObjectClass, dataGetStruct, dataWrapStruct, display, doClone, dup, eqlInternal, equalInternal, evalSimple, evalUnder, evalWithBinding, extend, frozen, getInstanceVariable, getInstanceVariables, getInstanceVariablesSnapshot, getMetaClass, getRuntime, getSingletonClass, getSingletonClassClone, getType, id_deprecated, infectBy, inherited, initCopy, initialize_copy, initialize, inspect, instance_eval, instance_exec, instance_of, instance_variable_get, instance_variable_set, instance_variables, instanceVariableNames, isFalse, isFrozen, isKindOf, isNil, isSingleton, isTaint, isTrue, kind_of, makeMetaClass, match, method, methods, nil_p, obj_equal, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, respond_to, respondsTo, safeGetInstanceVariables, safeHasInstanceVariables, send, setFrozen, setInstanceVariable, setInstanceVariable, setInstanceVariables, setMetaClass, setTaint, singleton_methods, specificEval, tainted, testFrozen, to_s, toString, trueFalseNil, trueFalseNil, type_deprecated, type, untaint
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX

public static final long MAX
See Also:
Constant Field Values

MIN

public static final long MIN
See Also:
Constant Field Values

MAX_MARSHAL_FIXNUM

public static final long MAX_MARSHAL_FIXNUM
See Also:
Constant Field Values

MIN_MARSHAL_FIXNUM

public static final long MIN_MARSHAL_FIXNUM
See Also:
Constant Field Values

OP_PLUS_SWITCHVALUE

public static final byte OP_PLUS_SWITCHVALUE
See Also:
Constant Field Values

OP_MINUS_SWITCHVALUE

public static final byte OP_MINUS_SWITCHVALUE
See Also:
Constant Field Values

OP_LT_SWITCHVALUE

public static final byte OP_LT_SWITCHVALUE
See Also:
Constant Field Values

TO_S_SWITCHVALUE

public static final byte TO_S_SWITCHVALUE
See Also:
Constant Field Values

TO_I_SWITCHVALUE

public static final byte TO_I_SWITCHVALUE
See Also:
Constant Field Values

TO_INT_SWITCHVALUE

public static final byte TO_INT_SWITCHVALUE
See Also:
Constant Field Values

HASH_SWITCHVALUE

public static final byte HASH_SWITCHVALUE
See Also:
Constant Field Values

OP_GT_SWITCHVALUE

public static final byte OP_GT_SWITCHVALUE
See Also:
Constant Field Values

OP_TIMES_SWITCHVALUE

public static final byte OP_TIMES_SWITCHVALUE
See Also:
Constant Field Values

EQUALEQUAL_SWITCHVALUE

public static final byte EQUALEQUAL_SWITCHVALUE
See Also:
Constant Field Values

OP_LE_SWITCHVALUE

public static final byte OP_LE_SWITCHVALUE
See Also:
Constant Field Values

OP_SPACESHIP_SWITCHVALUE

public static final byte OP_SPACESHIP_SWITCHVALUE
See Also:
Constant Field Values

INSPECT_SWITCHVALUE

public static final byte INSPECT_SWITCHVALUE
See Also:
Constant Field Values
Constructor Detail

RubyFixnum

public RubyFixnum(Ruby runtime)

RubyFixnum

public RubyFixnum(Ruby runtime,
                  long value)
Method Detail

createFixnumClass

public static RubyClass createFixnumClass(Ruby runtime)

callMethod

public IRubyObject callMethod(ThreadContext context,
                              RubyModule rubyclass,
                              int methodIndex,
                              java.lang.String name,
                              IRubyObject[] args,
                              CallType callType,
                              Block block)
Specified by:
callMethod in interface IRubyObject
Overrides:
callMethod in class RubyObject
Returns:

getNativeTypeIndex

public int getNativeTypeIndex()
Description copied from class: RubyObject
This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.

Specified by:
getNativeTypeIndex in interface IRubyObject
Overrides:
getNativeTypeIndex in class RubyObject
Returns:
the ClassIndex of the native type this object was constructed from

eql

public final boolean eql(IRubyObject other)
short circuit for Fixnum key comparison

Specified by:
eql in interface IRubyObject
Overrides:
eql in class RubyObject

isImmediate

public boolean isImmediate()
Specified by:
isImmediate in interface IRubyObject
Overrides:
isImmediate in class RubyObject
Returns:

getJavaClass

public java.lang.Class getJavaClass()
Description copied from interface: IRubyObject
RubyMethod getJavaClass.

Specified by:
getJavaClass in interface IRubyObject
Overrides:
getJavaClass in class RubyObject
Returns:
Class

getDoubleValue

public double getDoubleValue()
Overrides:
getDoubleValue in class RubyNumeric

getLongValue

public long getLongValue()
Overrides:
getLongValue in class RubyNumeric

newFixnum

public static RubyFixnum newFixnum(Ruby runtime,
                                   long value)

newFixnum

public RubyFixnum newFixnum(long newValue)

zero

public static RubyFixnum zero(Ruby runtime)

one

public static RubyFixnum one(Ruby runtime)

minus_one

public static RubyFixnum minus_one(Ruby runtime)

hash

public RubyFixnum hash()
Overrides:
hash in class RubyObject

hashCode

public final int hashCode()
Overrides:
hashCode in class RubyObject

equals

public boolean equals(java.lang.Object other)
Description copied from class: RubyObject
This method is just a wrapper around the Ruby "==" method, provided so that RubyObjects can be used as keys in the Java HashMap object underlying RubyHash.

Overrides:
equals in class RubyObject

to_s

public RubyString to_s(IRubyObject[] args)
fix_to_s


id2name

public IRubyObject id2name()
fix_id2name


to_sym

public IRubyObject to_sym()
fix_to_sym


uminus

public IRubyObject uminus()
fix_uminus

Overrides:
uminus in class RubyNumeric

plus

public IRubyObject plus(IRubyObject other)
fix_plus


minus

public IRubyObject minus(IRubyObject other)
fix_minus


mul

public IRubyObject mul(IRubyObject other)
fix_mul


div_div

public IRubyObject div_div(IRubyObject other)
fix_div here is terrible MRI gotcha: 1.div 3.0 -> 0 1 / 3.0 -> 0.3333333333333333 MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: rb_funcall(x, ruby_frame->orig_func, 1, y); also note that RubyFloat doesn't override Numeric.div


div_slash

public IRubyObject div_slash(IRubyObject other)

idiv

public IRubyObject idiv(IRubyObject other,
                        java.lang.String method)

mod

public IRubyObject mod(IRubyObject other)
fix_mod


divmod

public IRubyObject divmod(IRubyObject other)
fix_divmod

Overrides:
divmod in class RubyNumeric

quo

public IRubyObject quo(IRubyObject other)
fix_quo

Overrides:
quo in class RubyNumeric

pow

public IRubyObject pow(IRubyObject other)
fix_pow


abs

public IRubyObject abs()
fix_abs

Overrides:
abs in class RubyNumeric

equal

public IRubyObject equal(IRubyObject other)
fix_equal

Specified by:
equal in interface IRubyObject
Overrides:
equal in class RubyNumeric

cmp

public IRubyObject cmp(IRubyObject other)
fix_cmp

Overrides:
cmp in class RubyNumeric

gt

public IRubyObject gt(IRubyObject other)
fix_gt


ge

public IRubyObject ge(IRubyObject other)
fix_ge


lt

public IRubyObject lt(IRubyObject other)
fix_lt


le

public IRubyObject le(IRubyObject other)
fix_le


rev

public IRubyObject rev()
fix_rev


and

public IRubyObject and(IRubyObject other)
fix_and


or

public IRubyObject or(IRubyObject other)
fix_or


xor

public IRubyObject xor(IRubyObject other)
fix_xor


aref

public IRubyObject aref(IRubyObject other)
fix_aref


lshift

public IRubyObject lshift(IRubyObject other)
fix_lshift


rshift

public IRubyObject rshift(IRubyObject other)
fix_rshift


to_f

public IRubyObject to_f()
fix_to_f


size

public IRubyObject size()
fix_size


zero_p

public IRubyObject zero_p()
fix_zero_p

Overrides:
zero_p in class RubyNumeric

id

public RubyFixnum id()
Description copied from class: RubyObject
Return the internal id of an object. CRuby function: rb_obj_id

Specified by:
id in interface IRubyObject
Overrides:
id in class RubyObject
Returns:

taint

public IRubyObject taint()
Description copied from class: RubyObject
rb_obj_taint

Overrides:
taint in class RubyObject

freeze

public IRubyObject freeze()
Description copied from class: RubyObject
Freeze an object. rb_obj_freeze

Overrides:
freeze in class RubyObject

unmarshalFrom

public static RubyFixnum unmarshalFrom(UnmarshalStream input)
                                throws java.io.IOException
Throws:
java.io.IOException

induced_from

public static IRubyObject induced_from(IRubyObject recv,
                                       IRubyObject other)
rb_fix_induced_from



Copyright © 2002-2007 JRuby Team. All Rights Reserved.