Class: CType::List
- Inherits:
-
Array
- Object
- Array
- CType::List
- Defined in:
- lib/dbc/ctype.rb
Overview
Type
Instance Method Summary collapse
- #ellipses? ⇒ Boolean
- #finalize ⇒ Object
-
#initialize(proto = false) ⇒ List
constructor
A new instance of List.
- #lookup(ident) ⇒ Object
-
#prototype? ⇒ Boolean
check if K & R style prototype: main();.
- #to_s ⇒ Object
- #with_ellipses ⇒ Object
Constructor Details
#initialize(proto = false) ⇒ List
Returns a new instance of List.
546 547 548 549 550 551 |
# File 'lib/dbc/ctype.rb', line 546 def initialize(proto=false) super() @ellipses = false @prototype = proto self.freeze if @prototype end |
Instance Method Details
#ellipses? ⇒ Boolean
569 570 571 |
# File 'lib/dbc/ctype.rb', line 569 def ellipses? @ellipses end |
#finalize ⇒ Object
573 574 575 576 577 578 |
# File 'lib/dbc/ctype.rb', line 573 def finalize if self.length == 1 and self[0].to_s == 'void' self.pop # get rid of (void) end self.freeze end |
#lookup(ident) ⇒ Object
558 559 560 |
# File 'lib/dbc/ctype.rb', line 558 def lookup(ident) self.find { |p| p.identifier == ident } end |
#prototype? ⇒ Boolean
check if K & R style prototype: main();
554 555 556 |
# File 'lib/dbc/ctype.rb', line 554 def prototype? @prototype end |
#to_s ⇒ Object
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/dbc/ctype.rb', line 580 def to_s if self.length == 0 if prototype? '' else 'void' end else if ellipses? [self, '...'] else self end.join(', ') end end |
#with_ellipses ⇒ Object
562 563 564 565 566 567 |
# File 'lib/dbc/ctype.rb', line 562 def with_ellipses() raise "already has ellipses #{self}" if ellipses? raise "prototype with ellipses?" if prototype? @ellipses = true self.freeze end |