remove div and add div10
general division is for another day, the 10 version is manageable also same code produces mod10 wip
This commit is contained in:
@ -152,7 +152,7 @@ module Register
|
||||
@space.get_class_by_name(:Word).add_instance_method Builtin::Word.send(:putstring , nil)
|
||||
|
||||
obj = @space.get_class_by_name(:Integer)
|
||||
[:mod , :putint].each do |f|
|
||||
[:mod , :putint , :div10 , :mod10].each do |f|
|
||||
obj.add_instance_method Builtin::Integer.send(f , nil)
|
||||
end
|
||||
end
|
||||
|
@ -5,6 +5,22 @@ module Register
|
||||
module ClassMethods
|
||||
include AST::Sexp
|
||||
|
||||
def div10 context
|
||||
compiler = Soml::Compiler.new.create_method(:Integer,:div10 ).init_method
|
||||
do_div10(compiler)
|
||||
# return div
|
||||
return compiler.method
|
||||
end
|
||||
def mod10 context
|
||||
compiler = Soml::Compiler.new.create_method(:Integer,:mod10 ).init_method
|
||||
do_div10(compiler)
|
||||
#return mod
|
||||
return compiler.method
|
||||
end
|
||||
|
||||
def do_div10 compiler
|
||||
|
||||
end
|
||||
# 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
|
||||
|
Reference in New Issue
Block a user