From bee269f7a880cd636f6793029b1b35514493aad5 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 16 May 2015 12:54:11 +0300 Subject: [PATCH] just renaming --- lib/parfait.rb | 2 +- lib/parfait/class.rb | 2 +- lib/parfait/meta_class.rb | 2 +- lib/parfait/space.rb | 2 +- lib/register/builtin/integer.rb | 2 +- lib/register/builtin/kernel.rb | 2 +- lib/register/builtin/object.rb | 4 ++-- lib/virtual/compiler/basic_expressions.rb | 2 +- lib/virtual/compiler/function_expression.rb | 4 ++-- lib/virtual/compiler/module_expression.rb | 2 +- lib/virtual/machine.rb | 10 +++++----- lib/virtual/passes/send_implementation.rb | 2 +- test/fragments/test_while_fibo.rb | 4 ++-- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/parfait.rb b/lib/parfait.rb index 9959f838..84983572 100644 --- a/lib/parfait.rb +++ b/lib/parfait.rb @@ -25,7 +25,7 @@ module Parfait class Object include FakeMem def self.new_object *args -# Space.space.get_or_create_class(:Word) +# Space.space.get_class_by_name(:Word) puts "I am #{self}" object = self.new(*args) object diff --git a/lib/parfait/class.rb b/lib/parfait/class.rb index ad3bee29..367e086f 100644 --- a/lib/parfait/class.rb +++ b/lib/parfait/class.rb @@ -40,7 +40,7 @@ module Parfait method = get_instance_method(m_name) unless method unless( @name == :Object) - supr = Space.space.get_or_create_class(@super_class_name) + supr = Space.space.get_class_by_name(@super_class_name) method = supr.resolve_method(m_name) end end diff --git a/lib/parfait/meta_class.rb b/lib/parfait/meta_class.rb index 0b31e621..87de2532 100644 --- a/lib/parfait/meta_class.rb +++ b/lib/parfait/meta_class.rb @@ -37,7 +37,7 @@ module Virtual puts "no function for :#{name} in Meta #{@me_self.inspect}" return nil else #recurse up class hierachy unless we're at Object - return @me_self.context.object_space.get_or_create_class(@me_self.super_class).get_function name + return @me_self.context.object_space.get_class_by_name(@me_self.super_class).get_function name end end diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index 7778b75d..b9463bff 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -52,7 +52,7 @@ module Parfait # this is the way to instantiate classes (not Parfait::Class.new) # so we get and keep exactly one per name - def get_or_create_class name + def get_class_by_name name raise "uups #{name}.#{name.class}" unless name.is_a? Symbol c = @classes[name] unless c diff --git a/lib/register/builtin/integer.rb b/lib/register/builtin/integer.rb index 6c8144cf..52d14a8c 100644 --- a/lib/register/builtin/integer.rb +++ b/lib/register/builtin/integer.rb @@ -32,7 +32,7 @@ module Builtin context.object_space.add_object buffer # and save it (function local variable: a no no) int = putint_function.receiver moved_int = putint_function.new_local - utoa = context.object_space.get_or_create_class(:Object).resolve_method(:utoa) + utoa = context.object_space.get_class_by_name(:Object).resolve_method(:utoa) putint_function.instance_eval do mov( moved_int , int ) # move arg up add( int , buffer ,nil ) # string to write to (add string address to pc) diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index e24e6328..507eaa7d 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -12,7 +12,7 @@ module Builtin # so it is responsible for initial setup (and relocation) def __init__ context function = Virtual::CompiledMethod.new(:__init__ , [] , Virtual::Integer) - clazz = Virtual::Machine.instance.space.get_or_create_class :Kernel + clazz = Virtual::Machine.instance.space.get_class_by_name :Kernel method = clazz.resolve_method :main me = Virtual::Self.new(Virtual::Reference) code = Virtual::Set.new(Virtual::Self.new(me.type), me) diff --git a/lib/register/builtin/object.rb b/lib/register/builtin/object.rb index e1965d47..59dd975f 100644 --- a/lib/register/builtin/object.rb +++ b/lib/register/builtin/object.rb @@ -29,7 +29,7 @@ module Builtin var_name = get_function.args.first return_to = get_function.return_type - index_function = ::Virtual::Machine.instance.space.get_or_create_class(:Object).resolve_method(:index_of) + index_function = ::Virtual::Machine.instance.space.get_class_by_name(:Object).resolve_method(:index_of) # get_function.push( [me] ) # index = get_function.call( index_function ) @@ -50,7 +50,7 @@ module Builtin me = set_function.receiver var_name = set_function.args.first return_to = set_function.return_type - index_function = context.object_space.get_or_create_class(:Object).resolve_method(:index_of) + index_function = context.object_space.get_class_by_name(:Object).resolve_method(:index_of) set_function.push( [me] ) set_function.call( index_function ) after_body = set_function.new_block("after_index") diff --git a/lib/virtual/compiler/basic_expressions.rb b/lib/virtual/compiler/basic_expressions.rb index 934d3c1b..d2492922 100644 --- a/lib/virtual/compiler/basic_expressions.rb +++ b/lib/virtual/compiler/basic_expressions.rb @@ -62,7 +62,7 @@ module Virtual def self.compile_module expression , method - clazz = Space.space.get_or_create_class name + clazz = Space.space.get_class_by_name name raise "uups #{clazz}.#{name}" unless clazz to = Return.new(Reference , clazz ) method.add_code Set.new( to , clazz ) diff --git a/lib/virtual/compiler/function_expression.rb b/lib/virtual/compiler/function_expression.rb index f4465d98..f6586720 100644 --- a/lib/virtual/compiler/function_expression.rb +++ b/lib/virtual/compiler/function_expression.rb @@ -9,7 +9,7 @@ module Virtual r = expression.receiver ? Compiler.compile(expression.receiver, method ) : Self.new() new_method = CompiledMethod.new(expression.name , args , r ) new_method.class_name = r.is_a?(Parfait::Class) ? r.name : method.class_name - clazz = Machine.instance.space.get_or_create_class(new_method.class_name) + clazz = Machine.instance.space.get_class_by_name(new_method.class_name) clazz.add_instance_method new_method #frame = frame.new_frame @@ -36,7 +36,7 @@ module Virtual if expression.receiver.nil? clazz = context.current_class else - c = context.object_space.get_or_create_class expression.receiver.name.to_sym + c = context.object_space.get_class_by_name expression.receiver.name.to_sym clazz = c.meta_class end diff --git a/lib/virtual/compiler/module_expression.rb b/lib/virtual/compiler/module_expression.rb index 5b97a265..be83edb3 100644 --- a/lib/virtual/compiler/module_expression.rb +++ b/lib/virtual/compiler/module_expression.rb @@ -6,7 +6,7 @@ module Virtual end def self.compile_class expression , method - clazz = ::Space.space.get_or_create_class expression.name + clazz = ::Space.space.get_class_by_name expression.name puts "Created class #{clazz.name.inspect}" expression.expressions.each do |expr| # check if it's a function definition and add diff --git a/lib/virtual/machine.rb b/lib/virtual/machine.rb index 7aabb4eb..7030e6af 100644 --- a/lib/virtual/machine.rb +++ b/lib/virtual/machine.rb @@ -93,11 +93,11 @@ module Virtual # very fiddly chicken 'n egg problem. Functions need to be in the right order, and in fact we # have to define some dummies, just for the other to compile # TODO: go through the virtual parfait layer and adjust function names to what they really are - obj = @space.get_or_create_class :Object + obj = @space.get_class_by_name :Object [:index_of , :_get_instance_variable , :_set_instance_variable].each do |f| obj.add_instance_method Builtin::Object.send(f , nil) end - obj = @space.get_or_create_class :Kernel + obj = @space.get_class_by_name :Kernel # create main first, __init__ calls it @main = Builtin::Kernel.send(:main , @context) obj.add_instance_method @main @@ -110,15 +110,15 @@ module Virtual # the point of which is that by the time main executes, all is "normal" @init = Block.new(:_init_ , nil ) @init.add_code(Register::RegisterMain.new(underscore_init)) - obj = @space.get_or_create_class :Integer + obj = @space.get_class_by_name :Integer [:putint,:fibo].each do |f| obj.add_instance_method Builtin::Integer.send(f , nil) end - obj = @space.get_or_create_class :Word + obj = @space.get_class_by_name :Word [:get , :set , :puts].each do |f| obj.add_instance_method Builtin::Word.send(f , nil) end - obj = space.get_or_create_class :Array + obj = space.get_class_by_name :Array [:get , :set , :push].each do |f| obj.add_instance_method Builtin::Array.send(f , nil) end diff --git a/lib/virtual/passes/send_implementation.rb b/lib/virtual/passes/send_implementation.rb index 15ef8f26..497eaad6 100644 --- a/lib/virtual/passes/send_implementation.rb +++ b/lib/virtual/passes/send_implementation.rb @@ -28,7 +28,7 @@ module Virtual else # note: this is the current view: call internal send, even the method name says else # but send is "special" and accesses the internal method name and resolves. - kernel = Virtual::Machine.instance.space.get_or_create_class(:Kernel) + kernel = Virtual::Machine.instance.space.get_class_by_name(:Kernel) method = kernel.get_instance_method(:__send) new_codes << MethodCall.new( method ) raise "unimplemented: \n#{code}" diff --git a/test/fragments/test_while_fibo.rb b/test/fragments/test_while_fibo.rb index 5c43a459..d9b12201 100644 --- a/test/fragments/test_while_fibo.rb +++ b/test/fragments/test_while_fibo.rb @@ -31,12 +31,12 @@ HERE # not my hand off course, found in the net from a basic introduction def test_kernel_fibo int = Register::Integer.new(Virtual::RegisterMachine.instance.receiver_register) - fibo = @object_space.get_or_create_class(:Object).resolve_method(:fibo) + fibo = @object_space.get_class_by_name(:Object).resolve_method(:fibo) main = @object_space.main main.mov int , 10 main.call( fibo ) main.mov( Virtual::RegisterMachine.instance.receiver_register , Virtual::RegisterMachine.instance.return_register ) - putint = @object_space.get_or_create_class(:Object).resolve_method(:putint) + putint = @object_space.get_class_by_name(:Object).resolve_method(:putint) main.call( putint ) @should = [0x0,0x40,0x2d,0xe9,0x1,0x0,0x52,0xe3,0x2,0x0,0xa0,0xd1,0x7,0x0,0x0,0xda,0x1,0x30,0xa0,0xe3,0x0,0x40,0xa0,0xe3,0x4,0x30,0x83,0xe0,0x4,0x40,0x43,0xe0,0x1,0x20,0x42,0xe2,0x1,0x0,0x52,0xe3,0xfa,0xff,0xff,0x1a,0x3,0x0,0xa0,0xe1,0x0,0x80,0xbd,0xe8] @target = [:Object , :fibo]