use instance_variable_set/get instead of eval
opal doesn’t like eval anymore
This commit is contained in:
parent
4a2a1da3ff
commit
b9f85f9d2e
@ -34,7 +34,7 @@ module Parfait
|
||||
def get_internal_word(index)
|
||||
name = get_type().name_at(index)
|
||||
return nil unless name
|
||||
eval "@#{name}"
|
||||
instance_variable_get("@#{name}".to_sym)
|
||||
end
|
||||
|
||||
# 1 -based index
|
||||
@ -43,7 +43,7 @@ module Parfait
|
||||
raise "not type #{@type.class}" unless @type.is_a?(Type)
|
||||
name = @type.name_at(index)
|
||||
raise "object type has no name at index #{index} " unless name
|
||||
eval "@#{name} = value"
|
||||
instance_variable_set("@#{name}".to_sym, value)
|
||||
value
|
||||
end
|
||||
|
||||
@ -116,7 +116,7 @@ module Parfait
|
||||
end
|
||||
|
||||
# name comes in as a ruby @var name
|
||||
def instance_variable_get name
|
||||
def instance_variable_ged name
|
||||
var = get_instance_variable name.to_s[1 .. -1].to_sym
|
||||
#puts "getting #{name} #{var}"
|
||||
var
|
||||
|
@ -45,7 +45,7 @@ class TestSpace < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_types
|
||||
assert @space.instance_variable_get("@types").is_a? Parfait::Dictionary
|
||||
assert @space.instance_variable_ged("@types").is_a? Parfait::Dictionary
|
||||
end
|
||||
|
||||
def test_types_each
|
||||
@ -55,7 +55,7 @@ class TestSpace < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_types_hashes
|
||||
types = @space.instance_variable_get("@types")
|
||||
types = @space.instance_variable_ged("@types")
|
||||
types.each do |has , type|
|
||||
assert has.is_a?(Fixnum) , has.inspect
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ class TypeHash < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@space = Parfait.object_space
|
||||
@types = @space.instance_variable_get("@types")
|
||||
@types = @space.instance_variable_ged("@types")
|
||||
@first = @types.values.first
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user