Class: AdLint::Cc1::BranchGroup

Inherits:
Object
  • Object
show all
Includes:
BranchGroupOptions, BranchOptions
Defined in:
lib/adlint/cc1/branch.rb

Constant Summary

Constants included from BranchGroupOptions

AdLint::Cc1::BranchGroupOptions::COMPLETE, AdLint::Cc1::BranchGroupOptions::ITERATION

Constants included from BranchOptions

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

#branchesObject (readonly)

Returns the value of attribute branches.



191
192
193
# File 'lib/adlint/cc1/branch.rb', line 191

def branches
  @branches
end

#environmentObject (readonly)

Returns the value of attribute environment.



189
190
191
# File 'lib/adlint/cc1/branch.rb', line 189

def environment
  @environment
end

#trunkObject (readonly)

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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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_variablesObject



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

Returns:

  • (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

Returns:

  • (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_branchObject



259
260
261
# File 'lib/adlint/cc1/branch.rb', line 259

def current_branch
  @branches.last
end

#in_iteration?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


214
215
216
# File 'lib/adlint/cc1/branch.rb', line 214

def iteration?
  @options.include?(ITERATION)
end

#trunk_groupObject



193
194
195
# File 'lib/adlint/cc1/branch.rb', line 193

def trunk_group
  @trunk ? @trunk.group : nil
end