Class: AdLint::Cc1::BranchGroup
Constant Summary
AdLint::Cc1::BranchGroupOptions::COMPLETE, AdLint::Cc1::BranchGroupOptions::ITERATION
AdLint::Cc1::BranchOptions::COMPLEMENTAL, AdLint::Cc1::BranchOptions::FINAL, AdLint::Cc1::BranchOptions::FIRST, AdLint::Cc1::BranchOptions::IMPLICIT_COND, AdLint::Cc1::BranchOptions::NARROWING, AdLint::Cc1::BranchOptions::SMOTHER_BREAK, AdLint::Cc1::BranchOptions::WIDENING
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(env, trunk, *opts) ⇒ BranchGroup
Returns a new instance of BranchGroup.
182
183
184
185
186
187
|
# File 'lib/adlint/cc1/branch.rb', line 182
def initialize(env, trunk, *opts)
@environment = env
@trunk = trunk
@options = opts
@branches = []
end
|
Instance Attribute Details
Returns the value of attribute branches.
191
192
193
|
# File 'lib/adlint/cc1/branch.rb', line 191
def branches
@branches
end
|
#environment ⇒ Object
Returns the value of attribute environment.
189
190
191
|
# File 'lib/adlint/cc1/branch.rb', line 189
def environment
@environment
end
|
Returns the value of attribute trunk.
190
191
192
|
# File 'lib/adlint/cc1/branch.rb', line 190
def trunk
@trunk
end
|
Instance Method Details
#add_options(*new_opts) ⇒ Object
206
207
208
|
# File 'lib/adlint/cc1/branch.rb', line 206
def add_options(*new_opts)
@options = (@options + new_opts).uniq
end
|
#all_branches_break_with_break? ⇒ Boolean
247
248
249
|
# File 'lib/adlint/cc1/branch.rb', line 247
def all_branches_break_with_break?
@branches.all? { |br| br.break_with_break? }
end
|
#all_branches_break_with_continue? ⇒ Boolean
251
252
253
|
# File 'lib/adlint/cc1/branch.rb', line 251
def all_branches_break_with_continue?
@branches.all? { |br| br.break_with_continue? }
end
|
#all_branches_break_with_return? ⇒ Boolean
255
256
257
|
# File 'lib/adlint/cc1/branch.rb', line 255
def all_branches_break_with_return?
@branches.all? { |br| br.break_with_return? }
end
|
#all_controlling_variables ⇒ Object
237
238
239
240
241
|
# File 'lib/adlint/cc1/branch.rb', line 237
def all_controlling_variables
@branches.map { |br|
ctrlexpr = br.ctrlexpr and ctrlexpr.affected_variables
}.compact.flatten.uniq
end
|
#all_controlling_variables_value_exist? ⇒ Boolean
243
244
245
|
# File 'lib/adlint/cc1/branch.rb', line 243
def all_controlling_variables_value_exist?
all_controlling_variables.all? { |var| var.value.exist? }
end
|
#branches_to_trunk(acc = []) ⇒ Object
197
198
199
200
201
202
203
204
|
# File 'lib/adlint/cc1/branch.rb', line 197
def branches_to_trunk(acc = [])
if @trunk
acc.push(@trunk)
@trunk.group.branches_to_trunk(acc)
else
acc
end
end
|
#complete? ⇒ Boolean
210
211
212
|
# File 'lib/adlint/cc1/branch.rb', line 210
def complete?
@options.include?(COMPLETE)
end
|
#create_first_branch(*opts) ⇒ Object
227
228
229
230
|
# File 'lib/adlint/cc1/branch.rb', line 227
def create_first_branch(*opts)
@branches.push(new_branch = Branch.new(self, FIRST, *opts))
new_branch
end
|
#create_trailing_branch(*opts) ⇒ Object
232
233
234
235
|
# File 'lib/adlint/cc1/branch.rb', line 232
def create_trailing_branch(*opts)
@branches.push(new_branch = Branch.new(self, *opts))
new_branch
end
|
#current_branch ⇒ Object
259
260
261
|
# File 'lib/adlint/cc1/branch.rb', line 259
def current_branch
@branches.last
end
|
#in_iteration? ⇒ Boolean
218
219
220
221
222
223
224
225
|
# File 'lib/adlint/cc1/branch.rb', line 218
def in_iteration?
branch_group = trunk_group
while branch_group
return true if branch_group.iteration?
branch_group = branch_group.trunk_group
end
false
end
|
#iteration? ⇒ Boolean
214
215
216
|
# File 'lib/adlint/cc1/branch.rb', line 214
def iteration?
@options.include?(ITERATION)
end
|
#trunk_group ⇒ Object
193
194
195
|
# File 'lib/adlint/cc1/branch.rb', line 193
def trunk_group
@trunk ? @trunk.group : nil
end
|