Class: AdLint::Cc1::LogicalAndExpression

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

Instance Attribute Summary

Attributes inherited from BinaryExpression

#lhs_operand, #operator, #rhs_operand

Attributes inherited from SyntaxNode

#head_token, #subsequent_sequence_point, #tail_token

Instance Method Summary collapse

Methods inherited from BinaryExpression

#inspect, #location, #to_s

Methods inherited from Expression

#constant?, #full=, #object_specifiers, #to_s

Methods inherited from SyntaxNode

#head_location, #inspect, #location, #short_class_name, #tail_location

Methods included from LocationHolder

#analysis_target?

Methods included from Visitable

#accept

Constructor Details

#initialize(op, lhs_operand, rhs_operand) ⇒ LogicalAndExpression

Returns a new instance of LogicalAndExpression.



1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
# File 'lib/adlint/cc1/syntax.rb', line 1957

def initialize(op, lhs_operand, rhs_operand)
  super

  # NOTE: The ISO C99 standard says;
  #
  # 6.5.13 Logical AND operator
  #
  # Semantics
  #
  # 4 Unlike the bitwise binary & operator, the && operator guarantees
  #   left-to-right evaluation; there is a sequence point after the
  #   evaluation of the first operand.  If the first operand compares equal
  #   to 0, the second operand is not evaluated.
  #
  # NOTE: Sequence point will be reached after lhs value reference.
  #       So, notification should be done by ExpressionEvaluator manually.
  # @lhs_operand.append_sequence_point!
end

Instance Method Details

#arithmetic?Boolean

Returns:

  • (Boolean)


1984
1985
1986
# File 'lib/adlint/cc1/syntax.rb', line 1984

def arithmetic?
  false
end

#bitwise?Boolean

Returns:

  • (Boolean)


1988
1989
1990
# File 'lib/adlint/cc1/syntax.rb', line 1988

def bitwise?
  false
end

#have_side_effect?Boolean

Returns:

  • (Boolean)


1976
1977
1978
# File 'lib/adlint/cc1/syntax.rb', line 1976

def have_side_effect?
  lhs_operand.have_side_effect? || rhs_operand.have_side_effect?
end

#logical?Boolean

Returns:

  • (Boolean)


1980
1981
1982
# File 'lib/adlint/cc1/syntax.rb', line 1980

def logical?
  true
end

#to_complemental_logicalObject



1998
1999
2000
2001
2002
# File 'lib/adlint/cc1/syntax.rb', line 1998

def to_complemental_logical
  LogicalOrExpression.new(Token.new("||", "||", @operator.location),
                          @lhs_operand.to_complemental_logical,
                          @rhs_operand.to_complemental_logical)
end

#to_normalized_logical(parent_expr = nil) ⇒ Object



1992
1993
1994
1995
1996
# File 'lib/adlint/cc1/syntax.rb', line 1992

def to_normalized_logical(parent_expr = nil)
  LogicalAndExpression.new(@operator,
                           @lhs_operand.to_normalized_logical(self),
                           @rhs_operand.to_normalized_logical(self))
end