Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ fn v4_std_model_core_declares_ratified_q1_carriers() {
for name in [
"ModelCore",
"PrimitiveFactBundle",
"PrimitiveFactAxisBinding",
"AlgebraInhabitanceDecl",
"AlgebraLawObligation",
"EffectSemanticsDecl",
Expand Down Expand Up @@ -221,25 +220,9 @@ fn v4_std_model_core_primitive_fact_bundle_uses_axis_keyed_spec_facts() {
bundle_fields,
vec![
("substrate_carrier".to_string(), "Node".to_string()),
(
"spec_facts".to_string(),
"List<PrimitiveFactAxisBinding>".to_string(),
),
("spec_facts".to_string(), "Map<Symbol, Node>".to_string()),
],
"PrimitiveFactBundle.spec_facts must be a structured axis-keyed bundle, not an opaque Node"
);
let axis_fields: Vec<(String, String)> =
type_record_fields(&module, "PrimitiveFactAxisBinding")
.iter()
.map(|f| (f.name.clone(), surface_type_name(&f.ty)))
.collect();
assert_eq!(
axis_fields,
vec![
("axis".to_string(), "Symbol".to_string()),
("fact".to_string(), "Node".to_string()),
],
"PrimitiveFactAxisBinding pairs a declared axis Symbol with a substrate fact Node"
"PrimitiveFactBundle.spec_facts must be a Map keyed by axis Symbol so duplicate axis bindings are structurally unrepresentable"
);
for axis in [
"primitive_fact_axis_width",
Expand All @@ -251,7 +234,7 @@ fn v4_std_model_core_primitive_fact_bundle_uses_axis_keyed_spec_facts() {
] {
assert!(
surface_declares_data(&module, axis, "Symbol"),
"declared axis Symbol `{axis}` is the canonical key for PrimitiveFactAxisBinding.axis"
"declared axis Symbol `{axis}` is the canonical key for PrimitiveFactBundle.spec_facts"
);
}
}
Expand Down
150 changes: 96 additions & 54 deletions src/v4/extdeps/languages/cpp.dag
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ module v4.extdeps.languages.cpp

import v4.std.logic { Bool, bool_boolean_algebra }
import v4.std.algebra { BooleanAlgebra, free_monoid_fold }
import v4.std.collection { List, Set, list_append, list_snoc_item }
import v4.std.collection { List, Map, Set, list_append, list_snoc_item }
import v4.std.model_core {
EffectSemanticsDecl,
ModelCore,
PartialitySemanticsDecl,
PrimitiveFactAxisBinding,
PrimitiveFactBundle,
primitive_fact_axis_encoding,
primitive_fact_axis_overflow_disposition,
Expand Down Expand Up @@ -535,35 +534,90 @@ fn cpp_language_model_canonical_symbols(target_profile: Node) -> Set<Symbol> {
}
}

fn cpp_primitive_axis_binding(axis: Symbol, fact: Node) -> PrimitiveFactAxisBinding {
PrimitiveFactAxisBinding { axis: axis, fact: fact }
fn cpp_primitive_fact_map_5(
axis0: Symbol,
fact0: Node,
axis1: Symbol,
fact1: Node,
axis2: Symbol,
fact2: Node,
axis3: Symbol,
fact3: Node,
axis4: Symbol,
fact4: Node,
) -> Map<Symbol, Node> {
map_insert(
map_insert(
map_insert(
map_insert(
map_insert(empty_map(), axis0, fact0),
axis1,
fact1
),
axis2,
fact2
),
axis3,
fact3
),
axis4,
fact4
)
}

fn cpp_primitive_fact_map_4(
axis0: Symbol,
fact0: Node,
axis1: Symbol,
fact1: Node,
axis2: Symbol,
fact2: Node,
axis3: Symbol,
fact3: Node,
) -> Map<Symbol, Node> {
map_insert(
map_insert(
map_insert(
map_insert(empty_map(), axis0, fact0),
axis1,
fact1
),
axis2,
fact2
),
axis3,
fact3
)
}

fn cpp_primitive_fact_map_2(
axis0: Symbol,
fact0: Node,
axis1: Symbol,
fact1: Node,
) -> Map<Symbol, Node> {
map_insert(
map_insert(empty_map(), axis0, fact0),
axis1,
fact1
)
}

fn cpp_primitive_bundle_from_integer_facts(facts: CppIntegerPrimitiveFacts) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: cpp_integer_facts_node(facts: facts),
spec_facts: [
cpp_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: cpp_atom(id: facts.surface_spelling)
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_width,
fact: facts.width_fact
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_signedness,
fact: facts.signedness_fact
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: facts.encoding_fact
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_overflow_disposition,
fact: facts.overflow_fact
)
]
spec_facts: cpp_primitive_fact_map_5(
axis0: primitive_fact_axis_surface_spelling,
fact0: cpp_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_width,
fact1: facts.width_fact,
axis2: primitive_fact_axis_signedness,
fact2: facts.signedness_fact,
axis3: primitive_fact_axis_encoding,
fact3: facts.encoding_fact,
axis4: primitive_fact_axis_overflow_disposition,
fact4: facts.overflow_fact
)
}
}

Expand All @@ -572,40 +626,28 @@ fn cpp_primitive_bundle_from_character_facts(
) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: cpp_character_facts_node(facts: facts),
spec_facts: [
cpp_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: cpp_atom(id: facts.surface_spelling)
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_width,
fact: facts.width_fact
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_signedness,
fact: facts.signedness_fact
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: facts.encoding_fact
)
]
spec_facts: cpp_primitive_fact_map_4(
axis0: primitive_fact_axis_surface_spelling,
fact0: cpp_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_width,
fact1: facts.width_fact,
axis2: primitive_fact_axis_signedness,
fact2: facts.signedness_fact,
axis3: primitive_fact_axis_encoding,
fact3: facts.encoding_fact
)
}
}

fn cpp_primitive_bundle_from_bool_facts(facts: CppBoolPrimitiveFacts) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: cpp_bool_facts_node(facts: facts),
spec_facts: [
cpp_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: cpp_atom(id: facts.surface_spelling)
),
cpp_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: facts.encoding_fact
)
]
spec_facts: cpp_primitive_fact_map_2(
axis0: primitive_fact_axis_surface_spelling,
fact0: cpp_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_encoding,
fact1: facts.encoding_fact
)
}
}

Expand Down
96 changes: 42 additions & 54 deletions src/v4/extdeps/languages/python.dag
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

module v4.extdeps.languages.python

import v4.std.collection { List }
import v4.std.collection { List, Map }
import v4.std.model_core {
EffectSemanticsDecl,
ModelCore,
PartialitySemanticsDecl,
PrimitiveFactAxisBinding,
PrimitiveFactBundle,
primitive_fact_axis_encoding,
primitive_fact_axis_surface_spelling
Expand Down Expand Up @@ -309,8 +308,17 @@ fn python_singleton_facts_node(facts: PythonSingletonPrimitiveFacts) -> Node {
}
}

fn python_primitive_axis_binding(axis: Symbol, fact: Node) -> PrimitiveFactAxisBinding {
PrimitiveFactAxisBinding { axis: axis, fact: fact }
fn python_primitive_fact_map_2(
axis0: Symbol,
fact0: Node,
axis1: Symbol,
fact1: Node,
) -> Map<Symbol, Node> {
map_insert(
map_insert(empty_map(), axis0, fact0),
axis1,
fact1
)
}

// C-PYINT: only surface_spelling + encoding axes bind — width/signedness/overflow are
Expand All @@ -320,16 +328,12 @@ fn python_primitive_bundle_from_integer_facts(
) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: python_integer_facts_node(facts: facts),
spec_facts: [
python_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: python_inhabitant_atom(id: facts.surface_spelling)
),
python_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: python_inhabitant_atom(id: facts.encoding)
)
]
spec_facts: python_primitive_fact_map_2(
axis0: primitive_fact_axis_surface_spelling,
fact0: python_inhabitant_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_encoding,
fact1: python_inhabitant_atom(id: facts.encoding)
)
}
}

Expand All @@ -338,16 +342,12 @@ fn python_primitive_bundle_from_float_facts(
) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: python_float_facts_node(facts: facts),
spec_facts: [
python_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: python_inhabitant_atom(id: facts.surface_spelling)
),
python_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: python_inhabitant_atom(id: facts.machine_representation)
)
]
spec_facts: python_primitive_fact_map_2(
axis0: primitive_fact_axis_surface_spelling,
fact0: python_inhabitant_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_encoding,
fact1: python_inhabitant_atom(id: facts.machine_representation)
)
}
}

Expand All @@ -356,16 +356,12 @@ fn python_primitive_bundle_from_complex_facts(
) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: python_complex_facts_node(facts: facts),
spec_facts: [
python_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: python_inhabitant_atom(id: facts.surface_spelling)
),
python_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: python_inhabitant_atom(id: facts.component_machine_representation)
)
]
spec_facts: python_primitive_fact_map_2(
axis0: primitive_fact_axis_surface_spelling,
fact0: python_inhabitant_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_encoding,
fact1: python_inhabitant_atom(id: facts.component_machine_representation)
)
}
}

Expand All @@ -377,16 +373,12 @@ fn python_primitive_bundle_from_bool_facts(
) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: python_bool_facts_node(facts: facts),
spec_facts: [
python_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: python_inhabitant_atom(id: facts.surface_spelling)
),
python_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: python_inhabitant_atom(id: facts.encoding)
)
]
spec_facts: python_primitive_fact_map_2(
axis0: primitive_fact_axis_surface_spelling,
fact0: python_inhabitant_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_encoding,
fact1: python_inhabitant_atom(id: facts.encoding)
)
}
}

Expand All @@ -395,16 +387,12 @@ fn python_primitive_bundle_from_singleton_facts(
) -> PrimitiveFactBundle {
PrimitiveFactBundle {
substrate_carrier: python_singleton_facts_node(facts: facts),
spec_facts: [
python_primitive_axis_binding(
axis: primitive_fact_axis_surface_spelling,
fact: python_inhabitant_atom(id: facts.surface_spelling)
),
python_primitive_axis_binding(
axis: primitive_fact_axis_encoding,
fact: python_inhabitant_atom(id: python_repr_singleton_sole_inhabitant)
)
]
spec_facts: python_primitive_fact_map_2(
axis0: primitive_fact_axis_surface_spelling,
fact0: python_inhabitant_atom(id: facts.surface_spelling),
axis1: primitive_fact_axis_encoding,
fact1: python_inhabitant_atom(id: python_repr_singleton_sole_inhabitant)
)
}
}

Expand Down
Loading
Loading