srdatalog.ir.hir.types¶
Python mirror of src/srdatalog/hir/hir_types.nim.
These are the high-level IR types that HIR passes (stratification, planning, index selection, lowering) read and write. The Python pipeline must produce HIR that serializes byte-identically to the Nim golden for differential testing.
Keep field names in sync with the Nim side; the canonical emitter (hir_emit.py, TBD) will translate between snake_case Python and the camelCase keys used in json_printer.nim’s output.
Module Contents¶
Classes¶
Access pattern for a single body clause. |
|
The complete HIR program. Mirrors HirProgram. |
|
One delta variant of a rule (mirrors HirRuleVariant). |
|
An SCC + its rule variants. Mirrors HirStratum. |
|
Relation declaration; subset of syntax.nim RelationDecl. |
|
Mirrors Nim hir_types.Version. |
API¶
- class srdatalog.ir.hir.types.AccessPattern[source]¶
Access pattern for a single body clause.
Mirrors hir_types.nim AccessPattern. All fields default-initialized for ease of construction inside passes; the planner fills them in.
- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.hir.types.HirProgram[source]¶
The complete HIR program. Mirrors HirProgram.
- relation_decls: list[srdatalog.ir.hir.types.RelationDecl]¶
‘field(…)’
- strata: list[srdatalog.ir.hir.types.HirStratum]¶
‘field(…)’
- class srdatalog.ir.hir.types.HirRuleVariant[source]¶
One delta variant of a rule (mirrors HirRuleVariant).
Non-recursive rules have delta_idx == -1 and a single base variant. Recursive rules fan out into N variants (one delta per recursive body clause).
- access_patterns: list[srdatalog.ir.hir.types.AccessPattern]¶
‘field(…)’
- clause_versions: list[srdatalog.ir.hir.types.Version]¶
‘field(…)’
- negation_patterns: list[srdatalog.ir.hir.types.AccessPattern]¶
‘field(…)’
- original_rule: srdatalog.dsl.Rule¶
None
- class srdatalog.ir.hir.types.HirStratum[source]¶
An SCC + its rule variants. Mirrors HirStratum.
- base_variants: list[srdatalog.ir.hir.types.HirRuleVariant]¶
‘field(…)’
- recursive_variants: list[srdatalog.ir.hir.types.HirRuleVariant]¶
‘field(…)’
- stratum_rules: list[srdatalog.dsl.Rule]¶
‘field(…)’
- class srdatalog.ir.hir.types.RelationDecl[source]¶
Relation declaration; subset of syntax.nim RelationDecl.
NimNode-typed fields in Nim (relname, types, semiring) are reduced to strings here. Python emitter must reproduce the same repr() the Nim emitter writes.
- class srdatalog.ir.hir.types.Version(*args, **kwds)[source]¶
Bases:
enum.EnumMirrors Nim hir_types.Version.
.valuestays the plain string ("FULL","DELTA","NEW") so the MIR S-expr emitter’s byte-match against Nim continues to work. For C++ codegen the extra properties below surface the forms the backend needs:.method— method-suffix used in C++ helpers (full,delta,newt).number— numeric index Nim’s template backend uses ("0","1","2").code—*_VERmacro the non-template codegen emits into types
Initialization
- DELTA¶
‘DELTA’
- FULL¶
‘FULL’
- NEW¶
‘NEW’