Class: AdLint::Cc1::ConditionalExpression
Instance Attribute Summary collapse
Attributes inherited from SyntaxNode
#head_token, #subsequent_sequence_point, #tail_token
Instance Method Summary
collapse
Methods inherited from Expression
#constant?, #full=, #object_specifiers
Methods inherited from SyntaxNode
#head_location, #short_class_name, #tail_location
#analysis_target?
Methods included from Visitable
#accept
Constructor Details
#initialize(cond, then_expr, else_expr, question_mark) ⇒ ConditionalExpression
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
|
# 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
@condition.append_sequence_point!
@then_expression.append_sequence_point!
@else_expression.append_sequence_point!
end
|
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
2085
2086
2087
|
# File 'lib/adlint/cc1/syntax.rb', line 2085
def condition
@condition
end
|
#else_expression ⇒ Object
Returns the value of attribute else_expression.
2087
2088
2089
|
# File 'lib/adlint/cc1/syntax.rb', line 2087
def else_expression
@else_expression
end
|
#then_expression ⇒ Object
Returns the value of attribute then_expression.
2086
2087
2088
|
# File 'lib/adlint/cc1/syntax.rb', line 2086
def then_expression
@then_expression
end
|
Instance Method Details
#arithmetic? ⇒ Boolean
2103
2104
2105
|
# File 'lib/adlint/cc1/syntax.rb', line 2103
def arithmetic?
@then_expression.arithmetic? || @else_expression.arithmetic?
end
|
#bitwise? ⇒ Boolean
2107
2108
2109
|
# File 'lib/adlint/cc1/syntax.rb', line 2107
def bitwise?
@then_expression.bitwise? || @else_expression.bitwise?
end
|
#have_side_effect? ⇒ Boolean
2093
2094
2095
2096
2097
|
# 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) ⇒ Object
2129
2130
2131
2132
2133
2134
|
# 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
|
2089
2090
2091
|
# File 'lib/adlint/cc1/syntax.rb', line 2089
def location
@question_mark.location
end
|
#logical? ⇒ Boolean
2099
2100
2101
|
# File 'lib/adlint/cc1/syntax.rb', line 2099
def logical?
@then_expression.logical? || @else_expression.logical?
end
|
#to_complemental_logical ⇒ Object
2120
2121
2122
|
# File 'lib/adlint/cc1/syntax.rb', line 2120
def to_complemental_logical
self
end
|
#to_normalized_logical(parent_expr = nil) ⇒ Object
2111
2112
2113
2114
2115
2116
2117
2118
|
# 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
|
2124
2125
2126
2127
|
# File 'lib/adlint/cc1/syntax.rb', line 2124
def to_s
"#{@condition.to_s} ? " +
"#{@then_expression.to_s} : #{@else_expression.to_s}"
end
|