move kernel to core and apply the classmethod pattern to all core classes
This commit is contained in:
parent
12b6800efe
commit
fa123e0354
@ -1,4 +1,7 @@
|
||||
module Core
|
||||
module Integer
|
||||
class Integer
|
||||
module ClassMethods
|
||||
end
|
||||
extend ClassMethods
|
||||
end
|
||||
end
|
@ -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
|
||||
|
@ -1,4 +1,7 @@
|
||||
module Core
|
||||
module String
|
||||
class String
|
||||
module ClassMethods
|
||||
end
|
||||
extend ClassMethods
|
||||
end
|
||||
end
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
require_relative "kernel"
|
||||
require "core/kernel"
|
||||
require_relative "program"
|
||||
|
||||
module Vm
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user