From 7136450bde42a728e9bcdc43bc3fe8fff044f9a4 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 1 Jul 2015 21:45:41 +0300 Subject: [PATCH] move put string to string where it belongs --- lib/register/builtin/kernel.rb | 6 ------ lib/register/builtin/object.rb | 3 ++- lib/register/builtin/word.rb | 14 ++++++++++++++ lib/virtual/boot.rb | 4 +++- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 lib/register/builtin/word.rb diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index c3c32f7b..266ca991 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -24,11 +24,6 @@ module Register emit_syscall( function , :exit ) return function end - def putstring context - function = Virtual::CompiledMethodInfo.create_method(:Kernel , :putstring , [] ) - emit_syscall( function , :putstring ) - function - end def exit context function = Virtual::CompiledMethodInfo.create_method(:Kernel,:exit , []) function.info.return_type = Virtual::Integer @@ -43,7 +38,6 @@ module Register return function end - private def emit_syscall function , name save_message( function ) function.info.add_code Syscall.new( name ) diff --git a/lib/register/builtin/object.rb b/lib/register/builtin/object.rb index 79b910fc..6d1de3f8 100644 --- a/lib/register/builtin/object.rb +++ b/lib/register/builtin/object.rb @@ -73,5 +73,6 @@ module Register end require_relative "integer" -require_relative "array" +require_relative "list" require_relative "kernel" +require_relative "word" diff --git a/lib/register/builtin/word.rb b/lib/register/builtin/word.rb new file mode 100644 index 00000000..9c3beddc --- /dev/null +++ b/lib/register/builtin/word.rb @@ -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 diff --git a/lib/virtual/boot.rb b/lib/virtual/boot.rb index 8aabccd3..c26ac868 100644 --- a/lib/virtual/boot.rb +++ b/lib/virtual/boot.rb @@ -105,10 +105,12 @@ module Virtual end obj = @class_mappings[:Kernel ] # 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) end + @class_mappings[:Word].add_instance_method Register::Builtin::Word.send(:putstring , nil) + obj = @class_mappings[:Integer ] [:putint,:fibo].each do |f| obj.add_instance_method Register::Builtin::Integer.send(f , nil)