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 Core
|
||||||
module Integer
|
class Integer
|
||||||
|
module ClassMethods
|
||||||
|
end
|
||||||
|
extend ClassMethods
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
module Vm
|
module Core
|
||||||
class Kernel
|
class Kernel
|
||||||
|
|
||||||
#there are no Kernel instances, only class methods.
|
#there are no Kernel instances, only class methods.
|
||||||
@ -6,21 +6,21 @@ module Vm
|
|||||||
module ClassMethods
|
module ClassMethods
|
||||||
def main_start
|
def main_start
|
||||||
#TODO extract args into array of strings
|
#TODO extract args into array of strings
|
||||||
Machine.instance.main_start
|
Vm::Machine.instance.main_start
|
||||||
end
|
end
|
||||||
def main_exit
|
def main_exit
|
||||||
# Machine.exit mov r7 , 0 + swi 0
|
# Machine.exit mov r7 , 0 + swi 0
|
||||||
Machine.instance.main_exit
|
Vm::Machine.instance.main_exit
|
||||||
end
|
end
|
||||||
def function_entry f_name
|
def function_entry f_name
|
||||||
Machine.instance.function_entry f_name
|
Vm::Machine.instance.function_entry f_name
|
||||||
end
|
end
|
||||||
def function_exit f_name
|
def function_exit f_name
|
||||||
Machine.instance.function_exit f_name
|
Vm::Machine.instance.function_exit f_name
|
||||||
end
|
end
|
||||||
def self.puts string
|
def self.puts string
|
||||||
# should unwrap from string to char*
|
# should unwrap from string to char*
|
||||||
Machine.instance.puts string
|
Vm::Machine.instance.puts string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,4 +1,7 @@
|
|||||||
module Core
|
module Core
|
||||||
module String
|
class String
|
||||||
|
module ClassMethods
|
||||||
|
end
|
||||||
|
extend ClassMethods
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
module Core
|
module Core
|
||||||
module System
|
module System
|
||||||
|
module ClassMethods
|
||||||
def puts io , c-string , length
|
def puts io , c-string , length
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
extend ClassMethods
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
require_relative "kernel"
|
require "core/kernel"
|
||||||
require_relative "program"
|
require_relative "program"
|
||||||
|
|
||||||
module Vm
|
module Vm
|
||||||
|
@ -15,8 +15,8 @@ module Vm
|
|||||||
def initialize(name , args = [])
|
def initialize(name , args = [])
|
||||||
super(name)
|
super(name)
|
||||||
@args = args
|
@args = args
|
||||||
@entry = Kernel::function_entry( name )
|
@entry = Core::Kernel::function_entry( name )
|
||||||
@exit = Kernel::function_exit( name )
|
@exit = Core::Kernel::function_exit( name )
|
||||||
end
|
end
|
||||||
attr_reader :args , :entry , :exit
|
attr_reader :args , :entry , :exit
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ module Vm
|
|||||||
def link_at address , context
|
def link_at address , context
|
||||||
# function = context.program.get_function(name)
|
# function = context.program.get_function(name)
|
||||||
# unless function
|
# unless function
|
||||||
# function = Vm::Kernel.send(name)
|
# function = Core::Kernel.send(name)
|
||||||
# context.program.get_or_create_function( name , function , arity )
|
# context.program.get_or_create_function( name , function , arity )
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ module Vm
|
|||||||
@objects = []
|
@objects = []
|
||||||
# global functions
|
# global functions
|
||||||
@functions = []
|
@functions = []
|
||||||
@entry = Vm::Kernel::main_start
|
@entry = Core::Kernel::main_start
|
||||||
#main gets executed between entry and exit
|
#main gets executed between entry and exit
|
||||||
@main = nil
|
@main = nil
|
||||||
@exit = Vm::Kernel::main_exit
|
@exit = Core::Kernel::main_exit
|
||||||
end
|
end
|
||||||
attr_reader :context , :main , :functions
|
attr_reader :context , :main , :functions
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user