rubyx/lib/builtin/kernel.rb
2014-09-10 21:35:52 +03:00

35 lines
1.2 KiB
Ruby

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