Class: AdLint::Cc1::LogicalOrExpression

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) ⇒ LogicalOrExpression

Returns a new instance of LogicalOrExpression.



2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
# File 'lib/adlint/cc1/syntax.rb', line 2006

def initialize(op, lhs_operand, rhs_operand)
  super

  # NOTE: The ISO C99 standard says;
  #
  # 6.5.14 Logical OR operator
  #
  # Semantics
  #
  # 4 Unlike the bitwise | 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
  #   unequal 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)


2033
2034
2035
# File 'lib/adlint/cc1/syntax.rb', line 2033

def arithmetic?
  false
end

#bitwise?Boolean

Returns:

  • (Boolean)


2037
2038
2039
# File 'lib/adlint/cc1/syntax.rb', line 2037

def bitwise?
  false
end

#have_side_effect?Boolean

Returns:

  • (Boolean)


2025
2026
2027
# File 'lib/adlint/cc1/syntax.rb', line 2025

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

#logical?Boolean

Returns:

  • (Boolean)


2029
2030
2031
# File 'lib/adlint/cc1/syntax.rb', line 2029

def logical?
  true
end

#to_complemental_logicalObject



2047
2048
2049
2050
2051
# File 'lib/adlint/cc1/syntax.rb', line 2047

def to_complemental_logical
  LogicalAndExpression.new(Token.new("&&", "&&", @operator.location),
                           @lhs_operand.to_complemental_logical,
                           @rhs_operand.to_complemental_logical)
end

#to_normalized_logical(parent_expr = nil) ⇒ Object



2041
2042
2043
2044
2045
# File 'lib/adlint/cc1/syntax.rb', line 2041

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