Module: Carbon::Concrete::Item::Base
Overview
A "base" for other items. This just has some common methods that all items need to share to be compatible with the index. This module is the bases of the build system in the Carbon::Concrete module.
Instance Attribute Summary collapse
-
#dependencies ⇒ Set<Request>
readonly
The dependencies that this item is based on.
-
#generics ⇒ <Type::Generic>
readonly
Returns the generic information associated with this item.
-
#name ⇒ ::String
readonly
Returns the full name of the item.
-
#type ⇒ Concrete::Type
readonly
Returns the type of the item.
Class Method Summary collapse
-
.from(type) ⇒ {::Symbol => ::Object}
private
Creates a hash from a given Type that can be used to intialize an instance of this object.
Instance Method Summary collapse
-
#==(other) ⇒ ::Boolean
(also: #eql?)
Compares this item to another object.
-
#call(build, generics) ⇒ void
private
Performs compilation for the item.
-
#corrected_dependencies(request) {|dep| ... } ⇒ ::Enumerable, void
private
Modifies the dependencies of this item so that they conform to the given request.
-
#define(index) ⇒ Concrete::Item::Base
Performs modification to the item.
-
#hash ⇒ Numeric
private
Creates a hash of the item.
Instance Attribute Details
#dependencies ⇒ Set<Request> (readonly)
The dependencies that this item is based on. These are requests because we request the item from the index as a dependency. Requests contain the module name that it builds and the generics it requires.
51 52 53 |
# File 'lib/carbon/concrete/item/base.rb', line 51 def dependencies @dependencies end |
#generics ⇒ <Type::Generic> (readonly)
Returns the generic information associated with this item. This is used internally for generic substitution later on.
40 41 42 |
# File 'lib/carbon/concrete/item/base.rb', line 40 def generics @generics end |
#name ⇒ ::String (readonly)
Returns the full name of the item. This can include generic information.
31 32 33 |
# File 'lib/carbon/concrete/item/base.rb', line 31 def name @name end |
#type ⇒ Concrete::Type (readonly)
Returns the type of the item. This is the full Type.
23 24 25 |
# File 'lib/carbon/concrete/item/base.rb', line 23 def type @type end |
Class Method Details
.from(type) ⇒ {::Symbol => ::Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a hash from a given Type that can be used to intialize an instance of this object. This is mostly used for Carbon::Concrete::Index#define and shouldn't be used anywhere else.
60 61 62 |
# File 'lib/carbon/concrete/item/base.rb', line 60 def self.from(type) { type: type } end |
Instance Method Details
#==(other) ⇒ ::Boolean Also known as: eql?
Compares this item to another object. If the other object is this item, then it returns true; otherwise, it returns false.
77 78 79 |
# File 'lib/carbon/concrete/item/base.rb', line 77 def ==(other) equal?(other) end |
#call(build, generics) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Performs compilation for the item. This converts the item into an
LLVM-based value or type, to be used for compiling. If
unimplemented, it raises a NotImplementedError
.
103 104 105 |
# File 'lib/carbon/concrete/item/base.rb', line 103 def call(build, generics) fail NotImplementedError, "Could not build #{self.class}" end |
#corrected_dependencies(request) {|dep| ... } ⇒ ::Enumerable, void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Modifies the dependencies of this item so that they conform to the given request. This should resolve all of our dependencies so that they no longer hold any sort of generic class.
129 130 131 132 133 134 |
# File 'lib/carbon/concrete/item/base.rb', line 129 def corrected_dependencies(request, &block) return to_enum(:corrected_dependencies, request) unless block_given? return dependencies.each(&block) if generics.empty? forced_corrected_dependencies(request, &block) end |
#define(index) ⇒ Concrete::Item::Base
Performs modification to the item. This is done after all items are loaded into the index, so that an item can load outside information if need be.
114 115 116 |
# File 'lib/carbon/concrete/item/base.rb', line 114 def define(index) self end |
#hash ⇒ Numeric
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a hash of the item. This is used mostly in the Hash class.
87 88 89 |
# File 'lib/carbon/concrete/item/base.rb', line 87 def hash type.hash end |