just renaming

This commit is contained in:
Torsten Ruger 2015-05-16 12:54:11 +03:00
parent 9376b8bc16
commit bee269f7a8
13 changed files with 20 additions and 20 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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")

View File

@ -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 )

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}"

View File

@ -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]