Mostly replaced Fixnum with integer
also in the rx-file dependency
all travis and testing with 2.4+
This commit is contained in:
Torsten Ruger 2019-02-07 18:24:35 +02:00
parent 51eff62931
commit 8d3a1954fa
25 changed files with 30 additions and 27 deletions

View File

@ -1 +1 @@
2.3.8 2.6.1

View File

@ -4,4 +4,7 @@ script:
- ruby test/test_all.rb - ruby test/test_all.rb
- bundle exec codeclimate-test-reporter - bundle exec codeclimate-test-reporter
rvm: rvm:
- 2.3.7 - 2.4.5
- 2.5.3
- 2.6.1

View File

@ -1,6 +1,6 @@
GIT GIT
remote: https://github.com/ruby-x/rx-file remote: https://github.com/ruby-x/rx-file
revision: c1de10352d8af105fe532008ceafcdd30b5fbdab revision: 7c4a5546136d1bad065803da91778b209c18cb4d
specs: specs:
rx-file (0.3.0) rx-file (0.3.0)

View File

@ -19,7 +19,7 @@ module Arm
# for the shift handling that makes the arm so unique # for the shift handling that makes the arm so unique
def shift val , by def shift val , by
raise "Not integer #{val}:#{val.class} #{inspect}" unless val.is_a? Fixnum raise "Not integer #{val}:#{val.class} #{inspect}" unless val.is_a? ::Integer
val << by val << by
end end

View File

@ -63,7 +63,7 @@ module Arm
if r_name.is_a? ::Risc::RegisterValue if r_name.is_a? ::Risc::RegisterValue
r_name = r_name.symbol r_name = r_name.symbol
end end
if r_name.is_a? Fixnum if r_name.is_a? ::Integer
r_name = "r#{r_name}" r_name = "r#{r_name}"
end end
r = REGISTERS[r_name.to_s] r = REGISTERS[r_name.to_s]

View File

@ -5,7 +5,7 @@ module Arm
super(nil) super(nil)
@attributes = attributes @attributes = attributes
@left = left @left = left
@right = right.is_a?(Fixnum) ? IntegerConstant.new(right) : right @right = right.is_a?(::Integer) ? IntegerConstant.new(right) : right
@attributes[:condition_code] = :al if @attributes[:condition_code] == nil @attributes[:condition_code] = :al if @attributes[:condition_code] == nil
@operand = 0 @operand = 0
@attributes[:update_status] = 1 @attributes[:update_status] = 1

View File

@ -85,7 +85,7 @@ module Parfait
# add a type, meaning the instance given must be a valid type # add a type, meaning the instance given must be a valid type
def add_type( type ) def add_type( type )
hash = type.hash hash = type.hash
raise "upps #{hash} #{hash.class}" unless hash.is_a?(Fixnum) raise "upps #{hash} #{hash.class}" unless hash.is_a?(::Integer)
was = types[hash] was = types[hash]
return was if was return was if was
types[hash] = type types[hash] = type

View File

@ -27,7 +27,7 @@ module Parfait
def initialize( len ) def initialize( len )
super() super()
self.char_length = 0 self.char_length = 0
raise "Must init with int, not #{len.class}" unless len.kind_of? Fixnum raise "Must init with int, not #{len.class}" unless len.kind_of? ::Integer
raise "Must init with positive, not #{len}" if len < 0 raise "Must init with positive, not #{len}" if len < 0
set_length( len , 32 ) unless len == 0 #32 being ascii space set_length( len , 32 ) unless len == 0 #32 being ascii space
#puts "type #{self.get_type} #{self.object_id.to_s(16)}" #puts "type #{self.get_type} #{self.object_id.to_s(16)}"
@ -87,7 +87,7 @@ module Parfait
# the index starts at one, but may be negative to count from the end # the index starts at one, but may be negative to count from the end
# indexes out of range will raise an error # indexes out of range will raise an error
def set_char( at , char ) def set_char( at , char )
raise "char not fixnum #{char.class}" unless char.kind_of? Fixnum raise "char not fixnum #{char.class}" unless char.kind_of? ::Integer
index = range_correct_index(at) index = range_correct_index(at)
set_internal_byte( index , char) set_internal_byte( index , char)
end end
@ -137,7 +137,7 @@ module Parfait
def range_correct_index( at ) def range_correct_index( at )
index = at index = at
# index = self.length + at if at < 0 # index = self.length + at if at < 0
raise "index not integer #{at.class}" unless at.is_a?(Fixnum) raise "index not integer #{at.class}" unless at.is_a?(::Integer)
raise "index must be positive , not #{at}" if (index < 0) raise "index must be positive , not #{at}" if (index < 0)
raise "index too large #{at} > #{self.length}" if (index >= self.length ) raise "index too large #{at} > #{self.length}" if (index >= self.length )
return index + 11 return index + 11

View File

@ -36,7 +36,7 @@ require_relative "risc/method_compiler"
require_relative "risc/block_compiler" require_relative "risc/block_compiler"
require_relative "risc/assembler" require_relative "risc/assembler"
class Fixnum class Integer
def fits_u8? def fits_u8?
self >= 0 and self <= 255 self >= 0 and self <= 255
end end

View File

@ -34,7 +34,7 @@ module Risc
# Objects are data and get assembled after functions # Objects are data and get assembled after functions
def self.add_object( objekt , depth) def self.add_object( objekt , depth)
return false if Position.set?(objekt) return false if Position.set?(objekt)
return true if objekt.is_a? Fixnum return true if objekt.is_a? ::Integer
return true if objekt.is_a?( Risc::Label) return true if objekt.is_a?( Risc::Label)
#puts message(objekt , depth) #puts message(objekt , depth)
#puts "ADD #{objekt.inspect}, #{objekt.name}" if objekt.is_a? Parfait::CallableMethod #puts "ADD #{objekt.inspect}, #{objekt.name}" if objekt.is_a? Parfait::CallableMethod

View File

@ -73,7 +73,7 @@ module Risc
def set_register( reg , val ) def set_register( reg , val )
old = get_register( reg ) # also ensures format old = get_register( reg ) # also ensures format
if val.is_a? Fixnum if val.is_a? ::Integer
@flags[:zero] = (val == 0) @flags[:zero] = (val == 0)
@flags[:plus] = (val >= 0) @flags[:plus] = (val >= 0)
@flags[:minus] = (val < 0) @flags[:minus] = (val < 0)
@ -190,7 +190,7 @@ module Risc
end end
raise "Unsupported action, must convert symbol to word:#{object}" if object.is_a?(Symbol) raise "Unsupported action, must convert symbol to word:#{object}" if object.is_a?(Symbol)
value = object.get_char( index ) value = object.get_char( index )
#value = value.object_id unless value.is_a? Fixnum #value = value.object_id unless value.is_a? ::Integer
set_register( @instruction.register , value ) set_register( @instruction.register , value )
true true
end end

View File

@ -142,7 +142,7 @@ module Risc
when Label when Label
ins = Risc.load_constant("#{right.class} to #{self.type}" , right , self) ins = Risc.load_constant("#{right.class} to #{self.type}" , right , self)
builder.compiler.add_constant(right.address) if builder builder.compiler.add_constant(right.address) if builder
when Fixnum when ::Integer
ins = Risc.load_data("#{right.class} to #{self.type}" , right , self) ins = Risc.load_data("#{right.class} to #{self.type}" , right , self)
when RegisterValue when RegisterValue
ins = Risc.transfer("#{right.type} to #{self.type}" , right , self) ins = Risc.transfer("#{right.type} to #{self.type}" , right , self)

View File

@ -206,7 +206,7 @@ module Risc
case object case object
when nil when nil
@stream.write_signed_int_32(0) @stream.write_signed_int_32(0)
when Fixnum when ::Integer
@stream.write_signed_int_32(object) @stream.write_signed_int_32(object)
else else
@stream.write_signed_int_32(Position.get(object) + @linker.platform.loaded_at) @stream.write_signed_int_32(Position.get(object) + @linker.platform.loaded_at)

View File

View File

@ -12,7 +12,7 @@ module Arm
assert_equal Arm::Translator , @arm.translator.class assert_equal Arm::Translator , @arm.translator.class
end end
def test_platform_loaded_class def test_platform_loaded_class
assert_equal Fixnum , @arm.loaded_at.class assert_equal ::Integer , @arm.loaded_at.class
end end
end end
end end

View File

@ -10,7 +10,7 @@ module Mains
end end
def test_chain # max 1011 iterations on 1014 integers (1024 - 10 reserve) def test_chain # max 1011 iterations on 1014 integers (1024 - 10 reserve)
run_all run_all
assert_equal Fixnum , get_return.class , " " assert_equal ::Integer , get_return.class , " "
assert_equal 0 , get_return , " " assert_equal 0 , get_return , " "
end end

View File

@ -53,7 +53,7 @@ module Parfait
def test_types_hashes def test_types_hashes
types = @space.instance_variable_ged("@types") types = @space.instance_variable_ged("@types")
types.each do |has , type| types.each do |has , type|
assert has.is_a?(Fixnum) , has.inspect assert has.is_a?(::Integer) , has.inspect
end end
end end
def test_classes_types_in_space_types def test_classes_types_in_space_types

View File

@ -34,7 +34,7 @@ module Risc
ret = main_ticks(19) ret = main_ticks(19)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal Fixnum , link.class assert_equal ::Integer , link.class
end end
def test_transfer def test_transfer
transfer = main_ticks(20) transfer = main_ticks(20)

View File

@ -51,7 +51,7 @@ module Risc
assert_equal :- , op.operator assert_equal :- , op.operator
assert_equal :r3 , op.left.symbol assert_equal :r3 , op.left.symbol
assert_equal :r1 , op.right.symbol assert_equal :r1 , op.right.symbol
assert_equal Fixnum , @interpreter.get_register(:r3).class assert_equal ::Integer , @interpreter.get_register(:r3).class
assert 0 != @interpreter.get_register(:r3) assert 0 != @interpreter.get_register(:r3)
end end
def test_branch def test_branch

View File

@ -47,7 +47,7 @@ module Risc
ret = main_ticks(93) ret = main_ticks(93)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal Fixnum , link.class assert_equal ::Integer , link.class
end end
end end
end end

View File

@ -40,7 +40,7 @@ module Risc
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, # 140 SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, # 140
SlotToReg, SlotToReg, Syscall, NilClass, ] SlotToReg, SlotToReg, Syscall, NilClass, ]
assert_equal Fixnum , get_return.class assert_equal ::Integer , get_return.class
assert_equal 1 , get_return assert_equal 1 , get_return
end end
@ -63,7 +63,7 @@ module Risc
ret = main_ticks(139) ret = main_ticks(139)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal Fixnum , link.class assert_equal ::Integer , link.class
end end
def test_sys def test_sys
sys = main_ticks(143) sys = main_ticks(143)

View File

@ -47,7 +47,7 @@ module Risc
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 30 RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 30
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn, SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn,
Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ] Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ]
assert_equal Fixnum , get_return.class assert_equal ::Integer , get_return.class
assert_equal 5 , get_return assert_equal 5 , get_return
end end
def test_length def test_length

View File

@ -32,7 +32,7 @@ module Risc
ret = main_ticks(15) ret = main_ticks(15)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal Fixnum , link.class assert_equal ::Integer , link.class
end end
def test_transfer def test_transfer
transfer = main_ticks(16) transfer = main_ticks(16)

View File

@ -12,7 +12,7 @@ module Risc
assert_equal Risc::IdentityTranslator , @inter.translator.class assert_equal Risc::IdentityTranslator , @inter.translator.class
end end
def test_platform_loaded_class def test_platform_loaded_class
assert_equal Fixnum , @inter.loaded_at.class assert_equal ::Integer , @inter.loaded_at.class
end end
def test_translator def test_translator
assert IdentityTranslator.new assert IdentityTranslator.new

View File