From aabde4b9a6e736fc2c18e5829923de39448506f0 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 19 Nov 2015 16:40:00 +0200 Subject: [PATCH] fix word indexes on arm which affected offsets in the ruby side too the hidden dead word needed accounting for --- lib/register/parfait/word.rb | 2 +- lib/soml/parfait/word.soml | 10 +++++----- test/soml/helper.rb | 5 ++--- test/soml/parfait/test_word.rb | 12 ++++++------ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/register/parfait/word.rb b/lib/register/parfait/word.rb index b1d99015..4c8cc244 100644 --- a/lib/register/parfait/word.rb +++ b/lib/register/parfait/word.rb @@ -139,7 +139,7 @@ module Parfait index = self.length + at if at < 0 raise "index must be positive , not #{at}" if (index <= 0) raise "index too large #{at} > #{self.length}" if (index > self.length ) - return index + Word.get_length_index * 4 + return index + Word.get_length_index * 4 + 4 end # compare the word to another diff --git a/lib/soml/parfait/word.soml b/lib/soml/parfait/word.soml index bec7d586..013e467e 100644 --- a/lib/soml/parfait/word.soml +++ b/lib/soml/parfait/word.soml @@ -1,11 +1,11 @@ class Word < Object - int correct_index(int index) - return index + 8 + int _internal_index(int index) + return index + 12 end - int char_at(int index) - index = correct_index(index) + int get_char_at(int index) + index = _internal_index(index) return get_internal_byte(index) end @@ -15,7 +15,7 @@ class Word < Object end int set_char_at( int index , int val) - index = correct_index(index) + index = _internal_index(index) return set_internal_byte(index , val) end diff --git a/test/soml/helper.rb b/test/soml/helper.rb index aa4f2e5f..d0615954 100644 --- a/test/soml/helper.rb +++ b/test/soml/helper.rb @@ -52,7 +52,6 @@ module RuntimeTests def check_remote ret return unless box = connected - return unless ret.is_a?(Numeric) file = write_object_file r_file = file.sub("./" , "salama/") box.file_upload file , r_file @@ -64,7 +63,7 @@ module RuntimeTests end assert_equal @stdout , ret.stdout.join , "remote std was #{ret.stdout}" if @stdout assert_equal "" , ret.stderr.join , "remote had error" - if ret + if ret and ret.is_a?(Numeric) should = @interpreter.get_register(:r0).return_value should &= 0xFF # don't knwo why exit codes are restricted but there you are assert_equal should , ret.exit_status.to_i , "remote exit failed for #{@string_input}" @@ -72,7 +71,7 @@ module RuntimeTests end def write_object_file - file_name = caller(3).first.split("in ").last.chop.sub("`","") + file_name = caller(4).first.split("in ").last.chop.sub("`","") return if file_name.include?("run") file_name = "./tmp/" + file_name + ".o" Register.machine.translate_arm diff --git a/test/soml/parfait/test_word.rb b/test/soml/parfait/test_word.rb index 8d3bc905..e4aa072d 100644 --- a/test/soml/parfait/test_word.rb +++ b/test/soml/parfait/test_word.rb @@ -14,7 +14,7 @@ HERE def test_space @main = <