Sha256: a93e202046b1a25c593e8bc44e987a45f01667ef2fa7e1f22907a23769cd17e7

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module Wool
  module SexpAnalysis
    # Wool representation of a class. I named it WoolClass so it wouldn't
    # clash with regular Class. This links the class to its protocol. It
    # has lists of methods, instance variables, and so on.
    class WoolClass
      attr_reader :path, :methods, :protocol, :scope, :class_object
      attr_accessor :superclass

      def initialize(full_path, scope = Scope::GlobalScope)
        @path = full_path
        @methods = {}
        @protocol = Protocols::ClassProtocol.new(self)
        @scope = scope
        @class_object = Symbol.new(@protocol, self)
        ProtocolRegistry.add_class_protocol(@protocol)
        yield self if block_given?
      end
      
      def add_method(method)
        @methods[method.name] = method
      end
      
      def signatures
        @methods.values.map(&:signatures).flatten
      end
    end
    
    # Wool representation of a method. This name is tweaked so it doesn't
    # collide with ::Method.
    class WoolMethod
      extend ModuleExtensions
      attr_reader :name, :signatures
      attr_accessor_with_default :pure, false
      
      def initialize(name)
        @name = name
        @signatures = []
        yield self if block_given?
      end
      
      def add_signature(return_proto, arg_protos)
        @signatures << Signature.new(self.name, return_proto, arg_protos)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wool-0.5.1 lib/wool/analysis/wool_class.rb