move space accesor to boot_space
This commit is contained in:
parent
dd82095cca
commit
0b65e5840e
@ -49,7 +49,7 @@ module Ast
|
|||||||
class ModuleName < NameExpression
|
class ModuleName < NameExpression
|
||||||
|
|
||||||
def compile method , message
|
def compile method , message
|
||||||
clazz = ::Virtual::Object.space.get_or_create_class name
|
clazz = ::Virtual::BootSpace.space.get_or_create_class name
|
||||||
raise "uups #{clazz}.#{name}" unless clazz
|
raise "uups #{clazz}.#{name}" unless clazz
|
||||||
#class qualifier, means call from metaclass
|
#class qualifier, means call from metaclass
|
||||||
#clazz = clazz.meta_class
|
#clazz = clazz.meta_class
|
||||||
@ -61,7 +61,7 @@ module Ast
|
|||||||
# attr_reader :string
|
# attr_reader :string
|
||||||
def compile method , message
|
def compile method , message
|
||||||
value = Virtual::StringConstant.new(string)
|
value = Virtual::StringConstant.new(string)
|
||||||
::Virtual::Object.space.add_object value
|
::Virtual::BootSpace.space.add_object value
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ module Ast
|
|||||||
r = receiver ? receiver.compile(method,message) : Virtual::Self.new()
|
r = receiver ? receiver.compile(method,message) : Virtual::Self.new()
|
||||||
new_method = Virtual::MethodDefinition.new(name , args , r )
|
new_method = Virtual::MethodDefinition.new(name , args , r )
|
||||||
new_method.class_name = r.is_a?(BootClass) ? r.name : method.class_name
|
new_method.class_name = r.is_a?(BootClass) ? r.name : method.class_name
|
||||||
clazz = Virtual::Object.space.get_or_create_class(new_method.class_name)
|
clazz = Virtual::BootSpace.space.get_or_create_class(new_method.class_name)
|
||||||
clazz.add_instance_method new_method
|
clazz.add_instance_method new_method
|
||||||
|
|
||||||
#frame = frame.new_frame
|
#frame = frame.new_frame
|
||||||
|
@ -20,7 +20,7 @@ module Ast
|
|||||||
|
|
||||||
class ClassExpression < ModuleExpression
|
class ClassExpression < ModuleExpression
|
||||||
def compile method , message
|
def compile method , message
|
||||||
clazz = ::Virtual::Object.space.get_or_create_class name
|
clazz = ::Virtual::BootSpace.space.get_or_create_class name
|
||||||
puts "Created class #{clazz.name.inspect}"
|
puts "Created class #{clazz.name.inspect}"
|
||||||
# context.current_class = clazz
|
# context.current_class = clazz
|
||||||
expressions.each do |expression|
|
expressions.each do |expression|
|
||||||
|
@ -18,5 +18,5 @@ module Register
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Virtual::Object.space.add_pass_after CallImplementation , SetImplementation
|
Virtual::BootSpace.space.add_pass_after CallImplementation , SetImplementation
|
||||||
end
|
end
|
||||||
|
@ -11,5 +11,5 @@ module Register
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Virtual::Object.space.add_pass_after GetImplementation, Virtual::SendImplementation
|
Virtual::BootSpace.space.add_pass_after GetImplementation, Virtual::SendImplementation
|
||||||
end
|
end
|
||||||
|
@ -17,5 +17,5 @@ module Register
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Virtual::Object.space.add_pass_after SetImplementation , GetImplementation
|
Virtual::BootSpace.space.add_pass_after SetImplementation , GetImplementation
|
||||||
end
|
end
|
||||||
|
@ -39,6 +39,14 @@ module Virtual
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.space
|
||||||
|
if defined? @@space
|
||||||
|
@@space
|
||||||
|
else
|
||||||
|
@@space = BootSpace.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Passes are initiated empty and added to by anyone who want (basically)
|
# Passes are initiated empty and added to by anyone who want (basically)
|
||||||
# Even linking and assembly are passes and so there are quite a few system passes neccesary to result in a
|
# Even linking and assembly are passes and so there are quite a few system passes neccesary to result in a
|
||||||
# working binary. Other than that, this is intentionally quite flexible
|
# working binary. Other than that, this is intentionally quite flexible
|
||||||
|
@ -44,7 +44,7 @@ module Virtual
|
|||||||
class_for(MoveInstruction).new(value , self , :opcode => :mov)
|
class_for(MoveInstruction).new(value , self , :opcode => :mov)
|
||||||
end
|
end
|
||||||
def clazz
|
def clazz
|
||||||
Object.space.get_or_create_class(:String)
|
BootSpace.space.get_or_create_class(:String)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,13 +28,6 @@ module Virtual
|
|||||||
Sof::Writer.write(self)
|
Sof::Writer.write(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.space
|
|
||||||
if defined? @@space
|
|
||||||
@@space
|
|
||||||
else
|
|
||||||
@@space = BootSpace.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Layout < Object
|
class Layout < Object
|
||||||
|
@ -7,9 +7,9 @@ class HelloTest < MiniTest::Test
|
|||||||
machine = Virtual::Machine.boot
|
machine = Virtual::Machine.boot
|
||||||
expressions = machine.compile_main @string_input
|
expressions = machine.compile_main @string_input
|
||||||
puts ""
|
puts ""
|
||||||
Virtual::Object.space.run_passes
|
Virtual::BootSpace.space.run_passes
|
||||||
puts Sof::Writer.write(expressions)
|
puts Sof::Writer.write(expressions)
|
||||||
# puts Sof::Writer.write(Virtual::Object.space)
|
# puts Sof::Writer.write(Virtual::BootSpace.space)
|
||||||
end
|
end
|
||||||
|
|
||||||
def qtest_simplest_function
|
def qtest_simplest_function
|
||||||
|
Loading…
Reference in New Issue
Block a user