type now means class name
update reader (with new type definition) remove type class (now symbol) update all types to class name symbols
This commit is contained in:
@ -4,14 +4,14 @@ module Register
|
||||
module Integer
|
||||
module ClassMethods
|
||||
def plus c
|
||||
plus_function = Virtual::MethodSource.create_method(:Integer,:int,:plus , [:int] )
|
||||
plus_function.source.set_return_type Phisol::Type.int
|
||||
plus_function.source.receiver = Phisol::Integer
|
||||
plus_function = Virtual::MethodSource.create_method(:Integer,:Integer,:plus , [:Integer] )
|
||||
plus_function.source.set_return_type :Integer
|
||||
plus_function.source.receiver = :Integer
|
||||
|
||||
tmp = Register.tmp_reg :int
|
||||
tmp = Register.tmp_reg :Integer
|
||||
index = Register.arg_index 1
|
||||
plus_function.source.add_code Register.get_slot( plus_function , :message , index , tmp )
|
||||
add = Register::OperatorInstruction.new( plus_function, :add , Register.self_reg , tmp )
|
||||
add = Register::OperatorInstruction.new( plus_function, :add , Register.self_reg(:Integer) , tmp )
|
||||
plus_function.source.add_code add
|
||||
return plus_function
|
||||
end
|
||||
@ -23,9 +23,9 @@ module Register
|
||||
# As we write before we recurse (save a push) we write the number backwards
|
||||
# arguments: string address , integer
|
||||
# def utoa context
|
||||
# utoa_function = Virtual::MethodSource.create_method(:Integer ,:utoa , [ Phisol::Integer ] )
|
||||
# function.source.return_type = Phisol::Type.int
|
||||
# function.source.receiver = Phisol::Integer
|
||||
# utoa_function = Virtual::MethodSource.create_method(:Integer ,:utoa , [ :Integer ] )
|
||||
# function.source.return_type = :Integer
|
||||
# function.source.receiver = :Integer
|
||||
# return utoa_function
|
||||
# # str_addr = utoa_function.receiver
|
||||
# # number = utoa_function.args.first
|
||||
@ -43,9 +43,9 @@ module Register
|
||||
# end
|
||||
|
||||
def putint context
|
||||
putint_function = Virtual::MethodSource.create_method(:Integer,:int,:putint , [] )
|
||||
putint_function.source.set_return_type Phisol::Type.int
|
||||
putint_function.source.receiver = Phisol::Integer
|
||||
putint_function = Virtual::MethodSource.create_method(:Integer,:Integer,:putint , [] )
|
||||
putint_function.source.set_return_type :Integer
|
||||
putint_function.source.receiver = :Integer
|
||||
return putint_function
|
||||
# buffer = Parfait::Word.new(" ") # create a buffer
|
||||
# context.object_space.add_object buffer # and save it (function local variable: a no no)
|
||||
@ -72,9 +72,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 = Virtual::MethodSource.create_method(:Integer,:int,:fibo , [] )
|
||||
fibo_function.source.set_return_type Phisol::Type.int
|
||||
fibo_function.source.receiver = Phisol::Integer
|
||||
fibo_function = Virtual::MethodSource.create_method(:Integer,:Integer,:fibo , [] )
|
||||
fibo_function.source.set_return_type :Integer
|
||||
fibo_function.source.receiver = :Integer
|
||||
return fibo_function
|
||||
# result = fibo_function.return_type
|
||||
# int = fibo_function.receiver
|
||||
|
@ -6,14 +6,14 @@ 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 = Virtual::MethodSource.create_method(:Kernel,:int,:__init__ , [])
|
||||
function.source.set_return_type Phisol::Type.int
|
||||
function = Virtual::MethodSource.create_method(:Kernel,:Integer,:__init__ , [])
|
||||
function.source.set_return_type :Integer
|
||||
# no method enter or return (automatically added), remove
|
||||
function.source.blocks.first.codes.pop # no Method enter
|
||||
function.source.blocks.last.codes.pop # no Method return
|
||||
#Set up the Space as self upon init
|
||||
space = Parfait::Space.object_space
|
||||
function.source.add_code LoadConstant.new(function, space , Register.self_reg)
|
||||
function.source.add_code LoadConstant.new(function, space , Register.self_reg(:Space))
|
||||
message_ind = Register.resolve_index( :space , :first_message )
|
||||
# Load the message to new message register (r3)
|
||||
function.source.add_code Register.get_slot( function , :self , message_ind , :new_message)
|
||||
@ -25,16 +25,16 @@ module Register
|
||||
return function
|
||||
end
|
||||
def exit context
|
||||
function = Virtual::MethodSource.create_method(:Kernel,:int,:exit , [])
|
||||
function.source.set_return_type Phisol::Type.int
|
||||
function = Virtual::MethodSource.create_method(:Kernel,:Integer,:exit , [])
|
||||
function.source.set_return_type :Integer
|
||||
return function
|
||||
ret = Virtual::RegisterMachine.instance.exit(function)
|
||||
function.set_return ret
|
||||
function
|
||||
end
|
||||
def __send context
|
||||
function = Virtual::MethodSource.create_method(:Kernel,:int ,:__send , [] )
|
||||
function.source.set_return_type Phisol::Type.int
|
||||
function = Virtual::MethodSource.create_method(:Kernel,:Integer ,:__send , [] )
|
||||
function.source.set_return_type :Integer
|
||||
return function
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Register
|
||||
# main entry point, ie __init__ calls this
|
||||
# defined here as empty, to be redefined
|
||||
def main context
|
||||
function = Virtual::MethodSource.create_method(:Object, :int , :main , [])
|
||||
function = Virtual::MethodSource.create_method(:Object, :Integer , :main , [])
|
||||
return function
|
||||
end
|
||||
|
||||
@ -17,8 +17,8 @@ module Register
|
||||
# end
|
||||
# The at_index is just "below" the api, something we need but don't want to expose,
|
||||
# so we can't code the above in ruby
|
||||
def _get_instance_variable context , name = :int
|
||||
get_function = Virtual::MethodSource.create_method(:Object,:int, :_get_instance_variable , [ ] )
|
||||
def _get_instance_variable context , name = :Integer
|
||||
get_function = Virtual::MethodSource.create_method(:Object,:Integer, :_get_instance_variable , [ ] )
|
||||
return get_function
|
||||
# me = get_function.receiver
|
||||
# var_name = get_function.args.first
|
||||
@ -38,8 +38,8 @@ module Register
|
||||
# return get_function
|
||||
end
|
||||
|
||||
def _set_instance_variable(context , name = :int , value = :int )
|
||||
set_function = Virtual::MethodSource.create_method(:Object,:int,:_set_instance_variable ,[] )
|
||||
def _set_instance_variable(context , name = :Integer , value = :Integer )
|
||||
set_function = Virtual::MethodSource.create_method(:Object,:Integer,:_set_instance_variable ,[] )
|
||||
return set_function
|
||||
# receiver set_function
|
||||
# me = set_function.receiver
|
||||
|
@ -3,7 +3,7 @@ module Register
|
||||
module Word
|
||||
module ClassMethods
|
||||
def putstring context
|
||||
function = Virtual::MethodSource.create_method(:Word,:int , :putstring , [] )
|
||||
function = Virtual::MethodSource.create_method(:Word,:Integer , :putstring , [] )
|
||||
Kernel.emit_syscall( function , :putstring )
|
||||
function
|
||||
end
|
||||
|
Reference in New Issue
Block a user