move main to space

This commit is contained in:
Torsten Ruger 2015-11-30 16:09:12 +02:00
parent 707c180cab
commit dc560aaa5e
6 changed files with 31 additions and 15 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -17,7 +17,7 @@ module ParfaitTests
def main
runko = <<HERE
class Object
class Space < Object
int main()
PROGRAM
end