diff --git a/lib/core/integer.rb b/lib/core/integer.rb index 0c6a5016..05bfb94f 100644 --- a/lib/core/integer.rb +++ b/lib/core/integer.rb @@ -1,4 +1,7 @@ module Core - module Integer + class Integer + module ClassMethods + end + extend ClassMethods end end \ No newline at end of file diff --git a/lib/vm/kernel.rb b/lib/core/kernel.rb similarity index 69% rename from lib/vm/kernel.rb rename to lib/core/kernel.rb index 4c3e9ad9..f5e27631 100644 --- a/lib/vm/kernel.rb +++ b/lib/core/kernel.rb @@ -1,4 +1,4 @@ -module Vm +module Core class Kernel #there are no Kernel instances, only class methods. @@ -6,21 +6,21 @@ module Vm module ClassMethods def main_start #TODO extract args into array of strings - Machine.instance.main_start + Vm::Machine.instance.main_start end def main_exit # Machine.exit mov r7 , 0 + swi 0 - Machine.instance.main_exit + Vm::Machine.instance.main_exit end def function_entry f_name - Machine.instance.function_entry f_name + Vm::Machine.instance.function_entry f_name end def function_exit f_name - Machine.instance.function_exit f_name + Vm::Machine.instance.function_exit f_name end def self.puts string # should unwrap from string to char* - Machine.instance.puts string + Vm::Machine.instance.puts string end end diff --git a/lib/core/string.rb b/lib/core/string.rb index 38ca05a6..94d7bfbb 100644 --- a/lib/core/string.rb +++ b/lib/core/string.rb @@ -1,4 +1,7 @@ module Core - module String + class String + module ClassMethods + end + extend ClassMethods end end diff --git a/lib/core/system.rb b/lib/core/system.rb index d5e90dd7..4bd466f5 100644 --- a/lib/core/system.rb +++ b/lib/core/system.rb @@ -1,9 +1,10 @@ module Core module System - - def puts io , c-string , length + module ClassMethods + def puts io , c-string , length + end end - + extend ClassMethods end end diff --git a/lib/vm/context.rb b/lib/vm/context.rb index cdc9dead..6cedf5fb 100644 --- a/lib/vm/context.rb +++ b/lib/vm/context.rb @@ -1,4 +1,4 @@ -require_relative "kernel" +require "core/kernel" require_relative "program" module Vm diff --git a/lib/vm/function.rb b/lib/vm/function.rb index dbf78919..b49c306f 100644 --- a/lib/vm/function.rb +++ b/lib/vm/function.rb @@ -15,8 +15,8 @@ module Vm def initialize(name , args = []) super(name) @args = args - @entry = Kernel::function_entry( name ) - @exit = Kernel::function_exit( name ) + @entry = Core::Kernel::function_entry( name ) + @exit = Core::Kernel::function_exit( name ) end attr_reader :args , :entry , :exit @@ -27,7 +27,7 @@ module Vm def link_at address , context # function = context.program.get_function(name) # unless function -# function = Vm::Kernel.send(name) +# function = Core::Kernel.send(name) # context.program.get_or_create_function( name , function , arity ) # end diff --git a/lib/vm/program.rb b/lib/vm/program.rb index 32907173..c0744b22 100644 --- a/lib/vm/program.rb +++ b/lib/vm/program.rb @@ -28,10 +28,10 @@ module Vm @objects = [] # global functions @functions = [] - @entry = Vm::Kernel::main_start + @entry = Core::Kernel::main_start #main gets executed between entry and exit @main = nil - @exit = Vm::Kernel::main_exit + @exit = Core::Kernel::main_exit end attr_reader :context , :main , :functions