irx.builder.base

irx.builder.base

Source: packages/irx/src/irx/builder/base.py

title: Base builder abstractions and command helpers.

Functions

run_command(command: Sequence[str], *, capture_stderr: bool=True, raise_on_error: bool=True, debug: bool=False) -> CommandResult

title: Run a shell command and return a structured CommandResult.
parameters:
  command:
    type: Sequence[str]
  capture_stderr:
    type: bool
    default: true
  raise_on_error:
    type: bool
    default: true
  debug:
    type: bool
    default: false
returns:
  type: CommandResult
raises:
  CommandError: When the command exits non-zero and raise_on_error=True.

Classes

CommandResult

title: Structured result from a shell command.
attributes:
  stdout:
    type: str
  stderr:
    type: str
  returncode:
    type: int
  command:
    type: Sequence[str]

Methods

success(self) -> bool
title: Return True if the command exited with code 0.
returns:
  type: bool

CommandError(RuntimeError)

title: Raised when a shell command exits with a non-zero status.
attributes:
  result:
    type: CommandResult

BuilderVisitor(BaseVisitor)

title: Builder translator visitor built on the shared visitor base.

Methods

visit(self, node: astx.AST) -> None
title: Visit AST nodes.
parameters:
  node:
    type: astx.AST
visit_child(self, node: astx.AST) -> None
title: Forward a child AST node through the public visit dispatcher.
parameters:
  node:
    type: astx.AST
translate(self, expr: astx.AST) -> str
title: Translate an ASTx expression to string.
parameters:
  expr:
    type: astx.AST
returns:
  type: str
examples: |-
  self.visit(expr)
  return str(self.result)

Builder(ABC)

title: ASTx Builder.
attributes:
  translator:
    type: BuilderVisitor
  tmp_path:
    type: str
  output_file:
    type: str
  sh_args:
    type: dict[str, Any]
  runtime_feature_names:
    type: set[str]

Methods

module(self) -> astx.Module
title: Create a new ASTx Module.
returns:
  type: astx.Module
translate(self, expr: astx.AST) -> str
title: Transpile ASTx to LLVM-IR.
parameters:
  expr:
    type: astx.AST
returns:
  type: str
activate_runtime_feature(self, feature_name: str) -> None
title: Activate a native runtime feature for this compilation unit.
parameters:
  feature_name:
    type: str
build(self, expr: astx.AST, output_file: str) -> None
title: Transpile ASTx to LLVM-IR and build an executable file.
parameters:
  expr:
    type: astx.AST
  output_file:
    type: str
run(self, *, capture_stderr: bool=True, raise_on_error: bool=True, debug: bool=False) -> CommandResult
title: Run the generated executable.
parameters:
  capture_stderr:
    type: bool
    default: true
  raise_on_error:
    type: bool
    default: true
  debug:
    type: bool
    default: false
returns:
  type: CommandResult