moving string to parfait
using parfait::word also rename builtins string to word
This commit is contained in:
@ -71,7 +71,7 @@ module Virtual
|
||||
|
||||
# attr_reader :string
|
||||
def self.compile_string expression , method
|
||||
value = StringConstant.new(expression.string)
|
||||
value = Parfait::Word.new(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(), StringConstant.new(expession.name))
|
||||
method.add_code Set.new(NewName.new(), Parfait::Word.new(expession.name))
|
||||
compiled_args = []
|
||||
expession.args.each_with_index do |arg , i|
|
||||
#compile in the running method, ie before passing control
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Virtual
|
||||
|
||||
|
||||
class Constant < ::Virtual::Object
|
||||
end
|
||||
class TrueConstant < Constant
|
||||
@ -10,7 +10,7 @@ module Virtual
|
||||
end
|
||||
|
||||
# another abstract "marker" class (so we can check for it)
|
||||
# derived classes are Boot/Meta Class and StringConstant
|
||||
# derived classes are Boot/Meta Class and StringConstant
|
||||
class ObjectConstant < Constant
|
||||
def type
|
||||
Virtual::Reference
|
||||
@ -32,36 +32,5 @@ module Virtual
|
||||
integer >= 0 and integer <= 255
|
||||
end
|
||||
end
|
||||
|
||||
# The name really says it all.
|
||||
# The only interesting thing is storage.
|
||||
# Currently string are stored "inline" , ie in the code segment.
|
||||
# Mainly because that works an i aint no elf expert.
|
||||
|
||||
class StringConstant < ObjectConstant
|
||||
def initialize str
|
||||
@string = str
|
||||
end
|
||||
attr_reader :string
|
||||
|
||||
def result= value
|
||||
raise "called"
|
||||
class_for(MoveInstruction).new(value , self , :opcode => :mov)
|
||||
end
|
||||
def clazz
|
||||
Space.space.get_or_create_class(:String)
|
||||
end
|
||||
def layout
|
||||
Virtual::Object.layout
|
||||
end
|
||||
def mem_length
|
||||
padded(1 + string.length)
|
||||
end
|
||||
def position
|
||||
return @position if @position
|
||||
return @string.position if @string.position
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -113,9 +113,9 @@ module Virtual
|
||||
[:putint,:fibo].each do |f|
|
||||
obj.add_instance_method Builtin::Integer.send(f , nil)
|
||||
end
|
||||
obj = @space.get_or_create_class :String
|
||||
obj = @space.get_or_create_class :Word
|
||||
[:get , :set , :puts].each do |f|
|
||||
obj.add_instance_method Builtin::String.send(f , nil)
|
||||
obj.add_instance_method Builtin::Word.send(f , nil)
|
||||
end
|
||||
obj = space.get_or_create_class :Array
|
||||
[:get , :set , :push].each do |f|
|
||||
|
@ -63,7 +63,7 @@ module Virtual
|
||||
|
||||
def layout_for(object)
|
||||
case object
|
||||
when Array , Symbol , String , Virtual::CompiledMethod , Virtual::Block , Virtual::StringConstant
|
||||
when Array , Symbol , String , Virtual::CompiledMethod , Virtual::Block , Parfait::Word
|
||||
@@ARRAY
|
||||
when Hash
|
||||
@@HASH.merge :keys => object.keys , :values => object.values
|
||||
|
Reference in New Issue
Block a user