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.io.Serializable, java.lang.Cloneable, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType

public class RubyFixnum
extends RubyInteger

Implementation of the Fixnum class.

See Also:
Serialized Form

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, RubyObject.ObjectMethods, RubyObject.VariableTableEntry
 
Field Summary
static long MAX
           
static long MAX_MARSHAL_FIXNUM
           
static long MIN
           
static long MIN_MARSHAL_FIXNUM
           
static long SIGN_BIT
           
 
Fields inherited from class org.jruby.RubyNumeric
DBL_EPSILON, NUMERIC_ALLOCATOR
 
Fields inherited from class org.jruby.RubyObject
ALL_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, metaClassName, NEVER, NIL_F, OBJECT_ALLOCATOR, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, VARIABLE_TABLE_DEFAULT_CAPACITY, VARIABLE_TABLE_EMPTY_TABLE, VARIABLE_TABLE_LOAD_FACTOR, VARIABLE_TABLE_MAXIMUM_CAPACITY, variableTable, variableTableSize, variableTableThreshold
 
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
 java.lang.String asJavaString()
          rb_to_id Will try to convert this object to a String using the Ruby "to_str" if the object isn't already a String.
static RubyClass createFixnumClass(Ruby runtime)
           
 IRubyObject div_div(ThreadContext context, 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 divmod(ThreadContext context, IRubyObject other)
          fix_divmod
 boolean eql(IRubyObject other)
          short circuit for Fixnum key comparison
 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.
 RubyBoolean even_p()
           
 IRubyObject freeze()
          rb_obj_freeze call-seq: obj.freeze => obj Prevents further modifications to obj.
 double getDoubleValue()
           
 java.lang.Class<?> getJavaClass()
          Will return the Java interface that most closely can represent this object, when working through JAva integration translations.
 long getLongValue()
           
 int getNativeTypeIndex()
          This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.
 RubyClass getSingletonClass()
          rb_singleton_class Note: this method is specialized for RubyFixnum, RubySymbol, RubyNil and RubyBoolean Will either return the existing singleton class for this object, or create a new one and rutning that.
 RubyFixnum hash()
          rb_obj_id Will return the hash code of this object.
 int hashCode()
          Override the Object#hashCode method to make sure that the Ruby hash is actually used as the hashcode for Ruby objects.
 IRubyObject id()
          rb_obj_id Return the internal id of an object.
 IRubyObject id2name()
          fix_id2name
 IRubyObject idiv(ThreadContext context, IRubyObject other, java.lang.String method)
           
static IRubyObject induced_from(IRubyObject recv, IRubyObject other)
          rb_fix_induced_from
 boolean isImmediate()
          Is object immediate (def: Fixnum, Symbol, true, false, nil?).
static RubyFixnum minus_one(Ruby runtime)
           
 RubyFixnum newFixnum(long newValue)
           
static RubyFixnum newFixnum(Ruby runtime, long value)
           
 RubyBoolean odd_p()
           
static RubyFixnum one(Ruby runtime)
           
 IRubyObject op_and(ThreadContext context, IRubyObject other)
          fix_and
 IRubyObject op_aref(IRubyObject other)
          fix_aref
 IRubyObject op_cmp(ThreadContext context, IRubyObject other)
          fix_cmp
 IRubyObject op_div(ThreadContext context, IRubyObject other)
           
 IRubyObject op_equal(ThreadContext context, IRubyObject other)
          fix_equal
 IRubyObject op_ge(ThreadContext context, IRubyObject other)
          fix_ge
 IRubyObject op_gt(ThreadContext context, IRubyObject other)
          fix_gt
 IRubyObject op_le(ThreadContext context, IRubyObject other)
          fix_le
 IRubyObject op_lshift(IRubyObject other)
          fix_lshift
 IRubyObject op_lt(ThreadContext context, IRubyObject other)
          fix_lt
 IRubyObject op_minus(ThreadContext context, IRubyObject other)
          fix_minus
 IRubyObject op_mod(ThreadContext context, IRubyObject other)
          fix_mod
 IRubyObject op_mul(ThreadContext context, IRubyObject other)
          fix_mul
 IRubyObject op_neg()
          fix_rev
 IRubyObject op_or(ThreadContext context, IRubyObject other)
          fix_or
 IRubyObject op_plus(ThreadContext context, IRubyObject other)
          fix_plus
 IRubyObject op_pow(ThreadContext context, IRubyObject other)
          fix_pow
 IRubyObject op_rshift(IRubyObject other)
          fix_rshift
 IRubyObject op_uminus()
          fix_uminus
 IRubyObject op_xor(ThreadContext context, IRubyObject other)
          fix_xor
 IRubyObject pred()
           
 IRubyObject quo(ThreadContext context, IRubyObject other)
          fix_quo
 IRubyObject size()
          fix_size
 IRubyObject taint()
          rb_obj_taint call-seq: obj.taint -> obj Marks obj as tainted---if the $SAFE level is set appropriately, many method calls which might alter the running programs environment will refuse to accept tainted strings.
 IRubyObject to_f()
          fix_to_f
 RubyString to_s(IRubyObject[] args)
          fix_to_s
 IRubyObject to_sym()
          fix_to_sym
static RubyFixnum unmarshalFrom(UnmarshalStream input)
           
 IRubyObject zero_p()
          fix_zero_p
static RubyFixnum zero(Ruby runtime)
           
 
Methods inherited from class org.jruby.RubyInteger
chr, convertToInteger, createIntegerClass, downto, even_p, induced_from, integer_p, odd_p, pred, succ, times, to_i, toFloat, upto
 
Methods inherited from class org.jruby.RubyNumeric
abs, asNumeric, callCoerced, callCoerced, ceil, checkInt, coerce, coerceBin, coerceBody, coerceCmp, coerceRelOp, createNumericClass, dbl_cmp, dbl2num, div, doCoerce, eql_p, fix2int, fix2long, floor, getCoerced, initialize_copy, int2fix, modulo, newNumeric, nonzero_p, num2chr, num2dbl, num2fix, num2int, num2long, op_cmp, op_num_equal, op_uminus, op_uplus, remainder, round, sadded, step, str2fnum, str2fnum, str2inum, str2inum, to_int, truncate, zero_p
 
Methods inherited from class org.jruby.RubyObject
addFinalizer, anyToString, asString, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkFrozen, checkStringType, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToString, convertToType, copySpecialInstanceVariables, createObjectClass, dataGetStruct, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eqlInternal, equal_p, equalInternal, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, frozen_p, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariableList, getInternalVariables, getMetaClass, getRuntime, getSingletonClassClone, getType, getVariableCount, getVariableList, getVariableMap, getVariableNameList, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, infectBy, initialize, inspect, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isClass, isFalse, isFrozen, isModule, isNil, isRubyVariable, isTaint, isTrue, kind_of_p, makeMetaClass, method, methods, nil_p, op_eqq, op_match, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, send, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, singleton_methods, specificEval, syncVariables, tainted_p, testFrozen, to_a, to_s, toString, type_deprecated, type, untaint, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableGetMap, variableTableGetMap, variableTableGetSize, variableTableGetTable, variableTableReadLocked, variableTableRehash, variableTableRemove, variableTableStore, variableTableSync
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SIGN_BIT

public static final long SIGN_BIT
See Also:
Constant Field Values

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
Constructor Detail

RubyFixnum

public RubyFixnum(Ruby runtime)

RubyFixnum

public RubyFixnum(Ruby runtime,
                  long value)
Method Detail

createFixnumClass

public static RubyClass createFixnumClass(Ruby runtime)

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. Will generally return a value from org.jruby.runtime.ClassIndex

Specified by:
getNativeTypeIndex in interface CoreObjectType
Overrides:
getNativeTypeIndex in class RubyObject
Returns:
the ClassIndex of the native type this object was constructed from
See Also:
org.jruby.runtime.ClassInde

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()
Description copied from class: RubyObject
Is object immediate (def: Fixnum, Symbol, true, false, nil?).

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

getSingletonClass

public RubyClass getSingletonClass()
Description copied from class: RubyObject
rb_singleton_class Note: this method is specialized for RubyFixnum, RubySymbol, RubyNil and RubyBoolean Will either return the existing singleton class for this object, or create a new one and rutning that.

Specified by:
getSingletonClass in interface IRubyObject
Overrides:
getSingletonClass in class RubyObject
Returns:
RubyClass

getJavaClass

public java.lang.Class<?> getJavaClass()
Description copied from class: RubyObject
Will return the Java interface that most closely can represent this object, when working through JAva integration translations.

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()
Description copied from class: RubyObject
rb_obj_id Will return the hash code of this object. In comparison to MRI, this method will use the Java identity hash code instead of using rb_obj_id, since the usage of id in JRuby will incur the cost of some. ObjectSpace maintainence.

Overrides:
hash in class RubyObject

hashCode

public final int hashCode()
Description copied from class: RubyObject
Override the Object#hashCode method to make sure that the Ruby hash is actually used as the hashcode for Ruby objects. If the Ruby "hash" method doesn't return a number, the Object#hashCode implementation will be used instead.

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


op_uminus

public IRubyObject op_uminus()
fix_uminus


op_plus

public IRubyObject op_plus(ThreadContext context,
                           IRubyObject other)
fix_plus


op_minus

public IRubyObject op_minus(ThreadContext context,
                            IRubyObject other)
fix_minus


op_mul

public IRubyObject op_mul(ThreadContext context,
                          IRubyObject other)
fix_mul


div_div

public IRubyObject div_div(ThreadContext context,
                           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


op_div

public IRubyObject op_div(ThreadContext context,
                          IRubyObject other)

odd_p

public RubyBoolean odd_p()

even_p

public RubyBoolean even_p()

pred

public IRubyObject pred()

idiv

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

op_mod

public IRubyObject op_mod(ThreadContext context,
                          IRubyObject other)
fix_mod


divmod

public IRubyObject divmod(ThreadContext context,
                          IRubyObject other)
fix_divmod

Overrides:
divmod in class RubyNumeric

quo

public IRubyObject quo(ThreadContext context,
                       IRubyObject other)
fix_quo

Overrides:
quo in class RubyNumeric

op_pow

public IRubyObject op_pow(ThreadContext context,
                          IRubyObject other)
fix_pow


abs

public IRubyObject abs()
fix_abs


op_equal

public IRubyObject op_equal(ThreadContext context,
                            IRubyObject other)
fix_equal

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

op_cmp

public IRubyObject op_cmp(ThreadContext context,
                          IRubyObject other)
fix_cmp


op_gt

public IRubyObject op_gt(ThreadContext context,
                         IRubyObject other)
fix_gt


op_ge

public IRubyObject op_ge(ThreadContext context,
                         IRubyObject other)
fix_ge


op_lt

public IRubyObject op_lt(ThreadContext context,
                         IRubyObject other)
fix_lt


op_le

public IRubyObject op_le(ThreadContext context,
                         IRubyObject other)
fix_le


op_neg

public IRubyObject op_neg()
fix_rev


op_and

public IRubyObject op_and(ThreadContext context,
                          IRubyObject other)
fix_and


op_or

public IRubyObject op_or(ThreadContext context,
                         IRubyObject other)
fix_or


op_xor

public IRubyObject op_xor(ThreadContext context,
                          IRubyObject other)
fix_xor


op_aref

public IRubyObject op_aref(IRubyObject other)
fix_aref


op_lshift

public IRubyObject op_lshift(IRubyObject other)
fix_lshift


op_rshift

public IRubyObject op_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


id

public IRubyObject id()
Description copied from class: RubyObject
rb_obj_id Return the internal id of an object. FIXME: Should this be renamed to match its ruby name?

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

taint

public IRubyObject taint()
Description copied from class: RubyObject
rb_obj_taint call-seq: obj.taint -> obj Marks obj as tainted---if the $SAFE level is set appropriately, many method calls which might alter the running programs environment will refuse to accept tainted strings.

Overrides:
taint in class RubyObject

freeze

public IRubyObject freeze()
Description copied from class: RubyObject
rb_obj_freeze call-seq: obj.freeze => obj Prevents further modifications to obj. A TypeError will be raised if modification is attempted. There is no way to unfreeze a frozen object. See also Object#frozen?. a = [ "a", "b", "c" ] a.freeze a << "z" produces: prog.rb:3:in `<<': can't modify frozen array (TypeError) from prog.rb:3

Overrides:
freeze in class RubyObject

asJavaString

public java.lang.String asJavaString()
Description copied from class: RubyObject
rb_to_id Will try to convert this object to a String using the Ruby "to_str" if the object isn't already a String. If this still doesn't work, will throw a Ruby TypeError.

Specified by:
asJavaString in interface IRubyObject
Overrides:
asJavaString in class RubyObject
Returns:
String the symbol name

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.