Class: AdLint::Cc1::ConstantSpecifier

Inherits:
PrimaryExpression show all
Defined in:
lib/adlint/cc1/syntax.rb

Instance Attribute Summary collapse

Attributes inherited from SyntaxNode

#head_token, #subsequent_sequence_point, #tail_token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#constant?, #full=, #object_specifiers

Methods inherited from SyntaxNode

#head_location, #short_class_name, #tail_location

Methods included from LocationHolder

#analysis_target?

Methods included from Visitable

#accept

Constructor Details

#initialize(const) ⇒ ConstantSpecifier

Returns a new instance of ConstantSpecifier.



631
632
633
634
# File 'lib/adlint/cc1/syntax.rb', line 631

def initialize(const)
  super()
  @constant = const
end

Instance Attribute Details

#constantObject (readonly)

Returns the value of attribute constant.



636
637
638
# File 'lib/adlint/cc1/syntax.rb', line 636

def constant
  @constant
end

Class Method Details

.of_zero(loc = nil) ⇒ Object



627
628
629
# File 'lib/adlint/cc1/syntax.rb', line 627

def self.of_zero(loc = nil)
  self.new(Token.new(:CONSTANT, "0", loc || Location.new))
end

Instance Method Details

#arithmetic?Boolean

Returns:

  • (Boolean)


662
663
664
# File 'lib/adlint/cc1/syntax.rb', line 662

def arithmetic?
  false
end

#bitwise?Boolean

Returns:

  • (Boolean)


666
667
668
# File 'lib/adlint/cc1/syntax.rb', line 666

def bitwise?
  false
end

#character?Boolean

Returns:

  • (Boolean)


650
651
652
# File 'lib/adlint/cc1/syntax.rb', line 650

def character?
  @constant.value =~ /'.*'/
end

#have_side_effect?Boolean

Returns:

  • (Boolean)


654
655
656
# File 'lib/adlint/cc1/syntax.rb', line 654

def have_side_effect?
  false
end

#inspect(indent = 0) ⇒ Object



687
688
689
690
# File 'lib/adlint/cc1/syntax.rb', line 687

def inspect(indent = 0)
  " " * indent + "#{short_class_name} (#{location.inspect}) " +
    "#{@constant.value}"
end

#locationObject



638
639
640
# File 'lib/adlint/cc1/syntax.rb', line 638

def location
  @constant.location
end

#logical?Boolean

Returns:

  • (Boolean)


658
659
660
# File 'lib/adlint/cc1/syntax.rb', line 658

def logical?
  false
end

#prefixObject



642
643
644
# File 'lib/adlint/cc1/syntax.rb', line 642

def prefix
  @constant.value.scan(/\A(?:0x|0b|0(?=[0-9])|L)/i).first
end

#suffixObject



646
647
648
# File 'lib/adlint/cc1/syntax.rb', line 646

def suffix
  @constant.value.scan(/(?:[UL]+|[FL]+)\z/i).first
end

#to_complemental_logicalObject



679
680
681
# File 'lib/adlint/cc1/syntax.rb', line 679

def to_complemental_logical
  self
end

#to_normalized_logical(parent_expr = nil) ⇒ Object



670
671
672
673
674
675
676
677
# File 'lib/adlint/cc1/syntax.rb', line 670

def to_normalized_logical(parent_expr = nil)
  case parent_expr
  when nil, LogicalAndExpression, LogicalOrExpression
    create_normalized_logical_of(self)
  else
    self
  end
end

#to_sObject



683
684
685
# File 'lib/adlint/cc1/syntax.rb', line 683

def to_s
  @constant.value
end