42 lines
1.6 KiB
Ruby
Raw Normal View History

2014-09-10 21:35:52 +03:00
module Builtin
module Kernel
module ClassMethods
# 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::CompiledMethodInfo.create_method(:Kernel,:__init__ , [])
2015-05-31 11:07:49 +03:00
# puts "INIT LAYOUT #{function.get_layout.get_layout}"
function.info.return_type = Virtual::Integer
main = Virtual.machine.space.get_main
2014-09-11 15:01:50 +03:00
me = Virtual::Self.new(Virtual::Reference)
2014-09-11 21:26:22 +03:00
code = Virtual::Set.new(Virtual::Self.new(me.type), me)
function.info.add_code(code)
2015-05-30 14:49:10 +03:00
function.info.add_code Virtual::MethodCall.new(main)
2014-09-10 21:35:52 +03:00
return function
end
2015-05-13 12:15:14 +03:00
def putstring context
function = Virtual::CompiledMethodInfo.create_method(:Kernel , :putstring , [] )
2014-09-10 21:35:52 +03:00
return function
ret = Virtual::RegisterMachine.instance.write_stdout(function)
function.set_return ret
function
end
def exit context
function = Virtual::CompiledMethodInfo.create_method(:Kernel,:exit , [])
function.info.return_type = Virtual::Integer
2014-09-10 21:35:52 +03:00
return function
ret = Virtual::RegisterMachine.instance.exit(function)
function.set_return ret
function
end
2014-09-24 18:14:23 +03:00
def __send context
function = Virtual::CompiledMethodInfo.create_method(:Kernel ,:__send , [] )
function.info.return_type = Virtual::Integer
return function
end
2014-09-10 21:35:52 +03:00
end
extend ClassMethods
end
end