change to module style like other modules in this dir

This commit is contained in:
Torsten Ruger 2014-09-11 15:08:56 +03:00
parent 3d66ffcc17
commit 98a88ec10e

View File

@ -1,12 +1,13 @@
#integer related kernel functions #integer related kernel functions
module Builtin module Builtin
module Integer module Integer
module ClassMethods
# The conversion to base10 is quite a bit more complicated than i thought. The bulk of it is in div10 # 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 # We set up variables, do the devision and write the result to the string
# then check if were done and recurse if neccessary # then check if were done and recurse if neccessary
# As we write before we recurse (save a push) we write the number backwards # As we write before we recurse (save a push) we write the number backwards
# arguments: string address , integer # arguments: string address , integer
def self.utoa context def utoa context
utoa_function = Virtual::CompiledMethod.new(:utoa , [ Virtual::Integer ] , Virtual::Integer ,Virtual::Integer ) utoa_function = Virtual::CompiledMethod.new(:utoa , [ Virtual::Integer ] , Virtual::Integer ,Virtual::Integer )
return utoa_function return utoa_function
str_addr = utoa_function.receiver str_addr = utoa_function.receiver
@ -24,7 +25,7 @@ module Builtin
return utoa_function return utoa_function
end end
def self.putint context def putint context
putint_function = Virtual::CompiledMethod.new(:putint , [] , Virtual::Integer ,Virtual::Integer ) putint_function = Virtual::CompiledMethod.new(:putint , [] , Virtual::Integer ,Virtual::Integer )
return putint_function return putint_function
buffer = Virtual::StringConstant.new(" ") # create a buffer buffer = Virtual::StringConstant.new(" ") # create a buffer
@ -51,7 +52,7 @@ module Builtin
# result comes in return_register # result comes in return_register
# a hand coded version of the fibonachi numbers # 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 # not my hand off course, found in the net http://www.peter-cockerell.net/aalp/html/ch-5.html
def self.fibo context def fibo context
fibo_function = Virtual::CompiledMethod.new(:fibo , [] , Virtual::Integer ,Virtual::Integer ) fibo_function = Virtual::CompiledMethod.new(:fibo , [] , Virtual::Integer ,Virtual::Integer )
return fibo_function return fibo_function
result = fibo_function.return_type result = fibo_function.return_type
@ -84,6 +85,7 @@ module Builtin
fibo_function fibo_function
end end
end
extend ClassMethods
end end
end end