move kernel to core and apply the classmethod pattern to all core classes

This commit is contained in:
Torsten Ruger
2014-05-06 12:47:07 +03:00
parent 12b6800efe
commit fa123e0354
7 changed files with 24 additions and 17 deletions

View File

@ -1,4 +1,7 @@
module Core
module Integer
class Integer
module ClassMethods
end
extend ClassMethods
end
end

29
lib/core/kernel.rb Normal file
View 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

View File

@ -1,4 +1,7 @@
module Core
module String
class String
module ClassMethods
end
extend ClassMethods
end
end

View File

@ -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