removing meta class (for now)

This commit is contained in:
Torsten Ruger
2016-12-29 18:39:59 +02:00
parent 80237e5033
commit 4c3007e6c0
5 changed files with 1 additions and 120 deletions

View File

@ -45,11 +45,7 @@ module Typed
def on_ClassExpression expression
name = expression.value
clazz = Parfait::Space.object_space.get_class_by_name! name
raise "No such class #{name}" unless clazz
reg = use_reg :MetaClass , clazz
add_load_constant( expression, clazz , reg )
return reg
raise "No meta class #{name}"
end
end

View File

@ -10,7 +10,6 @@ require_relative "parfait/list"
require_relative "parfait/word"
require_relative "parfait/binary_code"
require_relative "parfait/typed_method"
require_relative "parfait/meta_class"
require_relative "parfait/dictionary"
require_relative "parfait/type"
require_relative "parfait/message"

View File

@ -1,58 +0,0 @@
module Parfait
# class that acts like a class, but is really the object
# described in the ruby language book as the eigenclass, what you get with
# class MyClass
# class << self <--- this is called the eigenclass, or metaclass, and really is just
# .... the class object but gives us the ability to use the
# syntax as if it were a class
# While the "real" metaclass is the type, we need to honor the constancy of the type
# So the type needs to be copied and replaced anytime it is edited.
# And then changed in the original object, and thus we need this level of indirection
# Basically we implement the Behaviour protocol, by forwarding to the type
class MetaClass < Object
include Logging
attribute :object
def initialize(object)
super()
self.object = object
end
def name
self.object.get_type.name
end
# first part of the protocol is read, just forward to self.object.type
def methods
self.object.get_type.methods
end
def method_names
self.object.get_type.method_names
end
def get_instance_method fname
self.object.get_type.get_instance_method fname
end
# the modifying part creates a new type
# forwards the action and replaces the type
def add_instance_method method
type = self.object.get_type.dup
ret = type.add_instance_method(method)
self.object.set_type type
ret
end
def remove_instance_method method_name
type = self.object.get_type.dup
ret = type.remove_instance_method(method_name)
self.object.set_type type
ret
end
end
end