class AdLint::Cc1::ConditionalExpression
Attributes
condition[R]
else_expression[R]
then_expression[R]
Public Class Methods
new(cond, then_expr, else_expr, question_mark)
click to toggle source
Calls superclass method
AdLint::Cc1::Expression::new
# File lib/adlint/cc1/syntax.rb, line 2055 def initialize(cond, then_expr, else_expr, question_mark) super() @condition = cond @then_expression = then_expr @else_expression = else_expr @question_mark = question_mark # NOTE: The ISO C99 standard says; # # 6.5.15 Conditional operator # # Semantics # # 4 The first operand is evaluated; there is a sequence poit after its # evaluation. The second operand is evaluated only if the first # compares unequal to 0; the third operand is evaluated only if the # first compares equal to 0; thre result is the value of the second or # third operand (whichever is evaluated), converted to the type # described below. If an attempt is made to modify the result of a # conditional operator or to access it after the next sequence point, # the behavior is undefined. @condition.append_sequence_point! # NOTE: Add extra sequence points in order not to warn about side-effects # in both the 2nd and 3rd expressions because only one of the 2nd # and 3rd expressions is actually executed. @then_expression.append_sequence_point! @else_expression.append_sequence_point! end
Public Instance Methods
arithmetic?()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2103 def arithmetic? @then_expression.arithmetic? || @else_expression.arithmetic? end
bitwise?()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2107 def bitwise? @then_expression.bitwise? || @else_expression.bitwise? end
have_side_effect?()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2093 def have_side_effect? @condition.have_side_effect? || @then_expression.have_side_effect? || @else_expression.have_side_effect? end
inspect(indent = 0)
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2129 def inspect(indent = 0) " " * indent + "#{short_class_name}\n" + @condition.inspect(indent + 1) + "\n" + @then_expression.inspect(indent + 1) + "\n" + @else_expression.inspect(indent + 1) end
location()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2089 def location @question_mark.location end
logical?()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2099 def logical? @then_expression.logical? || @else_expression.logical? end
to_complemental_logical()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2120 def to_complemental_logical self end
to_normalized_logical(parent_expr = nil)
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2111 def to_normalized_logical(parent_expr = nil) case parent_expr when nil, LogicalAndExpression, LogicalOrExpression create_normalized_logical_of(self) else self end end
to_s()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 2124 def to_s "#{@condition.to_s} ? " + "#{@then_expression.to_s} : #{@else_expression.to_s}" end