diff --git a/lib/register/boot.rb b/lib/register/boot.rb index a6cfed7b..a0508034 100644 --- a/lib/register/boot.rb +++ b/lib/register/boot.rb @@ -140,8 +140,10 @@ module Register # very fiddly chicken 'n egg problem. Functions need to be in the right order, and in fact we # have to define some dummies, just for the other to compile # TODO go through the virtual parfait layer and adjust function names to what they really are + @space.get_class_by_name(:Space).add_instance_method Builtin::Space.send(:main, nil) + obj = @space.get_class_by_name(:Object) - [:main , :get_internal_word , :set_internal_word ].each do |f| + [ :get_internal_word , :set_internal_word ].each do |f| obj.add_instance_method Builtin::Object.send(f , nil) end obj = @space.get_class_by_name(:Kernel) diff --git a/lib/register/builtin/object.rb b/lib/register/builtin/object.rb index 62f056be..439fdcaa 100644 --- a/lib/register/builtin/object.rb +++ b/lib/register/builtin/object.rb @@ -6,13 +6,6 @@ module Register module ClassMethods include AST::Sexp - # main entry point, ie __init__ calls this - # defined here as empty, to be redefined - def main context - compiler = Soml::Compiler.new.create_method(:Object , :main ).init_method - return compiler.method - end - # self[index] basically. Index is the first arg # return is stored in return_value # (this method returns a new method off course, like all builtin) @@ -55,7 +48,3 @@ module Register end end end - -require_relative "integer" -require_relative "kernel" -require_relative "word" diff --git a/lib/register/builtin/space.rb b/lib/register/builtin/space.rb new file mode 100644 index 00000000..a20e8cda --- /dev/null +++ b/lib/register/builtin/space.rb @@ -0,0 +1,25 @@ +require "ast/sexp" + +module Register + module Builtin + class Space + module ClassMethods + include AST::Sexp + + # main entry point, ie __init__ calls this + # defined here as empty, to be redefined + def main context + compiler = Soml::Compiler.new.create_method(:Space , :main ).init_method + return compiler.method + end + + end + extend ClassMethods + end + end +end + +require_relative "integer" +require_relative "object" +require_relative "kernel" +require_relative "word" diff --git a/lib/register/parfait/space.rb b/lib/register/parfait/space.rb index 4e725930..9636e340 100644 --- a/lib/register/parfait/space.rb +++ b/lib/register/parfait/space.rb @@ -49,7 +49,7 @@ module Parfait end def get_main - kernel = get_class_by_name :Object + kernel = get_class_by_name :Space kernel.get_instance_method :main end diff --git a/lib/salama.rb b/lib/salama.rb index 6185e255..65859dfe 100644 --- a/lib/salama.rb +++ b/lib/salama.rb @@ -12,6 +12,6 @@ end require 'parser/transform' require "salama-object-file" require "register" -require "register/builtin/object" +require "register/builtin/space" require "arm/arm_machine" require "arm/translator" diff --git a/test/soml/parfait/helper.rb b/test/soml/parfait/helper.rb index 6d9dc954..d70a2971 100644 --- a/test/soml/parfait/helper.rb +++ b/test/soml/parfait/helper.rb @@ -17,7 +17,7 @@ module ParfaitTests def main runko = <