move main to space
This commit is contained in:
parent
707c180cab
commit
dc560aaa5e
@ -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)
|
||||
|
@ -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"
|
||||
|
25
lib/register/builtin/space.rb
Normal file
25
lib/register/builtin/space.rb
Normal 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"
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -17,7 +17,7 @@ module ParfaitTests
|
||||
|
||||
def main
|
||||
runko = <<HERE
|
||||
class Object
|
||||
class Space < Object
|
||||
int main()
|
||||
PROGRAM
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user