test compatibility layer
test from and to std/parfait objects for list and word for now moved some of that code to virtual, out of parfait
This commit is contained in:
@ -55,25 +55,6 @@ module Parfait
|
||||
class Parfait::List
|
||||
end
|
||||
|
||||
# Functions to generate parfait objects
|
||||
def self.new_word( string )
|
||||
string = string.to_s if string.is_a? Symbol
|
||||
word = Parfait::Word.new( string.length )
|
||||
string.codepoints.each_with_index do |code , index |
|
||||
word.set_char(index + 1 , code)
|
||||
end
|
||||
word
|
||||
end
|
||||
def self.new_list array
|
||||
list = List.new_object
|
||||
list.set_length array.length
|
||||
index = 1
|
||||
while index < array.length do
|
||||
list.set(index , array[index - 1])
|
||||
end
|
||||
list
|
||||
end
|
||||
|
||||
Word.class_eval do
|
||||
def to_s
|
||||
string = ""
|
||||
@ -85,4 +66,37 @@ module Parfait
|
||||
string
|
||||
end
|
||||
end
|
||||
List.class_eval do
|
||||
def to_a
|
||||
array = []
|
||||
index = 1
|
||||
while( index <= self.get_length)
|
||||
array[index - 1] = get(index)
|
||||
index = index + 1
|
||||
end
|
||||
array
|
||||
end
|
||||
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( string.length )
|
||||
string.codepoints.each_with_index do |code , index |
|
||||
word.set_char(index + 1 , code)
|
||||
end
|
||||
word
|
||||
end
|
||||
def self.new_list array
|
||||
list = Parfait::List.new_object
|
||||
list.set_length array.length
|
||||
index = 1
|
||||
while index <= array.length do
|
||||
list.set(index , array[index - 1])
|
||||
index = index + 1
|
||||
end
|
||||
list
|
||||
end
|
||||
end
|
||||
|
@ -71,7 +71,7 @@ module Virtual
|
||||
|
||||
# attr_reader :string
|
||||
def self.compile_string expression , method
|
||||
value = Parfait.new_word(expression.string)
|
||||
value = Virtual.new_word(expression.string)
|
||||
to = Return.new(Reference , value)
|
||||
Machine.instance.space.add_object value
|
||||
method.add_code Set.new( to , value )
|
||||
|
@ -8,7 +8,7 @@ module Virtual
|
||||
me = Compiler.compile( expession.receiver , method )
|
||||
method.add_code NewMessage.new
|
||||
method.add_code Set.new(NewSelf.new(me.type), me)
|
||||
method.add_code Set.new(NewName.new(), Parfait.new_word(expession.name))
|
||||
method.add_code Set.new(NewName.new(), Virtual.new_word(expession.name))
|
||||
compiled_args = []
|
||||
expession.args.each_with_index do |arg , i|
|
||||
#compile in the running method, ie before passing control
|
||||
|
@ -143,7 +143,10 @@ module Virtual
|
||||
cl = @space.get_class_by_name( name )
|
||||
cl.set_super_class(object_class)
|
||||
end
|
||||
#boot_layouts
|
||||
boot_layouts!
|
||||
end
|
||||
def boot_layouts!
|
||||
|
||||
end
|
||||
def boot
|
||||
# read all the files needed for a minimal system at compile
|
||||
|
Reference in New Issue
Block a user