ProgramFacts.Model.Builder (program_facts v0.2.1)

Copy Markdown View Source

Builder API for constructing ProgramFacts.Model values.

The builder is useful for custom generators and tests that want to describe a semantic program model first, then materialize source and facts through ProgramFacts.Model.to_program/1.

Summary

Functions

Adds a branch fact.

Adds a directed function call edge.

Adds a declared call path.

Adds a data-flow fact.

Adds an effect fact.

Adds one feature atom.

Adds multiple feature atoms.

Adds a source file to the model.

Adds a function id and its module to the model.

Adds a module to the model.

Starts a model builder.

Replaces architecture facts.

Merges metadata into the model metadata.

Types

t()

@type t() :: %ProgramFacts.Model.Builder{
  architecture: map(),
  branches: [map()],
  call_edges: MapSet.t(ProgramFacts.Facts.call_edge()),
  call_paths: [[ProgramFacts.Facts.function_id()]],
  data_flows: [map()],
  effects: MapSet.t(ProgramFacts.Facts.effect()),
  features: MapSet.t(atom()),
  files: [ProgramFacts.File.t()],
  functions: MapSet.t(ProgramFacts.Facts.function_id()),
  id: String.t(),
  metadata: map(),
  modules: MapSet.t(module()),
  policy: atom(),
  seed: integer()
}

Functions

add_branch(builder, branch)

Adds a branch fact.

add_call(builder, source, target)

Adds a directed function call edge.

Source and target functions are added automatically.

add_call_path(builder, path)

Adds a declared call path.

Functions and pairwise call edges in the path are added automatically.

add_data_flow(builder, data_flow)

Adds a data-flow fact.

add_effect(builder, fact)

Adds an effect fact.

add_effect(builder, function, effect)

Adds an effect fact.

add_feature(builder, feature)

Adds one feature atom.

add_features(builder, features)

Adds multiple feature atoms.

add_file(builder, file)

Adds a source file to the model.

add_function(builder, mfa)

Adds a function id and its module to the model.

add_module(builder, module)

Adds a module to the model.

build(builder)

Builds a ProgramFacts.Model.

new(opts)

Starts a model builder.

Requires :id, :seed, and :policy.

put_architecture(builder, architecture)

Replaces architecture facts.

put_metadata(builder, metadata)

Merges metadata into the model metadata.