Class: AdLint::Cc1::OuterVariable

Inherits:
ScopedVariable show all
Defined in:
lib/adlint/cc1/object.rb

Direct Known Subclasses

InnerVariable, NamedVariable, TemporaryVariable

Instance Attribute Summary collapse

Attributes inherited from ScopedVariable

#scope

Attributes inherited from TypedObject

#type

Attributes inherited from Object

#declarations_and_definitions

Attributes included from Bindable

#binding

Instance Method Summary collapse

Methods inherited from ScopedVariable

#declared_as_auto?, #declared_as_extern?

Methods inherited from Variable

#function?, #name, #named?, #narrow_value_domain!, #outer?, #uninitialize!, #value, #variable?, #widen_value_domain!

Methods inherited from TypedObject

#to_pointer, #to_pointer_value, #to_value, #to_variable

Methods inherited from Object

#declared_as_auto?, #declared_as_extern?, #declared_as_register?, #declared_as_static?, #designated_by_lvalue?, #function?, #named?, #storage_class_specifiers, #temporary?, #variable?

Methods included from Bindable

#be_alias_to, #bind_to

Constructor Details

#initialize(mem, dcl_or_def, type, scope) ⇒ OuterVariable

Returns a new instance of OuterVariable.



337
338
339
340
341
342
# File 'lib/adlint/cc1/object.rb', line 337

def initialize(mem, dcl_or_def, type, scope)
  super(mem, dcl_or_def, type, scope)
  # TODO: If too slow, make an index of inner variables.
  @inner_variables = create_inner_variables(type.unqualify, scope)
  @representative_element = create_representative_element(type.unqualify)
end

Instance Attribute Details

#representative_elementObject (readonly)

Returns the value of attribute representative_element.



344
345
346
# File 'lib/adlint/cc1/object.rb', line 344

def representative_element
  @representative_element
end

Instance Method Details

#assign!(val, src = nil, br = nil) ⇒ Object



346
347
348
349
350
351
352
353
354
355
356
# File 'lib/adlint/cc1/object.rb', line 346

def assign!(val, src = nil, br = nil)
  super
  if @representative_element
    if val.undefined?
      repr_val = @representative_element.type.undefined_value
    else
      repr_val = @representative_element.type.arbitrary_value
    end
    @representative_element.assign!(repr_val, src, br)
  end
end

#begin_value_versioningObject



382
383
384
385
386
387
388
389
390
391
392
# File 'lib/adlint/cc1/object.rb', line 382

def begin_value_versioning
  if @inner_variables
    @inner_variables.each do |inner|
      inner.begin_value_versioning
    end
  end
  super
  if @representative_element
    @representative_element.begin_value_versioning
  end
end

#end_value_versioningObject



394
395
396
397
398
399
400
401
402
403
404
# File 'lib/adlint/cc1/object.rb', line 394

def end_value_versioning
  if @inner_variables
    @inner_variables.each do |inner|
      inner.end_value_versioning
    end
  end
  super
  if @representative_element
    @representative_element.end_value_versioning
  end
end

#enter_value_versioning_groupObject



358
359
360
361
362
363
364
365
366
367
368
# File 'lib/adlint/cc1/object.rb', line 358

def enter_value_versioning_group
  if @inner_variables
    @inner_variables.each do |inner|
      inner.enter_value_versioning_group
    end
  end
  super
  if @representative_element
    @representative_element.enter_value_versioning_group
  end
end

#inner?Boolean

Returns:

  • (Boolean)


430
431
432
# File 'lib/adlint/cc1/object.rb', line 430

def inner?
  false
end

#inner_variable_at(idx) ⇒ Object



434
435
436
437
438
439
440
441
442
443
# File 'lib/adlint/cc1/object.rb', line 434

def inner_variable_at(idx)
  if @type.array?
    # TODO: If linear searching is too slow, use an index of inner
    #       variables.
    target_name = ArrayElementVariable.component_name_of(idx)
    @inner_variables.find { |inner| inner.component_name == target_name }
  else
    nil
  end
end

#inner_variable_named(name) ⇒ Object



445
446
447
448
449
450
451
452
453
454
# File 'lib/adlint/cc1/object.rb', line 445

def inner_variable_named(name)
  if @type.composite?
    # TODO: If linear searching is too slow, use an index of inner
    #       variables.
    target_name = CompositeMemberVariable.component_name_of(name)
    @inner_variables.find { |inner| inner.component_name == target_name }
  else
    nil
  end
end

#leave_value_versioning_group(raise_complement) ⇒ Object



370
371
372
373
374
375
376
377
378
379
380
# File 'lib/adlint/cc1/object.rb', line 370

def leave_value_versioning_group(raise_complement)
  if @inner_variables
    @inner_variables.each do |inner|
      inner.leave_value_versioning_group(raise_complement)
    end
  end
  super
  if @representative_element
    @representative_element.leave_value_versioning_group(raise_complement)
  end
end

#rollback_all_value_versions!Object



418
419
420
421
422
423
424
425
426
427
428
# File 'lib/adlint/cc1/object.rb', line 418

def rollback_all_value_versions!
  if @inner_variables
    @inner_variables.each do |inner|
      inner.rollback_all_value_versions!
    end
  end
  super
  if @representative_element
    @representative_element.rollback_all_value_versions!
  end
end

#thin_latest_value_version!(with_rollback) ⇒ Object



406
407
408
409
410
411
412
413
414
415
416
# File 'lib/adlint/cc1/object.rb', line 406

def thin_latest_value_version!(with_rollback)
  if @inner_variables
    @inner_variables.each do |inner|
      inner.thin_latest_value_version!(with_rollback)
    end
  end
  super
  if @representative_element
    @representative_element.thin_latest_value_version!(with_rollback)
  end
end