Module: AutoC::Entity

Includes:
Comparable
Included in:
Allocator, BDWAllocator, Code, Composite, Function, Hasher, STD::Primitive
Defined in:
lib/autoc/module.rb

Defined Under Namespace

Classes: DependencySet

Constant Summary collapse

ReferenceSet =
::Set

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



327
# File 'lib/autoc/module.rb', line 327

def <=>(other) = position <=> other.position

#complexityObject

Interface part is not considered as it is shared across the sources



343
# File 'lib/autoc/module.rb', line 343

def complexity = forward_declarations.complexity + implementation.complexity # Interface part is not considered as it is shared across the sources

#dependenciesObject

A set of the entity’s immediate dependencies which enforce the entities relative ordering



306
# File 'lib/autoc/module.rb', line 306

def dependencies = @dependencies ||= DependencySet.new(self)

#forward_declarationsObject



352
353
354
355
356
357
# File 'lib/autoc/module.rb', line 352

def forward_declarations
  @forward_declarations ||= begin
    render_forward_declarations(stream = Module::Builder.new)
    stream
  end
end

#implementationObject



359
360
361
362
363
364
# File 'lib/autoc/module.rb', line 359

def implementation
  @implementation ||= begin
    render_implementation(stream = Module::Builder.new)
    stream
  end
end

#interfaceObject



345
346
347
348
349
350
# File 'lib/autoc/module.rb', line 345

def interface
  @interface ||= begin
    render_interface(stream = Module::Builder.new)
    stream
  end
end

#positionObject

Compute the entity’s relative position with respect to its dependencies



330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/autoc/module.rb', line 330

def position = @position ||= begin
  p = 0
  # This code goes into infinite recursion on circular dependency
  # which must be resolved manually with Entity#references
  total_dependencies.each do |d|
    unless equal?(d)
      dp = d.position
      p = dp if p < dp # p <- max(p, dp)
    end
  end
  p + 1 # Arrange entity to follow all its dependencies
end

#referencesObject

A set of the entity’s immediate references which, unlike dependencies, do not enforce the entities relative ordering



300
# File 'lib/autoc/module.rb', line 300

def references = @references ||= ReferenceSet.new

#total_dependenciesObject

Return the entire entity’s dependency set staring with self



309
# File 'lib/autoc/module.rb', line 309

def total_dependencies = @total_dependencies ||= collect_dependencies(::Set.new)

#total_referencesObject

Return the entire entity’s reference set staring with self



303
# File 'lib/autoc/module.rb', line 303

def total_references = @total_references ||= collect_references(::Set.new)