Class: Duby::AST::TypeReference
Constant Summary
collapse
- NoType =
TypeReference.new(:notype)
- NullType =
TypeReference.new(:null)
- ErrorType =
TypeReference.new(:error)
- UnreachableType =
TypeReference.new(:unreachable)
- BlockType =
TypeReference.new(:block)
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
#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #expr?, #initialize_copy, #insert, #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.
408
409
410
411
412
413
|
# File 'lib/duby/ast.rb', line 408
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.
403
404
405
|
# File 'lib/duby/ast.rb', line 403
def array
@array
end
|
Returns the value of attribute meta.
405
406
407
|
# File 'lib/duby/ast.rb', line 405
def meta
@meta
end
|
Instance Method Details
#==(other) ⇒ Object
419
420
421
|
# File 'lib/duby/ast.rb', line 419
def ==(other)
to_s == other.to_s
end
|
480
481
482
|
# File 'lib/duby/ast.rb', line 480
def block?
name == :block
end
|
#compatible?(other) ⇒ Boolean
436
437
438
439
440
441
|
# File 'lib/duby/ast.rb', line 436
def compatible?(other)
self == other ||
error? || other.error? ||
unreachable? || other.unreachable?
end
|
#component_type ⇒ Object
447
448
449
|
# File 'lib/duby/ast.rb', line 447
def component_type
AST.type(name) if array?
end
|
#eql?(other) ⇒ Boolean
423
424
425
|
# File 'lib/duby/ast.rb', line 423
def eql?(other)
self == other
end
|
468
469
470
|
# File 'lib/duby/ast.rb', line 468
def error?
name == :error
end
|
#hash ⇒ Object
427
428
429
|
# File 'lib/duby/ast.rb', line 427
def hash
to_s.hash
end
|
#is_parent(other) ⇒ Object
431
432
433
434
|
# File 'lib/duby/ast.rb', line 431
def is_parent(other)
self == other
end
|
443
444
445
|
# File 'lib/duby/ast.rb', line 443
def iterable?
array?
end
|
Returns the value of attribute meta.
406
407
408
|
# File 'lib/duby/ast.rb', line 406
def meta
@meta
end
|
#narrow(other) ⇒ Object
451
452
453
454
455
456
457
458
|
# File 'lib/duby/ast.rb', line 451
def narrow(other)
if error? || unreachable?
other
else
self
end
end
|
472
473
474
|
# File 'lib/duby/ast.rb', line 472
def null?
name == :null
end
|
484
485
486
|
# File 'lib/duby/ast.rb', line 484
def primitive?
true
end
|
#to_s ⇒ Object
415
416
417
|
# File 'lib/duby/ast.rb', line 415
def to_s
"Type(#{name}#{array? ? ' array' : ''}#{meta? ? ' meta' : ''})"
end
|
460
461
462
|
# File 'lib/duby/ast.rb', line 460
def unmeta
TypeReference.new(name, array, false)
end
|
#unreachable? ⇒ Boolean
476
477
478
|
# File 'lib/duby/ast.rb', line 476
def unreachable?
name == :unreachable
end
|