Class: Duby::AST::TypeReference
Constant Summary
collapse
- NoType =
TypeReference.new(:notype)
- NullType =
TypeReference.new(:null)
- ErrorType =
TypeReference.new(:error)
- UnreachableType =
TypeReference.new(:unreachable)
Instance Attribute Summary collapse
Attributes included from Named
#name
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary
collapse
Methods inherited from Node
#[], #each, #expr?, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp
Constructor Details
#initialize(name, array = false, meta = false, position = nil) ⇒ TypeReference
Returns a new instance of TypeReference.
178
179
180
181
182
183
|
# File 'lib/duby/ast.rb', line 178
def initialize(name, array = false, meta = false, position=nil)
super(nil, position)
@name = name
@array = array
@meta = meta
end
|
Instance Attribute Details
#array ⇒ Object
Also known as:
array?
Returns the value of attribute array.
173
174
175
|
# File 'lib/duby/ast.rb', line 173
def array
@array
end
|
Returns the value of attribute meta.
175
176
177
|
# File 'lib/duby/ast.rb', line 175
def meta
@meta
end
|
Instance Method Details
#==(other) ⇒ Object
189
190
191
|
# File 'lib/duby/ast.rb', line 189
def ==(other)
to_s == other.to_s
end
|
#compatible?(other) ⇒ Boolean
206
207
208
209
210
211
|
# File 'lib/duby/ast.rb', line 206
def compatible?(other)
self == other ||
error? || other.error? ||
unreachable? || other.unreachable?
end
|
#component_type ⇒ Object
217
218
219
|
# File 'lib/duby/ast.rb', line 217
def component_type
AST.type(name) if array?
end
|
#eql?(other) ⇒ Boolean
193
194
195
|
# File 'lib/duby/ast.rb', line 193
def eql?(other)
self == other
end
|
238
239
240
|
# File 'lib/duby/ast.rb', line 238
def error?
name == :error
end
|
197
198
199
|
# File 'lib/duby/ast.rb', line 197
def hash
to_s.hash
end
|
#is_parent(other) ⇒ Object
201
202
203
204
|
# File 'lib/duby/ast.rb', line 201
def is_parent(other)
self == other
end
|
213
214
215
|
# File 'lib/duby/ast.rb', line 213
def iterable?
array?
end
|
Returns the value of attribute meta.
176
177
178
|
# File 'lib/duby/ast.rb', line 176
def meta
@meta
end
|
#narrow(other) ⇒ Object
221
222
223
224
225
226
227
228
|
# File 'lib/duby/ast.rb', line 221
def narrow(other)
if error? || unreachable?
other
else
self
end
end
|
246
247
248
|
# File 'lib/duby/ast.rb', line 246
def primitive?
true
end
|
185
186
187
|
# File 'lib/duby/ast.rb', line 185
def to_s
"Type(#{name}#{array? ? ' array' : ''}#{meta? ? ' meta' : ''})"
end
|
230
231
232
|
# File 'lib/duby/ast.rb', line 230
def unmeta
TypeReference.new(name, array, false)
end
|
#unreachable? ⇒ Boolean
242
243
244
|
# File 'lib/duby/ast.rb', line 242
def unreachable?
name == :unreachable
end
|