PtcRunner.Context (PtcRunner v0.2.0)

View Source

Manages variable bindings for program execution.

Stores context variables and provides lookup functionality.

Summary

Types

t()

Context structure containing variables and tool registry.

Functions

Retrieves a variable from context.

Creates a new context with variables and tools.

Sets a variable in context.

Types

t()

@type t() :: %PtcRunner.Context{tools: map(), variables: map()}

Context structure containing variables and tool registry.

Functions

get_var(context, name)

@spec get_var(t(), String.t()) :: {:ok, any()} | {:error, {atom(), String.t()}}

Retrieves a variable from context.

Returns nil if variable doesn't exist, per architecture.md specifications.

Arguments

  • context: The context
  • name: Variable name to retrieve

Returns

  • {:ok, value} if variable exists
  • {:ok, nil} if variable doesn't exist

new(variables \\ %{}, tools \\ %{})

@spec new(map(), map()) :: t()

Creates a new context with variables and tools.

Arguments

  • variables: Map of variable names to values
  • tools: Map of tool names to functions (reserved for Phase 4)

Returns

  • New Context struct

put_var(context, name, value)

@spec put_var(t(), String.t(), any()) :: t()

Sets a variable in context.

Arguments

  • context: The context
  • name: Variable name
  • value: Value to set

Returns

  • Updated context