remove return_type

soon to be obsolete with multi returns
This commit is contained in:
Torsten Ruger
2015-10-28 12:19:10 +02:00
parent 142c36a374
commit 7e0778dc70
7 changed files with 24 additions and 38 deletions

View File

@ -13,7 +13,6 @@ module Register
# arguments: string address , integer
# def utoa context
# utoa_function = MethodSource.create_method(:Integer ,:utoa , [ :Integer ] )
# function.source.return_type = :Integer
# function.source.receiver = :Integer
# return utoa_function
# # str_addr = utoa_function.receiver
@ -32,8 +31,7 @@ module Register
# end
def putint context
putint_function = MethodSource.create_method(:Integer,:Integer,:putint , [] )
putint_function.source.set_return_type :Integer
putint_function = MethodSource.create_method(:Integer,:putint , [] )
putint_function.source.receiver = :Integer
return putint_function
# buffer = Parfait::Word.new(" ") # create a buffer
@ -61,11 +59,9 @@ module Register
# a hand coded version of the fibonachi numbers
# not my hand off course, found in the net http://www.peter-cockerell.net/aalp/html/ch-5.html
def fibo context
fibo_function = MethodSource.create_method(:Integer,:Integer,:fibo , [] )
fibo_function.source.set_return_type :Integer
fibo_function = MethodSource.create_method(:Integer,:fibo , [] )
fibo_function.source.receiver = :Integer
return fibo_function
# result = fibo_function.return_type
# int = fibo_function.receiver
#
# last = fibo_function.new_block("return")

View File

@ -6,13 +6,12 @@ module Register
# 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
def __init__ context
function = MethodSource.create_method(:Kernel,:Integer,:__init__ , [])
function.source.set_return_type :Integer
function = MethodSource.create_method(:Kernel,:__init__ , [])
# no method enter or return (automatically added), remove
new_start = Label.new(function , "__init__" )
function.source.instructions = new_start
function.source.current = new_start
#Set up the Space as self upon init
space = Parfait::Space.object_space
space_reg = Register.tmp_reg(:Space)
@ -28,8 +27,7 @@ module Register
return function
end
def exit context
function = MethodSource.create_method(:Kernel,:Integer,:exit , [])
function.source.set_return_type :Integer
function = MethodSource.create_method(:Kernel,:exit , [])
return function
ret = RegisterMachine.instance.exit(function)
function.set_return ret
@ -53,7 +51,7 @@ module Register
def restore_message(function)
r8 = RegisterValue.new( :r8 , :Message)
return_tmp = Register.tmp_reg function.source.return_type
return_tmp = Register.tmp_reg :Integer
# get the sys return out of the way
function.source.add_code RegisterTransfer.new(function, Register.message_reg , return_tmp )
# load the stored message into the base RegisterMachine

View File

@ -6,7 +6,7 @@ module Register
# main entry point, ie __init__ calls this
# defined here as empty, to be redefined
def main context
function = MethodSource.create_method(:Object, :Integer , :main , [])
function = MethodSource.create_method(:Object , :main , [])
return function
end

View File

@ -3,7 +3,7 @@ module Register
module Word
module ClassMethods
def putstring context
function = MethodSource.create_method(:Word,:Integer , :putstring , [] )
function = MethodSource.create_method(:Word , :putstring , [] )
function.source.add_code Register.get_slot( function , :message , :receiver , :new_message )
Kernel.emit_syscall( function , :putstring )
function