fixup names in builtin module
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
#integer related kernel functions
|
||||
module Builtin
|
||||
module Kernel
|
||||
module Integer
|
||||
# The conversion to base10 is quite a bit more complicated than i thought. The bulk of it is in div10
|
||||
# We set up variables, do the devision and write the result to the string
|
||||
# then check if were done and recurse if neccessary
|
||||
|
34
lib/builtin/kernel.rb
Normal file
34
lib/builtin/kernel.rb
Normal file
@ -0,0 +1,34 @@
|
||||
module Builtin
|
||||
module Kernel
|
||||
module ClassMethods
|
||||
# main entry point, ie __init__ calls this
|
||||
# defined here as empty, to be redefined
|
||||
def main context
|
||||
function = Virtual::CompiledMethod.new(:main , [] , Virtual::Integer)
|
||||
return function
|
||||
end
|
||||
# this is the really really first place the machine starts.
|
||||
# it isn't really a function, ie it is jumped to (not called), exits and may not return
|
||||
# so it is responsible for initial setup (and relocation)
|
||||
def __init__ context
|
||||
function = Virtual::CompiledMethod.new(:__init__ , [] , Virtual::Integer)
|
||||
return function
|
||||
end
|
||||
def putstring context
|
||||
function = Virtual::CompiledMethod.new(:putstring , [] )
|
||||
return function
|
||||
ret = Virtual::RegisterMachine.instance.write_stdout(function)
|
||||
function.set_return ret
|
||||
function
|
||||
end
|
||||
def exit context
|
||||
function = Virtual::CompiledMethod.new(:exit , [] , Virtual::Integer)
|
||||
return function
|
||||
ret = Virtual::RegisterMachine.instance.exit(function)
|
||||
function.set_return ret
|
||||
function
|
||||
end
|
||||
end
|
||||
extend ClassMethods
|
||||
end
|
||||
end
|
@ -78,4 +78,4 @@ end
|
||||
require_relative "integer"
|
||||
require_relative "string"
|
||||
require_relative "array"
|
||||
require_relative "system"
|
||||
require_relative "kernel"
|
||||
|
@ -1,13 +1,4 @@
|
||||
module Builtin
|
||||
module Kernel
|
||||
def self.putstring context
|
||||
function = Virtual::CompiledMethod.new(:putstring , [] )
|
||||
return function
|
||||
ret = Virtual::RegisterMachine.instance.write_stdout(function)
|
||||
function.set_return ret
|
||||
function
|
||||
end
|
||||
end
|
||||
class String
|
||||
module ClassMethods
|
||||
def get context , index = Virtual::Integer
|
||||
|
@ -1,11 +0,0 @@
|
||||
module Builtin
|
||||
module Kernel
|
||||
def self.exit context
|
||||
function = Virtual::CompiledMethod.new(:exit , [] , Virtual::Integer)
|
||||
return function
|
||||
ret = Virtual::RegisterMachine.instance.exit(function)
|
||||
function.set_return ret
|
||||
function
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user