Class: AdLint::Cc1::ArraySubscriptExpression

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

Instance Attribute Summary collapse

Attributes inherited from PostfixExpression

#operator

Attributes inherited from SyntaxNode

#head_token, #subsequent_sequence_point, #tail_token

Instance Method Summary collapse

Methods inherited from PostfixExpression

#location

Methods inherited from Expression

#constant?, #full=, #object_specifiers

Methods inherited from SyntaxNode

#head_location, #location, #short_class_name, #tail_location

Methods included from LocationHolder

#analysis_target?

Methods included from Visitable

#accept

Constructor Details

#initialize(expr, ary_subs, left_bracket) ⇒ ArraySubscriptExpression

Returns a new instance of ArraySubscriptExpression.



865
866
867
868
869
# File 'lib/adlint/cc1/syntax.rb', line 865

def initialize(expr, ary_subs, left_bracket)
  super(left_bracket)
  @expression = expr
  @array_subscript = ary_subs
end

Instance Attribute Details

#array_subscriptObject (readonly)

Returns the value of attribute array_subscript.



872
873
874
# File 'lib/adlint/cc1/syntax.rb', line 872

def array_subscript
  @array_subscript
end

#expressionObject (readonly)

Returns the value of attribute expression.



871
872
873
# File 'lib/adlint/cc1/syntax.rb', line 871

def expression
  @expression
end

Instance Method Details

#arithmetic?Boolean

Returns:

  • (Boolean)


882
883
884
# File 'lib/adlint/cc1/syntax.rb', line 882

def arithmetic?
  false
end

#bitwise?Boolean

Returns:

  • (Boolean)


886
887
888
# File 'lib/adlint/cc1/syntax.rb', line 886

def bitwise?
  false
end

#have_side_effect?Boolean

Returns:

  • (Boolean)


874
875
876
# File 'lib/adlint/cc1/syntax.rb', line 874

def have_side_effect?
  @expression.have_side_effect? || @array_subscript.have_side_effect?
end

#inspect(indent = 0) ⇒ Object



907
908
909
910
911
# File 'lib/adlint/cc1/syntax.rb', line 907

def inspect(indent = 0)
  " " * indent + "#{short_class_name} (#{location.inspect})\n" +
    @expression.inspect(indent + 1) + "\n" +
    @array_subscript.inspect(indent + 1)
end

#logical?Boolean

Returns:

  • (Boolean)


878
879
880
# File 'lib/adlint/cc1/syntax.rb', line 878

def logical?
  false
end

#to_complemental_logicalObject



899
900
901
# File 'lib/adlint/cc1/syntax.rb', line 899

def to_complemental_logical
  self
end

#to_normalized_logical(parent_expr = nil) ⇒ Object



890
891
892
893
894
895
896
897
# File 'lib/adlint/cc1/syntax.rb', line 890

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



903
904
905
# File 'lib/adlint/cc1/syntax.rb', line 903

def to_s
  "#{@expression.to_s}[#{@array_subscript.to_s}]"
end