Skip to content

Commit

Permalink
Replaced more Fixnum, Bignum primitives.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Jan 6, 2020
1 parent a3e0c7d commit d1b029c
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 167 deletions.
25 changes: 0 additions & 25 deletions core/bignum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ def -@

# binary math operators

def +(o)
Rubinius.primitive :bignum_add
redo_coerced :+, o
end

def -(o)
Rubinius.primitive :bignum_sub
redo_coerced :-, o
Expand Down Expand Up @@ -99,26 +94,6 @@ def >>(other)

# comparison operators

def <(other)
Rubinius.primitive :bignum_lt
redo_compare :<, other
end

def <=(other)
Rubinius.primitive :bignum_le
redo_compare :<=, other
end

def >(other)
Rubinius.primitive :bignum_gt
redo_compare :>, other
end

def >=(other)
Rubinius.primitive :bignum_ge
redo_compare :>=, other
end

def <=>(other)
Rubinius.primitive :bignum_compare

Expand Down
142 changes: 0 additions & 142 deletions core/fixnum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,6 @@ def -@

# binary math operators

def +(o)
Rubinius.asm(o) do |o|
add = new_label
done = new_label

r0 = new_register
r1 = new_register

r_load_m_binops r0, r1

b_if_int r0, r1, add
goto done

add.set!
n_iadd_o r0, r0, r1
r_ret r0

done.set!

# TODO: teach the bytecode compiler better
push_true
end

redo_coerced :+, o
end

def -(o)
Rubinius.asm(o) do |o|
sub = new_label
Expand Down Expand Up @@ -229,122 +203,6 @@ def <=>(other)
end
end

def <(other)
Rubinius.asm do
cmp = new_label
done = new_label

r0 = new_register
r1 = new_register

r_load_m_binops r0, r1

b_if_int r0, r1, cmp
goto done

cmp.set!
n_ilt r0, r0, r1

r_load_bool r0, r0
r_ret r0

done.set!

# TODO: teach the bytecode compiler better
push_true
end

b, a = math_coerce other, :compare_error
a < b
end

def <=(other)
Rubinius.asm(o) do |o|
cmp = new_label
done = new_label

r0 = new_register
r1 = new_register

r_load_m_binops r0, r1

b_if_int r0, r1, cmp
goto done

cmp.set!
n_ile r0, r0, r1

r_load_bool r0, r0
r_ret r0

done.set!

# TODO: teach the bytecode compiler better
push_true
end

b, a = math_coerce other, :compare_error
a <= b
end

def >(other)
Rubinius.asm(o) do |o|
cmp = new_label
done = new_label

r0 = new_register
r1 = new_register

r_load_m_binops r0, r1

b_if_int r0, r1, cmp
goto done

cmp.set!
n_igt r0, r0, r1

r_load_bool r0, r0
r_ret r0

done.set!

# TODO: teach the bytecode compiler better
push_true
end

b, a = math_coerce other, :compare_error
a > b
end

def >=(other)
Rubinius.asm(o) do |o|
cmp = new_label
done = new_label

r0 = new_register
r1 = new_register

r_load_m_binops r0, r1

b_if_int r0, r1, cmp
goto done

cmp.set!
n_ige r0, r0, r1

r_load_bool r0, r0
r_ret r0

done.set!

# TODO: teach the bytecode compiler better
push_true
end

b, a = math_coerce other, :compare_error
a >= b
end

# predicates

def zero?
Expand Down

0 comments on commit d1b029c

Please sign in to comment.