revert to symbols

Parfait::Words were nice, but endless problems with the fact that when
you write “String” you get a string.
Symbols take care of uniqueness at the same time
This commit is contained in:
Torsten Ruger
2015-05-31 18:34:18 +03:00
parent 5d870ef154
commit bee73801eb
18 changed files with 101 additions and 85 deletions

View File

@ -33,7 +33,7 @@ class TestMoves < MiniTest::Test
assert_code code , :mvn , [0x05,0x10,0xe0,0xe3] #e3 e0 10 05
end
def test_constant_small # like test_mov
const = Virtual.new_word "harvey"
const = :harvey
const.set_position( 13 ) # 13 = 5 + 8 , 8 for the arm pipeline offset, gets subtracted
code = @machine.mov :r1 , 5
code.set_position(0)
@ -41,7 +41,7 @@ class TestMoves < MiniTest::Test
assert_code code , :mov , [0x05,0x10,0xa0,0xe3] #e3 ef 10 05
end
def test_constant_big # like test_mov_big
const = Virtual.new_word "harvey"
const = :harvey
const.set_position( 0x222 )
code = @machine.mov :r0 , 0x222
code.set_position(0)

View File

@ -28,7 +28,17 @@ module VirtualHelper
end
end
module Virtual
# Functions to generate parfait objects
def self.new_word( string )
string = string.to_s if string.is_a? Symbol
word = Parfait::Word.new_object( string.length )
string.codepoints.each_with_index do |code , index |
word.set_char(index + 1 , code)
end
word
end
end
class UnusedSofEquality
# simple thought: don't recurse for Blocks, just check their names
def == other