move kernel to core and apply the classmethod pattern to all core classes
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
module Core
|
||||
module Integer
|
||||
class Integer
|
||||
module ClassMethods
|
||||
end
|
||||
extend ClassMethods
|
||||
end
|
||||
end
|
29
lib/core/kernel.rb
Normal file
29
lib/core/kernel.rb
Normal file
@ -0,0 +1,29 @@
|
||||
module Core
|
||||
class Kernel
|
||||
|
||||
#there are no Kernel instances, only class methods.
|
||||
# We use this module syntax to avoid the (ugly) self.
|
||||
module ClassMethods
|
||||
def main_start
|
||||
#TODO extract args into array of strings
|
||||
Vm::Machine.instance.main_start
|
||||
end
|
||||
def main_exit
|
||||
# Machine.exit mov r7 , 0 + swi 0
|
||||
Vm::Machine.instance.main_exit
|
||||
end
|
||||
def function_entry f_name
|
||||
Vm::Machine.instance.function_entry f_name
|
||||
end
|
||||
def function_exit f_name
|
||||
Vm::Machine.instance.function_exit f_name
|
||||
end
|
||||
def self.puts string
|
||||
# should unwrap from string to char*
|
||||
Vm::Machine.instance.puts string
|
||||
end
|
||||
end
|
||||
|
||||
extend ClassMethods
|
||||
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
|
||||
|
Reference in New Issue
Block a user