move put string to string where it belongs

This commit is contained in:
Torsten Ruger 2015-07-01 21:45:41 +03:00
parent f8ba77dff7
commit 7136450bde
4 changed files with 19 additions and 8 deletions

View File

@ -24,11 +24,6 @@ module Register
emit_syscall( function , :exit ) emit_syscall( function , :exit )
return function return function
end end
def putstring context
function = Virtual::CompiledMethodInfo.create_method(:Kernel , :putstring , [] )
emit_syscall( function , :putstring )
function
end
def exit context def exit context
function = Virtual::CompiledMethodInfo.create_method(:Kernel,:exit , []) function = Virtual::CompiledMethodInfo.create_method(:Kernel,:exit , [])
function.info.return_type = Virtual::Integer function.info.return_type = Virtual::Integer
@ -43,7 +38,6 @@ module Register
return function return function
end end
private
def emit_syscall function , name def emit_syscall function , name
save_message( function ) save_message( function )
function.info.add_code Syscall.new( name ) function.info.add_code Syscall.new( name )

View File

@ -73,5 +73,6 @@ module Register
end end
require_relative "integer" require_relative "integer"
require_relative "array" require_relative "list"
require_relative "kernel" require_relative "kernel"
require_relative "word"

View File

@ -0,0 +1,14 @@
module Register
module Builtin
module Word
module ClassMethods
def putstring context
function = Virtual::CompiledMethodInfo.create_method(:Word , :putstring , [] )
Kernel.emit_syscall( function , :putstring )
function
end
end
extend ClassMethods
end
end
end

View File

@ -105,10 +105,12 @@ module Virtual
end end
obj = @class_mappings[:Kernel ] obj = @class_mappings[:Kernel ]
# create dummy main first, __init__ calls it # create dummy main first, __init__ calls it
[:putstring,:exit,:__send , :__init__ ].each do |f| [:exit,:__send , :__init__ ].each do |f|
obj.add_instance_method Register::Builtin::Kernel.send(f , nil) obj.add_instance_method Register::Builtin::Kernel.send(f , nil)
end end
@class_mappings[:Word].add_instance_method Register::Builtin::Word.send(:putstring , nil)
obj = @class_mappings[:Integer ] obj = @class_mappings[:Integer ]
[:putint,:fibo].each do |f| [:putint,:fibo].each do |f|
obj.add_instance_method Register::Builtin::Integer.send(f , nil) obj.add_instance_method Register::Builtin::Integer.send(f , nil)