From 77836a5554639096822263a7deed6dc85395cd4c Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 20:29:53 +0000 Subject: [PATCH 01/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- dsl/std/effects.dag | 3 +-- dsl/std/realization_schedule.dag | 14 +------------- dsl/std/types.dag | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/dsl/std/effects.dag b/dsl/std/effects.dag index e89bf26efb8..a0af8fd4712 100644 --- a/dsl/std/effects.dag +++ b/dsl/std/effects.dag @@ -38,8 +38,7 @@ module std.effects -import std.types { HttpMethod, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, String, List } -import std.realization_schedule { string_list_eq } +import std.types { HttpMethod, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, String, List, string_list_eq } import std.http_path { PathTemplate, PathTemplateParseResult, ParsedPathTemplate, MalformedPathTemplate, diff --git a/dsl/std/realization_schedule.dag b/dsl/std/realization_schedule.dag index 749d6ea35ad..58e2f4ccd60 100644 --- a/dsl/std/realization_schedule.dag +++ b/dsl/std/realization_schedule.dag @@ -7,7 +7,7 @@ module std.realization_schedule -import std.types { ContentHash, Bool, String, List, Int } +import std.types { ContentHash, Bool, String, List, Int, string_list_eq } import std.nat { Nat } import std.measure { Measure, Time, ByteSize, Watt, @@ -195,18 +195,6 @@ fn schedule_witness_entry_eq(a: ScheduleWitnessEntry, b: ScheduleWitnessEntry) - (a.entry == b.entry) && (a.function == b.function) } -fn string_list_eq(left: List, right: List) -> Bool { - if left.length() != right.length() { - false - } else if left.length() == 0 { - true - } else if left.first() != right.first() { - false - } else { - string_list_eq(left: left.skip(n: 1), right: right.skip(n: 1)) - } -} - fn schedule_witness_entry_list_eq(left: List, right: List) -> Bool { if left.length() != right.length() { false diff --git a/dsl/std/types.dag b/dsl/std/types.dag index c4a94837009..065158d51f2 100644 --- a/dsl/std/types.dag +++ b/dsl/std/types.dag @@ -177,6 +177,27 @@ fn canonical_container_names() -> List { ["BooleanAlgebra", "FreeMonoid", "List", "Map", "PartialFunction", "Set", "Witness"] } +// Element-wise structural equality of two string lists. Generic-free +// bootstrap helper -- the concrete String specialization (no element-Eq +// inhabitance / phantom generics), so the v1 seed renders it directly. +// Relocated here from std.realization_schedule (DESIGN.md §3: a plain +// List equality does not belong in a MEASURED/peripheral +// realization module); std.realization_schedule and std.effects now both +// consume it from std.types. Uses `.count()` (the templated list-length, +// renders to `.len() as i64`) -- NOT `.length()`, which the v1 emitter has +// no runtime bridge for. +fn string_list_eq(left: List, right: List) -> Bool { + if left.count() != right.count() { + false + } else if left.count() == 0 { + true + } else if left.first() != right.first() { + false + } else { + string_list_eq(left: left.skip(n: 1), right: right.skip(n: 1)) + } +} + // Bool: two-valued coproduct. Structurally: Disj + 2 unit variants. // Target: Bool = BooleanAlgebra over {True, False}. // Note: std.logic.Classical and std.bit.Bit carry the same structural From b20bb89cc6c773c09a89e33e0cf2019795c10946 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 20:41:48 +0000 Subject: [PATCH 02/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- src/v1/stage0/src/bin/regen_stage0.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index c9ec215fefe..512c4bb65b5 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -51,14 +51,7 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "std_http_path.rs", "std_induction.rs", "std_iteration.rs", - "std_lens_verdict.rs", - "std_logic.rs", - "std_magnitude.rs", - "std_measure.rs", - "std_nat.rs", "std_node.rs", - "std_pareto.rs", - "std_realization_schedule.rs", "std_syntax.rs", "std_termination.rs", "std_types.rs", From dd46d49104df83fa6bea2e370fce4663a6530e7f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 21:11:36 +0000 Subject: [PATCH 03/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- src/v1/stage0/src/compiler_tests.rs | 6 +- src/v1/stage0/src/extdeps_cargo.rs | 107 ++- .../src/extdeps_languages_python_types.rs | 3 + .../src/extdeps_languages_rust_types.rs | 8 + src/v1/stage0/src/lib.rs | 7 - src/v1/stage0/src/main.rs | 6 - src/v1/stage0/src/std_algebra.rs | 18 + src/v1/stage0/src/std_computation.rs | 7 + src/v1/stage0/src/std_effects.rs | 52 +- src/v1/stage0/src/std_emit_model.rs | 3 + src/v1/stage0/src/std_error_primitives.rs | 3 + src/v1/stage0/src/std_induction.rs | 6 + src/v1/stage0/src/std_syntax.rs | 36 + src/v1/stage0/src/std_termination.rs | 4 + src/v1/stage0/src/std_types.rs | 89 +- src/v1/stage0/src/v1_compiler_artifact.rs | 12 + src/v1/stage0/src/v1_compiler_complexity.rs | 3 + src/v1/stage0/src/v1_compiler_emit.rs | 12 + src/v1/stage0/src/v1_compiler_emit_rust.rs | 909 +++++++++--------- src/v1/stage0/src/v1_compiler_infer_items.rs | 7 + src/v1/stage0/src/v1_compiler_infer_method.rs | 35 - .../stage0/src/v1_compiler_infer_resolve.rs | 33 +- src/v1/stage0/src/v1_compiler_languages.rs | 12 + src/v1/stage0/src/v1_compiler_ownership.rs | 5 + src/v1/stage0/src/v1_compiler_parse.rs | 4 + .../stage0/src/v1_compiler_stage0_crates.rs | 3 + src/v1/stage0/src/v1_std_core.rs | 70 ++ 27 files changed, 913 insertions(+), 547 deletions(-) diff --git a/src/v1/stage0/src/compiler_tests.rs b/src/v1/stage0/src/compiler_tests.rs index fc07fce7ded..fe59340b25a 100644 --- a/src/v1/stage0/src/compiler_tests.rs +++ b/src/v1/stage0/src/compiler_tests.rs @@ -50,11 +50,7 @@ mod compiler_tests { .unwrap() .to_string_lossy() .to_string(); - // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules; - // exclude them so the self_* whole-tree module scans don't try to parse - // them as modules and panic. The only .dag under src/v1/**/tests/ is the - // fixture, so this skips exactly it (#5124 added the fixture; the cargo-test - // CI gate surfaced the panic). No real module lives under a tests/ dir. + // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules. if rel.contains("/tests/") { continue; } diff --git a/src/v1/stage0/src/extdeps_cargo.rs b/src/v1/stage0/src/extdeps_cargo.rs index 793c4c9abe1..58ffce73f17 100644 --- a/src/v1/stage0/src/extdeps_cargo.rs +++ b/src/v1/stage0/src/extdeps_cargo.rs @@ -3,7 +3,9 @@ use self::CargoDepSource::*; use self::CargoTarget::*; +use self::RustEdition::*; use self::TestHarness::*; +pub use crate::std_types::FilePathParts; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -13,11 +15,40 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum RustEdition { + Edition2015, + Edition2018, + Edition2021, + Edition2024, +} + +pub fn rust_edition_str(edition: RustEdition) -> String { + match edition { + RustEdition::Edition2015 => "2015".to_string(), + RustEdition::Edition2018 => "2018".to_string(), + RustEdition::Edition2021 => "2021".to_string(), + RustEdition::Edition2024 => "2024".to_string(), + } +} + +pub fn default_rust_edition() -> RustEdition { + thread_local! { + static CACHED: RustEdition = { + RustEdition::Edition2021 + }; + } + CACHED.with(|c: &RustEdition| c.clone()) +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoPackage { pub name: String, pub version: String, - pub edition: String, + pub edition: RustEdition, pub path: String, } @@ -60,6 +91,64 @@ impl CargoTarget { } } +pub fn cargo_target_source_path( + target: Rc, + package_name: String, +) -> Rc { + match (*target).clone() { + CargoTarget::Lib => Rc::new(FilePathParts { + segments: Rc::new(vec!["src".to_string(), "lib.rs".to_string()]), + }), + CargoTarget::Bin { name: name, .. } => { + if (name.clone().as_str() == package_name.as_str()) { + Rc::new(FilePathParts { + segments: Rc::new(vec!["src".to_string(), "main.rs".to_string()]), + }) + } else { + Rc::new(FilePathParts { + segments: Rc::new(vec![ + "src".to_string(), + "bin".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }) + } + } + CargoTarget::CargoTest { name: name, .. } => Rc::new(FilePathParts { + segments: Rc::new(vec![ + "tests".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }), + CargoTarget::Example { name: name, .. } => Rc::new(FilePathParts { + segments: Rc::new(vec![ + "examples".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }), + CargoTarget::Bench { name: name, .. } => Rc::new(FilePathParts { + segments: Rc::new(vec![ + "benches".to_string(), + v1_rt::concat(name.clone(), ".rs".to_string()), + ]), + }), + } +} + +pub fn rust_module_candidate_paths(stem: String) -> Rc>> { + Rc::new(vec![ + Rc::new(FilePathParts { + segments: Rc::new(vec![ + "src".to_string(), + v1_rt::concat(stem.clone(), ".rs".to_string()), + ]), + }), + Rc::new(FilePathParts { + segments: Rc::new(vec!["src".to_string(), stem.clone(), "mod.rs".to_string()]), + }), + ]) +} + pub type CargoProfile = String; pub fn canonical_profiles() -> Rc> { @@ -86,15 +175,6 @@ pub enum TestHarness { NoHarness, } -pub fn default_edition() -> String { - thread_local! { - static CACHED: String = { - "2021".to_string() - }; - } - CACHED.with(|c: &String| c.clone()) -} - pub fn default_profile() -> String { thread_local! { static CACHED: String = { @@ -103,3 +183,10 @@ pub fn default_profile() -> String { } CACHED.with(|c: &String| c.clone()) } + +pub struct Edition2015; +pub struct Edition2018; +pub struct Edition2021; +pub struct Edition2024; +pub struct Harness; +pub struct NoHarness; diff --git a/src/v1/stage0/src/extdeps_languages_python_types.rs b/src/v1/stage0/src/extdeps_languages_python_types.rs index 113a676ad25..29759774f9e 100644 --- a/src/v1/stage0/src/extdeps_languages_python_types.rs +++ b/src/v1/stage0/src/extdeps_languages_python_types.rs @@ -258,3 +258,6 @@ pub fn python_cast_syntax() -> Rc { } CACHED.with(|c: &Rc| c.clone()) } + +pub struct DynamicType; +pub struct AnnotatedType; diff --git a/src/v1/stage0/src/extdeps_languages_rust_types.rs b/src/v1/stage0/src/extdeps_languages_rust_types.rs index eb83a073861..7daf897f12a 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_types.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_types.rs @@ -216,3 +216,11 @@ pub fn serde_rename_template() -> String { } CACHED.with(|c: &String| c.clone()) } + +pub struct Owned; +pub struct SharedRef; +pub struct MutRef; +pub struct RawPtr; +pub struct BoxPtr; +pub struct RcPtr; +pub struct ArcPtr; diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index 14c590f9f66..be4f2f0ac56 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -27,12 +27,6 @@ pub mod extdeps_languages_python_types; pub mod extdeps_languages_rust_emit; pub mod extdeps_languages_rust_syntax; pub mod extdeps_languages_rust_types; -pub mod extdeps_shape_transport_policy_project; -pub mod fact_cardinality_census; -pub mod import_resolution_project; -pub mod layering_imports_project; -pub mod module_path_index; -pub mod recorded_fixture; pub mod resolved_graph_cache; pub mod rest_transport_facts; pub mod std_algebra; @@ -49,7 +43,6 @@ pub mod std_node; pub mod std_syntax; pub mod std_termination; pub mod std_types; -pub mod transport_script_position_project; pub mod v1_compiler_artifact; pub mod v1_compiler_coercion; pub mod v1_compiler_compile; diff --git a/src/v1/stage0/src/main.rs b/src/v1/stage0/src/main.rs index 5817bef1c05..52ee2e54b0b 100644 --- a/src/v1/stage0/src/main.rs +++ b/src/v1/stage0/src/main.rs @@ -44,8 +44,6 @@ enum Commands { #[arg(long, default_value = "rust")] target: String, }, - /// Run repo CI from CiSpec (delegates to dsl/tools/gunbc_ci.dag) - Ci, /// Execute a .dag program directly (interpreter) Run { /// Source root directories (searched recursively for .dag files) @@ -386,10 +384,6 @@ fn main() { } } - Commands::Ci {} => { - cli_run::handle_ci(); - } - Commands::Run { source_roots, function, diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index e4beb0a704e..a3b3ff672a6 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -1416,3 +1416,21 @@ pub fn algebra_type_param_names(profile: AlgebraProfile) -> Rc> { AlgebraProfile::PartialFunctionProfile => Rc::new(vec!["K".to_string(), "V".to_string()]), } } + +pub struct Less; +pub struct Equal; +pub struct Greater; +pub struct OrderedRingProfile; +pub struct ApproximateFieldProfile; +pub struct BooleanAlgebraProfile; +pub struct BooleanAlgebraCollectionProfile; +pub struct FreeMonoidScalarProfile; +pub struct FreeMonoidCollectionProfile; +pub struct PartialFunctionProfile; +pub struct ShrinkEffect; +pub struct ProjectionEffect; +pub struct IdentityEffect; +pub struct ShapeConstant; +pub struct ShapeLinearScan; +pub struct ShapeIterateBody; +pub struct ShapeSortBody; diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index 2337843f5b2..216005c5f43 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -242,3 +242,10 @@ pub fn type_iteration_dimension(type_name: String) -> Option } } } + +pub struct Fold; +pub struct Descend; +pub struct Repeat; +pub struct TreeDescent; +pub struct CollectionFold; +pub struct ArithmeticRepeat; diff --git a/src/v1/stage0/src/std_effects.rs b/src/v1/stage0/src/std_effects.rs index 1e870d01f38..a21411c37b5 100644 --- a/src/v1/stage0/src/std_effects.rs +++ b/src/v1/stage0/src/std_effects.rs @@ -11,6 +11,7 @@ use self::ModifierAgreement::*; use crate::std_http_path::PathTemplateParseResult::{MalformedPathTemplate, ParsedPathTemplate}; pub use crate::std_http_path::{has_path_params, last_path_param, parse_path_template}; pub use crate::std_http_path::{PathTemplate, PathTemplateParseResult}; +pub use crate::std_types::string_list_eq; pub use crate::std_types::HttpMethod; use crate::std_types::HttpMethod::{DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT}; use crate::v1_rt; @@ -95,18 +96,18 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { } } -pub fn key_source_eq(a: Rc, b: Rc) -> bool { - match (*a).clone() { - KeySource::PathParam { param: pa, .. } => match (*b).clone() { +pub fn key_source_eq(left: Rc, right: Rc) -> bool { + match (*left).clone() { + KeySource::PathParam { param: pa, .. } => match (*right).clone() { KeySource::PathParam { param: pb, .. } => (pa.clone().as_str() == pb.clone().as_str()), _ => false, }, - KeySource::InputField { field: fa, .. } => match (*b).clone() { + KeySource::InputField { field: fa, .. } => match (*right).clone() { KeySource::InputField { field: fb, .. } => (fa.clone().as_str() == fb.clone().as_str()), _ => false, }, - KeySource::CompositeKey { fields: fa, .. } => match (*b).clone() { - KeySource::CompositeKey { fields: fb, .. } => (fa.clone() == fb.clone()), + KeySource::CompositeKey { fields: fa, .. } => match (*right).clone() { + KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa.clone(), fb.clone()), _ => false, }, } @@ -307,16 +308,14 @@ pub fn check_modifier_vs_derivation( } else { if (declared_idempotent.clone() && !derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { - CreateCause::PostAlways => Rc::new(ModifierAgreement::DerivationUnknown { - reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared" - .to_string(), - }), - CreateCause::CreateIfAbsent { .. } => Rc::new(ModifierAgreement::Disagrees { - reason: "derivation says non-idempotent but modifier declares idempotent" - .to_string(), - }), - }, + EffectShape::CreateEffect { ref cause, .. } => { + let CreateCause::PostAlways = cause.as_ref() else { + unreachable!() + }; + Rc::new(ModifierAgreement::DerivationUnknown { + reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared".to_string(), +}) + } _ => Rc::new(ModifierAgreement::Disagrees { reason: "derivation says non-idempotent but modifier declares idempotent" .to_string(), @@ -325,15 +324,18 @@ pub fn check_modifier_vs_derivation( } else { if (!declared_idempotent.clone() && derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { - CreateCause::CreateIfAbsent { .. } => { - Rc::new(ModifierAgreement::Disagrees { - reason: "create-if-absent has proven identity but modifier declares non-idempotent" - .to_string(), - }) - } - CreateCause::PostAlways => Rc::new(ModifierAgreement::Agrees), - }, + EffectShape::CreateEffect { ref cause, .. } => { + let CreateCause::CreateIfAbsent { + key_source: key_source, + .. + } = cause.as_ref() + else { + unreachable!() + }; + Rc::new(ModifierAgreement::Disagrees { + reason: "create-if-absent has proven identity but modifier declares non-idempotent".to_string(), +}) + } _ => Rc::new(ModifierAgreement::Agrees), } } else { diff --git a/src/v1/stage0/src/std_emit_model.rs b/src/v1/stage0/src/std_emit_model.rs index 5bd6eebf3a1..b91287355d7 100644 --- a/src/v1/stage0/src/std_emit_model.rs +++ b/src/v1/stage0/src/std_emit_model.rs @@ -37,3 +37,6 @@ pub struct MethodTemplateContract { pub wraps_result: bool, pub placeholder_convention: PlaceholderConvention, } + +pub struct IndexedArgs; +pub struct NamedArg; diff --git a/src/v1/stage0/src/std_error_primitives.rs b/src/v1/stage0/src/std_error_primitives.rs index e0c45702a3b..b6cf7b7a27a 100644 --- a/src/v1/stage0/src/std_error_primitives.rs +++ b/src/v1/stage0/src/std_error_primitives.rs @@ -29,3 +29,6 @@ pub enum DivError { DivideByZero, Overflow, } + +pub struct DivideByZero; +pub struct Overflow; diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index 5fecbc40044..8bb79f20f72 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -1102,3 +1102,9 @@ pub fn bellman_ford_bound() -> Rc { pub fn floyd_warshall_bound() -> Rc { cost_poly("V".to_string(), 3) } + +pub struct DirectRecursion; +pub struct ListRecursion; +pub struct OptionalRecursion; +pub struct SetRecursion; +pub struct MapValueRecursion; diff --git a/src/v1/stage0/src/std_syntax.rs b/src/v1/stage0/src/std_syntax.rs index 019ae09f706..1e280cc963c 100644 --- a/src/v1/stage0/src/std_syntax.rs +++ b/src/v1/stage0/src/std_syntax.rs @@ -156,3 +156,39 @@ pub struct SyntaxSpec { pub keyword_literals: Rc>>, pub keyword_set: Rc>, } + +pub struct Add; +pub struct Sub; +pub struct Mul; +pub struct Div; +pub struct Mod; +pub struct Eq; +pub struct Ne; +pub struct Lt; +pub struct Gt; +pub struct Le; +pub struct Ge; +pub struct And; +pub struct Or; +pub struct NullCoalesce; +pub struct ExprBody; +pub struct BlockBody; +pub struct TypeBody; +pub struct ValueBody; +pub struct NoBody; +pub struct ServiceBody; +pub struct ResourceBody; +pub struct FuncForm; +pub struct StructForm; +pub struct EnumForm; +pub struct TypeAliasForm; +pub struct ModuleForm; +pub struct OtherForm; +pub struct AlgAdd; +pub struct AlgMul; +pub struct AlgReciprocal; +pub struct AlgQuotient; +pub struct AlgRemainder; +pub struct AlgCompare; +pub struct AlgMeet; +pub struct AlgJoin; diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index 3c3f23e0a92..46d3e739ca9 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -256,3 +256,7 @@ pub struct ProofEdge { pub callee: String, pub evidence: Rc>, } + +pub struct Strict; +pub struct NonIncreasing; +pub struct DescentUnknown; diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index f42de5caade..203ebaf52bc 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -199,6 +199,34 @@ pub fn canonical_container_names() -> Rc> { ]) } +pub fn string_list_eq(mut left: Rc>, mut right: Rc>) -> bool { + loop { + if ((left.clone().len() as i64) != (right.clone().len() as i64)) { + break false; + } else { + if ((left.clone().len() as i64) == 0) { + break true; + } else { + if (left.clone().first().cloned().as_deref() + != right.clone().first().cloned().as_deref()) + { + break false; + } else { + { + let __tco_0 = + Rc::new(left.iter().cloned().skip(1 as usize).collect::>()); + let __tco_1 = + Rc::new(right.iter().cloned().skip(1 as usize).collect::>()); + left = __tco_0; + right = __tco_1; + continue; + } + } + } + } + } +} + #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, )] @@ -208,9 +236,9 @@ pub enum Bool { False, } -pub type Json = serde_json::Value; +pub type Json = Json; -pub type Bytes = Vec; +pub type Bytes = Bytes; pub type Char = i64; @@ -654,3 +682,60 @@ pub struct DocSource { pub path: FilePath, pub kind: DocSourceKind, } + +pub struct True; +pub struct False; +pub struct Pure; +pub struct Transport; +pub struct SubDag; +pub struct Env; +pub struct Template; +pub struct Generated; +pub struct Static; +pub struct Xs; +pub struct S; +pub struct M; +pub struct L; +pub struct Xl; +pub struct X86_64; +pub struct X86; +pub struct Aarch64; +pub struct Arm; +pub struct Armv7; +pub struct Mipsel; +pub struct Mips64; +pub struct Mips64el; +pub struct Riscv64; +pub struct Wasm32; +pub struct UnknownVendor; +pub struct Pc; +pub struct Apple; +pub struct W64; +pub struct Freebsd; +pub struct Android; +pub struct Ios; +pub struct Wasi; +pub struct NoneAbi; +pub struct Gnu; +pub struct GnuEabi; +pub struct GnuEabihf; +pub struct Musl; +pub struct Msvc; +pub struct AndroidAbi; +pub struct Eabi; +pub struct Eabihf; +pub struct Native; +pub struct Wsl; +pub struct Container; +pub struct Ci; +pub struct Emulator; +pub struct GET; +pub struct POST; +pub struct PUT; +pub struct PATCH; +pub struct DELETE; +pub struct HEAD; +pub struct OPTIONS; +pub struct Rust; +pub struct Go; +pub struct C; diff --git a/src/v1/stage0/src/v1_compiler_artifact.rs b/src/v1/stage0/src/v1_compiler_artifact.rs index 8b235a5ebfd..933b218e2e0 100644 --- a/src/v1/stage0/src/v1_compiler_artifact.rs +++ b/src/v1/stage0/src/v1_compiler_artifact.rs @@ -163,3 +163,15 @@ pub struct DagArtifact { pub diagnostics: Rc>, pub files: Rc>, } + +pub struct Python; +pub struct Dag; +pub struct ServiceBinary; +pub struct Library; +pub struct Frontend; +pub struct GeneratedSupport; +pub struct DirectCall; +pub struct HttpJson; +pub struct MessageQueue; +pub struct Ffi; +pub struct FileProtocol; diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index ae8d86f6d14..b1397c9cf29 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -9915,3 +9915,6 @@ pub fn build_complexity_report( }) } } + +pub struct Proven; +pub struct Conservative; diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 9471d8bd69f..e49c1480475 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -6105,3 +6105,15 @@ pub fn emit_typed_tco_reassign_shared( pub fn seed_bindings(key: String, value: String) -> Rc> { v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, value) } + +pub struct CapServiceEmit; +pub struct CapAsyncTransport; +pub struct CapTestGeneration; +pub struct CapDryRunMode; +pub struct CapRcOwnership; +pub struct ExprCatLeaf; +pub struct ExprCatCompound; +pub struct ExprCatControlFlow; +pub struct ExprCatBinding; +pub struct ExprCatService; +pub struct ExprCatNone; diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index be5edfca11e..d0eb62844b4 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -83,7 +83,6 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -289,10 +288,19 @@ pub fn render_rust_applied_type_arg( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), + _ => render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + source_indices, + variant_to_enum, + env, + ), } } @@ -301,6 +309,8 @@ pub fn render_rust_applied_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { { let base = rust_named_type_base(authored_name_at(source_indices.clone(), n.clone())); @@ -316,6 +326,8 @@ pub fn render_rust_applied_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), )); } __result @@ -366,6 +378,8 @@ pub fn render_rust_decl_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, + env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -408,39 +422,51 @@ pub fn render_rust_decl_type( name.clone() } else { if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + && ((n.children.clone().len() as i64) == 0)) { + rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) { - let base = rust_named_type_base(name.clone()); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - )); - } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, + { + let base = rust_named_type_base(name.clone()); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + )); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, + shared_types.clone(), + ) + } + } else { + render_rust_type_with_applied_binding( + n.clone(), shared_types.clone(), + source_indices.clone(), ) } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - ) } } } @@ -449,17 +475,20 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b, - None => { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { - Some(b) => b, - None => return false, + { + let binding = match lookup_type_for(env.clone(), n.clone()) { + Some(b) => b.clone(), + None => { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + match lookup_type_by_name(env.clone(), name) { + Some(b) => b.clone(), + None => return false, + } } - } - }; - (binding.children.clone().len() as i64) == 0 && (binding.params.clone().len() as i64) == 0 + }; + (((binding.children.clone().len() as i64) == 0) + && ((binding.params.clone().len() as i64) == 0)) + } } pub fn render_rust_fn_sig_type( @@ -467,20 +496,35 @@ pub fn render_rust_fn_sig_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) + render_rust_decl_type( + n.clone(), + generic_param_names.clone(), + shared_types, + source_indices.clone(), + variant_to_enum, + env.clone(), + ) } else { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0) - && !is_container_type(name.clone()) - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) { - render_rust_shared_type_if_needed(name.clone(), name, shared_types.clone()) - } else { - render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !is_container_type(name.clone())) + && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) + { + render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types, + source_indices.clone(), + env.clone(), + ) + } } } } @@ -498,25 +542,37 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name, - shared_types.clone(), - ) - } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if ((((outer_name.clone().as_str() != "".to_string().as_str()) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + && rust_fn_sig_peel_closed_alias(env, n.clone())) + { + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name.clone(), + shared_types, + ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + source_indices.clone(), + ) + } } } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + source_indices.clone(), + ) } } - None => render_rust_type_with_applied_binding(n, shared_types, source_indices), + None => { + render_rust_type_with_applied_binding(n.clone(), shared_types, source_indices.clone()) + } } } @@ -550,76 +606,80 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - { - rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - scope.type_env.clone(), - ) - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( + rust_render_type_leaf_name( name.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = if (def_mod.clone().as_str() != local_mod.as_str()) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - }; - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - scope.clone(), + variant_to_enum.clone(), + scope.type_env.clone(), + ) + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + { + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), imports.clone(), + scope.clone(), registry.clone(), - module_name.clone(), export_sets.clone(), typed_modules.clone(), + source_indices.clone(), module_index.clone(), - variant_to_enum.clone(), - )); + ); + let base = if (def_mod.clone().as_str() != local_mod.as_str()) { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + }; + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + )); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + } else { + applied_ty.clone() + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) - { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) } else { - applied_ty.clone() + render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } } - } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -1023,32 +1083,13 @@ pub fn rust_string_policy_for_naming( if (naming_name.clone().as_str() == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - match required_literal_string_policy_field( - naming.clone(), - "prefix".to_string(), - source_indices.clone(), - ) { - Some(prefix) => match required_literal_string_policy_field( - naming.clone(), - "suffix".to_string(), - source_indices.clone(), - ) { - Some(suffix) => rust_serde_policy( - "".to_string(), - Some(prefix.clone()), - Some(suffix.clone()), - Some("StripAffixAndSnakeCase".to_string()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { + Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { + Some(suffix) => rust_serde_policy("".to_string(), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1150,38 +1191,13 @@ pub fn rust_internal_policy_for_naming( if (naming_name.clone().as_str() == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - match required_literal_string_policy_field( - naming.clone(), - "prefix".to_string(), - source_indices.clone(), - ) { - Some(prefix) => match required_literal_string_policy_field( - naming.clone(), - "suffix".to_string(), - source_indices.clone(), - ) { - Some(suffix) => rust_serde_policy( - v1_rt::concat( - v1_rt::concat( - "#[serde(tag = \"".to_string(), - tag_field, - ), - "\")]".to_string(), - ), - Some(prefix.clone()), - Some(suffix.clone()), - Some("StripAffixAndSnakeCase".to_string()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { + Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { + Some(suffix) => rust_serde_policy(v1_rt::concat(v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string()), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -2020,40 +2036,204 @@ pub fn emit_rust_init_block_stmts( scope: scope.clone(), }); } - Some(_) => { - let raw_line = emit_typed_expr( - stmt.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ); - let is_let = match (*stmt.expr_data.clone()).clone() { - ExprData::ExprLet => true, - _ => false, - }; - let line = if is_let { - raw_line - } else { - v1_rt::concat(raw_line, ";".to_string()) - }; - let next_scope = scope_after_expr(stmt.clone(), scope.clone()); + Some(_) => { + let raw_line = emit_typed_expr( + stmt.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ); + let is_let = match (*stmt.expr_data.clone()).clone() { + ExprData::ExprLet => true, + _ => false, + }; + let line = if is_let { + raw_line + } else { + v1_rt::concat(raw_line, ";".to_string()) + }; + let next_scope = scope_after_expr(stmt.clone(), scope.clone()); + { + let __tco_0 = rest.clone(); + let __tco_1 = v1_rt::rc_list_push(text, line); + let __tco_2 = next_scope; + remaining = __tco_0; + text = __tco_1; + scope = __tco_2; + continue; + } + } + } + } + } + } +} + +pub fn rust_qualify_type_leaf_name( + name: String, + variant_to_enum: Rc>, +) -> String { + match v1_rt::map_get(&variant_to_enum, name.clone()) { + Some(parent) => { + if (parent.clone().as_str() != "".to_string().as_str()) { + v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: String, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name.clone() + } else { + rust_qualify_type_leaf_name(name.clone(), variant_to_enum) + } +} + +pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { + { + let markers = Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if ((child.children.clone().len() as i64) == 0) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + if is_phantom_unit_variant_type_arg( + env.clone(), + authored_name(env.clone(), child.clone()), + ) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + __result.push({ + let vname = authored_name(env.clone(), child.clone()); + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + vname.clone(), + ), + ";".to_string(), + ) + }); + } + __result + }) + .join(&"\n".to_string()); + markers + } +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (is_type_def_item(item.clone()) && { + let mut __all = true; + for c in item.children.clone().iter().cloned() { + if !((c.children.clone().len() as i64) == 0) { + __all = false; + break; + } + } + __all + }) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { + item.children.clone().iter().cloned().fold( + acc, + |inner: Rc>, child: Rc| { + if ((child.children.clone().len() as i64) == 0) { + { + let vname = authored_name(env.clone(), child.clone()); + if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !{ + let mut __found = false; + for n in inner.clone().iter().cloned() { + if (n.clone().as_str() == vname.clone().as_str()) { + __found = true; + break; + } + } + __found + }) { - let __tco_0 = rest.clone(); - let __tco_1 = v1_rt::rc_list_push(text, line); - let __tco_2 = next_scope; - remaining = __tco_0; - text = __tco_1; - scope = __tco_2; - continue; + v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) + } else { + inner.clone() } } + } else { + inner.clone() } - } + }, + ) + }) +} + +pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + vname.clone(), + ), + ";".to_string(), + )); } - } + __result + }) + .join(&"\n".to_string()) } pub fn has_complex_variants(item: Rc) -> bool { @@ -2913,10 +3093,10 @@ pub fn emit_module_full( .join(&"\n\n".to_string()); let phantom_zst_markers = emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); - let phantom_section = if phantom_zst_markers.as_str() == "" { + let phantom_section = if (phantom_zst_markers.clone().as_str() == "".to_string().as_str()) { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), phantom_zst_markers) + v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { @@ -6568,25 +6748,27 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if outer_name.as_str() != "" - && outer_name != applied_name - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name, - shared_types.clone(), - ) - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types, - source_indices.clone(), - ) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if ((((outer_name.clone().as_str() != "".to_string().as_str()) + && (outer_name.clone().as_str() != applied_name.as_str())) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + { + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name.clone(), + shared_types, + ) + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types, + source_indices.clone(), + ) + } } } else { render_rust_type(n.clone(), shared_types, source_indices.clone()) @@ -7329,87 +7511,41 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } -pub fn wire_variant_tag_for_policy( - authored: String, - policy: Rc, -) -> Option { - if policy.error_message.is_some() { - return None; - } - match policy.rename_style.clone() { - Some(style) => { - if style.as_str() == "StripAffixAndSnakeCase" { - let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix) { - Some(stripped) => stripped, - None => return None, - }, - None => authored, - }; - let without_suffix = match policy.rename_suffix.clone() { - Some(suffix) => match string_without_suffix(without_prefix, suffix) { - Some(stripped) => stripped, - None => return None, - }, - None => without_prefix, - }; - Some(to_snake(without_suffix)) - } else { - None - } - } - None => { - if policy.enum_attr.contains("rename_all = \"snake_case\"") { - Some(to_snake(authored)) - } else if policy.enum_attr.is_empty() - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - { - Some(authored) - } else { - None - } - } - } -} - -pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { - let needle = "tag = \""; - let start = policy.enum_attr.find(needle)? + needle.len(); - let rest = &policy.enum_attr[start..]; - let end = rest.find('"')?; - Some(rest[..end].to_string()) -} - -pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { - policy.enum_attr.contains("untagged") -} - -pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { - !policy.enum_attr.contains("tag =") - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - && policy.rename_style.is_none() -} - pub fn wire_variant_rename_attr_for_policy( authored: String, policy: Rc, ) -> String { - match wire_variant_tag_for_policy(authored, policy.clone()) { - Some(tag) => match policy.rename_style.clone() { - Some(style) => { - if style.as_str() == "StripAffixAndSnakeCase" { + match policy.rename_style.clone() { + Some(style) => { + if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { + { + let without_prefix = match policy.rename_prefix.clone() { + Some(prefix) => match string_without_prefix(authored, prefix.clone()) { + Some(stripped) => stripped.clone(), + None => return "".to_string(), + }, + None => authored, + }; + let without_suffix = match policy.rename_suffix.clone() { + Some(suffix) => match string_without_suffix(without_prefix, suffix.clone()) + { + Some(stripped) => stripped.clone(), + None => return "".to_string(), + }, + None => without_prefix, + }; v1_rt::concat( - v1_rt::concat(" #[serde(rename = \"".to_string(), tag), + v1_rt::concat( + " #[serde(rename = \"".to_string(), + to_snake(without_suffix), + ), "\")]\n".to_string(), ) - } else { - "".to_string() } + } else { + "".to_string() } - None => "".to_string(), - }, + } None => "".to_string(), } } @@ -7825,6 +7961,7 @@ pub fn emit_fn_def( shared_types.clone(), si.clone(), emit_info.read_only_params.clone(), + emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let ret_str = emit_inferred( @@ -7832,6 +7969,7 @@ pub fn emit_fn_def( generic_param_names.clone(), shared_types.clone(), si.clone(), + emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); @@ -7847,6 +7985,7 @@ pub fn emit_fn_def( generic_param_names.clone(), shared_types.clone(), si.clone(), + emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let body_str = emit_typed_tco_body( @@ -8076,7 +8215,6 @@ pub fn emit_func_def( shared_types.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), - scope.type_env.clone(), ); let ret_str = emit_func_inferred( inferred, @@ -8295,6 +8433,7 @@ pub fn emit_tco_params( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8306,6 +8445,7 @@ pub fn emit_tco_params( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8320,6 +8460,7 @@ pub fn emit_tco_param( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8330,7 +8471,8 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( @@ -8338,6 +8480,7 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8364,7 +8507,6 @@ pub fn emit_func_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, - env: Rc, ) -> String { { let param_strs = Rc::new({ @@ -8376,7 +8518,6 @@ pub fn emit_func_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), - env.clone(), )); } __result @@ -8436,6 +8577,7 @@ pub fn emit_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8448,6 +8590,7 @@ pub fn emit_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8462,23 +8605,27 @@ pub fn render_rust_param_sig_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { { - let type_node = resolved_type(param.clone()); + let type_node = resolved_type(param); if ((generic_param_names.clone().len() as i64) > 0) { render_rust_decl_type( type_node, generic_param_names.clone(), shared_types, source_indices, + variant_to_enum, + env, ) } else { render_rust_fn_sig_type( type_node, - generic_param_names, + generic_param_names.clone(), shared_types, source_indices, + variant_to_enum, env, ) } @@ -8490,6 +8637,7 @@ pub fn emit_rust_param_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -8502,6 +8650,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8514,6 +8663,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -8535,7 +8685,8 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - env, + variant_to_enum.clone(), + env.clone(), ) } } @@ -8546,6 +8697,7 @@ pub fn emit_param( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8556,7 +8708,8 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( @@ -8564,6 +8717,7 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8583,6 +8737,7 @@ pub fn emit_inferred( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -8592,6 +8747,7 @@ pub fn emit_inferred( generic_param_names, shared_types, source_indices, + variant_to_enum, env, ), ) @@ -10325,115 +10481,6 @@ pub fn clone_iterator_suffix() -> String { sharing_for_target(RenderTarget::Rust).clone_suffix.clone() } -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - match v1_rt::map_get(&variant_to_enum, name.clone()) { - Some(parent) => { - if parent.as_str() != "" { - v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name - } else { - rust_qualify_type_leaf_name(name, variant_to_enum) - } -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - } - } - __result - }) - .join("\n") -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut names: Vec = Vec::new(); - for item in items.iter().cloned() { - if is_type_def_item(item.clone()) - && item - .children - .clone() - .iter() - .all(|c| c.children.clone().len() as i64 == 0) - { - for child in item.children.clone().iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !names.iter().any(|n| n == &vname) - { - names.push(vname); - } - } - } - } - } - names - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env.clone()) - .iter() - .cloned() - { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - __result - }) - .join("\n") -} - pub fn effective_variant_parent( name: String, binding_kind: Option>, @@ -17759,7 +17806,8 @@ pub fn emit_operation_method( Rc::new(vec![]), shared_types.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } @@ -19791,7 +19839,8 @@ pub fn emit_capability_method( Rc::new(vec![]), shared_types.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::(), + env.clone().clone(), ), )); } @@ -20366,14 +20415,6 @@ pub fn emit_test_file( pub fn rust_test_signature_comment(projection: Rc) -> String { { - let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), - recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), - source_indices: projection.source_indices.clone(), - intern_table: empty_intern_table(), - }); let params_str = Rc::new({ let mut __result = Vec::new(); for p in projection.params.clone().iter().cloned() { @@ -20387,7 +20428,7 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { Rc::new(vec![]), v1_rt::rc_empty_set::(), projection.source_indices.clone(), - stub_env.clone(), + v1_rt::rc_empty_map::(), ), )); } @@ -21539,15 +21580,7 @@ pub fn emit_compile_match_arm(crate_name: String) -> String { } pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat( - v1_rt::concat( - "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" - .to_string(), - " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" - .to_string(), - ), - " },".to_string(), - ) + v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) } pub fn emit_main_pipeline_fns(crate_name: String) -> String { diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 6f94f923962..f8f68621146 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -225,3 +225,10 @@ pub fn variant_locals_from_items( }, ) } + +pub struct FnItem; +pub struct FuncItem; +pub struct TypeItem; +pub struct DataItem; +pub struct ServiceItem; +pub struct OtherItem; diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index b1e11632882..abb62be0e84 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -191,11 +191,6 @@ pub fn builtin_function_registry() -> Rc>> { "extdeps_dead_param_count_for_operation".to_string(), int_type(), ); - let m = v1_rt::rc_map_insert( - m.clone(), - "shell_materialize_argv_for_operation".to_string(), - list_of_element(string_type()), - ); let m = v1_rt::rc_map_insert( m.clone(), "extdeps_dead_param_count_for_path".to_string(), @@ -251,36 +246,6 @@ pub fn builtin_function_registry() -> Rc>> { "transport_script_literal_violation_count_for_path".to_string(), int_type(), ); - let m = v1_rt::rc_map_insert( - m.clone(), - "layer_import_facts".to_string(), - list_of_type_variable("layer_import_fact_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "import_resolution_facts".to_string(), - list_of_type_variable("import_resolution_fact_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_coexistence_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_diverged_fork_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_is_coexistence".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_is_diverged_fork".to_string(), - bool_type(), - ); m.clone() } } diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index c6f8c18b5e4..7cd8064ee66 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -2015,9 +2015,6 @@ pub fn resolve_expr_types( descent_evidence: de, .. } => { - // bind-once: resolve each arg child a SINGLE time, then split - // into resolved children + diagnostics. Resolving twice made a - // nested constructor literal O(2^depth). let arg_results = Rc::new({ let mut __result = Vec::new(); for arg_node in texpr.children.clone().iter().cloned() { @@ -2047,14 +2044,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.iter().cloned() { + for r in arg_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.iter().cloned() { + for r in arg_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2078,7 +2075,6 @@ pub fn resolve_expr_types( method_semantics: ms, .. } => { - // bind-once: resolve each child a SINGLE time (see ExprCall). let mc_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2144,14 +2140,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.iter().cloned() { + for r in mc_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.iter().cloned() { + for r in mc_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2171,7 +2167,6 @@ pub fn resolve_expr_types( }) } ExprData::ExprMatch => { - // bind-once: resolve each scrutinee/arm a SINGLE time (see ExprCall). let match_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2282,14 +2277,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in match_results.iter().cloned() { + for r in match_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in match_results.iter().cloned() { + for r in match_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2390,9 +2385,6 @@ pub fn resolve_expr_types( ExprData::ExprRecordLit { parent_enum: pe, .. } => { - // bind-once: resolve each field-init value a SINGLE time. This is - // the arm hit by deep nested constructor literals (Cons/record - // chains) — resolving twice per field was O(2^depth). let fi_results = Rc::new({ let mut __result = Vec::new(); for fi_node in texpr.children.clone().iter().cloned() { @@ -2418,14 +2410,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.iter().cloned() { + for r in fi_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.iter().cloned() { + for r in fi_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2559,7 +2551,6 @@ pub fn resolve_expr_types( }) } ExprData::ExprStringInterp => { - // bind-once: resolve each interpolation part a SINGLE time (see ExprCall). let part_results = Rc::new({ let mut __result = Vec::new(); for part_node in texpr.children.clone().iter().cloned() { @@ -2594,14 +2585,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in part_results.iter().cloned() { + for r in part_results.clone().iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in part_results.iter().cloned() { + for r in part_results.clone().iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -3316,3 +3307,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }) }) } + +pub struct AliasParameterized; +pub struct AliasLeaf; +pub struct AliasPassthrough; diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index 55bfc8d5028..8305799b23f 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -1345,3 +1345,15 @@ pub fn wrap_shared_type(target: RenderTarget, inner: String) -> String { v1_rt::replace(tmpl, "{0}".to_string(), inner) } } + +pub struct SnakeCaseTestNames; +pub struct PascalCaseTestNames; +pub struct IfExpression; +pub struct ConditionalTernary; +pub struct IfStatement; +pub struct MatchExpression; +pub struct MatchStatementArmReturn; +pub struct PascalCase; +pub struct SnakeCase; +pub struct CamelCase; +pub struct AsAuthored; diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 881d0355c8b..adacc83a08e 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -1246,3 +1246,8 @@ pub fn analyze_ownership( }) } } + +pub struct Consumed; +pub struct Read; +pub struct Threaded; +pub struct Projected; diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index e5170bf42d7..de03eb7556a 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -14558,3 +14558,7 @@ pub fn peek_is_colon_after_ident(tokens: Rc>>) -> bool { None => false, } } + +pub struct ParserHelperSkipNewlines; +pub struct ParserHelperSkipContinuationNewlines; +pub struct ParserHelperWith; diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index baa2ce9dd3a..47f5de648ab 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -401,3 +401,6 @@ pub fn emit_stage0_crate_boundary_files(plan: Rc) -> Rc Rc>> { emit_stage0_crate_boundary_files(stage0_crate_plan()) } + +pub struct CoreCrate; +pub struct EmitCoreCrate; diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index 9d3cd07113f..f8ef5220ab7 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -3600,3 +3600,73 @@ pub fn with_required_cardinality(n: Rc) -> Rc { expr_data: n.expr_data.clone(), }) } + +pub struct ShKeyword; +pub struct ShLBrace; +pub struct ShRBrace; +pub struct ShLParen; +pub struct ShRParen; +pub struct ShLBracket; +pub struct ShRBracket; +pub struct ShLt; +pub struct ShGt; +pub struct ShLe; +pub struct ShGe; +pub struct ShFatArrow; +pub struct ShArrow; +pub struct ShColon; +pub struct ShComma; +pub struct ShDot; +pub struct ShDotDot; +pub struct ShEq; +pub struct ShEqEq; +pub struct ShNe; +pub struct ShPlus; +pub struct ShMinus; +pub struct ShStar; +pub struct ShSlash; +pub struct ShPercent; +pub struct ShBang; +pub struct ShAnd; +pub struct ShOr; +pub struct ShQuestion; +pub struct ShNullCoalesce; +pub struct ShCaret; +pub struct ShPipe; +pub struct ShPipeArrow; +pub struct ShLitStr; +pub struct ShLitInt; +pub struct ShLitFloat; +pub struct ShIdent; +pub struct ShStrBegin; +pub struct ShStrMid; +pub struct ShStrEnd; +pub struct ShNewline; +pub struct ShEof; +pub struct ShUnknown; +pub struct Conj; +pub struct Disj; +pub struct NoConnective; +pub struct Arrow; +pub struct Required; +pub struct CardOptional; +pub struct StoredField; +pub struct EnumAccessor; +pub struct OptionalUnwrap; +pub struct TupleFirst; +pub struct TupleSecond; +pub struct PlainValue; +pub struct OptionalValue; +pub struct PlainCallSemantics; +pub struct LookupCallSemantics; +pub struct ParseRecoveryError; +pub struct SemanticExprError; +pub struct InternalExprError; +pub struct Not; +pub struct Neg; +pub struct Idempotent; +pub struct Readonly; +pub struct Hermetic; +pub struct ChildrenListField; +pub struct SubValueField; +pub struct MetadataField; From fcb5b44a263ca586634a2c4ba60c8be1ac7ec9ce Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 21:51:58 +0000 Subject: [PATCH 04/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- dsl/gunbc/ci_spec.dag | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dsl/gunbc/ci_spec.dag b/dsl/gunbc/ci_spec.dag index 4bdbf2fe554..230259971c5 100644 --- a/dsl/gunbc/ci_spec.dag +++ b/dsl/gunbc/ci_spec.dag @@ -15,6 +15,7 @@ type Gate | DslCompileCleanGate | CiYamlGate | SourceRootIngestGate + | Stage0LockstepGate type DiffMode = DiffMergeBase | DiffTwoDot @@ -40,7 +41,8 @@ data gunbc_ci_gates: List = [ ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, - SourceRootIngestGate + SourceRootIngestGate, + Stage0LockstepGate ] data gunbc_ci_spec: CiSpec = { From 62413385fcc3f8dc8146408ed456e686a113fe30 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 21:54:51 +0000 Subject: [PATCH 05/15] =?UTF-8?q?Stage0LockstepGate:=20enroll=20regen-lock?= =?UTF-8?q?step=20verify=20into=20CI=20floor=20(=C2=A76=20gate)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes the §6 hole that let the stage0 seed drift undetected: nothing in CI gated on the seed being a clean function of the .dag. Adds a closed Gate coproduct variant Stage0LockstepGate across the floor roster (ci_spec type + gunbc_ci_gates, ci_gates run_spec_gate + sequential, floor_effect_gate_witness adapter, ci_floor_plan gate_node + gate_runnable) plus the transport (regen_stage0 --verify, GREEN) and a planted-drift RED receipt (the +/- teeth, proven by execution: clean seed verify exit 0, perturbed seed exit 1). ci.yml is plan-driven (claim_executor over gunbc_ci_floor_batches) so the gate is discovered at runtime -- no ci.yml change. Roster witness is reflection-driven (discriminant + coproduct_arm_keys) so it self-maintains. NOT yet compile-checked: the v1 seed build is RED pending fierce-ant's emitter gaps A/B/C; gate .dag is outside the v1 seed closure so regen --verify is unaffected. Compile-check + floor-witness proof at co-land over the green build. Co-Authored-By: Claude Opus 4.8 (1M context) --- dsl/tools/ci_gates.dag | 7 +- dsl/tools/floor_effect_gate_witness.dag | 7 +- dsl/tools/stage0_lockstep_gate.dag | 38 +++++++ dsl/tools/stage0_lockstep_transport.dag | 136 ++++++++++++++++++++++++ src/v2/workflow/ci_floor_plan.dag | 4 +- 5 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 dsl/tools/stage0_lockstep_gate.dag create mode 100644 dsl/tools/stage0_lockstep_transport.dag diff --git a/dsl/tools/ci_gates.dag b/dsl/tools/ci_gates.dag index c6059b85769..7831d86781c 100644 --- a/dsl/tools/ci_gates.dag +++ b/dsl/tools/ci_gates.dag @@ -14,7 +14,7 @@ import std.process { ProcessExit, ExitSuccess, exit_failure } import gunbc.ci_spec { gunbc_ci_spec, CiSpec, Gate, RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, - SourceRootIngestGate + SourceRootIngestGate, Stage0LockstepGate } import tools.rust_gates_ci { run_rust_monolith_gate } import tools.emit_host_gate { run_emit_host_ci_gate } @@ -22,6 +22,7 @@ import tools.layering_imports_gate { run_layering_imports_ci_gate } import tools.resolved_imports_gate { run_resolved_imports_ci_gate } import tools.dsl_compile_clean_gate { run_dsl_compile_clean_gate } import tools.ci_yaml_gate { run_ci_yaml_gate } +import tools.stage0_lockstep_gate { run_stage0_lockstep_gate } fn exit_ok(e: ProcessExit) -> Bool { match e { ExitSuccess => true _ => false } @@ -38,6 +39,7 @@ fn run_spec_gate(g: Gate) -> ProcessExit { SourceRootIngestGate => exit_failure( reason: "SourceRootIngestGate: run via ci_floor_plan v2.workflow.source_root_ingest_gate (slice 3)" ) + Stage0LockstepGate => run_stage0_lockstep_gate() } } @@ -49,7 +51,8 @@ func run_ci_gates_sequential(spec: CiSpec) -> ProcessExit { let g3 = if exit_ok(g2) { run_spec_gate(g: ResolvedImportsGate) } else { g2 } let g4 = if exit_ok(g3) { run_spec_gate(g: DslCompileCleanGate) } else { g3 } let g5 = if exit_ok(g4) { run_spec_gate(g: CiYamlGate) } else { g4 } - if exit_ok(g5) { run_spec_gate(g: SourceRootIngestGate) } else { g5 } + let g6 = if exit_ok(g5) { run_spec_gate(g: SourceRootIngestGate) } else { g5 } + if exit_ok(g6) { run_spec_gate(g: Stage0LockstepGate) } else { g6 } } func main() -> ProcessExit { diff --git a/dsl/tools/floor_effect_gate_witness.dag b/dsl/tools/floor_effect_gate_witness.dag index f2ae81efd74..b3a86b67ca6 100644 --- a/dsl/tools/floor_effect_gate_witness.dag +++ b/dsl/tools/floor_effect_gate_witness.dag @@ -11,7 +11,8 @@ module tools.floor_effect_gate_witness import gunbc.ci_spec { - RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate + RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, + Stage0LockstepGate } import tools.ci_gates { exit_ok, run_spec_gate } @@ -38,3 +39,7 @@ func dsl_compile_clean_gate_passes() -> Bool { func ci_yaml_gate_passes() -> Bool { exit_ok(e: run_spec_gate(g: CiYamlGate)) } + +func stage0_lockstep_gate_passes() -> Bool { + exit_ok(e: run_spec_gate(g: Stage0LockstepGate)) +} diff --git a/dsl/tools/stage0_lockstep_gate.dag b/dsl/tools/stage0_lockstep_gate.dag new file mode 100644 index 00000000000..6ebe46cc21d --- /dev/null +++ b/dsl/tools/stage0_lockstep_gate.dag @@ -0,0 +1,38 @@ +// tools/stage0_lockstep_gate.dag — stage0 regen-lockstep gate, run by the CI floor. +// +// Closes the §6 hole: nothing in CI gated on the stage0 seed being a clean +// function of the `.dag`, so the seed silently drifted. This gate runs +// `regen_stage0 --verify` (the lockstep oracle) over the live tree (GREEN) plus +// a planted-drift RED receipt (the +/- teeth), mirroring tools.dsl_compile_clean_gate. +// +// Run standalone: +// cargo run -p v1-compiler --release --bin gunbc -- run \ +// --source-root dsl --entry dsl/tools/stage0_lockstep_gate.dag --function main + +module tools.stage0_lockstep_gate + +import std.process { ProcessExit, ExitSuccess, exit_failure } +import tools.stage0_lockstep_transport { + run_stage0_lockstep_verify, + run_stage0_lockstep_perturb_red_receipt +} + +func run_stage0_lockstep_gate_body() -> ProcessExit { + let clean = run_stage0_lockstep_verify() + let perturb = run_stage0_lockstep_perturb_red_receipt() + return if clean && perturb { + ExitSuccess + } else { + exit_failure( + reason: "stage0 regen-lockstep gate failed: regen_stage0 --verify and/or planted-drift red receipt" + ) + } +} + +func run_stage0_lockstep_gate() -> ProcessExit { + run_stage0_lockstep_gate_body() +} + +func main() -> ProcessExit { + run_stage0_lockstep_gate_body() +} diff --git a/dsl/tools/stage0_lockstep_transport.dag b/dsl/tools/stage0_lockstep_transport.dag new file mode 100644 index 00000000000..3f3912ad406 --- /dev/null +++ b/dsl/tools/stage0_lockstep_transport.dag @@ -0,0 +1,136 @@ +// tools/stage0_lockstep_transport.dag — shell transport for the stage0 regen-lockstep gate. +// +// The §6 enforcement the CI floor was MISSING: the committed v1 stage0 seed +// (`src/v1/stage0/src/*.rs`) must be a clean function of the `.dag` authorities. +// `regen_stage0 --verify` is the lockstep oracle — it self-compiles the `.dag` +// tree, then byte-compares every GENERATED_STAGE0_FILES entry, the split-crate +// boundary files, and the workspace-members region against the committed seed, +// failing (exit 1) on any drift. +// +// GREEN: `regen_stage0 --verify` over the live tree exits 0. +// RED receipt: clobber one committed generated seed file, run `--verify` +// (MUST fail), restore via `git checkout`. The +/- teeth: a drifted seed +// is caught. (Proven by execution at authoring time; this encodes it for CI.) +// +// Both transports are structured `ShellProgram`s rendered by `serialize_bash` +// (extdeps.languages.bash.program), mirroring tools.dsl_compile_clean_transport. +// The RED receipt overwrites a tracked file then restores it with `git checkout` +// (verify must read the on-disk committed seed, so — unlike the compile-clean +// perturb — it cannot stay in a TMP dir); the CI checkout is ephemeral. + +module tools.stage0_lockstep_transport + +import extdeps.shell +import extdeps.languages.bash.program { + ShellProgram, ShellStmt, ShellWord, + Command, Assign, If, Subshell, AndOr, WithRedir, Heredoc, Exit, + Lit, VarRef, Concat, CmdSubst, + AndThen, OrElse, StderrToNull, StdoutAndStderrToNull, + lit, var_ref, command, assign, serialize_bash +} + +// ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) +// REGEN="$ROOT"/target/release/regen_stage0 +// if [ ! -x "$REGEN" ]; then (cd "$ROOT" && cargo build -p v1-compiler --release --bin regen_stage0) || exit 1; fi +fn ensure_regen_stage0_built() -> List { + let root = var_ref(name: "ROOT") + let regen = var_ref(name: "REGEN") + [ + assign(name: "ROOT", value: CmdSubst { body: AndOr { + left: WithRedir { + stmt: command(words: [lit(text: "git"), lit(text: "rev-parse"), lit(text: "--show-toplevel")]), + redir: StderrToNull + }, + op: OrElse, + right: command(words: [lit(text: "pwd")]) + } }), + assign(name: "REGEN", value: Concat { parts: [root, lit(text: "/target/release/regen_stage0")] }), + If { + cond: command(words: [lit(text: "["), lit(text: "!"), lit(text: "-x"), regen, lit(text: "]")]), + then: [ + AndOr { + left: Subshell { body: [ + AndOr { + left: command(words: [lit(text: "cd"), root]), + op: AndThen, + right: command(words: [ + lit(text: "cargo"), lit(text: "build"), lit(text: "-p"), lit(text: "v1-compiler"), + lit(text: "--release"), lit(text: "--bin"), lit(text: "regen_stage0") + ]) + } + ] }, + op: OrElse, + right: Exit { code: 1 } + } + ] + } + ] +} + +// GREEN: ; "$REGEN" --verify +fn stage0_lockstep_verify_program() -> ShellProgram { + let regen = var_ref(name: "REGEN") + ShellProgram { + set_e: true, + statements: concat(ensure_regen_stage0_built(), [ + command(words: [regen, lit(text: "--verify")]) + ]) + } +} + +fn run_stage0_lockstep_verify() -> Bool { + let result = shell.Exec.Run(script: serialize_bash(p: stage0_lockstep_verify_program())) + result.success +} + +// The committed generated seed file the RED receipt clobbers. Any GENERATED +// entry works; std_node is a small, stable generated module. +data perturb_seed_relpath: String = "src/v1/stage0/src/std_node.rs" + +// Drift sentinel written over the seed file — content that a fresh self-compile +// will never reproduce, so `--verify` must report the byte mismatch. +data perturb_seed_drift_body: String = "// __stage0_lockstep_perturb_red__ planted drift sentinel — not a fixpoint of the .dag" + +// RED receipt: clobber one committed generated seed file, run `--verify` (MUST +// fail), restore via `git checkout` on both branches. If `--verify` SUCCEEDS on +// the drifted seed the gate is toothless → exit 1. +// set -e; +// cat > "$ROOT"/ <<'PERTURB' ... PERTURB +// if "$REGEN" --verify >/dev/null 2>&1; then git -C "$ROOT" checkout -- ; exit 1; fi +// git -C "$ROOT" checkout -- ; exit 0 +fn stage0_lockstep_perturb_program() -> ShellProgram { + let root = var_ref(name: "ROOT") + let regen = var_ref(name: "REGEN") + let seed_abs = Concat { parts: [root, lit(text: "/"), lit(text: perturb_seed_relpath)] } + let restore = command(words: [ + lit(text: "git"), lit(text: "-C"), root, lit(text: "checkout"), + lit(text: "--"), lit(text: perturb_seed_relpath) + ]) + ShellProgram { + set_e: true, + statements: concat(ensure_regen_stage0_built(), [ + Heredoc { + path: seed_abs, + delimiter: "PERTURB", + body: perturb_seed_drift_body + }, + If { + cond: WithRedir { + stmt: command(words: [regen, lit(text: "--verify")]), + redir: StdoutAndStderrToNull + }, + then: [ + restore, + Exit { code: 1 } + ] + }, + restore, + Exit { code: 0 } + ]) + } +} + +fn run_stage0_lockstep_perturb_red_receipt() -> Bool { + let result = shell.Exec.Run(script: serialize_bash(p: stage0_lockstep_perturb_program())) + result.success +} diff --git a/src/v2/workflow/ci_floor_plan.dag b/src/v2/workflow/ci_floor_plan.dag index 6a57c16492c..ae90d4bf2b0 100644 --- a/src/v2/workflow/ci_floor_plan.dag +++ b/src/v2/workflow/ci_floor_plan.dag @@ -30,7 +30,7 @@ import gunbc.ci_layer_roots { witness_layer_roots, witness_discovery_scan_dirs } import gunbc.ci_spec { gunbc_ci_spec, CiSpec, Gate, RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, - SourceRootIngestGate + SourceRootIngestGate, Stage0LockstepGate } import v2.std.algebra { list_snoc_item } import v2.std.collection { List } @@ -83,6 +83,7 @@ fn gate_node(g: Gate) -> Node { DslCompileCleanGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_compile } }, children: [] } CiYamlGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_ciyaml } }, children: [] } SourceRootIngestGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_sourceingest } }, children: [] } + Stage0LockstepGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_stage0_lockstep } }, children: [] } } } @@ -100,6 +101,7 @@ fn gate_runnable(g: Gate) -> Runnable { entry: floor_source_root_ingest_gate_entry, function: "source_root_ingest_gate_passes" } + Stage0LockstepGate => RunnableSingleClaim { entry: floor_gate_witness_entry, function: "stage0_lockstep_gate_passes" } } } From 1b340afec368976b167f0887995a2c9fe99ef625 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 22:05:33 +0000 Subject: [PATCH 06/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- dsl/tools/stage0_lockstep_gate.dag | 8 ++++++++ dsl/tools/stage0_lockstep_transport.dag | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/dsl/tools/stage0_lockstep_gate.dag b/dsl/tools/stage0_lockstep_gate.dag index 6ebe46cc21d..ae672e82d6f 100644 --- a/dsl/tools/stage0_lockstep_gate.dag +++ b/dsl/tools/stage0_lockstep_gate.dag @@ -8,6 +8,14 @@ // Run standalone: // cargo run -p v1-compiler --release --bin gunbc -- run \ // --source-root dsl --entry dsl/tools/stage0_lockstep_gate.dag --function main +// +// §2 DEDUP MARKER (dissolution trigger — prompt follow-up, not someday): this gate's +// `regen_stage0 --verify` self-compiles the .dag tree, and DslCompileCleanGate ALSO +// self-compiles the whole tree in the same floor run — TWO full self-compiles per CI +// pass (real §1-time redundancy). Dissolve by having the lockstep verify REUSE the +// DslCompileCleanGate whole-tree compile artifact (content-addressed) rather than +// recompiling. Landed as always-run (option A) now; this is the named optimization to +// reclaim the second compile once the artifact-reuse seam exists. module tools.stage0_lockstep_gate diff --git a/dsl/tools/stage0_lockstep_transport.dag b/dsl/tools/stage0_lockstep_transport.dag index 3f3912ad406..9bd9c364416 100644 --- a/dsl/tools/stage0_lockstep_transport.dag +++ b/dsl/tools/stage0_lockstep_transport.dag @@ -94,7 +94,18 @@ data perturb_seed_drift_body: String = "// __stage0_lockstep_perturb_red__ plant // RED receipt: clobber one committed generated seed file, run `--verify` (MUST // fail), restore via `git checkout` on both branches. If `--verify` SUCCEEDS on // the drifted seed the gate is toothless → exit 1. +// +// CRASH-SAFETY: this mutates a TRACKED seed file in place (verify must read the +// on-disk committed seed, so — unlike the compile-clean perturb — it cannot stay +// in a TMP dir). Two guards: (1) the floor gate is CI-EPHEMERAL — it runs in a +// fresh per-run checkout, so a crash cannot corrupt a persistent tree; (2) a +// fail-closed PRE-CHECK refuses to run if the seed is already dirty (`git diff +// --quiet`), so it never clobbers a dev's uncommitted seed and surfaces a prior +// crash's residue instead of compounding it. The bash program model has no +// `trap`, and `RawLine` is the banned transport-position escape hatch, so the +// pre-check + ephemeral-checkout posture is the model-expressible safety net. // set -e; +// git -C "$ROOT" diff --quiet -- || exit 1 # refuse to clobber a dirty seed // cat > "$ROOT"/ <<'PERTURB' ... PERTURB // if "$REGEN" --verify >/dev/null 2>&1; then git -C "$ROOT" checkout -- ; exit 1; fi // git -C "$ROOT" checkout -- ; exit 0 @@ -109,6 +120,14 @@ fn stage0_lockstep_perturb_program() -> ShellProgram { ShellProgram { set_e: true, statements: concat(ensure_regen_stage0_built(), [ + AndOr { + left: command(words: [ + lit(text: "git"), lit(text: "-C"), root, lit(text: "diff"), lit(text: "--quiet"), + lit(text: "--"), lit(text: perturb_seed_relpath) + ]), + op: OrElse, + right: Exit { code: 1 } + }, Heredoc { path: seed_abs, delimiter: "PERTURB", From 0f09bddecfb0e401e84e5d6b59179e938362dd5d Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 22:44:12 +0000 Subject: [PATCH 07/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- src/v1/05_emit_rust.dag | 195 +++- src/v1/stage0/src/v1_compiler_emit_rust.rs | 1160 +++++++++++--------- 2 files changed, 784 insertions(+), 571 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index a86ee4196d1..eb1baccc590 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -71,6 +71,7 @@ import extdeps.languages.rust.emit { rust_serde_rename_all_snake_case, rust_serde_rename_all_screaming_snake_case, HigherOrderMethodSpec, rust_higher_order_methods } +import extdeps.cargo_version { render_cargo_package_header_prefix } import v1.compiler.languages { scaffold_for_target, serialization_for_target, TestConventions, ItemKeywords, @@ -189,7 +190,12 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, Absent => emit_rust_compile_error_expr(message: "Set missing element type") } } else { - render_node_type(n: n, target: Rust, shared_types: shared_types, source_indices: source_indices) + let tn = authored_name_at(source_indices: source_indices, node: n) + if tn == "String" && n.children |> count == 0 { + render_rust_text_carrier(shared_types: shared_types) + } else { + render_node_type(n: n, target: Rust, shared_types: shared_types, source_indices: source_indices) + } } } @@ -201,9 +207,52 @@ fn rust_type_is_rc_wrapped(type_name: String) -> Bool { string_length(s: type_name) >= 3 && substring(s: type_name, start: 0, end: 3) == "Rc<" } +// §3 faithful DAG String carrier for v2 Rust self-host (String = FreeMonoid, Char = Nat). +fn render_rust_text_carrier(shared_types: Set) -> String { + render_rust_shared_type_if_needed(type_name: "FreeMonoid", rendered: "FreeMonoid", shared_types: shared_types) +} + +// §2 — route ALL host→DAG String boundary bridges through HostStringText seam (one authority). +fn emit_rust_host_to_dag_string_via_seam(host_expr: String) -> String { + concat("crate::v2_std_text::host_string_text_from_rust_host(", host_expr, ")") +} + +fn emit_rust_dag_string_to_host_via_seam(dag_expr: String) -> String { + concat("crate::v2_std_text::host_string_text_to_rust_host(", dag_expr, ")") +} + +fn rust_host_string_seam_fn_emit(name: String) -> String? { + if name == "host_string_text_from_rust_host" { + Present { value: concat( + "pub fn host_string_text_from_rust_host(host: String) -> String {\n", + " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ", + "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n", + "}\n" + ) } + } else if name == "host_string_text_to_rust_host" { + Present { value: concat( + "pub fn host_string_text_to_rust_host(text: String) -> String {\n", + " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n", + "}\n" + ) } + } else { + none + } +} + +fn rust_opaque_kernel_alias_carrier(name: String) -> String? { + if name == "Json" || name == "Bytes" { + Present { value: coerce_primitive_type(target: Rust, dag_name: name) } + } else { + none + } +} + fn rust_named_type_base(name: String) -> String { if name == "Witness" || name == "witness" { "Witness" + } else if name == "String" { + "FreeMonoid" } else { coerce_primitive_type(target: Rust, dag_name: name) } @@ -270,12 +319,20 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name } else if n.connective == NoConnective && n.children |> count == 0 { - rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: env) + if name == "String" { + render_rust_text_carrier(shared_types: shared_types) + } else { + rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: env) + } } else if n.connective == NoConnective && n.children |> count > 0 { + if !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { + render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) + } else { let base = rust_named_type_base(name: name) let args = n.children |> map(arg => render_rust_decl_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env)) |> join(separator: ", ") let applied_ty = concat(base, "<", args, ">") render_rust_shared_type_if_needed(type_name: name, rendered: applied_ty, shared_types: shared_types) + } } else { render_rust_type_with_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) } @@ -284,9 +341,15 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type // Compose generic-arg preservation with canonical rendering — do not replace the // applied-binding path when the enclosing item has type params. -// Closed type aliases (e.g. NanosecondDuration = Measure<...>) expand to applied -// shells in inference; fn signatures must emit the alias name only. +// RC3: Closed type aliases (e.g. String = FreeMonoid, NanosecondDuration = +// Measure<...>) expand to applied shells in inference; fn signatures and alias RHS +// must emit the alias name only. Alias RHS may be brand-preserved (children > 0); +// peel on declared param count, not structural child count. fn rust_fn_sig_peel_closed_alias(env: TypeEnv, n: Node) -> Bool { + let name = authored_name_at(source_indices: env.source_indices, node: n) + if name == "String" { + return false + } let binding = match lookup_type_for(env: env, node: n) { Present { value: b } => b Absent => @@ -296,19 +359,17 @@ fn rust_fn_sig_peel_closed_alias(env: TypeEnv, n: Node) -> Bool { Absent => return false } } - (binding.children |> count) == 0 && (binding.params |> count) == 0 + (binding.params |> count) == 0 } fn render_rust_fn_sig_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { - if generic_param_names |> count > 0 { + let name = authored_name_at(source_indices: source_indices, node: n) + if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { + render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) + } else if generic_param_names |> count > 0 { render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } else { - let name = authored_name_at(source_indices: source_indices, node: n) - if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { - render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) - } else { - render_rust_fn_sig_type_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices, env: env) - } + render_rust_fn_sig_type_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices, env: env) } } @@ -336,7 +397,12 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name } else if n.connective == NoConnective && n.children |> count == 0 { - rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: scope.type_env) + if name == "String" { + render_rust_text_carrier(shared_types: shared_types) + } else if match rust_opaque_kernel_alias_carrier(name: name) { + Present { value: carrier } => carrier + Absent => rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: scope.type_env) + } } else if n.connective == NoConnective && n.children |> count > 0 { let local_mod = module_to_filename(name: module_name) let def_mod = alias_rhs_rust_qualify_module_filename(name: name, alias_module: module_name, imports: imports, scope: scope, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) @@ -345,12 +411,20 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } else { name } - let args = n.children |> map(arg => render_rust_alias_rhs_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum)) |> join(separator: ", ") - let applied_ty = concat(base, "<", args, ">") - if set_contains(shared_types, name) && !rust_type_is_rc_wrapped(type_name: applied_ty) { - wrap_shared_type(target: Rust, inner: applied_ty) + if !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: scope.type_env, n: n) { + if set_contains(shared_types, name) && !rust_type_is_rc_wrapped(type_name: base) { + wrap_shared_type(target: Rust, inner: base) + } else { + base + } } else { - applied_ty + let args = n.children |> map(arg => render_rust_alias_rhs_type(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum)) |> join(separator: ", ") + let applied_ty = concat(base, "<", args, ">") + if set_contains(shared_types, name) && !rust_type_is_rc_wrapped(type_name: applied_ty) { + wrap_shared_type(target: Rust, inner: applied_ty) + } else { + applied_ty + } } } else { render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices) @@ -1108,7 +1182,10 @@ fn rust_render_type_leaf_name(name: String, variant_to_enum: Map if is_phantom_unit_variant_type_arg(env: env, variant_name: name) { name } else { - rust_qualify_type_leaf_name(name: name, variant_to_enum: variant_to_enum) + match rust_opaque_kernel_alias_carrier(name: name) { + Present { value: carrier } => carrier + Absent => rust_qualify_type_leaf_name(name: name, variant_to_enum: variant_to_enum) + } } } @@ -1364,7 +1441,7 @@ fn emit_lib_rs_from_files(all_module_files: List, has_compiler_tests: // rest_transport_facts.rs bounded substrate seed). // These are not generated — they survive regen as non-generated files. let hand_maintained_mods = if has_compiler_tests { - "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;" + "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;" } else { "" } @@ -1582,7 +1659,9 @@ fn has_physical_type_def_in_module_filename(rhs_name: String, mod_filename: Stri Present { value: mods } => mods |> any(tm => tm.items |> any(item => authored_name_at(source_indices: source_indices, node: item) == rhs_name - && is_type_def_item(item: item) + && (is_type_def_item(item: item) + || is_type_alias_item(item: item, source_indices: source_indices) + || is_type_decl_item(item: item, source_indices: source_indices)) ) ) Absent => false @@ -3291,6 +3370,9 @@ fn emit_variant_from_child(child: Node, enum_name: String, recursive_types: Set< // ========================================================================= fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, registry: Map, scope: InferScope, shared_types: Set, emit_info: EmitGraphInfo) -> String { + match rust_host_string_seam_fn_emit(name: name) { + Present { value: seam_fn } => seam_fn + Absent => { let si = scope.type_env.source_indices let type_params = function_type_params(params: params) let value_params = function_value_params(params: params) @@ -3318,6 +3400,8 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg } else { emit_fn_def_non_tco(name: name, type_params_str: type_params_str, params_str: params_str, ret_str: ret_str, body: body, registry: registry, scope: body_scope, depth: depth, shared_types: shared_types, emit_info: emit_info, needs_stacker: needs_stacker) } + } + } } fn emit_fn_def_non_tco(name: String, type_params_str: String, params_str: String, ret_str: String, body: Node, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo, needs_stacker: Bool) -> String { @@ -3479,11 +3563,7 @@ fn emit_params(params: List, generic_param_names: List, shared_typ // between the type signature and ownership analysis and breaks fixed-point. fn render_rust_param_sig_type(param: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { let type_node = resolved_type(n: param) - if generic_param_names |> count > 0 { - render_rust_decl_type(n: type_node, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) - } else { - render_rust_fn_sig_type(n: type_node, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) - } + render_rust_fn_sig_type(n: type_node, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } fn emit_rust_param_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { @@ -4706,7 +4786,7 @@ fn emit_discriminant_call_lowering(value_arg: Node, registry: Map \"", child_text, "\".to_string(),") + concat(" ", pat, " => ", emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", child_text, "\"")), ",") ) // Borrow the scrutinee so the arms (which never bind fields) don't move it. Shared types // are Rc-wrapped, so deref through the Rc with `&*` to reach `&T`; owned values use `&`. @@ -4718,9 +4798,9 @@ fn emit_discriminant_call_lowering(value_arg: Node, registry: Map join(separator: "\n"), "\n })") } else { // Product/record type: the discriminant is the type's own name (interpreter returns type_name). - concat("\"", ty_name, "\".to_string()") + emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", ty_name, "\"")) } - Absent => concat("\"", ty_name, "\".to_string()") + Absent => emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", ty_name, "\"")) } } @@ -4802,11 +4882,26 @@ fn emit_typed_call(func: String, args: List, registry: Map first { Present { value: value_arg } => - concat("(", emit_typed_expr(texpr: arg_value(n: value_arg), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024), ").to_string()") + emit_rust_host_to_dag_string_via_seam(host_expr: concat("(", emit_typed_expr(texpr: arg_value(n: value_arg), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024), ").to_string()")) Absent => "compile_error!(\"to_string call missing value argument\")" } return ts_result } + // `utf8_decode_bytes(payload)` — RFC 3629 decode of wire Bytes → String (fail-closed §5). + // REST Secret Manager AccessVersion returns decoded payload bytes; text secrets cross here. + if func == "utf8_decode_bytes" { + let decode_args = order_typed_call_args(args: args, func: func, scope: scope) + let decode_result = match decode_args |> first { + Present { value: value_arg } => + concat( + "String::from_utf8(", + emit_typed_expr(texpr: arg_value(n: value_arg), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024), + ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))?" + ) + Absent => "compile_error!(\"utf8_decode_bytes call missing value argument\")" + } + return decode_result + } if func == "discriminant" { let disc_args = order_typed_call_args(args: args, func: func, scope: scope) let disc_result = match disc_args |> first { @@ -6011,7 +6106,7 @@ fn emit_typed_record_lit(type_name: String?, fields: List, parent_enum: St fn rust_zero_value(type_name: String) -> String? { if type_name == "Int" { Present { value: "0" } } else if type_name == "Bool" { Present { value: "false" } } - else if type_name == "String" { Present { value: concat("\"\"", ".to_string()") } } + else if type_name == "String" { Present { value: "crate::v2_std_algebra::freemonoid_empty::()" } } else { none } } @@ -6026,11 +6121,11 @@ fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, ri let l_optional = is_optional_typed_expr(e: left) let r_optional = is_optional_typed_expr(e: right) if l_optional || r_optional { - let l_cmp = if l_optional { concat(l_str, ".as_deref()") } else { concat("Some(", l_str, ".as_str())") } - let r_cmp = if r_optional { concat(r_str, ".as_deref()") } else { concat("Some(", r_str, ".as_str())") } + let l_cmp = if l_optional { concat(l_str, ".as_deref()") } else { concat("Some(", emit_rust_dag_string_to_host_via_seam(dag_expr: l_str), ")") } + let r_cmp = if r_optional { concat(r_str, ".as_deref()") } else { concat("Some(", emit_rust_dag_string_to_host_via_seam(dag_expr: r_str), ")") } concat("(", l_cmp, " ", op_str, " ", r_cmp, ")") } else { - concat("(", l_str, ".as_str() ", op_str, " ", r_str, ".as_str())") + concat("(", emit_rust_dag_string_to_host_via_seam(dag_expr: l_str), " ", op_str, " ", emit_rust_dag_string_to_host_via_seam(dag_expr: r_str), ")") } } else { concat("(", l_str, " ", op_str, " ", r_str, ")") @@ -6072,10 +6167,10 @@ fn emit_typed_string_interp(parts: List, registry: Map map(p => p.arg_expr) |> filter(a => a != "") if args |> count == 0 { - concat("\"", fmt_str, "\".to_string()") + emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", fmt_str, "\"")) } else { let args_str = args |> join(separator: ", ") - concat("format!(\"", fmt_str, "\", ", args_str, ")") + emit_rust_host_to_dag_string_via_seam(host_expr: concat("format!(\"", fmt_str, "\", ", args_str, ")")) } } @@ -6703,8 +6798,8 @@ fn emit_rest_query_line(transport: Node, source_indices: Map { let pairs = q.children |> map(fi => concat("(\"", field_init_node_name_at(n: fi, source_indices: source_indices), "\", &", - emit_simple_expr(expr: field_init_node_value(n: fi), target: Rust, source_indices: source_indices), - ".to_string())") + emit_rust_dag_string_to_host_via_seam(dag_expr: emit_simple_expr(expr: field_init_node_value(n: fi), target: Rust, source_indices: source_indices)), + ")") ) if pairs |> count > 0 { concat("let request = request.query(&[", pairs |> join(separator: ", "), "]);") @@ -6886,8 +6981,8 @@ fn emit_json_value_extract(var_name: String, from_path: String, dag_type_name: S let escaped_path = from_path |> split("/") |> map(seg => escape_json_pointer_segment(seg: seg)) |> join(separator: "/") let pointer = concat("/", escaped_path) let rust_type = coerce_primitive_type(target: Rust, dag_name: dag_type_name) - let accessor = if rust_type == "String" { - concat(".and_then(|v| v.as_str()).map(|s| s.to_string()).ok_or(\"missing field: ", from_path, "\")?") + let accessor = if dag_type_name == "String" { + concat(".and_then(|v| v.as_str()).map(|s| crate::v2_std_text::host_string_text_from_rust_host(s.to_string())).ok_or(\"missing field: ", from_path, "\")?") } else if rust_type == "i64" { concat(".and_then(|v| v.as_i64()).ok_or(\"missing field: ", from_path, "\")?") } else if rust_type == "f64" { @@ -7026,7 +7121,7 @@ fn emit_exit_code_handling(op_node: Node, inferred: Node, source_indices: Map any(p => field_init_node_name_at(n: p, source_indices: source_indices) == "exit_nonzero") let exit_arms = exit_props |> map(p => emit_exit_arm(prop: p, inferred: inferred, source_indices: source_indices)) let default_arm = if has_nonzero { "" } - else { "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(stderr.into()) }," } + else { "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(crate::v2_std_text::host_string_text_from_rust_host(stderr)) }," } concat( "let exit_code = output.status.code().unwrap_or(-1);\n", "match exit_code {\n", @@ -7045,7 +7140,7 @@ fn emit_exit_arm(prop: Node, inferred: Node, source_indices: Map { ", emit_shell_return(inferred: inferred, source_indices: source_indices), " },") } else { - concat(" ", pattern, " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(stderr.into()) },") + concat(" ", pattern, " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(crate::v2_std_text::host_string_text_from_rust_host(stderr)) },") } } @@ -7144,9 +7239,9 @@ fn emit_shell_argv_element(arg: Node, optional_params: Map, source Absent => false } if is_opt { - concat("&", var_name, ".as_deref().unwrap_or(\"\").to_string()") + emit_rust_dag_string_to_host_via_seam(dag_expr: concat(var_name, ".as_deref().unwrap_or(\"\")")) } else { - concat("&", var_name, ".to_string()") + emit_rust_dag_string_to_host_via_seam(dag_expr: var_name) } } _ => emit_simple_expr(expr: arg, target: Rust, source_indices: source_indices) @@ -7400,7 +7495,7 @@ fn emit_data_def_body(type_node: Node, value: Node, registry: Map let inserts = value.children |> map(f => let val_str = emit_typed_expr(texpr: field_init_node_value(n: f), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) - concat(" __m.insert(\"", field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), "\".to_string(), ", val_str, ");") + concat(" __m.insert(", emit_rust_host_to_dag_string_via_seam(host_expr: concat("\"", field_init_node_name_at(n: f, source_indices: scope.type_env.source_indices), "\"")), ", ", val_str, ");") ) let inserts_str = inserts |> join(separator: "\n") concat(" let mut __m = HashMap::new();\n", @@ -7511,7 +7606,7 @@ fn emit_cargo_dep(name: String, version: String, features: List) -> Stri } fn emit_cargo_toml(crate_name: String, has_services: Bool) -> TextFile { - let header = concat("[package]\nname = \"", crate_name, "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n") + let header = concat(render_cargo_package_header_prefix(name: crate_name), "\nedition = \"2021\"\n") let workspace = "\n[workspace]\n" let base_deps = [ emit_cargo_dep(name: "serde", version: "1", features: ["derive", "rc"]), @@ -7886,8 +7981,12 @@ fn emit_cli_param_type_node(n: Node, source_indices: Map) "String" } else if n.children |> count == 0 { let nname = authored_name_at(source_indices: source_indices, node: n) - let mapped = coerce_primitive_type(target: Rust, dag_name: nname) - if mapped != nname { mapped } else { "String" } + if nname == "String" { + "String" + } else { + let mapped = coerce_primitive_type(target: Rust, dag_name: nname) + if mapped != nname { mapped } else { "String" } + } } else { "String" } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index d0eb62844b4..4308b36527c 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -83,6 +83,7 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; +use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -230,12 +231,19 @@ pub fn render_rust_type_without_applied_binding( None => emit_rust_compile_error_expr("Set missing element type".to_string()), } } else { - render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types, - source_indices.clone(), - ) + let tn = authored_name_at(source_indices.clone(), n.clone()); + if (tn.clone().as_str() == "String".to_string().as_str() + && ((n.children.clone().len() as i64) == 0)) + { + render_rust_text_carrier(shared_types.clone()) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) + } } } } @@ -249,11 +257,79 @@ pub fn rust_type_is_rc_wrapped(type_name: String) -> bool { && (v1_rt::substring(&type_name, 0, 3).as_str() == "Rc<".to_string().as_str())) } +pub fn render_rust_text_carrier(shared_types: Rc>) -> String { + render_rust_shared_type_if_needed( + "FreeMonoid".to_string(), + "FreeMonoid".to_string(), + shared_types, + ) +} + +pub fn emit_rust_host_to_dag_string_via_seam(host_expr: String) -> String { + v1_rt::concat( + v1_rt::concat( + "crate::v2_std_text::host_string_text_from_rust_host(".to_string(), + host_expr, + ), + ")".to_string(), + ) +} + +pub fn emit_rust_dag_string_to_host_via_seam(dag_expr: String) -> String { + v1_rt::concat( + v1_rt::concat( + "crate::v2_std_text::host_string_text_to_rust_host(".to_string(), + dag_expr, + ), + ")".to_string(), + ) +} + +pub fn rust_host_string_seam_fn_emit(name: String) -> Option { + if name.as_str() == "host_string_text_from_rust_host" { + Some(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), + " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string(), + ), + "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string(), + ), + "}\n".to_string(), + )) + } else if name.as_str() == "host_string_text_to_rust_host" { + Some(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), + " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string(), + ), + "}\n".to_string(), + ), + "".to_string(), + )) + } else { + None + } +} + +pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { + if (name.clone().as_str() == "Json".to_string().as_str()) + || (name.clone().as_str() == "Bytes".to_string().as_str()) + { + Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) + } else { + None + } +} + pub fn rust_named_type_base(name: String) -> String { if ((name.clone().as_str() == "Witness".to_string().as_str()) || (name.clone().as_str() == "witness".to_string().as_str())) { "Witness".to_string() + } else if name.clone().as_str() == "String".to_string().as_str() { + "FreeMonoid".to_string() } else { coerce_primitive_type(RenderTarget::Rust, name.clone()) } @@ -288,19 +364,10 @@ pub fn render_rust_applied_type_arg( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type( - n.clone(), - generic_param_names, - shared_types, - source_indices, - variant_to_enum, - env, - ), + _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), } } @@ -309,8 +376,6 @@ pub fn render_rust_applied_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { { let base = rust_named_type_base(authored_name_at(source_indices.clone(), n.clone())); @@ -326,8 +391,6 @@ pub fn render_rust_applied_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), )); } __result @@ -378,8 +441,6 @@ pub fn render_rust_decl_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, - env: Rc, ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( @@ -422,51 +483,39 @@ pub fn render_rust_decl_type( name.clone() } else { if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) + && ((n.children.clone().len() as i64) > 0)) { - rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - env.clone(), - ) - } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) { - { - let base = rust_named_type_base(name.clone()); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), - )); - } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, - shared_types.clone(), - ) - } - } else { - render_rust_type_with_applied_binding( - n.clone(), + let base = rust_named_type_base(name.clone()); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + )); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, shared_types.clone(), - source_indices.clone(), ) } + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types.clone(), + source_indices.clone(), + ) } } } @@ -475,20 +524,21 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - { - let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b.clone(), - None => { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { - Some(b) => b.clone(), - None => return false, - } - } - }; - (((binding.children.clone().len() as i64) == 0) - && ((binding.params.clone().len() as i64) == 0)) + let name = authored_name_at(env.source_indices.clone(), n.clone()); + if name.clone().as_str() == "String".to_string().as_str() { + return false; } + let binding = match lookup_type_for(env.clone(), n.clone()) { + Some(b) => b, + None => { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + match lookup_type_by_name(env.clone(), name) { + Some(b) => b, + None => return false, + } + } + }; + (binding.params.clone().len() as i64) == 0 } pub fn render_rust_fn_sig_type( @@ -496,36 +546,19 @@ pub fn render_rust_fn_sig_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { - if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type( - n.clone(), - generic_param_names.clone(), - shared_types, - source_indices.clone(), - variant_to_enum, - env.clone(), - ) + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0) + && !is_container_type(name.clone()) + && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) + { + render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types.clone()) + } else if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) } else { - { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !is_container_type(name.clone())) - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) - { - render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types) - } else { - render_rust_fn_sig_type_applied_binding( - n.clone(), - shared_types, - source_indices.clone(), - env.clone(), - ) - } - } + render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) } } @@ -542,37 +575,25 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if outer_name.as_str() != "" + && n.connective.clone() == Connective::NoConnective + && (n.children.clone().len() as i64) == 0 + && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if ((((outer_name.clone().as_str() != "".to_string().as_str()) - && (n.connective.clone() == Connective::NoConnective)) - && ((n.children.clone().len() as i64) == 0)) - && rust_fn_sig_peel_closed_alias(env, n.clone())) - { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name.clone(), - shared_types, - ) - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types, - source_indices.clone(), - ) - } + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name, + shared_types.clone(), + ) + } else { + render_rust_type_with_applied_binding(n, shared_types, source_indices) } } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types, - source_indices.clone(), - ) + render_rust_type_with_applied_binding(n, shared_types, source_indices) } } - None => { - render_rust_type_with_applied_binding(n.clone(), shared_types, source_indices.clone()) - } + None => render_rust_type_with_applied_binding(n, shared_types, source_indices), } } @@ -606,80 +627,94 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - { + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + { + if name.clone().as_str() == "String".to_string().as_str() { + render_rust_text_carrier(shared_types.clone()) + } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { + carrier + } else { rust_render_type_leaf_name( name.clone(), variant_to_enum.clone(), scope.type_env.clone(), ) - } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + } + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + { + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); + let base = if (def_mod.clone().as_str() != local_mod.as_str()) { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + }; + if !is_container_type(name.clone()) + && rust_fn_sig_peel_closed_alias(scope.type_env.clone(), n.clone()) { + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(base.clone())) { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( - name.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = if (def_mod.clone().as_str() != local_mod.as_str()) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - }; - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), - variant_to_enum.clone(), - )); - } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) - { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) - } else { - applied_ty.clone() - } + wrap_shared_type(RenderTarget::Rust, base.clone()) + } else { + base.clone() } } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + )); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + } else { + applied_ty.clone() + } } } + } else { + render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } @@ -1083,13 +1118,32 @@ pub fn rust_string_policy_for_naming( if (naming_name.clone().as_str() == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { - Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { - Some(suffix) => rust_serde_policy("".to_string(), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), -}, - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), -} + match required_literal_string_policy_field( + naming.clone(), + "prefix".to_string(), + source_indices.clone(), + ) { + Some(prefix) => match required_literal_string_policy_field( + naming.clone(), + "suffix".to_string(), + source_indices.clone(), + ) { + Some(suffix) => rust_serde_policy( + "".to_string(), + Some(prefix.clone()), + Some(suffix.clone()), + Some("StripAffixAndSnakeCase".to_string()), + ), + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal suffix" + .to_string(), + ), + }, + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal prefix" + .to_string(), + ), + } } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1191,13 +1245,38 @@ pub fn rust_internal_policy_for_naming( if (naming_name.clone().as_str() == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) { - match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { - Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { - Some(suffix) => rust_serde_policy(v1_rt::concat(v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string()), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), -}, - None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), -} + match required_literal_string_policy_field( + naming.clone(), + "prefix".to_string(), + source_indices.clone(), + ) { + Some(prefix) => match required_literal_string_policy_field( + naming.clone(), + "suffix".to_string(), + source_indices.clone(), + ) { + Some(suffix) => rust_serde_policy( + v1_rt::concat( + v1_rt::concat( + "#[serde(tag = \"".to_string(), + tag_field, + ), + "\")]".to_string(), + ), + Some(prefix.clone()), + Some(suffix.clone()), + Some("StripAffixAndSnakeCase".to_string()), + ), + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal suffix" + .to_string(), + ), + }, + None => rust_serde_error_policy( + "StripPrefixSuffixAndSnakeCase requires a literal prefix" + .to_string(), + ), + } } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -2072,170 +2151,6 @@ pub fn emit_rust_init_block_stmts( } } -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - match v1_rt::map_get(&variant_to_enum, name.clone()) { - Some(parent) => { - if (parent.clone().as_str() != "".to_string().as_str()) { - v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name.clone() - } else { - rust_qualify_type_leaf_name(name.clone(), variant_to_enum) - } -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - { - let markers = Rc::new({ - let mut __result = Vec::new(); - for child in Rc::new({ - let mut __result = Vec::new(); - for child in Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if ((child.children.clone().len() as i64) == 0) { - __result.push(child); - } - } - __result - }) - .iter() - .cloned() - { - if is_phantom_unit_variant_type_arg( - env.clone(), - authored_name(env.clone(), child.clone()), - ) { - __result.push(child); - } - } - __result - }) - .iter() - .cloned() - { - __result.push({ - let vname = authored_name(env.clone(), child.clone()); - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - vname.clone(), - ), - ";".to_string(), - ) - }); - } - __result - }) - .join(&"\n".to_string()); - markers - } -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for item in items.iter().cloned() { - if (is_type_def_item(item.clone()) && { - let mut __all = true; - for c in item.children.clone().iter().cloned() { - if !((c.children.clone().len() as i64) == 0) { - __all = false; - break; - } - } - __all - }) { - __result.push(item); - } - } - __result - }) - .iter() - .cloned() - .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { - item.children.clone().iter().cloned().fold( - acc, - |inner: Rc>, child: Rc| { - if ((child.children.clone().len() as i64) == 0) { - { - let vname = authored_name(env.clone(), child.clone()); - if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !{ - let mut __found = false; - for n in inner.clone().iter().cloned() { - if (n.clone().as_str() == vname.clone().as_str()) { - __found = true; - break; - } - } - __found - }) - { - v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) - } else { - inner.clone() - } - } - } else { - inner.clone() - } - }, - ) - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - vname.clone(), - ), - ";".to_string(), - )); - } - __result - }) - .join(&"\n".to_string()) -} - pub fn has_complex_variants(item: Rc) -> bool { if ((item.children.clone().len() as i64) == 0) { false @@ -2775,7 +2690,7 @@ pub fn emit_lib_rs_from_files( __result }); let hand_maintained_mods = if has_compiler_tests.clone() { - "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;".to_string() + "\npub mod v1_interpreter;\npub mod cli_run;\npub mod rest_transport_facts;\npub mod wire_value_serialize;\npub mod coproduct_reflection;\npub mod resolved_graph_cache;\npub mod recorded_fixture;\npub mod extdeps_shape_transport_policy_project;\npub mod fact_cardinality_census;\npub mod import_resolution_project;\npub mod layering_imports_project;\npub mod module_path_index;\npub mod transport_script_position_project;".to_string() } else { "".to_string() }; @@ -3093,10 +3008,10 @@ pub fn emit_module_full( .join(&"\n\n".to_string()); let phantom_zst_markers = emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); - let phantom_section = if (phantom_zst_markers.clone().as_str() == "".to_string().as_str()) { + let phantom_section = if phantom_zst_markers.as_str() == "" { "".to_string() } else { - v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) + v1_rt::concat("\n\n".to_string(), phantom_zst_markers) }; let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { @@ -3309,7 +3224,9 @@ pub fn has_physical_type_def_in_module_filename( for item in tm.items.clone().iter().cloned() { if ((authored_name_at(source_indices.clone(), item.clone()).as_str() == rhs_name.clone().as_str()) - && is_type_def_item(item.clone())) + && (is_type_def_item(item.clone()) + || is_type_alias_item(item.clone(), source_indices.clone()) + || is_type_decl_item(item.clone(), source_indices.clone()))) { __found = true; break; @@ -6748,27 +6665,25 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if outer_name.as_str() != "" + && outer_name != applied_name + && n.connective.clone() == Connective::NoConnective + && (n.children.clone().len() as i64) == 0 { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if ((((outer_name.clone().as_str() != "".to_string().as_str()) - && (outer_name.clone().as_str() != applied_name.as_str())) - && (n.connective.clone() == Connective::NoConnective)) - && ((n.children.clone().len() as i64) == 0)) - { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name.clone(), - shared_types, - ) - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types, - source_indices.clone(), - ) - } + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name, + shared_types.clone(), + ) + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types, + source_indices.clone(), + ) } } else { render_rust_type(n.clone(), shared_types, source_indices.clone()) @@ -7511,41 +7426,87 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } -pub fn wire_variant_rename_attr_for_policy( +pub fn wire_variant_tag_for_policy( authored: String, policy: Rc, -) -> String { +) -> Option { + if policy.error_message.is_some() { + return None; + } match policy.rename_style.clone() { Some(style) => { - if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { - { - let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix.clone()) { - Some(stripped) => stripped.clone(), - None => return "".to_string(), - }, - None => authored, - }; - let without_suffix = match policy.rename_suffix.clone() { - Some(suffix) => match string_without_suffix(without_prefix, suffix.clone()) - { - Some(stripped) => stripped.clone(), - None => return "".to_string(), - }, - None => without_prefix, - }; + if style.as_str() == "StripAffixAndSnakeCase" { + let without_prefix = match policy.rename_prefix.clone() { + Some(prefix) => match string_without_prefix(authored, prefix) { + Some(stripped) => stripped, + None => return None, + }, + None => authored, + }; + let without_suffix = match policy.rename_suffix.clone() { + Some(suffix) => match string_without_suffix(without_prefix, suffix) { + Some(stripped) => stripped, + None => return None, + }, + None => without_prefix, + }; + Some(to_snake(without_suffix)) + } else { + None + } + } + None => { + if policy.enum_attr.contains("rename_all = \"snake_case\"") { + Some(to_snake(authored)) + } else if policy.enum_attr.is_empty() + && policy.rename_prefix.is_none() + && policy.rename_suffix.is_none() + { + Some(authored) + } else { + None + } + } + } +} + +pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { + let needle = "tag = \""; + let start = policy.enum_attr.find(needle)? + needle.len(); + let rest = &policy.enum_attr[start..]; + let end = rest.find('"')?; + Some(rest[..end].to_string()) +} + +pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { + policy.enum_attr.contains("untagged") +} + +pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { + !policy.enum_attr.contains("tag =") + && policy.rename_prefix.is_none() + && policy.rename_suffix.is_none() + && policy.rename_style.is_none() +} + +pub fn wire_variant_rename_attr_for_policy( + authored: String, + policy: Rc, +) -> String { + match wire_variant_tag_for_policy(authored, policy.clone()) { + Some(tag) => match policy.rename_style.clone() { + Some(style) => { + if style.as_str() == "StripAffixAndSnakeCase" { v1_rt::concat( - v1_rt::concat( - " #[serde(rename = \"".to_string(), - to_snake(without_suffix), - ), + v1_rt::concat(" #[serde(rename = \"".to_string(), tag), "\")]\n".to_string(), ) + } else { + "".to_string() } - } else { - "".to_string() } - } + None => "".to_string(), + }, None => "".to_string(), } } @@ -7940,6 +7901,9 @@ pub fn emit_fn_def( shared_types: Rc>, emit_info: Rc, ) -> String { + if let Some(seam_fn) = rust_host_string_seam_fn_emit(name.clone()) { + return seam_fn; + } { let si = scope.type_env.clone().source_indices.clone(); let type_params = function_type_params(params.clone()); @@ -7961,7 +7925,6 @@ pub fn emit_fn_def( shared_types.clone(), si.clone(), emit_info.read_only_params.clone(), - emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let ret_str = emit_inferred( @@ -7969,7 +7932,6 @@ pub fn emit_fn_def( generic_param_names.clone(), shared_types.clone(), si.clone(), - emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let body_scope = build_params_scope(scope.clone(), value_params.clone()); @@ -7985,7 +7947,6 @@ pub fn emit_fn_def( generic_param_names.clone(), shared_types.clone(), si.clone(), - emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let body_str = emit_typed_tco_body( @@ -8215,6 +8176,7 @@ pub fn emit_func_def( shared_types.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), + scope.type_env.clone(), ); let ret_str = emit_func_inferred( inferred, @@ -8433,7 +8395,6 @@ pub fn emit_tco_params( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8445,7 +8406,6 @@ pub fn emit_tco_params( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -8460,7 +8420,6 @@ pub fn emit_tco_param( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8471,8 +8430,7 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( @@ -8480,7 +8438,6 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, env, ) }; @@ -8507,6 +8464,7 @@ pub fn emit_func_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + env: Rc, ) -> String { { let param_strs = Rc::new({ @@ -8518,6 +8476,7 @@ pub fn emit_func_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), + env.clone(), )); } __result @@ -8577,7 +8536,6 @@ pub fn emit_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8590,7 +8548,6 @@ pub fn emit_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -8605,30 +8562,17 @@ pub fn render_rust_param_sig_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { { - let type_node = resolved_type(param); - if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type( - type_node, - generic_param_names.clone(), - shared_types, - source_indices, - variant_to_enum, - env, - ) - } else { - render_rust_fn_sig_type( - type_node, - generic_param_names.clone(), - shared_types, - source_indices, - variant_to_enum, - env, - ) - } + let type_node = resolved_type(param.clone()); + render_rust_fn_sig_type( + type_node, + generic_param_names, + shared_types, + source_indices, + env, + ) } } @@ -8637,7 +8581,6 @@ pub fn emit_rust_param_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { if ((n.params.clone().len() as i64) > 0) { @@ -8650,7 +8593,6 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), )); } @@ -8663,7 +8605,6 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -8685,8 +8626,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - variant_to_enum.clone(), - env.clone(), + env, ) } } @@ -8697,7 +8637,6 @@ pub fn emit_param( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, - variant_to_enum: Rc>, env: Rc, ) -> String { { @@ -8708,8 +8647,7 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, - env, + env.clone(), ) } else { render_rust_param_sig_type( @@ -8717,7 +8655,6 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), - variant_to_enum, env, ) }; @@ -8737,7 +8674,6 @@ pub fn emit_inferred( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, - variant_to_enum: Rc>, env: Rc, ) -> String { v1_rt::concat( @@ -8747,7 +8683,6 @@ pub fn emit_inferred( generic_param_names, shared_types, source_indices, - variant_to_enum, env, ), ) @@ -10481,6 +10416,117 @@ pub fn clone_iterator_suffix() -> String { sharing_for_target(RenderTarget::Rust).clone_suffix.clone() } +pub fn rust_qualify_type_leaf_name( + name: String, + variant_to_enum: Rc>, +) -> String { + match v1_rt::map_get(&variant_to_enum, name.clone()) { + Some(parent) => { + if parent.as_str() != "" { + v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: String, + variant_to_enum: Rc>, + env: Rc, +) -> String { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name + } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { + carrier + } else { + rust_qualify_type_leaf_name(name, variant_to_enum) + } +} + +pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if (child.children.clone().len() as i64) == 0 { + let vname = authored_name(env.clone(), child.clone()); + if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + v1_rt::concat(vname, ";".to_string()), + )); + } + } + } + __result + }) + .join("\n") +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut names: Vec = Vec::new(); + for item in items.iter().cloned() { + if is_type_def_item(item.clone()) + && item + .children + .clone() + .iter() + .all(|c| c.children.clone().len() as i64 == 0) + { + for child in item.children.clone().iter().cloned() { + if (child.children.clone().len() as i64) == 0 { + let vname = authored_name(env.clone(), child.clone()); + if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !names.iter().any(|n| n == &vname) + { + names.push(vname); + } + } + } + } + } + names + }) +} + +pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env.clone()) + .iter() + .cloned() + { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + v1_rt::concat(vname, ";".to_string()), + )); + } + __result + }) + .join("\n") +} + pub fn effective_variant_parent( name: String, binding_kind: Option>, @@ -11974,11 +12020,14 @@ pub fn emit_discriminant_call_lowering( v1_rt::concat( v1_rt::concat( v1_rt::concat(" ".to_string(), pat.clone()), - " => \"".to_string(), + " => ".to_string(), ), - child_text.clone(), + emit_rust_host_to_dag_string_via_seam(v1_rt::concat( + v1_rt::concat("\"".to_string(), child_text.clone()), + "\"".to_string(), + )), ), - "\".to_string(),".to_string(), + ",".to_string(), ) }); } @@ -12007,16 +12056,16 @@ pub fn emit_discriminant_call_lowering( ) } } else { - v1_rt::concat( + emit_rust_host_to_dag_string_via_seam(v1_rt::concat( v1_rt::concat("\"".to_string(), ty_name.clone()), - "\".to_string()".to_string(), - ) + "\"".to_string(), + )) } } - None => v1_rt::concat( + None => emit_rust_host_to_dag_string_via_seam(v1_rt::concat( v1_rt::concat("\"".to_string(), ty_name.clone()), - "\".to_string()".to_string(), - ), + "\"".to_string(), + )), } } } @@ -12248,7 +12297,7 @@ pub fn emit_typed_call( let to_string_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let ts_result = match to_string_args.first().cloned() { - Some(value_arg) => v1_rt::concat( + Some(value_arg) => emit_rust_host_to_dag_string_via_seam(v1_rt::concat( v1_rt::concat( "(".to_string(), emit_typed_expr( @@ -12262,12 +12311,43 @@ pub fn emit_typed_call( ), ), ").to_string()".to_string(), - ), + )), None => "compile_error!(\"to_string call missing value argument\")".to_string(), }; return ts_result; } } + if (func.clone().as_str() == "utf8_decode_bytes".to_string().as_str()) { + { + let decode_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); + let decode_result = match decode_args.first().cloned() { + Some(value_arg) => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "String::from_utf8(".to_string(), + emit_typed_expr( + arg_value(value_arg.clone()), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ), + ), + ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {e}\"))?" + .to_string(), + ), + "".to_string(), + ), + None => { + "compile_error!(\"utf8_decode_bytes call missing value argument\")" + .to_string() + } + }; + return decode_result; + } + } if (func.clone().as_str() == "discriminant".to_string().as_str()) { { let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -16126,10 +16206,10 @@ pub fn rust_zero_value(type_name: String) -> Option { Some("false".to_string()) } else { if (type_name.clone().as_str() == "String".to_string().as_str()) { - Some(v1_rt::concat( - "\"\"".to_string(), - ".to_string()".to_string(), - )) + Some( + "crate::v2_std_algebra::freemonoid_empty::()" + .to_string(), + ) } else { None } @@ -16187,16 +16267,22 @@ pub fn emit_typed_bin_op( v1_rt::concat(l_str, ".as_deref()".to_string()) } else { v1_rt::concat( - v1_rt::concat("Some(".to_string(), l_str), - ".as_str())".to_string(), + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), + ), + ")".to_string(), ) }; let r_cmp = if r_optional.clone() { v1_rt::concat(r_str, ".as_deref()".to_string()) } else { v1_rt::concat( - v1_rt::concat("Some(".to_string(), r_str), - ".as_str())".to_string(), + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ")".to_string(), ) }; v1_rt::concat( @@ -16222,16 +16308,21 @@ pub fn emit_typed_bin_op( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("(".to_string(), l_str), - ".as_str() ".to_string(), + v1_rt::concat( + "(".to_string(), + emit_rust_dag_string_to_host_via_seam( + l_str.clone(), + ), + ), + " ".to_string(), ), op_str, ), " ".to_string(), ), - r_str, + emit_rust_dag_string_to_host_via_seam(r_str.clone()), ), - ".as_str())".to_string(), + ")".to_string(), ) } } @@ -16368,14 +16459,14 @@ pub fn emit_typed_string_interp( __result }); if ((args.clone().len() as i64) == 0) { - v1_rt::concat( + emit_rust_host_to_dag_string_via_seam(v1_rt::concat( v1_rt::concat("\"".to_string(), fmt_str), - "\".to_string()".to_string(), - ) + "\"".to_string(), + )) } else { { let args_str = args.clone().join(&", ".to_string()); - v1_rt::concat( + emit_rust_host_to_dag_string_via_seam(v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat("format!(\"".to_string(), fmt_str), @@ -16384,7 +16475,7 @@ pub fn emit_typed_string_interp( args_str, ), ")".to_string(), - ) + )) } } } @@ -17806,8 +17897,7 @@ pub fn emit_operation_method( Rc::new(vec![]), shared_types.clone(), env.source_indices.clone(), - v1_rt::rc_empty_map::(), - env.clone().clone(), + env.clone(), ), )); } @@ -18410,13 +18500,13 @@ pub fn emit_rest_query_line( ), "\", &".to_string(), ), - emit_simple_expr( + emit_rust_dag_string_to_host_via_seam(emit_simple_expr( field_init_node_value(fi.clone()), RenderTarget::Rust, source_indices.clone(), - ), + )), ), - ".to_string())".to_string(), + ")".to_string(), )); } __result @@ -18863,11 +18953,12 @@ pub fn emit_json_value_extract( }) .join(&"/".to_string()); let pointer = v1_rt::concat("/".to_string(), escaped_path); + let is_dag_string = dag_type_name.as_str() == "String"; let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name); - let accessor = if (rust_type.clone().as_str() == "String".to_string().as_str()) { + let accessor = if is_dag_string { v1_rt::concat( v1_rt::concat( - ".and_then(|v| v.as_str()).map(|s| s.to_string()).ok_or(\"missing field: " + ".and_then(|v| v.as_str()).map(|s| crate::v2_std_text::host_string_text_from_rust_host(s.to_string())).ok_or(\"missing field: " .to_string(), from_path.clone(), ), @@ -19253,7 +19344,7 @@ pub fn emit_exit_code_handling( let default_arm = if has_nonzero { "".to_string() } else { - "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(stderr.into()) },".to_string() + "\n _ => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(crate::v2_std_text::host_string_text_from_rust_host(stderr)) },".to_string() }; v1_rt::concat( v1_rt::concat( @@ -19299,7 +19390,7 @@ pub fn emit_exit_arm( " },".to_string(), ) } else { - v1_rt::concat(v1_rt::concat(" ".to_string(), pattern), " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(stderr.into()) },".to_string()) + v1_rt::concat(v1_rt::concat(" ".to_string(), pattern), " => { let stderr = String::from_utf8_lossy(&output.stderr).to_string(); Err(crate::v2_std_text::host_string_text_from_rust_host(stderr)) },".to_string()) } } } @@ -19588,15 +19679,12 @@ pub fn emit_shell_argv_element( None => false, }); if is_opt.clone() { - v1_rt::concat( - v1_rt::concat("&".to_string(), var_name.clone()), - ".as_deref().unwrap_or(\"\").to_string()".to_string(), - ) + emit_rust_dag_string_to_host_via_seam(v1_rt::concat( + var_name.clone(), + ".as_deref().unwrap_or(\"\")".to_string(), + )) } else { - v1_rt::concat( - v1_rt::concat("&".to_string(), var_name.clone()), - ".to_string()".to_string(), - ) + emit_rust_dag_string_to_host_via_seam(var_name.clone()) } } _ => emit_simple_expr(arg.clone(), RenderTarget::Rust, source_indices.clone()), @@ -19839,8 +19927,7 @@ pub fn emit_capability_method( Rc::new(vec![]), shared_types.clone(), env.source_indices.clone(), - v1_rt::rc_empty_map::(), - env.clone().clone(), + env.clone(), ), )); } @@ -20265,22 +20352,33 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - " __m.insert(\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + " __m.insert(".to_string(), + emit_rust_host_to_dag_string_via_seam( + v1_rt::concat( + v1_rt::concat( + "\"".to_string(), + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), + ), + ), + "\"".to_string(), ), ), - "\".to_string(), ".to_string(), ), - val_str.clone(), + v1_rt::concat( + v1_rt::concat( + ", ".to_string(), + val_str.clone(), + ), + ");".to_string(), + ), ), - ");".to_string(), + "".to_string(), ) }); } @@ -20415,6 +20513,14 @@ pub fn emit_test_file( pub fn rust_test_signature_comment(projection: Rc) -> String { { + let stub_env = Rc::new(TypeEnv { + bindings: Rc::new(HashMap::new()), + recursive_types: Rc::new(vec![]), + recursive_type_set: Rc::new(HashMap::new()), + inductive_fields: Rc::new(HashMap::new()), + source_indices: projection.source_indices.clone(), + intern_table: empty_intern_table(), + }); let params_str = Rc::new({ let mut __result = Vec::new(); for p in projection.params.clone().iter().cloned() { @@ -20428,7 +20534,7 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { Rc::new(vec![]), v1_rt::rc_empty_set::(), projection.source_indices.clone(), - v1_rt::rc_empty_map::(), + stub_env.clone(), ), )); } @@ -21580,7 +21686,15 @@ pub fn emit_compile_match_arm(crate_name: String) -> String { } pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) + v1_rt::concat( + v1_rt::concat( + "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" + .to_string(), + " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" + .to_string(), + ), + " },".to_string(), + ) } pub fn emit_main_pipeline_fns(crate_name: String) -> String { From 34daedaaa1112c4a82bcd2d7dd710f7ee6c11611 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 19 Jun 2026 22:55:24 +0000 Subject: [PATCH 08/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- dsl/tools/stage0_lockstep_gate.dag | 9 +++ src/v1/05_emit_rust.dag | 102 ++++++++++++++++++++++++----- src/v1/stage0/src/lib.rs | 10 +++ src/v1/stage0/src/std_types.rs | 4 +- 4 files changed, 105 insertions(+), 20 deletions(-) diff --git a/dsl/tools/stage0_lockstep_gate.dag b/dsl/tools/stage0_lockstep_gate.dag index ae672e82d6f..ffea2ef6c86 100644 --- a/dsl/tools/stage0_lockstep_gate.dag +++ b/dsl/tools/stage0_lockstep_gate.dag @@ -5,6 +5,15 @@ // `regen_stage0 --verify` (the lockstep oracle) over the live tree (GREEN) plus // a planted-drift RED receipt (the +/- teeth), mirroring tools.dsl_compile_clean_gate. // +// Catches drift the existing floor MISSES — two observed data points: (1) a +// hand-patched seed fn with no `.dag` source (the policy accessors that lived +// seed-only) regen-drops on a fresh self-compile, which `regen_stage0 --verify` +// flags but a typecheck of the committed seed does not; (2) a parse error in the +// emitter `.dag` that surfaces ONLY in regen's self-compile of the v1 tree — a PR +// whose `DslCompileCleanGate` was GREEN still failed `regen_stage0 --verify` (a +// parser-strictness divergence / compile-clean blind spot). Both are seed↔.dag +// lockstep failures the regen oracle detects and the rest of the floor does not. +// // Run standalone: // cargo run -p v1-compiler --release --bin gunbc -- run \ // --source-root dsl --entry dsl/tools/stage0_lockstep_gate.dag --function main diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index eb1baccc590..2cb5d8e5346 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -3211,27 +3211,93 @@ fn string_without_suffix(value: String, suffix: String) -> String? { } } -fn wire_variant_rename_attr_for_policy(authored: String, policy: RustEnumWireSerde) -> String { - match policy.rename_style { - Present { value: style } => - if style == "StripAffixAndSnakeCase" { - let without_prefix = match policy.rename_prefix { - Present { value: prefix } => match string_without_prefix(value: authored, prefix: prefix) { - Present { value: stripped } => stripped - Absent => return "" +fn string_index_of_from(haystack: String, needle: String, pos: Int) -> Int? { + if pos + string_length(s: needle) > string_length(s: haystack) { + none + } else if substring(s: haystack, start: pos, end: pos + string_length(s: needle)) == needle { + Present { value: pos } + } else { + string_index_of_from(haystack: haystack, needle: needle, pos: pos + 1) + } +} + +fn string_index_of(haystack: String, needle: String) -> Int? { + string_index_of_from(haystack: haystack, needle: needle, pos: 0) +} + +fn wire_variant_tag_for_policy(authored: String, policy: RustEnumWireSerde) -> String? { + if policy.error_message != none { + none + } else { + match policy.rename_style { + Present { value: style } => + if style == "StripAffixAndSnakeCase" { + let without_prefix = match policy.rename_prefix { + Present { value: prefix } => match string_without_prefix(value: authored, prefix: prefix) { + Present { value: stripped } => stripped + Absent => return none + } + Absent => authored } - Absent => authored - } - let without_suffix = match policy.rename_suffix { - Present { value: suffix } => match string_without_suffix(value: without_prefix, suffix: suffix) { - Present { value: stripped } => stripped - Absent => return "" + let without_suffix = match policy.rename_suffix { + Present { value: suffix } => match string_without_suffix(value: without_prefix, suffix: suffix) { + Present { value: stripped } => stripped + Absent => return none + } + Absent => without_prefix } - Absent => without_prefix + Present { value: to_snake(name: without_suffix) } + } else { + none } - concat(" #[serde(rename = \"", to_snake(name: without_suffix), "\")]\n") - } else { - "" + Absent => + if contains(policy.enum_attr, "rename_all = \"snake_case\"") { + Present { value: to_snake(name: authored) } + } else if policy.enum_attr == "" && policy.rename_prefix == none && policy.rename_suffix == none { + Present { value: authored } + } else { + none + } + } + } +} + +fn policy_serde_tag_field(policy: RustEnumWireSerde) -> String? { + let needle = "tag = \"" + match string_index_of(haystack: policy.enum_attr, needle: needle) { + Present { value: start } => + let after = start + string_length(s: needle) + match string_index_of_from(haystack: policy.enum_attr, needle: "\"", pos: after) { + Present { value: end } => + Present { value: substring(s: policy.enum_attr, start: after, end: end) } + Absent => none + } + Absent => none + } +} + +fn policy_is_untagged(policy: RustEnumWireSerde) -> Bool { + contains(policy.enum_attr, "untagged") +} + +fn policy_is_string_variant(policy: RustEnumWireSerde) -> Bool { + !contains(policy.enum_attr, "tag =") + && policy.rename_prefix == none + && policy.rename_suffix == none + && policy.rename_style == none +} + +fn wire_variant_rename_attr_for_policy(authored: String, policy: RustEnumWireSerde) -> String { + match wire_variant_tag_for_policy(authored: authored, policy: policy) { + Present { value: tag } => + match policy.rename_style { + Present { value: style } => + if style == "StripAffixAndSnakeCase" { + concat(" #[serde(rename = \"", tag, "\")]\n") + } else { + "" + } + Absent => "" } Absent => "" } diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index be4f2f0ac56..2cb62540a9c 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -84,6 +84,16 @@ pub mod v1_interpreter; pub mod v1_rt; pub mod v1_std_core; pub mod wire_value_serialize; +// BOOTSTRAP-ONLY (diagnostic): A-fix declares these 7 hand-maintained mods; the +// committed lib.rs predates A, so add them by hand to break the regen chicken-and-egg. +// regen_stage0 overwrites lib.rs with identical content (emitter now produces 13 mods). +pub mod recorded_fixture; +pub mod extdeps_shape_transport_policy_project; +pub mod fact_cardinality_census; +pub mod import_resolution_project; +pub mod layering_imports_project; +pub mod module_path_index; +pub mod transport_script_position_project; #[derive(Debug, Clone, PartialEq)] pub struct NonEmptyVec(Vec); diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index 203ebaf52bc..29388f2fc50 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -236,9 +236,9 @@ pub enum Bool { False, } -pub type Json = Json; +pub type Json = serde_json::Value; -pub type Bytes = Bytes; +pub type Bytes = Vec; pub type Char = i64; From 632a4b50c96b4c6cbe2e3de3f2529fedb432b305 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 00:23:52 +0000 Subject: [PATCH 09/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- src/v1/05_emit_rust.dag | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 2cb5d8e5346..38c30dbbee9 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -162,7 +162,7 @@ fn render_rust_type(n: Node, shared_types: Set, source_indices: Map if applied.children |> count > 0 { - render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices) + render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } else { render_rust_type_without_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices) } @@ -173,7 +173,7 @@ fn render_rust_type(n: Node, shared_types: Set, source_indices: Map, source_indices: Map) -> String { if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) { - render_rust_applied_type_shared(n: n, generic_param_names: [], shared_types: shared_types, source_indices: source_indices) + render_rust_applied_type_shared(n: n, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } else if node_is_set_collection(n: n, source_indices: source_indices) { match n.children |> first { Present { value: elem_child } => @@ -296,8 +296,8 @@ fn render_rust_shared_type_if_needed(type_name: String, rendered: String, shared } // Single authority: shared_types decides Rc<> on rendered Rust type shells. -fn render_rust_applied_type_shared(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map) -> String { - let rendered = render_rust_applied_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices) +fn render_rust_applied_type_shared(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, variant_to_enum: Map, env: TypeEnv) -> String { + let rendered = render_rust_applied_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) let type_name = authored_name_at(source_indices: source_indices, node: n) render_rust_shared_type_if_needed(type_name: type_name, rendered: rendered, shared_types: shared_types) } @@ -313,17 +313,16 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type } match applied_overlay { Present { value: applied } => - render_rust_applied_type_shared(n: applied, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices) + render_rust_applied_type_shared(n: applied, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) Absent => let name = authored_name_at(source_indices: source_indices, node: n) if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { name - } else if n.connective == NoConnective && n.children |> count == 0 { - if name == "String" { - render_rust_text_carrier(shared_types: shared_types) - } else { - rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: env) - } + } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && name == "String" { + render_rust_text_carrier(shared_types: shared_types) + } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && set_contains(shared_types, name) { + let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: env) + render_rust_shared_type_if_needed(type_name: name, rendered: rendered, shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count > 0 { if !is_container_type(name: name) && rust_fn_sig_peel_closed_alias(env: env, n: n) { render_rust_shared_type_if_needed(type_name: name, rendered: name, shared_types: shared_types) @@ -401,7 +400,10 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared render_rust_text_carrier(shared_types: shared_types) } else if match rust_opaque_kernel_alias_carrier(name: name) { Present { value: carrier } => carrier - Absent => rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: scope.type_env) + Absent => { + let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: scope.type_env) + render_rust_shared_type_if_needed(type_name: name, rendered: rendered, shared_types: shared_types) + } } } else if n.connective == NoConnective && n.children |> count > 0 { let local_mod = module_to_filename(name: module_name) @@ -3027,7 +3029,7 @@ fn render_rust_type_with_applied_binding(n: Node, shared_types: Set, sou if outer_name != "" && outer_name != applied_name && n.connective == NoConnective && (n.children |> count) == 0 { render_rust_shared_type_if_needed(type_name: outer_name, rendered: outer_name, shared_types: shared_types) } else { - render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices) + render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table() }) } } else { render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices) @@ -3516,7 +3518,7 @@ fn emit_func_def( Present { value: info } => info.service_names Absent => [] } - let params_str = emit_func_params(params: params, uses: uses, service_names: service_names, shared_types: shared_types, source_indices: scope.type_env.source_indices, read_only_params: emit_info.read_only_params) + let params_str = emit_func_params(params: params, uses: uses, service_names: service_names, shared_types: shared_types, source_indices: scope.type_env.source_indices, read_only_params: emit_info.read_only_params, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) let ret_str = emit_func_inferred(inferred: inferred, shared_types: shared_types, source_indices: scope.type_env.source_indices) let body_scope = build_params_scope(scope: scope, params: params) let si = scope.type_env.source_indices @@ -3589,8 +3591,8 @@ fn emit_tco_param(param: Node, generic_param_names: List, shared_types: concat("mut ", emit_ident(name: param_node_name_at(n: param, source_indices: source_indices), target: Rust), rust_items().param_type_sep, ty) } -fn emit_func_params(params: List, uses: List, service_names: List, shared_types: Set, source_indices: Map, read_only_params: Set) -> String { - let param_strs = params |> map(p => emit_param(param: p, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, read_only_params: read_only_params)) +fn emit_func_params(params: List, uses: List, service_names: List, shared_types: Set, source_indices: Map, read_only_params: Set, variant_to_enum: Map, env: TypeEnv) -> String { + let param_strs = params |> map(p => emit_param(param: p, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, read_only_params: read_only_params, variant_to_enum: variant_to_enum, env: env)) let resource_strs = uses |> map(u => concat(emit_ident(name: resource_use_name_at(n: u, source_indices: source_indices), target: Rust), ": &", render_rust_type(n: resource_use_resource(n: u), shared_types: shared_types, source_indices: source_indices)) ) From e6c75999d7584081b50943a94b979a709dec8ff5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 00:33:59 +0000 Subject: [PATCH 10/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- src/v1/05_emit_rust.dag | 12 +++++---- src/v1/stage0/src/v1_compiler_emit_rust.rs | 29 ++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 38c30dbbee9..c6b19197715 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -398,11 +398,13 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } else if n.connective == NoConnective && n.children |> count == 0 { if name == "String" { render_rust_text_carrier(shared_types: shared_types) - } else if match rust_opaque_kernel_alias_carrier(name: name) { - Present { value: carrier } => carrier - Absent => { - let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: scope.type_env) - render_rust_shared_type_if_needed(type_name: name, rendered: rendered, shared_types: shared_types) + } else { + match rust_opaque_kernel_alias_carrier(name: name) { + Present { value: carrier } => carrier + Absent => { + let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum, env: scope.type_env) + render_rust_shared_type_if_needed(type_name: name, rendered: rendered, shared_types: shared_types) + } } } } else if n.connective == NoConnective && n.children |> count > 0 { diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 4308b36527c..2f8e0f1abed 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -448,6 +448,7 @@ pub fn render_rust_decl_type( "__applied_type_args".to_string(), source_indices.clone(), ); + let has_applied_prop = applied_prop.is_some(); let applied_overlay = match applied_prop { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { @@ -481,6 +482,29 @@ pub fn render_rust_decl_type( }) { name.clone() + } else if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0) + && !has_applied_prop + && v1_rt::set_contains(&shared_types, name.clone())) + { + let stub_env = Rc::new(TypeEnv { + bindings: Rc::new(HashMap::new()), + recursive_types: Rc::new(vec![]), + recursive_type_set: Rc::new(HashMap::new()), + inductive_fields: Rc::new(HashMap::new()), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }); + let rendered = rust_render_type_leaf_name( + name.clone(), + v1_rt::rc_empty_map::(), + stub_env, + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) } else { if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) @@ -635,11 +659,12 @@ pub fn render_rust_alias_rhs_type( } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { carrier } else { - rust_render_type_leaf_name( + let rendered = rust_render_type_leaf_name( name.clone(), variant_to_enum.clone(), scope.type_env.clone(), - ) + ); + render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) } } else if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) From 7c7af89c3f8afcaeb6afe06b5b7f698618159df6 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 00:55:05 +0000 Subject: [PATCH 11/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- src/v1/stage0/src/bin/regen_stage0.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index 512c4bb65b5..0fce5fce89b 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -27,6 +27,7 @@ const DEFAULT_BOOTSTRAP_TIMING_RECEIPT: &str = const GENERATED_STAGE0_FILES: &[&str] = &[ "compiler_tests.rs", "extdeps_cargo.rs", + "extdeps_cargo_version.rs", "extdeps_languages_dag_emit.rs", "extdeps_languages_dag_syntax.rs", "extdeps_languages_dag_types.rs", @@ -39,6 +40,8 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "extdeps_languages_rust_emit.rs", "extdeps_languages_rust_syntax.rs", "extdeps_languages_rust_types.rs", + "extdeps_version.rs", + "extdeps_version_semver.rs", "lib.rs", "main.rs", "std_algebra.rs", @@ -52,6 +55,7 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "std_induction.rs", "std_iteration.rs", "std_node.rs", + "std_serialization.rs", "std_syntax.rs", "std_termination.rs", "std_types.rs", @@ -94,11 +98,27 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "v1_std_core.rs", ]; +// MUST stay in lockstep with the emitter's `hand_maintained_mods` declaration in +// src/v1/05_emit_rust.dag (`emit_lib_rs_from_files`): every `pub mod X;` the emitter +// writes into the generated lib.rs for a hand-maintained module must be copied into +// the fresh-compile temp dir here, or `cargo fmt` of the emitted crate fails to +// resolve the module. These two lists are a §3 parallel-authority pair (the deeper +// fix is a single source); until then this is the synced copy of the emitter's set +// (13 modules) plus the two dag_collect bootstrap modules injected by +// patch_bootstrap_dag_collect. The lens-`*_project` / `*_census` / recorded_fixture +// modules are hand-maintained Rust seed, not regenerated, so they live here. const HAND_MAINTAINED_STAGE0_FILES: &[&str] = &[ "cli_run.rs", "coproduct_reflection.rs", + "extdeps_shape_transport_policy_project.rs", + "fact_cardinality_census.rs", + "import_resolution_project.rs", + "layering_imports_project.rs", + "module_path_index.rs", + "recorded_fixture.rs", "resolved_graph_cache.rs", "rest_transport_facts.rs", + "transport_script_position_project.rs", "wire_value_serialize.rs", "v1_compiler_dag_collect.rs", "v1_compiler_dag_collect_support.rs", From 88ee181e0849ef730a00db00384d618a27daea7f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 01:05:38 +0000 Subject: [PATCH 12/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- src/v1/stage0/src/extdeps_cargo.rs | 55 +- src/v1/stage0/src/extdeps_cargo_version.rs | 48 + .../stage0/src/extdeps_languages_dag_emit.rs | 182 +- .../src/extdeps_languages_dag_syntax.rs | 118 +- .../stage0/src/extdeps_languages_go_emit.rs | 192 +- .../stage0/src/extdeps_languages_go_types.rs | 54 +- .../src/extdeps_languages_python_emit.rs | 204 +- .../src/extdeps_languages_python_types.rs | 132 +- .../stage0/src/extdeps_languages_rust_emit.rs | 276 +- .../src/extdeps_languages_rust_syntax.rs | 78 +- .../src/extdeps_languages_rust_types.rs | 72 +- src/v1/stage0/src/extdeps_version.rs | 23 + src/v1/stage0/src/extdeps_version_semver.rs | 39 + src/v1/stage0/src/lib.rs | 5 +- src/v1/stage0/src/std_algebra.rs | 24 +- src/v1/stage0/src/std_coercion.rs | 46 +- src/v1/stage0/src/std_computation.rs | 34 +- src/v1/stage0/src/std_effects.rs | 50 +- src/v1/stage0/src/std_emit_model.rs | 11 +- src/v1/stage0/src/std_graph.rs | 28 +- src/v1/stage0/src/std_http_path.rs | 87 +- src/v1/stage0/src/std_induction.rs | 58 +- src/v1/stage0/src/std_node.rs | 10 +- src/v1/stage0/src/std_serialization.rs | 81 + src/v1/stage0/src/std_syntax.rs | 12 +- src/v1/stage0/src/std_termination.rs | 24 +- src/v1/stage0/src/std_types.rs | 207 +- src/v1/stage0/src/v1_compiler_artifact.rs | 26 +- src/v1/stage0/src/v1_compiler_coercion.rs | 81 +- src/v1/stage0/src/v1_compiler_compile.rs | 150 +- .../src/v1_compiler_compiler_tests_rust.rs | 52 +- src/v1/stage0/src/v1_compiler_complexity.rs | 1031 ++-- .../src/v1_compiler_effect_derivation.rs | 4 +- src/v1/stage0/src/v1_compiler_emit.rs | 749 ++- .../src/v1_compiler_emit_core_support.rs | 83 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 128 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 119 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 5223 +++++++++-------- src/v1/stage0/src/v1_compiler_infer.rs | 2773 ++++----- src/v1/stage0/src/v1_compiler_infer_access.rs | 12 +- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 128 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 100 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 47 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 4 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 154 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 51 +- .../stage0/src/v1_compiler_infer_patterns.rs | 100 +- .../stage0/src/v1_compiler_infer_resolve.rs | 278 +- .../stage0/src/v1_compiler_infer_service.rs | 18 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 46 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 159 +- src/v1/stage0/src/v1_compiler_languages.rs | 291 +- src/v1/stage0/src/v1_compiler_normalize.rs | 2 +- src/v1/stage0/src/v1_compiler_ownership.rs | 112 +- src/v1/stage0/src/v1_compiler_parse.rs | 592 +- src/v1/stage0/src/v1_compiler_resolve.rs | 130 +- src/v1/stage0/src/v1_compiler_runtime_go.rs | 10 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 24 +- .../stage0/src/v1_compiler_stage0_crates.rs | 32 +- src/v1/stage0/src/v1_compiler_tokenize.rs | 112 +- src/v1/stage0/src/v1_compiler_trace.rs | 43 +- .../src/v1_compiler_workspace_members.rs | 8 +- src/v1/stage0/src/v1_rt.rs | 5 - src/v1/stage0/src/v1_std_core.rs | 475 +- 64 files changed, 8503 insertions(+), 6999 deletions(-) create mode 100644 src/v1/stage0/src/extdeps_cargo_version.rs create mode 100644 src/v1/stage0/src/extdeps_version.rs create mode 100644 src/v1/stage0/src/extdeps_version_semver.rs create mode 100644 src/v1/stage0/src/std_serialization.rs diff --git a/src/v1/stage0/src/extdeps_cargo.rs b/src/v1/stage0/src/extdeps_cargo.rs index 58ffce73f17..76ca6dd3270 100644 --- a/src/v1/stage0/src/extdeps_cargo.rs +++ b/src/v1/stage0/src/extdeps_cargo.rs @@ -5,6 +5,9 @@ use self::CargoDepSource::*; use self::CargoTarget::*; use self::RustEdition::*; use self::TestHarness::*; +pub use crate::extdeps_cargo_version::{ + CargoPackageVersion, CargoToolVersionFloor, CargoVersionRequirement, +}; pub use crate::std_types::FilePathParts; use crate::v1_rt; use crate::v1_rt::Witness; @@ -26,7 +29,7 @@ pub enum RustEdition { Edition2024, } -pub fn rust_edition_str(edition: RustEdition) -> String { +pub fn rust_edition_str(edition: RustEdition) -> Rc> { match edition { RustEdition::Edition2015 => "2015".to_string(), RustEdition::Edition2018 => "2018".to_string(), @@ -44,29 +47,39 @@ pub fn default_rust_edition() -> RustEdition { CACHED.with(|c: &RustEdition| c.clone()) } +pub fn min_cargo_version() -> SemVerConstraint { + thread_local! { + static CACHED: SemVerConstraint = { + serde_json::from_value(serde_json::json!(">= 1.56")) + .expect("valid data definition") + }; + } + CACHED.with(|c: &SemVerConstraint| c.clone()) +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoPackage { - pub name: String, - pub version: String, + pub name: Rc>, + pub version: Box, pub edition: RustEdition, - pub path: String, + pub path: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum CargoDepSource { RegistryDep { - version: String, + version: Box, features: Rc>, }, LocalPathDep { - path: String, + path: Rc>, }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoDependency { - pub name: String, + pub name: Rc>, pub source: Rc, } @@ -74,13 +87,13 @@ pub struct CargoDependency { #[serde(tag = "_variant")] pub enum CargoTarget { Lib, - Bin { name: String }, - CargoTest { name: String }, - Example { name: String }, - Bench { name: String }, + Bin { name: Rc> }, + CargoTest { name: Rc> }, + Example { name: Rc> }, + Bench { name: Rc> }, } impl CargoTarget { - pub fn name(&self) -> String { + pub fn name(&self) -> Rc> { match self { CargoTarget::Lib => panic!("no name on unit variant"), CargoTarget::Bin { name: __val, .. } => __val.clone(), @@ -93,14 +106,16 @@ impl CargoTarget { pub fn cargo_target_source_path( target: Rc, - package_name: String, + package_name: Rc>, ) -> Rc { match (*target).clone() { CargoTarget::Lib => Rc::new(FilePathParts { segments: Rc::new(vec!["src".to_string(), "lib.rs".to_string()]), }), CargoTarget::Bin { name: name, .. } => { - if (name.clone().as_str() == package_name.as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(package_name)) + { Rc::new(FilePathParts { segments: Rc::new(vec!["src".to_string(), "main.rs".to_string()]), }) @@ -135,7 +150,7 @@ pub fn cargo_target_source_path( } } -pub fn rust_module_candidate_paths(stem: String) -> Rc>> { +pub fn rust_module_candidate_paths(stem: Rc>) -> Rc>> { Rc::new(vec![ Rc::new(FilePathParts { segments: Rc::new(vec![ @@ -149,7 +164,7 @@ pub fn rust_module_candidate_paths(stem: String) -> Rc>> { ]) } -pub type CargoProfile = String; +pub type CargoProfile = Rc>; pub fn canonical_profiles() -> Rc> { thread_local! { @@ -162,7 +177,7 @@ pub fn canonical_profiles() -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoFeature { - pub name: String, + pub name: Rc>, pub dependencies: Rc>, } @@ -175,13 +190,13 @@ pub enum TestHarness { NoHarness, } -pub fn default_profile() -> String { +pub fn default_profile() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "dev".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub struct Edition2015; diff --git a/src/v1/stage0/src/extdeps_cargo_version.rs b/src/v1/stage0/src/extdeps_cargo_version.rs new file mode 100644 index 00000000000..d20dfe8d70e --- /dev/null +++ b/src/v1/stage0/src/extdeps_cargo_version.rs @@ -0,0 +1,48 @@ +// Generated by v1 compiler -- do not edit. +// Source module: extdeps.cargo_version + +pub use crate::extdeps_version_semver::{SemVerConstraint, SemVerIdentity}; +use crate::v1_rt; +use crate::v1_rt::Witness; +use crate::v1_rt::Witness::{Holds, Violates}; +use crate::NonEmptyBTreeSet; +use crate::NonEmptyVec; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::rc::Rc; + +pub type CargoPackageVersion = SemVerIdentity; + +pub type CargoVersionRequirement = SemVerConstraint; + +pub type CargoToolVersionFloor = SemVerConstraint; + +pub fn default_stage0_package_version() -> Rc> { + thread_local! { + static CACHED: Rc> = { + "0.1.0".to_string() + }; + } + CACHED.with(|c: &Rc>| c.clone()) +} + +pub fn render_cargo_package_version_field(version: CargoPackageVersion) -> Rc> { + v1_rt::concat( + v1_rt::concat("version = \"".to_string(), version), + "\"".to_string(), + ) +} + +pub fn render_cargo_version_requirement_toml(req: CargoVersionRequirement) -> Rc> { + v1_rt::concat(v1_rt::concat("\"".to_string(), req), "\"".to_string()) +} + +pub fn render_cargo_package_header_prefix(name: Rc>) -> Rc> { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("[package]\nname = \"".to_string(), name), + "\"\n".to_string(), + ), + render_cargo_package_version_field(default_stage0_package_version()), + ) +} diff --git a/src/v1/stage0/src/extdeps_languages_dag_emit.rs b/src/v1/stage0/src/extdeps_languages_dag_emit.rs index 53b714ba0d2..3fa03e74c98 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_emit.rs @@ -14,13 +14,13 @@ pub fn dag_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "true".to_string()); - __m.insert("false".to_string(), "false".to_string()); - __m.insert("null".to_string(), "none".to_string()); - __m.insert("and".to_string(), "&&".to_string()); - __m.insert("or".to_string(), "||".to_string()); - __m.insert("not".to_string(), "!".to_string()); - __m.insert("div".to_string(), "/".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "true".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "false".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "none".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "&&".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "||".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "!".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "/".to_string()); Rc::new(__m) }; } @@ -31,15 +31,15 @@ pub fn dag_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "List<{0}>".to_string()); - __m.insert("set".to_string(), "Set<{0}>".to_string()); - __m.insert("non_empty_list".to_string(), "NonEmptyList<{0}>".to_string()); - __m.insert("non_empty_set".to_string(), "NonEmptySet<{0}>".to_string()); - __m.insert("optional".to_string(), "{0}?".to_string()); - __m.insert("map".to_string(), "Map<{0}, {1}>".to_string()); - __m.insert("free_monoid".to_string(), "List<{0}>".to_string()); - __m.insert("partial_function".to_string(), "Map<{0}, {1}>".to_string()); - __m.insert("boolean_algebra".to_string(), "Bool".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "List<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "Set<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("non_empty_list"), "NonEmptyList<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("non_empty_set"), "NonEmptySet<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "{0}?".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "Map<{0}, {1}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "List<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "Map<{0}, {1}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "Bool".to_string()); Rc::new(__m) }; } @@ -64,227 +64,227 @@ pub fn dag_string_types() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_func_keyword() -> String { +pub fn dag_func_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "fn".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_async_prefix() -> String { +pub fn dag_async_prefix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_struct_keyword() -> String { +pub fn dag_struct_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "type".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_enum_keyword() -> String { +pub fn dag_enum_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "type".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_type_alias_keyword() -> String { +pub fn dag_type_alias_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "type".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_param_separator() -> String { +pub fn dag_param_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ", ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_return_arrow() -> String { +pub fn dag_return_arrow() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { " -> ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_param_type_sep() -> String { +pub fn dag_param_type_sep() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ": ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_module_keyword() -> String { +pub fn dag_module_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "module".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_import_keyword() -> String { +pub fn dag_import_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "import".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_import_from_keyword() -> String { +pub fn dag_import_from_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_lambda_template() -> String { +pub fn dag_lambda_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "({0}) => {1}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_error_expr_template() -> String { +pub fn dag_error_expr_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "error({0})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_list_literal_empty() -> String { +pub fn dag_list_literal_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_list_literal_template() -> String { +pub fn dag_list_literal_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[{0}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_null_coalesce_template() -> String { +pub fn dag_null_coalesce_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{0} ?? {1}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_error_type_template() -> String { +pub fn dag_error_type_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "__EMIT_BUG_{0}__".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_type_arg_open() -> String { +pub fn dag_type_arg_open() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "<".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_type_arg_close() -> String { +pub fn dag_type_arg_close() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ">".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_void_type() -> String { +pub fn dag_void_type() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "()".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_tuple_empty() -> String { +pub fn dag_tuple_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "()".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_tuple_pair_template() -> String { +pub fn dag_tuple_pair_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "({0}, {1})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_tuple_multi_template() -> String { +pub fn dag_tuple_multi_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "({0})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_tuple_separator() -> String { +pub fn dag_tuple_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ", ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_source_extension() -> String { +pub fn dag_source_extension() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ".dag".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } diff --git a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs index aa38fb08090..819ce9bf42d 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs @@ -108,14 +108,14 @@ pub fn dag_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), Rc::new(LiteralValue::LitBool { value: false, })); - __m.insert("none".to_string(), Rc::new(LiteralValue::LitNull)); - __m.insert("null".to_string(), Rc::new(LiteralValue::LitNull)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("none"), Rc::new(LiteralValue::LitNull)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), Rc::new(LiteralValue::LitNull)); Rc::new(__m) }; } @@ -126,41 +126,41 @@ pub fn dag_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("module".to_string(), true); - __m.insert("import".to_string(), true); - __m.insert("type".to_string(), true); - __m.insert("fn".to_string(), true); - __m.insert("func".to_string(), true); - __m.insert("resource".to_string(), true); - __m.insert("service".to_string(), true); - __m.insert("data".to_string(), true); - __m.insert("interface".to_string(), true); - __m.insert("pipeline".to_string(), true); - __m.insert("profile".to_string(), true); - __m.insert("pattern".to_string(), true); - __m.insert("let".to_string(), true); - __m.insert("return".to_string(), true); - __m.insert("match".to_string(), true); - __m.insert("if".to_string(), true); - __m.insert("then".to_string(), true); - __m.insert("else".to_string(), true); - __m.insert("for".to_string(), true); - __m.insert("in".to_string(), true); - __m.insert("where".to_string(), true); - __m.insert("with".to_string(), true); - __m.insert("true".to_string(), true); - __m.insert("false".to_string(), true); - __m.insert("none".to_string(), true); - __m.insert("null".to_string(), true); - __m.insert("acquire".to_string(), true); - __m.insert("release".to_string(), true); - __m.insert("capability".to_string(), true); - __m.insert("operation".to_string(), true); - __m.insert("input".to_string(), true); - __m.insert("output".to_string(), true); - __m.insert("idempotent".to_string(), true); - __m.insert("readonly".to_string(), true); - __m.insert("hermetic".to_string(), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("module"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("import"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("type"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("fn"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("func"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("resource"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("service"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("data"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("interface"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("pipeline"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("profile"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("pattern"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("let"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("return"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("match"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("if"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("then"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("else"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("for"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("in"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("where"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("with"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("none"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("acquire"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("release"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("capability"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("operation"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("input"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("output"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("idempotent"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("readonly"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("hermetic"), true); Rc::new(__m) }; } @@ -171,12 +171,12 @@ pub fn dag_non_name_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), true); - __m.insert("false".to_string(), true); - __m.insert("none".to_string(), true); - __m.insert("null".to_string(), true); - __m.insert("acquire".to_string(), true); - __m.insert("release".to_string(), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("none"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("acquire"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("release"), true); Rc::new(__m) }; } @@ -292,20 +292,20 @@ pub fn v3_supported_dag_operators() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("||".to_string(), true); - __m.insert("&&".to_string(), true); - __m.insert("==".to_string(), true); - __m.insert("!=".to_string(), true); - __m.insert("<".to_string(), true); - __m.insert(">".to_string(), true); - __m.insert("<=".to_string(), true); - __m.insert(">=".to_string(), true); - __m.insert("+".to_string(), true); - __m.insert("-".to_string(), true); - __m.insert("*".to_string(), true); - __m.insert("/".to_string(), true); - __m.insert("|>".to_string(), true); - __m.insert(".".to_string(), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("||"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("&&"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("=="), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("!="), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("<"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host(">"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("<="), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host(">="), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("+"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("-"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("*"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("/"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("|>"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("."), true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_go_emit.rs b/src/v1/stage0/src/extdeps_languages_go_emit.rs index 1ea6c48a70c..cc05e9642c6 100644 --- a/src/v1/stage0/src/extdeps_languages_go_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_go_emit.rs @@ -15,13 +15,13 @@ pub fn go_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "true".to_string()); - __m.insert("false".to_string(), "false".to_string()); - __m.insert("null".to_string(), "nil".to_string()); - __m.insert("and".to_string(), "&&".to_string()); - __m.insert("or".to_string(), "||".to_string()); - __m.insert("not".to_string(), "!".to_string()); - __m.insert("div".to_string(), "/".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "true".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "false".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "nil".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "&&".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "||".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "!".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn go_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "[]{0}".to_string()); - __m.insert("set".to_string(), "map[{0}]struct{}".to_string()); - __m.insert("optional".to_string(), "*{0}".to_string()); - __m.insert("map".to_string(), "map[{0}]{1}".to_string()); - __m.insert("free_monoid".to_string(), "[]{0}".to_string()); - __m.insert("partial_function".to_string(), "map[{0}]{1}".to_string()); - __m.insert("boolean_algebra".to_string(), "bool".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "[]{0}".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "map[{0}]struct{}".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "*{0}".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "map[{0}]{1}".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "[]{0}".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "map[{0}]{1}".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "bool".to_string()); Rc::new(__m) }; } @@ -54,130 +54,130 @@ pub fn go_reserved() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_reserved_escape_suffix() -> String { +pub fn go_reserved_escape_suffix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "_".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_func_keyword() -> String { +pub fn go_func_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "func".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_async_prefix() -> String { +pub fn go_async_prefix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_struct_keyword() -> String { +pub fn go_struct_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "struct".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_enum_keyword() -> String { +pub fn go_enum_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "type".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_type_alias_keyword() -> String { +pub fn go_type_alias_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "type".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_param_separator() -> String { +pub fn go_param_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ", ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_return_arrow() -> String { +pub fn go_return_arrow() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { " ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_param_type_sep() -> String { +pub fn go_param_type_sep() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { " ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_module_keyword() -> String { +pub fn go_module_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "package".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_import_keyword() -> String { +pub fn go_import_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "import".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_import_from_keyword() -> String { +pub fn go_import_from_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_manifest_file() -> String { +pub fn go_manifest_file() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "go.mod".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_source_extension() -> String { +pub fn go_source_extension() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ".go".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn go_string_types() -> Rc> { @@ -201,126 +201,126 @@ pub fn go_simple_method_specs() -> Rc>> { pub fn go_method_templates_flat() -> Rc> { go_simple_method_specs().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), spec.template.clone()) }, ) } -pub fn go_lambda_template() -> String { +pub fn go_lambda_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "func({0}) interface{} { {1} }".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_error_expr_template() -> String { +pub fn go_error_expr_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "panic({0})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_list_literal_empty() -> String { +pub fn go_list_literal_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[]interface{}{}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_list_literal_template() -> String { +pub fn go_list_literal_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[]interface{}{{0}}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_null_coalesce_template() -> String { +pub fn go_null_coalesce_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "func() interface{} { if {0} != nil { return {0} }; return {1} }()".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_error_type_template() -> String { +pub fn go_error_type_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "__EMIT_BUG_{0}__".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_type_arg_open() -> String { +pub fn go_type_arg_open() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "<".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_type_arg_close() -> String { +pub fn go_type_arg_close() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ">".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_void_type() -> String { +pub fn go_void_type() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_tuple_empty() -> String { +pub fn go_tuple_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "struct{}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_tuple_pair_template() -> String { +pub fn go_tuple_pair_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "struct{ First {0}; Second {1} }".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_tuple_multi_template() -> String { +pub fn go_tuple_multi_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "struct{ {0} }".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_tuple_separator() -> String { +pub fn go_tuple_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "; ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } diff --git a/src/v1/stage0/src/extdeps_languages_go_types.rs b/src/v1/stage0/src/extdeps_languages_go_types.rs index 7d529fc8148..eca848ba4d0 100644 --- a/src/v1/stage0/src/extdeps_languages_go_types.rs +++ b/src/v1/stage0/src/extdeps_languages_go_types.rs @@ -41,80 +41,80 @@ pub fn go_callable() -> Rc { CACHED.with(|c: &Rc| c.clone()) } -pub fn pointer_template() -> String { +pub fn pointer_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "*{0}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_optional_template() -> String { +pub fn go_optional_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "*{0}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn address_of_template() -> String { +pub fn address_of_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "&{value}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn nil_literal() -> String { +pub fn nil_literal() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "nil".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn visibility_by_case() -> bool { true } -pub fn embedded_field_syntax() -> String { +pub fn embedded_field_syntax() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{type}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn empty_interface() -> String { +pub fn empty_interface() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "interface{}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn any_type() -> String { +pub fn any_type() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "any".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn interface_def_template() -> String { +pub fn interface_def_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "type {name} interface {\n{methods}\n}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn integer_types() -> Rc> { @@ -135,13 +135,13 @@ pub fn float_types() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn type_conversion_template() -> String { +pub fn type_conversion_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{type}({expr})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn go_cast_syntax() -> Rc { diff --git a/src/v1/stage0/src/extdeps_languages_python_emit.rs b/src/v1/stage0/src/extdeps_languages_python_emit.rs index 383495ab200..04c578642ff 100644 --- a/src/v1/stage0/src/extdeps_languages_python_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_python_emit.rs @@ -15,13 +15,13 @@ pub fn python_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "True".to_string()); - __m.insert("false".to_string(), "False".to_string()); - __m.insert("null".to_string(), "None".to_string()); - __m.insert("and".to_string(), "and".to_string()); - __m.insert("or".to_string(), "or".to_string()); - __m.insert("not".to_string(), "not ".to_string()); - __m.insert("div".to_string(), "//".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "True".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "False".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "None".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "and".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "or".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "not ".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "//".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn python_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "list[{0}]".to_string()); - __m.insert("set".to_string(), "set[{0}]".to_string()); - __m.insert("optional".to_string(), "Optional[{0}]".to_string()); - __m.insert("map".to_string(), "dict[{0}, {1}]".to_string()); - __m.insert("free_monoid".to_string(), "list[{0}]".to_string()); - __m.insert("partial_function".to_string(), "dict[{0}, {1}]".to_string()); - __m.insert("boolean_algebra".to_string(), "bool".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "list[{0}]".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "set[{0}]".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "Optional[{0}]".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "dict[{0}, {1}]".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "list[{0}]".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "dict[{0}, {1}]".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "bool".to_string()); Rc::new(__m) }; } @@ -54,148 +54,148 @@ pub fn python_reserved() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_reserved_escape_suffix() -> String { +pub fn python_reserved_escape_suffix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "_".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_derive_attribute() -> String { +pub fn python_derive_attribute() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "@dataclass".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_default_value() -> String { +pub fn python_default_value() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "None".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_func_keyword() -> String { +pub fn python_func_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "def".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_async_prefix() -> String { +pub fn python_async_prefix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "async ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_struct_keyword() -> String { +pub fn python_struct_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "class".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_enum_keyword() -> String { +pub fn python_enum_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "class".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_type_alias_keyword() -> String { +pub fn python_type_alias_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_param_separator() -> String { +pub fn python_param_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ", ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_return_arrow() -> String { +pub fn python_return_arrow() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { " -> ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_param_type_sep() -> String { +pub fn python_param_type_sep() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ": ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_module_keyword() -> String { +pub fn python_module_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_import_keyword() -> String { +pub fn python_import_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "import".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_import_from_keyword() -> String { +pub fn python_import_from_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "from".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_source_extension() -> String { +pub fn python_source_extension() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ".py".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_module_init() -> String { +pub fn python_module_init() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "__init__.py".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn python_string_types() -> Rc> { @@ -219,126 +219,126 @@ pub fn python_simple_method_specs() -> Rc>> { pub fn python_method_templates_flat() -> Rc> { python_simple_method_specs().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), spec.template.clone()) }, ) } -pub fn python_lambda_template() -> String { +pub fn python_lambda_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "lambda {0}: {1}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_error_expr_template() -> String { +pub fn python_error_expr_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "raise RuntimeError({0})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_list_literal_empty() -> String { +pub fn python_list_literal_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_list_literal_template() -> String { +pub fn python_list_literal_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[{0}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_null_coalesce_template() -> String { +pub fn python_null_coalesce_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "({0} if {0} is not None else {1})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_error_type_template() -> String { +pub fn python_error_type_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "__EMIT_BUG_{0}__".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_type_arg_open() -> String { +pub fn python_type_arg_open() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_type_arg_close() -> String { +pub fn python_type_arg_close() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_void_type() -> String { +pub fn python_void_type() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "None".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_tuple_empty() -> String { +pub fn python_tuple_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Tuple".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_tuple_pair_template() -> String { +pub fn python_tuple_pair_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Tuple[{0}, {1}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_tuple_multi_template() -> String { +pub fn python_tuple_multi_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Tuple[{0}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_tuple_separator() -> String { +pub fn python_tuple_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ", ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } diff --git a/src/v1/stage0/src/extdeps_languages_python_types.rs b/src/v1/stage0/src/extdeps_languages_python_types.rs index 29759774f9e..64836ed0ca6 100644 --- a/src/v1/stage0/src/extdeps_languages_python_types.rs +++ b/src/v1/stage0/src/extdeps_languages_python_types.rs @@ -51,202 +51,202 @@ pub enum PythonTypeKind { AnnotatedType, } -pub fn dataclass_decorator() -> String { +pub fn dataclass_decorator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "@dataclass".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn dataclass_import() -> String { +pub fn dataclass_import() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "from dataclasses import dataclass, field".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn field_default_template() -> String { +pub fn field_default_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "field(default={value})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn field_default_factory_template() -> String { +pub fn field_default_factory_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "field(default_factory={factory})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_enum_import() -> String { +pub fn python_enum_import() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "from enum import Enum, auto".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn enum_class_template() -> String { +pub fn enum_class_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "class {name}(Enum):\n{variants}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn enum_auto_value() -> String { +pub fn enum_auto_value() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "auto()".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn union_syntax() -> String { +pub fn union_syntax() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{a} | {b}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn optional_syntax() -> String { +pub fn optional_syntax() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{type} | None".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn typing_optional() -> String { +pub fn typing_optional() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Optional[{type}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_optional_template() -> String { +pub fn python_optional_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Optional[{0}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn typing_union() -> String { +pub fn typing_union() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Union[{types}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_typing_import() -> String { +pub fn python_typing_import() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "from typing import Optional, Union".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn type_alias_template() -> String { +pub fn type_alias_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{name} = {type}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn generic_param_template() -> String { +pub fn generic_param_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "[{params}]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn typing_generic_import() -> String { +pub fn typing_generic_import() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "from typing import Generic, TypeVar".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn none_literal() -> String { +pub fn none_literal() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "None".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn none_check_template() -> String { +pub fn none_check_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{expr} is None".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn none_not_check_template() -> String { +pub fn none_not_check_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{expr} is not None".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn pass_statement() -> String { +pub fn pass_statement() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "pass".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn type_checker() -> String { +pub fn type_checker() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "mypy".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn type_checker_strict() -> String { +pub fn type_checker_strict() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "mypy --strict".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn python_cast_syntax() -> Rc { diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index 1892d93af82..b4cacad1608 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -15,13 +15,13 @@ pub fn rust_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), "true".to_string()); - __m.insert("false".to_string(), "false".to_string()); - __m.insert("null".to_string(), "None".to_string()); - __m.insert("and".to_string(), "&&".to_string()); - __m.insert("or".to_string(), "||".to_string()); - __m.insert("not".to_string(), "!".to_string()); - __m.insert("div".to_string(), "/".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "true".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "false".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "None".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "&&".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "||".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "!".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn rust_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("list".to_string(), "Vec<{0}>".to_string()); - __m.insert("set".to_string(), "std::collections::BTreeSet<{0}>".to_string()); - __m.insert("optional".to_string(), "Option<{0}>".to_string()); - __m.insert("map".to_string(), "HashMap<{0}, {1}>".to_string()); - __m.insert("free_monoid".to_string(), "Vec<{0}>".to_string()); - __m.insert("partial_function".to_string(), "HashMap<{0}, {1}>".to_string()); - __m.insert("boolean_algebra".to_string(), "bool".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "Vec<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "std::collections::BTreeSet<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "Option<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "HashMap<{0}, {1}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "Vec<{0}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "HashMap<{0}, {1}>".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "bool".to_string()); Rc::new(__m) }; } @@ -57,7 +57,7 @@ pub fn rust_simple_method_specs() -> Rc>> { pub fn rust_method_templates() -> Rc> { rust_simple_method_specs().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), spec.template.clone()) }, @@ -77,7 +77,7 @@ pub fn rust_method_wraps_result() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), true) }, @@ -93,13 +93,13 @@ pub fn rust_reserved() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_reserved_escape_suffix() -> String { +pub fn rust_reserved_escape_suffix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "_".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn rust_string_types() -> Rc> { @@ -111,325 +111,325 @@ pub fn rust_string_types() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_struct_derives() -> String { +pub fn rust_struct_derives() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_struct_derives_copy() -> String { +pub fn rust_struct_derives_copy() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_enum_derives() -> String { +pub fn rust_enum_derives() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_enum_derives_copy() -> String { +pub fn rust_enum_derives_copy() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_serde_tag() -> String { +pub fn rust_serde_tag() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[serde(tag = \"_variant\")]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_serde_rename_all_snake_case() -> String { +pub fn rust_serde_rename_all_snake_case() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[serde(rename_all = \"snake_case\")]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_serde_rename_all_screaming_snake_case() -> String { +pub fn rust_serde_rename_all_screaming_snake_case() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[serde(rename_all = \"SCREAMING_SNAKE_CASE\")]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_serde_rename_template() -> String { +pub fn rust_serde_rename_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[serde(rename = \"{0}\")]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_func_keyword() -> String { +pub fn rust_func_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "fn".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_async_prefix() -> String { +pub fn rust_async_prefix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "async ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_struct_keyword() -> String { +pub fn rust_struct_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "struct".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_enum_keyword() -> String { +pub fn rust_enum_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "enum".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_type_alias_keyword() -> String { +pub fn rust_type_alias_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "type".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_param_separator() -> String { +pub fn rust_param_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ", ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_return_arrow() -> String { +pub fn rust_return_arrow() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { " -> ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_param_type_sep() -> String { +pub fn rust_param_type_sep() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ": ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_module_keyword() -> String { +pub fn rust_module_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "mod".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_import_keyword() -> String { +pub fn rust_import_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "use".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_import_from_keyword() -> String { +pub fn rust_import_from_keyword() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_lambda_template() -> String { +pub fn rust_lambda_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "|{0}| {1}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_error_expr_template() -> String { +pub fn rust_error_expr_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "panic!({0})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_list_literal_empty() -> String { +pub fn rust_list_literal_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Rc::new(vec![])".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_list_literal_template() -> String { +pub fn rust_list_literal_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Rc::new(vec![{0}])".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_null_coalesce_template() -> String { +pub fn rust_null_coalesce_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{0}.unwrap_or_else(|| {1})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_error_type_template() -> String { +pub fn rust_error_type_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "compile_error!(\"{0}\")".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_type_arg_open() -> String { +pub fn rust_type_arg_open() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "<".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_type_arg_close() -> String { +pub fn rust_type_arg_close() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ">".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_void_type() -> String { +pub fn rust_void_type() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "()".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_tuple_empty() -> String { +pub fn rust_tuple_empty() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "()".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_tuple_pair_template() -> String { +pub fn rust_tuple_pair_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "({0}, {1})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_tuple_multi_template() -> String { +pub fn rust_tuple_multi_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "({0})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_tuple_separator() -> String { +pub fn rust_tuple_separator() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ", ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_source_extension() -> String { +pub fn rust_source_extension() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { ".rs".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_source_dir() -> String { +pub fn rust_source_dir() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "src/".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_visibility() -> String { +pub fn rust_visibility() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "pub ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RuntimeFunction { - pub name: String, - pub bridge_name: String, + pub name: Rc>, + pub bridge_name: Rc>, pub passes_by_ref: bool, pub wraps_result: bool, } @@ -446,7 +446,7 @@ pub fn rt_function_registry() -> Rc>> { pub fn rt_functions() -> Rc> { rt_function_registry().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), true) }, @@ -466,7 +466,7 @@ pub fn rt_ref_map_functions() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), true) }, @@ -486,7 +486,7 @@ pub fn rt_wraps_result() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), true) }, @@ -497,7 +497,9 @@ pub fn rt_bridge_function_names() -> Rc> { Rc::new({ let mut __result = Vec::new(); for f in rt_function_registry().iter().cloned() { - if (f.name.clone().as_str() != f.bridge_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(f.name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(f.bridge_name.clone())) + { __result.push(f); } } @@ -506,33 +508,33 @@ pub fn rt_bridge_function_names() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), entry.bridge_name.clone()) }, ) } -pub fn is_rt_function(name: String) -> bool { +pub fn is_rt_function(name: Rc>) -> bool { v1_rt::map_contains_key(&rt_functions(), name) } -pub fn rt_bridge_name(name: String) -> String { +pub fn rt_bridge_name(name: Rc>) -> Rc> { match v1_rt::map_get(&rt_bridge_function_names(), name.clone()) { Some(bridge) => bridge.clone(), None => name.clone(), } } -pub fn rt_passes_by_ref(name: String) -> bool { +pub fn rt_passes_by_ref(name: Rc>) -> bool { v1_rt::map_contains_key(&rt_ref_map_functions(), name) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct HigherOrderMethodSpec { - pub method_name: String, - pub inline_template: String, - pub fn_ref_template: String, + pub method_name: Rc>, + pub inline_template: Rc>, + pub fn_ref_template: Rc>, pub wraps_in_sharing: bool, } diff --git a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs index a9ef8cc021c..e8680b50a0d 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs @@ -113,10 +113,10 @@ pub fn rust_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), Rc::new(LiteralValue::LitBool { value: false, })); Rc::new(__m) @@ -129,43 +129,43 @@ pub fn rust_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("fn".to_string(), true); - __m.insert("struct".to_string(), true); - __m.insert("enum".to_string(), true); - __m.insert("type".to_string(), true); - __m.insert("trait".to_string(), true); - __m.insert("impl".to_string(), true); - __m.insert("const".to_string(), true); - __m.insert("static".to_string(), true); - __m.insert("mod".to_string(), true); - __m.insert("use".to_string(), true); - __m.insert("let".to_string(), true); - __m.insert("mut".to_string(), true); - __m.insert("return".to_string(), true); - __m.insert("match".to_string(), true); - __m.insert("if".to_string(), true); - __m.insert("else".to_string(), true); - __m.insert("for".to_string(), true); - __m.insert("in".to_string(), true); - __m.insert("while".to_string(), true); - __m.insert("loop".to_string(), true); - __m.insert("break".to_string(), true); - __m.insert("continue".to_string(), true); - __m.insert("pub".to_string(), true); - __m.insert("self".to_string(), true); - __m.insert("super".to_string(), true); - __m.insert("crate".to_string(), true); - __m.insert("as".to_string(), true); - __m.insert("where".to_string(), true); - __m.insert("ref".to_string(), true); - __m.insert("move".to_string(), true); - __m.insert("async".to_string(), true); - __m.insert("await".to_string(), true); - __m.insert("dyn".to_string(), true); - __m.insert("unsafe".to_string(), true); - __m.insert("extern".to_string(), true); - __m.insert("true".to_string(), true); - __m.insert("false".to_string(), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("fn"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("struct"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("enum"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("type"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("trait"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("impl"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("const"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("static"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("mod"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("use"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("let"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("mut"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("return"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("match"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("if"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("else"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("for"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("in"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("while"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("loop"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("break"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("continue"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("pub"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("self"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("super"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("crate"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("as"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("where"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("ref"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("move"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("async"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("await"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("dyn"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("unsafe"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("extern"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_rust_types.rs b/src/v1/stage0/src/extdeps_languages_rust_types.rs index 7daf897f12a..632ea8c6462 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_types.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_types.rs @@ -33,31 +33,31 @@ pub fn rust_algebra_inhabitants() -> Rc>> { CACHED.with(|c: &Rc>>| c.clone()) } -pub fn rust_optional_template() -> String { +pub fn rust_optional_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Option<{0}>".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_none_expr() -> String { +pub fn rust_none_expr() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "None".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_some_template() -> String { +pub fn rust_some_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Some({0})".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn rust_callable() -> Rc { @@ -89,22 +89,22 @@ pub fn pass_non_copy_by_ref() -> bool { true } -pub fn ref_prefix() -> String { +pub fn ref_prefix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "&".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn mut_ref_prefix() -> String { +pub fn mut_ref_prefix() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "&mut ".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } #[derive( @@ -117,31 +117,31 @@ pub enum SmartPointerKind { ArcPtr, } -pub fn box_template() -> String { +pub fn box_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Box<{0}>".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn rc_template() -> String { +pub fn rc_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Rc<{0}>".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn arc_template() -> String { +pub fn arc_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Arc<{0}>".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn common_trait_bounds() -> Rc> { @@ -153,22 +153,22 @@ pub fn common_trait_bounds() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn where_clause_template() -> String { +pub fn where_clause_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "where\n {constraints}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn trait_bound_template() -> String { +pub fn trait_bound_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "{type}: {bound}".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn integer_types() -> Rc> { @@ -199,22 +199,22 @@ pub fn rust_cast_syntax() -> Rc { CACHED.with(|c: &Rc| c.clone()) } -pub fn serde_enum_tag_attribute() -> String { +pub fn serde_enum_tag_attribute() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[serde(tag = \"_variant\")]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn serde_rename_template() -> String { +pub fn serde_rename_template() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "#[serde(rename = \"{key}\")]".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub struct Owned; diff --git a/src/v1/stage0/src/extdeps_version.rs b/src/v1/stage0/src/extdeps_version.rs new file mode 100644 index 00000000000..a630f55aba9 --- /dev/null +++ b/src/v1/stage0/src/extdeps_version.rs @@ -0,0 +1,23 @@ +// Generated by v1 compiler -- do not edit. +// Source module: extdeps.version + +pub use crate::std_algebra::Ordering; +use crate::std_algebra::Ordering::*; +pub use crate::std_types::NonEmptyStr; +use crate::v1_rt; +use crate::v1_rt::Witness; +use crate::v1_rt::Witness::{Holds, Violates}; +use crate::NonEmptyBTreeSet; +use crate::NonEmptyVec; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::rc::Rc; + +pub type VersionIdentity = String; + +#[derive(Clone)] +pub struct VersionScheme { + pub compare: Rc Ordering>, +} + +pub type VersionConstraint = String; diff --git a/src/v1/stage0/src/extdeps_version_semver.rs b/src/v1/stage0/src/extdeps_version_semver.rs new file mode 100644 index 00000000000..5a15e887696 --- /dev/null +++ b/src/v1/stage0/src/extdeps_version_semver.rs @@ -0,0 +1,39 @@ +// Generated by v1 compiler -- do not edit. +// Source module: extdeps.version.semver + +pub use crate::extdeps_version::{VersionConstraint, VersionIdentity, VersionScheme}; +pub use crate::std_algebra::Ordering; +use crate::std_algebra::Ordering::{Equal, Greater, Less}; +use crate::v1_rt; +use crate::v1_rt::Witness; +use crate::v1_rt::Witness::{Holds, Violates}; +use crate::NonEmptyBTreeSet; +use crate::NonEmptyVec; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::rc::Rc; + +pub type SemVerIdentity = NonEmptyStr; + +pub type SemVerConstraint = NonEmptyStr; + +pub fn semver_identity_compare(a: NonEmptyStr, b: NonEmptyStr) -> Ordering { + if (a.clone() == b.clone()) { + Ordering::Equal + } else { + if (a.clone() < b.clone()) { + Ordering::Less + } else { + Ordering::Greater + } + } +} + +pub fn semver_scheme() -> Rc { + thread_local! { + static CACHED: Rc = { + semver_identity_compare + }; + } + CACHED.with(|c: &Rc| c.clone()) +} diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index 7383cb17be5..2adffafffe6 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -15,6 +15,7 @@ pub mod cli_run; pub mod coproduct_reflection; pub mod extdeps_cargo; +pub mod extdeps_cargo_version; pub mod extdeps_languages_dag_emit; pub mod extdeps_languages_dag_syntax; pub mod extdeps_languages_dag_types; @@ -28,9 +29,10 @@ pub mod extdeps_languages_rust_emit; pub mod extdeps_languages_rust_syntax; pub mod extdeps_languages_rust_types; pub mod extdeps_shape_transport_policy_project; +pub mod extdeps_version; +pub mod extdeps_version_semver; pub mod fact_cardinality_census; pub mod import_resolution_project; -pub mod languages_consumer_census; pub mod layering_imports_project; pub mod module_path_index; pub mod recorded_fixture; @@ -47,6 +49,7 @@ pub mod std_http_path; pub mod std_induction; pub mod std_iteration; pub mod std_node; +pub mod std_serialization; pub mod std_syntax; pub mod std_termination; pub mod std_types; diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index a3b3ff672a6..431b9c53e82 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -199,10 +199,10 @@ pub enum AlgebraProfile { #[serde(tag = "_variant")] pub enum ContainerSource { SameAsReceiver, - Named { name: String }, + Named { name: Rc> }, } impl ContainerSource { - pub fn name(&self) -> String { + pub fn name(&self) -> Rc> { match self { ContainerSource::SameAsReceiver => panic!("no name on unit variant"), ContainerSource::Named { name: __val, .. } => __val.clone(), @@ -218,7 +218,7 @@ pub enum AlgebraTypeTemplate { ReceiverKey, ReceiverValue, NamedTemplate { - name: String, + name: Rc>, }, ContainerOf { source: Rc, @@ -239,7 +239,7 @@ pub enum AlgebraTypeTemplate { return_type: Rc, }, AlgebraTypeVariable { - id: String, + id: Rc>, }, } @@ -266,7 +266,7 @@ pub enum CostShape { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct AlgebraFieldTemplate { - pub name: String, + pub name: Rc>, pub param_types: Rc>>, pub return_type: Rc, pub size_effect: Option, @@ -278,13 +278,13 @@ pub fn kernel_algebra_profile() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("Int".to_string(), AlgebraProfile::OrderedRingProfile); - __m.insert("Float".to_string(), AlgebraProfile::ApproximateFieldProfile); - __m.insert("Bool".to_string(), AlgebraProfile::BooleanAlgebraProfile); - __m.insert("String".to_string(), AlgebraProfile::FreeMonoidScalarProfile); - __m.insert("List".to_string(), AlgebraProfile::FreeMonoidCollectionProfile); - __m.insert("Set".to_string(), AlgebraProfile::BooleanAlgebraCollectionProfile); - __m.insert("Map".to_string(), AlgebraProfile::PartialFunctionProfile); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Int"), AlgebraProfile::OrderedRingProfile); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Float"), AlgebraProfile::ApproximateFieldProfile); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Bool"), AlgebraProfile::BooleanAlgebraProfile); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("String"), AlgebraProfile::FreeMonoidScalarProfile); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), AlgebraProfile::FreeMonoidCollectionProfile); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), AlgebraProfile::BooleanAlgebraCollectionProfile); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), AlgebraProfile::PartialFunctionProfile); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/std_coercion.rs b/src/v1/stage0/src/std_coercion.rs index 861c5852c1a..f8e946d7a45 100644 --- a/src/v1/stage0/src/std_coercion.rs +++ b/src/v1/stage0/src/std_coercion.rs @@ -12,40 +12,40 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeCheckpoint { - pub dag_name: String, - pub target_type: String, - pub default_expr: Option, + pub dag_name: Rc>, + pub target_type: Rc>, + pub default_expr: Rc>, pub is_copy: Option, - pub literal_suffix: Option, + pub literal_suffix: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct InhabitantDecl { - pub algebra: String, - pub template: String, + pub algebra: Rc>, + pub template: Rc>, pub arity: i64, - pub identity_expr: Option, - pub import_path: Option, + pub identity_expr: Rc>, + pub import_path: Rc>, pub is_copy: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CallableRepr { - pub template: String, - pub param_separator: String, - pub return_separator: String, - pub import_path: Option, + pub template: Rc>, + pub param_separator: Rc>, + pub return_separator: Rc>, + pub import_path: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CastRule { - pub from_type: String, - pub to_type: String, + pub from_type: Rc>, + pub to_type: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CastSyntax { - pub template: String, + pub template: Rc>, pub cast_rules: Rc>>, } @@ -59,12 +59,14 @@ pub fn dag_cast_rules() -> Rc>> { CACHED.with(|c: &Rc>>| c.clone()) } -pub fn dag_can_cast(source_type: String, target_type: String) -> bool { +pub fn dag_can_cast(source_type: Rc>, target_type: Rc>) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((r.from_type.clone().as_str() == source_type.clone().as_str()) - && (r.to_type.clone().as_str() == target_type.clone().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(r.from_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(source_type.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host(r.to_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(target_type.clone()))) { __found = true; break; @@ -74,12 +76,14 @@ pub fn dag_can_cast(source_type: String, target_type: String) -> bool { } } -pub fn is_dag_cast_domain_type(name: String) -> bool { +pub fn is_dag_cast_domain_type(name: Rc>) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((r.from_type.clone().as_str() == name.clone().as_str()) - || (r.to_type.clone().as_str() == name.clone().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(r.from_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + || (crate::v2_std_text::host_string_text_to_rust_host(r.to_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone()))) { __found = true; break; diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index 216005c5f43..7f9ca88ac83 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -33,17 +33,17 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum SizeBound { - CollectionSize { param: String }, - ParserStreamSize { witness: String }, - WorklistDrainSize { element: String }, - TreeSize { param: String }, - ArithmeticParam { param: String }, + CollectionSize { param: Rc> }, + ParserStreamSize { witness: Rc> }, + WorklistDrainSize { element: Rc> }, + TreeSize { param: Rc> }, + ArithmeticParam { param: Rc> }, ExplicitCountZero, ExplicitCountPositive { steps: Rc }, Forever, } -pub fn tree_size_bound(param: String) -> Rc { +pub fn tree_size_bound(param: Rc>) -> Rc { Rc::new(SizeBound::TreeSize { param: param }) } @@ -51,28 +51,28 @@ pub fn tree_size_bound(param: String) -> Rc { #[serde(tag = "_variant")] pub enum CallPattern { ChildAccessorCall { - accessor: String, + accessor: Rc>, }, CollectionShrinkCall { amount: Rc, - collection: String, + collection: Rc>, }, ArithmeticSubtractCall { steps: Rc, - ring_param: String, + ring_param: Rc>, }, ArithmeticDivideCall { divisor: Rc, - ring_param: String, + ring_param: Rc>, }, ParserAdvanceCall { - witness: String, + witness: Rc>, }, WorklistDrainCall { - element: String, + element: Rc>, }, FoldBodyCall { - outer_collection: String, + outer_collection: Rc>, }, SameArgumentCall, } @@ -173,7 +173,7 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { } } -pub fn size_bound_param(bound: Rc) -> Option { +pub fn size_bound_param(bound: Rc) -> Rc> { match (*bound).clone() { SizeBound::TreeSize { param: p, .. } => Some(p.clone()), SizeBound::CollectionSize { param: p, .. } => Some(p.clone()), @@ -232,8 +232,10 @@ pub fn algebra_profile_to_dimension(profile: AlgebraProfile) -> Option Option { - if (type_name.clone().as_str() == "Node".to_string().as_str()) { +pub fn type_iteration_dimension(type_name: Rc>) -> Option { + if (crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Node".to_string())) + { Some(IterationDimension::TreeDescent) } else { match v1_rt::map_get(&kernel_algebra_profile(), type_name.clone()) { diff --git a/src/v1/stage0/src/std_effects.rs b/src/v1/stage0/src/std_effects.rs index a21411c37b5..e443c0f0024 100644 --- a/src/v1/stage0/src/std_effects.rs +++ b/src/v1/stage0/src/std_effects.rs @@ -12,8 +12,8 @@ use crate::std_http_path::PathTemplateParseResult::{MalformedPathTemplate, Parse pub use crate::std_http_path::{has_path_params, last_path_param, parse_path_template}; pub use crate::std_http_path::{PathTemplate, PathTemplateParseResult}; pub use crate::std_types::string_list_eq; -pub use crate::std_types::HttpMethod; use crate::std_types::HttpMethod::{DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT}; +pub use crate::std_types::{HttpMethod, List}; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -53,8 +53,8 @@ impl CreateCause { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum KeySource { - PathParam { param: String }, - InputField { field: String }, + PathParam { param: Rc> }, + InputField { field: Rc> }, CompositeKey { fields: Rc> }, } @@ -67,7 +67,7 @@ pub enum IdempotencyEvidence { IdentityEffect, NonIdempotent { shape: Rc, - reason: String, + reason: Rc>, }, } impl IdempotencyEvidence { @@ -99,11 +99,17 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { pub fn key_source_eq(left: Rc, right: Rc) -> bool { match (*left).clone() { KeySource::PathParam { param: pa, .. } => match (*right).clone() { - KeySource::PathParam { param: pb, .. } => (pa.clone().as_str() == pb.clone().as_str()), + KeySource::PathParam { param: pb, .. } => { + (crate::v2_std_text::host_string_text_to_rust_host(pa.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(pb.clone())) + } _ => false, }, KeySource::InputField { field: fa, .. } => match (*right).clone() { - KeySource::InputField { field: fb, .. } => (fa.clone().as_str() == fb.clone().as_str()), + KeySource::InputField { field: fb, .. } => { + (crate::v2_std_text::host_string_text_to_rust_host(fa.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(fb.clone())) + } _ => false, }, KeySource::CompositeKey { fields: fa, .. } => match (*right).clone() { @@ -148,7 +154,7 @@ pub fn create_double_init_collapsible(a: Rc, b: Rc) -> #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OperationEffect { - pub operation_name: String, + pub operation_name: Rc>, pub shape: Rc, pub evidence: Rc, } @@ -196,7 +202,7 @@ pub fn compose_effects(effects: Rc>>) -> Rc>, pub method: HttpMethod, pub path_template: Rc, pub shape: Rc, @@ -209,11 +215,11 @@ pub enum DeriveOpEffectResult { effect: Rc, }, MalformedPathInput { - operation_name: String, + operation_name: Rc>, method: HttpMethod, - raw_path: String, - segment: String, - reason: String, + raw_path: Rc>, + segment: Rc>, + reason: Rc>, }, } @@ -253,7 +259,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc>, method: HttpMethod, path: Rc, ) -> Rc { @@ -274,11 +280,11 @@ pub fn derive_op_effect( #[serde(tag = "_variant")] pub enum ModifierAgreement { Agrees, - Disagrees { reason: String }, - DerivationUnknown { reason: String }, + Disagrees { reason: Rc> }, + DerivationUnknown { reason: Rc> }, } impl ModifierAgreement { - pub fn reason(&self) -> String { + pub fn reason(&self) -> Rc> { match self { ModifierAgreement::Agrees => panic!("no reason on unit variant"), ModifierAgreement::Disagrees { reason: __val, .. } => __val.clone(), @@ -289,7 +295,7 @@ impl ModifierAgreement { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ModifierCheck { - pub operation_name: String, + pub operation_name: Rc>, pub declared_idempotent: bool, pub declared_readonly: bool, pub derived_shape: Rc, @@ -367,9 +373,9 @@ pub fn check_modifier_vs_derivation( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct IdempotencyTestObligation { - pub operation_name: String, + pub operation_name: Rc>, pub effect_shape: Rc, - pub claim: String, + pub claim: Rc>, pub witness_required: bool, } @@ -403,7 +409,7 @@ pub fn generate_idempotency_obligations( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct WorkflowEffectConcern { - pub workflow_name: String, - pub create_op: String, - pub reason: String, + pub workflow_name: Rc>, + pub create_op: Rc>, + pub reason: Rc>, } diff --git a/src/v1/stage0/src/std_emit_model.rs b/src/v1/stage0/src/std_emit_model.rs index b91287355d7..88117c9d09e 100644 --- a/src/v1/stage0/src/std_emit_model.rs +++ b/src/v1/stage0/src/std_emit_model.rs @@ -2,6 +2,7 @@ // Source module: std.emit_model use self::PlaceholderConvention::*; +pub use crate::std_serialization::DeclarationRef; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -11,8 +12,6 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub type DeclarationRef = String; - #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, )] @@ -24,16 +23,16 @@ pub enum PlaceholderConvention { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SimpleMethodSpec { - pub method_name: String, - pub template: String, + pub method_name: Rc>, + pub template: Rc>, pub wraps_result: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct MethodTemplateContract { pub dag_method: Box, - pub runtime_template: String, - pub emit_template: String, + pub runtime_template: Rc>, + pub emit_template: Rc>, pub wraps_result: bool, pub placeholder_convention: PlaceholderConvention, } diff --git a/src/v1/stage0/src/std_graph.rs b/src/v1/stage0/src/std_graph.rs index 0a335410820..e57741988ed 100644 --- a/src/v1/stage0/src/std_graph.rs +++ b/src/v1/stage0/src/std_graph.rs @@ -14,8 +14,8 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct GraphEdge { - pub caller: String, - pub callee: String, + pub caller: Rc>, + pub callee: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -49,8 +49,8 @@ pub struct SccCycleAcc { pub fn seed_adjacency_map(names: Rc>) -> Rc>>> { names.iter().cloned().fold( - v1_rt::rc_empty_map::>>(), - |acc: Rc>>>, name: String| { + v1_rt::rc_empty_map::>, Rc>>(), + |acc: Rc>>>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), Rc::new(vec![])) }, ) @@ -66,7 +66,9 @@ pub fn build_call_graph_from_proof_edges( for e in Rc::new({ let mut __result = Vec::new(); for e in edges.iter().cloned() { - if (e.caller.clone().as_str() != e.callee.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(e.caller.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(e.callee.clone())) + { __result.push(e); } } @@ -140,7 +142,7 @@ pub fn reverse_adjacency( } pub fn dfs_finish_order( - node: String, + node: Rc>, adjacency: Rc>>>, acc: Rc, ) -> Rc { @@ -159,7 +161,7 @@ pub fn dfs_finish_order( visited: next_visited, order: acc.order.clone(), }), - |inner: Rc, neighbor: String| { + |inner: Rc, neighbor: Rc>| { dfs_finish_order(neighbor.clone(), adjacency.clone(), inner) }, ); @@ -173,7 +175,7 @@ pub fn dfs_finish_order( } pub fn dfs_collect_component( - node: String, + node: Rc>, adjacency: Rc>>>, acc: Rc, ) -> Rc { @@ -193,7 +195,7 @@ pub fn dfs_collect_component( visited: next_visited, members: next_members, }), - |inner: Rc, neighbor: String| { + |inner: Rc, neighbor: Rc>| { dfs_collect_component(neighbor.clone(), adjacency.clone(), inner) }, ) @@ -210,7 +212,7 @@ pub fn graph_has_multi_node_scc(names: Rc>, graph: Rc) -> visited: v1_rt::rc_empty_set::(), order: Rc::new(vec![]), }), - |acc: Rc, name: String| { + |acc: Rc, name: Rc>| { dfs_finish_order(name.clone(), adjacency.forward.clone(), acc) }, ); @@ -219,7 +221,7 @@ pub fn graph_has_multi_node_scc(names: Rc>, graph: Rc) -> visited: v1_rt::rc_empty_set::(), has_cycle: false, }), - |acc: Rc, name: String| { + |acc: Rc, name: Rc>| { if (acc.has_cycle.clone() || v1_rt::set_contains(&acc.visited.clone(), name.clone())) { @@ -292,7 +294,9 @@ pub fn is_valid_proof(proof: Rc, edges: Rc>> let has_self_cycle = { let mut __found = false; for e in non_descending.clone().iter().cloned() { - if (e.caller.clone().as_str() == e.callee.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(e.caller.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(e.callee.clone())) + { __found = true; break; } diff --git a/src/v1/stage0/src/std_http_path.rs b/src/v1/stage0/src/std_http_path.rs index f5dd9a50bec..dc23ae5282d 100644 --- a/src/v1/stage0/src/std_http_path.rs +++ b/src/v1/stage0/src/std_http_path.rs @@ -16,8 +16,8 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum UrlPathToken { - LiteralToken { text: String }, - ParamToken { name: String }, + LiteralToken { text: Rc> }, + ParamToken { name: Rc> }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -28,8 +28,13 @@ pub struct PathTemplate { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum PathSegmentTokensResult { - ParsedSegmentTokens { tokens: Rc>> }, - MalformedPathSegment { segment: String, reason: String }, + ParsedSegmentTokens { + tokens: Rc>>, + }, + MalformedPathSegment { + segment: Rc>, + reason: Rc>, + }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -39,13 +44,13 @@ pub enum PathTemplateParseResult { template: Rc, }, MalformedPathTemplate { - raw: String, - segment: String, - reason: String, + raw: Rc>, + segment: Rc>, + reason: Rc>, }, } -pub fn parse_path_template(raw: String) -> Rc { +pub fn parse_path_template(raw: Rc>) -> Rc { { let path_only = match Rc::new( raw.clone() @@ -70,7 +75,9 @@ pub fn parse_path_template(raw: String) -> Rc { .iter() .cloned() { - if (s.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(s.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(s); } } @@ -112,7 +119,9 @@ pub fn parse_path_template(raw: String) -> Rc { tokens: first_tokens.clone(), }), }), - |acc: Rc, seg: String| match (*acc.clone()).clone() + |acc: Rc, seg: Rc>| match (*acc + .clone()) + .clone() { PathTemplateParseResult::MalformedPathTemplate { .. } => acc.clone(), PathTemplateParseResult::ParsedPathTemplate { @@ -148,7 +157,7 @@ pub fn parse_path_template(raw: String) -> Rc { } } -pub fn parse_segment_tokens(seg: String) -> Rc { +pub fn parse_segment_tokens(seg: Rc>) -> Rc { if !v1_rt::contains(seg.clone(), "{".to_string()) { if v1_rt::contains(seg.clone(), "}".to_string()) { Rc::new(PathSegmentTokensResult::MalformedPathSegment { @@ -227,28 +236,38 @@ pub fn parse_segment_tokens(seg: String) -> Rc { }) } }; - let prefix_tokens = if (prefix.clone().as_str() != "".to_string().as_str()) { - Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { - text: prefix.clone(), - })]) - } else { - Rc::new(vec![]) - }; - let param_tokens = if (param_name.clone().as_str() != "".to_string().as_str()) { - Rc::new(vec![Rc::new(UrlPathToken::ParamToken { - name: param_name.clone(), - })]) - } else { - Rc::new(vec![]) - }; - let suffix_tokens = if (suffix.clone().as_str() != "".to_string().as_str()) { - Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { - text: suffix.clone(), - })]) - } else { - Rc::new(vec![]) - }; - if (((param_name.clone().as_str() == "".to_string().as_str()) + let prefix_tokens = + if (crate::v2_std_text::host_string_text_to_rust_host(prefix.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { + text: prefix.clone(), + })]) + } else { + Rc::new(vec![]) + }; + let param_tokens = + if (crate::v2_std_text::host_string_text_to_rust_host(param_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + Rc::new(vec![Rc::new(UrlPathToken::ParamToken { + name: param_name.clone(), + })]) + } else { + Rc::new(vec![]) + }; + let suffix_tokens = + if (crate::v2_std_text::host_string_text_to_rust_host(suffix.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + Rc::new(vec![Rc::new(UrlPathToken::LiteralToken { + text: suffix.clone(), + })]) + } else { + Rc::new(vec![]) + }; + if (((crate::v2_std_text::host_string_text_to_rust_host(param_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) || v1_rt::contains(suffix.clone(), "{".to_string())) || v1_rt::contains(suffix.clone(), "}".to_string())) { @@ -284,7 +303,7 @@ pub fn has_path_params(template: Rc) -> bool { } } -pub fn last_path_param(template: Rc) -> Option { +pub fn last_path_param(template: Rc) -> Rc> { { let params = Rc::new({ let mut __result = Vec::new(); diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index 8bb79f20f72..e3956db985b 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -51,11 +51,11 @@ pub enum RecursionShape { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct InductiveField { - pub type_name: String, - pub variant_name: String, - pub field_name: String, + pub type_name: Rc>, + pub variant_name: Rc>, + pub field_name: Rc>, pub shape: RecursionShape, - pub element_type: String, + pub element_type: Rc>, } pub fn recursion_shape_eq(a: RecursionShape, b: RecursionShape) -> bool { @@ -84,16 +84,20 @@ pub fn recursion_shape_eq(a: RecursionShape, b: RecursionShape) -> bool { } pub fn inductive_field_eq(a: Rc, b: Rc) -> bool { - (((((a.type_name.clone().as_str() == b.type_name.clone().as_str()) - && (a.variant_name.clone().as_str() == b.variant_name.clone().as_str())) - && (a.field_name.clone().as_str() == b.field_name.clone().as_str())) + (((((crate::v2_std_text::host_string_text_to_rust_host(a.type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(b.type_name.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host(a.variant_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(b.variant_name.clone()))) + && (crate::v2_std_text::host_string_text_to_rust_host(a.field_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(b.field_name.clone()))) && recursion_shape_eq(a.shape.clone(), b.shape.clone())) - && (a.element_type.clone().as_str() == b.element_type.clone().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(a.element_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(b.element_type.clone()))) } pub fn inductive_field_to_dimension( field: Rc, - param: String, + param: Rc>, ) -> Rc { Rc::new(RankingDimension::TreeSize { param: param }) } @@ -109,7 +113,7 @@ pub enum SubValueRelation { field: Rc, }, ArithmeticDescent { - param: String, + param: Rc>, factor: Rc, }, PreservedValue, @@ -194,7 +198,8 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) factor: fac_b, .. } => { - ((pa.clone().as_str() == pb.clone().as_str()) + ((crate::v2_std_text::host_string_text_to_rust_host(pa.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(pb.clone())) && shrink_factor_eq(fac_a.clone(), fac_b.clone())) } _ => false, @@ -541,15 +546,15 @@ pub fn poly_exp_degree_one() -> Rc { #[serde(tag = "_variant")] pub enum AtomicCost { PolyCost { - param: String, + param: Rc>, exponent: Rc, }, LogCost { - param: String, + param: Rc>, }, } impl AtomicCost { - pub fn param(&self) -> String { + pub fn param(&self) -> Rc> { match self { AtomicCost::PolyCost { param: __val, .. } => __val.clone(), AtomicCost::LogCost { param: __val, .. } => __val.clone(), @@ -602,7 +607,7 @@ pub fn cost_constant() -> Rc { Rc::new(CostBound::ConstantBound) } -pub fn cost_linear(param: String) -> Rc { +pub fn cost_linear(param: Rc>) -> Rc { Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::PolyCost { param: param, @@ -611,7 +616,7 @@ pub fn cost_linear(param: String) -> Rc { }) } -pub fn cost_poly(param: String, degree: i64) -> Rc { +pub fn cost_poly(param: Rc>, degree: i64) -> Rc { if (degree.clone() < 0) { Rc::new(CostBound::ErrorBound) } else { @@ -638,7 +643,7 @@ pub fn cost_poly(param: String, degree: i64) -> Rc { } } -pub fn cost_root(param: String, k: i64) -> Rc { +pub fn cost_root(param: Rc>, k: i64) -> Rc { if (k.clone() <= 0) { Rc::new(CostBound::ErrorBound) } else { @@ -657,21 +662,21 @@ pub fn cost_root(param: String, k: i64) -> Rc { } } -pub fn cost_sqrt(param: String) -> Rc { +pub fn cost_sqrt(param: Rc>) -> Rc { cost_root(param, 2) } -pub fn cost_cbrt(param: String) -> Rc { +pub fn cost_cbrt(param: Rc>) -> Rc { cost_root(param, 3) } -pub fn cost_log(param: String) -> Rc { +pub fn cost_log(param: Rc>) -> Rc { Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::LogCost { param: param }), }) } -pub fn cost_nlogn(param: String) -> Rc { +pub fn cost_nlogn(param: Rc>) -> Rc { Rc::new(CostBound::ProductBound { factors: Rc::new(vec![ Rc::new(AtomicCost::PolyCost { @@ -685,7 +690,10 @@ pub fn cost_nlogn(param: String) -> Rc { }) } -pub fn cost_graph_linear(v_param: String, e_param: String) -> Rc { +pub fn cost_graph_linear( + v_param: Rc>, + e_param: Rc>, +) -> Rc { Rc::new(CostBound::SumOfProductsBound { terms: Rc::new(vec![ Rc::new(vec![Rc::new(AtomicCost::PolyCost { @@ -702,7 +710,7 @@ pub fn cost_graph_linear(v_param: String, e_param: String) -> Rc { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RecurrenceForm { - pub param: String, + pub param: Rc>, pub branches: i64, pub divisor: i64, pub work_exponent: i64, @@ -936,7 +944,7 @@ pub fn master_theorem(form: Rc) -> Rc { } } -pub fn catamorphism_bound(param: String, nesting_depth: i64) -> Rc { +pub fn catamorphism_bound(param: Rc>, nesting_depth: i64) -> Rc { if (nesting_depth.clone() < 0) { Rc::new(CostBound::ErrorBound) } else { @@ -949,7 +957,7 @@ pub fn catamorphism_bound(param: String, nesting_depth: i64) -> Rc { } pub fn derive_bound( - param: String, + param: Rc>, branches: i64, factor: Rc, work_exponent: i64, diff --git a/src/v1/stage0/src/std_node.rs b/src/v1/stage0/src/std_node.rs index 7ca1fbee5f6..6684584366a 100644 --- a/src/v1/stage0/src/std_node.rs +++ b/src/v1/stage0/src/std_node.rs @@ -105,17 +105,17 @@ pub fn compiler_recursive_types() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("Node".to_string(), true); - __m.insert("InferredNode".to_string(), true); - __m.insert("MatchPattern".to_string(), true); - __m.insert("MethodSemantics".to_string(), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Node"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("InferredNode"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("MatchPattern"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("MethodSemantics"), true); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_compiler_recursive_type(name: String) -> bool { +pub fn is_compiler_recursive_type(name: Rc>) -> bool { match v1_rt::map_get(&compiler_recursive_types(), name) { Some(_) => true, None => false, diff --git a/src/v1/stage0/src/std_serialization.rs b/src/v1/stage0/src/std_serialization.rs new file mode 100644 index 00000000000..0fe9773c060 --- /dev/null +++ b/src/v1/stage0/src/std_serialization.rs @@ -0,0 +1,81 @@ +// Generated by v1 compiler -- do not edit. +// Source module: std.serialization + +use self::VariantEncoding::*; +use self::VariantNaming::*; +use self::WireFormat::*; +use crate::v1_rt; +use crate::v1_rt::Witness; +use crate::v1_rt::Witness::{Holds, Violates}; +use crate::NonEmptyBTreeSet; +use crate::NonEmptyVec; +use std::collections::BTreeSet; +use std::collections::HashMap; +use std::rc::Rc; + +pub type DeclarationRef = Rc>; + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum VariantNaming { + AsAuthored, + SnakeCase, + ScreamingSnakeCase, + StripPrefixAndSnakeCase { + prefix: Rc>, + }, + StripSuffixAndSnakeCase { + suffix: Rc>, + }, + StripPrefixSuffixAndSnakeCase { + prefix: Rc>, + suffix: Rc>, + }, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum VariantEncoding { + StringVariant { + naming: Rc, + }, + InternallyTaggedObject { + tag_field: Rc>, + naming: Rc, + }, + UntaggedVariant, + TaggedVariant, +} +impl VariantEncoding { + pub fn naming(&self) -> Rc { + match self { + VariantEncoding::StringVariant { naming: __val, .. } => __val.clone(), + VariantEncoding::InternallyTaggedObject { naming: __val, .. } => __val.clone(), + VariantEncoding::UntaggedVariant => panic!("no naming on unit variant"), + VariantEncoding::TaggedVariant => panic!("no naming on unit variant"), + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct CoproductWireContract { + pub coproduct: Box, + pub encoding: Rc, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct WireContract { + pub variant_encoding: Rc, +} + +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum WireFormat { + Json, + Text, +} + +pub struct Json; +pub struct Text; diff --git a/src/v1/stage0/src/std_syntax.rs b/src/v1/stage0/src/std_syntax.rs index 1e280cc963c..939f3613c86 100644 --- a/src/v1/stage0/src/std_syntax.rs +++ b/src/v1/stage0/src/std_syntax.rs @@ -39,12 +39,12 @@ pub enum BinOp { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum LiteralValue { - LitStr { value: String }, + LitStr { value: Rc> }, LitInt { value: i64 }, - LitFloat { value: String }, + LitFloat { value: Rc> }, LitBool { value: bool }, LitNull, - LitSymbol { value: String }, + LitSymbol { value: Rc> }, } #[derive( @@ -77,7 +77,7 @@ pub enum ItemFormKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemForm { pub kind: ItemFormKind, - pub keyword: String, + pub keyword: Rc>, pub has_type_params: bool, pub has_params: bool, pub has_return_type: bool, @@ -104,7 +104,7 @@ pub enum AlgebraFieldKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct AlgebraFieldEntry { pub kind: AlgebraFieldKind, - pub field_name: String, + pub field_name: Rc>, } pub fn algebra_field_entries() -> Rc>> { @@ -142,7 +142,7 @@ pub fn algebra_field_entries() -> Rc>> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OperatorSpec { - pub symbol: String, + pub symbol: Rc>, pub left_bp: i64, pub right_bp: i64, pub binop: Option, diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index 46d3e739ca9..773cebea86e 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -99,7 +99,7 @@ pub fn optional_evidence_meet( pub fn map_evidence_merge_at( base: Rc>, - key: String, + key: Rc>, new_val: DescentEvidence, ) -> Rc> { match v1_rt::map_get(&base, key.clone()) { @@ -115,14 +115,14 @@ pub fn map_evidence_merge_at( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum RankingDimension { - TreeSize { param: String }, - ListLength { param: String }, - ArithmeticValue { param: String }, - TokenPosition { param: String }, - SetCardinality { param: String }, + TreeSize { param: Rc> }, + ListLength { param: Rc> }, + ArithmeticValue { param: Rc> }, + TokenPosition { param: Rc> }, + SetCardinality { param: Rc> }, } impl RankingDimension { - pub fn param(&self) -> String { + pub fn param(&self) -> Rc> { match self { RankingDimension::TreeSize { param: __val, .. } => __val.clone(), RankingDimension::ListLength { param: __val, .. } => __val.clone(), @@ -236,12 +236,12 @@ pub fn proportional_divisor_from_int_at_least_two(k: i64) -> Option> }, ListShrink { amount: Rc }, ArithmeticSubtractDescent { steps: Rc }, ArithmeticDivideDescent { divisor: Rc }, - ParserAdvance { witness: String }, - SetRemoval { element: String }, + ParserAdvance { witness: Rc> }, + SetRemoval { element: Rc> }, FoldIteration, } @@ -252,8 +252,8 @@ pub struct TerminationProof { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ProofEdge { - pub caller: String, - pub callee: String, + pub caller: Rc>, + pub callee: Rc>, pub evidence: Rc>, } diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index eed22a9dbf1..f5615714124 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -22,21 +22,21 @@ pub fn kernel_type_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("String".to_string(), true); - __m.insert("Int".to_string(), true); - __m.insert("Bool".to_string(), true); - __m.insert("Float".to_string(), true); - __m.insert("Secret".to_string(), true); - __m.insert("Json".to_string(), true); - __m.insert("Unit".to_string(), true); - __m.insert("Bytes".to_string(), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("String"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Int"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Bool"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Float"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Secret"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Json"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Unit"), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Bytes"), true); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_kernel_type(name: String) -> bool { +pub fn is_kernel_type(name: Rc>) -> bool { match v1_rt::map_get(&kernel_type_set(), name) { Some(_) => true, None => false, @@ -47,29 +47,31 @@ pub fn container_type_arity() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), 1); - __m.insert("Set".to_string(), 1); - __m.insert("Map".to_string(), 2); - __m.insert("Witness".to_string(), 1); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), 1); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), 1); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), 2); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Witness"), 1); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_container_type(name: String) -> bool { +pub fn is_container_type(name: Rc>) -> bool { match container_expected_arity(name) { Some(_) => true, None => false, } } -pub fn container_expected_arity(name: String) -> Option { +pub fn container_expected_arity(name: Rc>) -> Option { v1_rt::map_get(&container_type_arity(), name) } -pub fn container_param_names_for(kind_name: String) -> Rc> { - if (kind_name.clone().as_str() == "Witness".to_string().as_str()) { +pub fn container_param_names_for(kind_name: Rc>) -> Rc> { + if (crate::v2_std_text::host_string_text_to_rust_host(kind_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) + { Rc::new(vec!["T".to_string()]) } else { match v1_rt::map_get(&kernel_algebra_profile(), kind_name.clone()) { @@ -79,7 +81,7 @@ pub fn container_param_names_for(kind_name: String) -> Rc> { } } -pub fn container_param_name(kind_name: String, index: i64) -> Option { +pub fn container_param_name(kind_name: Rc>, index: i64) -> Rc> { { let names = container_param_names_for(kind_name); match Rc::new({ @@ -123,14 +125,14 @@ pub fn ordered_element_collections() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), true); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), true); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_ordered_element_collection(name: String) -> bool { +pub fn is_ordered_element_collection(name: Rc>) -> bool { v1_rt::map_contains_key(&ordered_element_collections(), name) } @@ -138,18 +140,18 @@ pub fn container_template_algebra_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), "FreeMonoid".to_string()); - __m.insert("list".to_string(), "FreeMonoid".to_string()); - __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("Map".to_string(), "PartialFunction".to_string()); - __m.insert("map".to_string(), "PartialFunction".to_string()); - __m.insert("FreeMonoid".to_string(), "FreeMonoid".to_string()); - __m.insert("free_monoid".to_string(), "FreeMonoid".to_string()); - __m.insert("BooleanAlgebra".to_string(), "BooleanAlgebra".to_string()); - __m.insert("boolean_algebra".to_string(), "BooleanAlgebra".to_string()); - __m.insert("PartialFunction".to_string(), "PartialFunction".to_string()); - __m.insert("partial_function".to_string(), "PartialFunction".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), "FreeMonoid".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "FreeMonoid".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), "BooleanAlgebra".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "BooleanAlgebra".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), "PartialFunction".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "PartialFunction".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("FreeMonoid"), "FreeMonoid".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "FreeMonoid".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("BooleanAlgebra"), "BooleanAlgebra".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "BooleanAlgebra".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("PartialFunction"), "PartialFunction".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "PartialFunction".to_string()); Rc::new(__m) }; } @@ -160,23 +162,23 @@ pub fn container_template_alias_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("List".to_string(), "FreeMonoid".to_string()); - __m.insert("list".to_string(), "FreeMonoid".to_string()); - __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("set".to_string(), "BooleanAlgebra".to_string()); - __m.insert("Map".to_string(), "PartialFunction".to_string()); - __m.insert("map".to_string(), "PartialFunction".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), "FreeMonoid".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "FreeMonoid".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), "BooleanAlgebra".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "BooleanAlgebra".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), "PartialFunction".to_string()); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "PartialFunction".to_string()); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn container_template_algebra(name: String) -> Option { +pub fn container_template_algebra(name: Rc>) -> Rc> { v1_rt::map_get(&container_template_algebra_rows(), name) } -pub fn container_template_alias_algebra(name: String) -> Option { +pub fn container_template_alias_algebra(name: Rc>) -> Rc> { v1_rt::map_get(&container_template_alias_rows(), name) } @@ -235,27 +237,27 @@ pub type Bytes = Vec; pub type Char = i64; -pub type CommitSha = String; +pub type CommitSha = Rc>; -pub type Sha256 = String; +pub type Sha256 = Rc>; pub type RetryCount = i64; pub type HttpStatus = i64; -pub type Email = String; +pub type Email = Rc>; pub type Port = i64; -pub type GistId = String; +pub type GistId = Rc>; -pub type Secret = String; +pub type Secret = Rc>; pub type SecretValue = String; -pub type Url = String; +pub type Url = Rc>; -pub type SemVer = String; +pub type SemVer = Rc>; pub type NonEmptyStr = String; @@ -286,7 +288,7 @@ pub struct SourceSpan { pub end: i64, } -pub type Timestamp = String; +pub type Timestamp = Rc>; pub type EpochMs = i64; @@ -363,7 +365,7 @@ pub type TextFilePath = String; pub type BinaryFilePath = String; -pub type MimeType = String; +pub type MimeType = Rc>; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, @@ -383,8 +385,8 @@ pub enum HttpMethod { #[serde(tag = "_variant")] pub enum AuthScheme { Bearer, - Header { name: String }, - Basic { username: String }, + Header { name: Rc> }, + Basic { username: Rc> }, ApiKey, } @@ -399,8 +401,8 @@ pub struct AccessToken { pub struct Credential { pub token: String, pub scheme: Rc, - pub header_name: Option, - pub source_id: String, + pub header_name: Rc>, + pub source_id: Rc>, pub required_scopes: Rc>, pub expires_in: Option, } @@ -414,30 +416,30 @@ pub type ToolHandle = String; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TransportRequest { pub method: HttpMethod, - pub url: String, + pub url: Rc>, pub headers: serde_json::Value, - pub body: String, + pub body: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TransportResponse { pub status: i64, pub headers: serde_json::Value, - pub body: String, + pub body: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FileResponse { - pub path: String, + pub path: Rc>, pub success: bool, - pub content: String, + pub content: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ShellResponse { pub exit_code: i64, - pub stdout: String, - pub stderr: String, + pub stdout: Rc>, + pub stderr: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -449,10 +451,10 @@ pub struct RestResponse { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TestResult { - pub name: String, + pub name: Rc>, pub ok: bool, - pub stdout: String, - pub stderr: String, + pub stdout: Rc>, + pub stderr: Rc>, pub duration_ms: Milliseconds, } @@ -465,53 +467,53 @@ pub struct Summary { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StageResult { - pub name: String, + pub name: Rc>, pub success: bool, - pub stdout: String, - pub stderr: String, + pub stdout: Rc>, + pub stderr: Rc>, pub skipped: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DocumentLine { - pub text: String, + pub text: Rc>, pub is_comment: bool, pub is_blank: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DocumentSection { - pub title: String, + pub title: Rc>, pub has_title: bool, pub lines: Rc>>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Document { - pub header: String, + pub header: Rc>, pub has_header: bool, - pub comment_prefix: String, + pub comment_prefix: Rc>, pub sections: Rc>>, pub trailing_newline: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TextFile { - pub path: String, + pub path: Rc>, pub document: Rc, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RenderedTextFile { - pub path: String, - pub content: String, + pub path: Rc>, + pub content: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ToolEntry { - pub name: String, - pub command: String, - pub description: Option, + pub name: Rc>, + pub command: Rc>, + pub description: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -528,17 +530,17 @@ pub struct DagTopology { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TopologyNode { - pub id: String, - pub label: String, + pub id: Rc>, + pub label: Rc>, pub kind: TopologyNodeKind, - pub parent: Option, + pub parent: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TopologyEdge { - pub from: String, - pub to: String, - pub port: Option, + pub from: Rc>, + pub to: Rc>, + pub port: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -550,9 +552,9 @@ pub struct DagDiff { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct PragmaDirective { - pub key: String, - pub value: String, - pub scope: Option, + pub key: Rc>, + pub value: Rc>, + pub scope: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -575,38 +577,6 @@ pub struct S; pub struct M; pub struct L; pub struct Xl; -pub struct X86_64; -pub struct X86; -pub struct Aarch64; -pub struct Arm; -pub struct Armv7; -pub struct Mipsel; -pub struct Mips64; -pub struct Mips64el; -pub struct Riscv64; -pub struct Wasm32; -pub struct UnknownVendor; -pub struct Pc; -pub struct Apple; -pub struct W64; -pub struct Freebsd; -pub struct Android; -pub struct Ios; -pub struct Wasi; -pub struct NoneAbi; -pub struct Gnu; -pub struct GnuEabi; -pub struct GnuEabihf; -pub struct Musl; -pub struct Msvc; -pub struct AndroidAbi; -pub struct Eabi; -pub struct Eabihf; -pub struct Native; -pub struct Wsl; -pub struct Container; -pub struct Ci; -pub struct Emulator; pub struct GET; pub struct POST; pub struct PUT; @@ -614,6 +584,3 @@ pub struct PATCH; pub struct DELETE; pub struct HEAD; pub struct OPTIONS; -pub struct Rust; -pub struct Go; -pub struct C; diff --git a/src/v1/stage0/src/v1_compiler_artifact.rs b/src/v1/stage0/src/v1_compiler_artifact.rs index 933b218e2e0..497279471b2 100644 --- a/src/v1/stage0/src/v1_compiler_artifact.rs +++ b/src/v1/stage0/src/v1_compiler_artifact.rs @@ -41,7 +41,7 @@ pub enum ArtifactKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Artifact { - pub name: String, + pub name: Rc>, pub kind: ArtifactKind, pub target: RenderTarget, pub entry_modules: Rc>, @@ -62,10 +62,10 @@ pub enum BoundaryKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Boundary { - pub from_artifact: String, - pub to_artifact: String, + pub from_artifact: Rc>, + pub to_artifact: Rc>, pub kind: BoundaryKind, - pub contract: String, + pub contract: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -121,7 +121,7 @@ pub fn default_artifact_plan( })) } -pub type DagNodeId = String; +pub type DagNodeId = Rc>; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] @@ -130,10 +130,10 @@ pub enum DagInferredRecord { node: Box, }, TypeVariableRef { - id: String, + id: Rc>, }, CompilerErrorRecord { - message: String, + message: Rc>, span: Rc, }, } @@ -147,16 +147,16 @@ pub struct DagModuleRef { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DagDiagnosticRecord { - pub severity: String, - pub message: String, + pub severity: Rc>, + pub message: Rc>, pub span: Rc, - pub module_name: Option, - pub category: Option, + pub module_name: Rc>, + pub category: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DagArtifact { - pub version: String, + pub version: Rc>, pub nodes: Rc>, pub modules: Rc>, pub item_registry_keys: Rc>, @@ -164,7 +164,9 @@ pub struct DagArtifact { pub files: Rc>, } +pub struct Rust; pub struct Python; +pub struct Go; pub struct Dag; pub struct ServiceBinary; pub struct Library; diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index d86d3d71511..5c9cda519ac 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -59,7 +59,7 @@ pub fn target_callable(target: RenderTarget) -> Rc { } } -pub fn target_optional_template(target: RenderTarget) -> String { +pub fn target_optional_template(target: RenderTarget) -> Rc> { match target { RenderTarget::Rust => rust_optional_template(), RenderTarget::Python => python_optional_template(), @@ -77,13 +77,19 @@ pub fn target_cast_syntax(target: RenderTarget) -> Option> { } } -pub fn can_cast(target: RenderTarget, source_type: String, target_type: String) -> bool { +pub fn can_cast( + target: RenderTarget, + source_type: Rc>, + target_type: Rc>, +) -> bool { match target_cast_syntax(target) { Some(syntax) => { let mut __found = false; for r in syntax.cast_rules.clone().iter().cloned() { - if ((r.from_type.clone().as_str() == source_type.clone().as_str()) - && (r.to_type.clone().as_str() == target_type.clone().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(r.from_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(source_type.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host(r.to_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(target_type.clone()))) { __found = true; break; @@ -95,7 +101,11 @@ pub fn can_cast(target: RenderTarget, source_type: String, target_type: String) } } -pub fn render_cast(expr_str: String, type_str: String, target: RenderTarget) -> String { +pub fn render_cast( + expr_str: Rc>, + type_str: Rc>, + target: RenderTarget, +) -> Rc> { { let syntax = match target_cast_syntax(target) { Some(s) => s.clone(), @@ -112,11 +122,16 @@ pub fn render_cast(expr_str: String, type_str: String, target: RenderTarget) -> } } -pub fn lookup_checkpoint(target: RenderTarget, dag_name: String) -> Option> { +pub fn lookup_checkpoint( + target: RenderTarget, + dag_name: Rc>, +) -> Option> { Rc::new({ let mut __result = Vec::new(); for cp in target_checkpoints(target).iter().cloned() { - if (cp.dag_name.clone().as_str() == dag_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(cp.dag_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(dag_name.clone())) + { __result.push(cp); } } @@ -126,21 +141,24 @@ pub fn lookup_checkpoint(target: RenderTarget, dag_name: String) -> Option String { +pub fn coerce_primitive_type( + target: RenderTarget, + dag_name: Rc>, +) -> Rc> { match lookup_checkpoint(target, dag_name.clone()) { Some(cp) => cp.target_type.clone(), None => dag_name.clone(), } } -pub fn is_copy(target: RenderTarget, dag_name: String) -> Option { +pub fn is_copy(target: RenderTarget, dag_name: Rc>) -> Option { match lookup_checkpoint(target, dag_name) { Some(cp) => cp.is_copy.clone(), None => None, } } -pub fn literal_suffix(target: RenderTarget, dag_name: String) -> Option { +pub fn literal_suffix(target: RenderTarget, dag_name: Rc>) -> Rc> { match lookup_checkpoint(target, dag_name) { Some(cp) => match cp.literal_suffix.clone() { Some(s) => Some(s.clone()), @@ -150,11 +168,16 @@ pub fn literal_suffix(target: RenderTarget, dag_name: String) -> Option } } -pub fn lookup_inhabitant(target: RenderTarget, algebra: String) -> Option> { +pub fn lookup_inhabitant( + target: RenderTarget, + algebra: Rc>, +) -> Option> { Rc::new({ let mut __result = Vec::new(); for inh in target_inhabitants(target).iter().cloned() { - if (inh.algebra.clone().as_str() == algebra.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(inh.algebra.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(algebra.clone())) + { __result.push(inh); } } @@ -164,7 +187,10 @@ pub fn lookup_inhabitant(target: RenderTarget, algebra: String) -> Option Option { +pub fn coerce_container_template( + target: RenderTarget, + container_name: Rc>, +) -> Rc> { match container_template_algebra(container_name) { Some(algebra) => match lookup_inhabitant(target, algebra.clone()) { Some(inh) => Some(inh.template.clone()), @@ -174,11 +200,18 @@ pub fn coerce_container_template(target: RenderTarget, container_name: String) - } } -pub fn apply_inhabitant_template1(template: String, inner: String) -> String { +pub fn apply_inhabitant_template1( + template: Rc>, + inner: Rc>, +) -> Rc> { v1_rt::replace(template, "{0}".to_string(), inner) } -pub fn apply_inhabitant_template2(template: String, first: String, second: String) -> String { +pub fn apply_inhabitant_template2( + template: Rc>, + first: Rc>, + second: Rc>, +) -> Rc> { v1_rt::replace( v1_rt::replace(template, "{0}".to_string(), first), "{1}".to_string(), @@ -191,33 +224,33 @@ pub fn apply_inhabitant_template2(template: String, first: String, second: Strin pub enum CoercionAssertion { CheckpointAssertion { target: RenderTarget, - dag_name: String, - expected_type: String, + dag_name: Rc>, + expected_type: Rc>, }, ContainerAssertion { target: RenderTarget, - container_name: String, - expected_template: String, + container_name: Rc>, + expected_template: Rc>, }, CopyAssertion { target: RenderTarget, - dag_name: String, + dag_name: Rc>, expected_copy: bool, }, TemplateAssertion { - template: String, + template: Rc>, args: Rc>, - expected: String, + expected: Rc>, }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CoercionTestEntry { - pub test_name: String, + pub test_name: Rc>, pub assertions: Rc>>, } -pub fn target_label(target: RenderTarget) -> String { +pub fn target_label(target: RenderTarget) -> Rc> { match target { RenderTarget::Rust => "rust".to_string(), RenderTarget::Python => "python".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index ec24f5bc208..b56e0508b8a 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -87,8 +87,8 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SourceFile { - pub path: String, - pub content: String, + pub path: Rc>, + pub content: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -332,7 +332,7 @@ pub fn empty_artifact_plan() -> Rc { }) } -pub fn compile_bundle_error(message: String) -> Rc { +pub fn compile_bundle_error(message: Rc>) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::InternalError { message: message, @@ -351,14 +351,14 @@ pub fn emit_artifact(typed: Rc, artifact: Rc) -> Rc>) -> String { +pub fn json_list(items: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat("[".to_string(), items.join(&", ".to_string())), "]".to_string(), ) } -pub fn json_optional_string(value: Option) -> String { +pub fn json_optional_string(value: Rc>) -> Rc> { match value { Some(inner) => json_quote(inner.clone()), None => "null".to_string(), @@ -536,12 +536,17 @@ pub fn build_dag_key_to_id(order: Rc>>) -> Rc(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, pair: (i64, Rc)| { v1_rt::rc_map_insert( acc, dag_node_key(pair.1.clone()), - v1_rt::concat("n".to_string(), (pair.0.clone()).to_string()), + v1_rt::concat( + "n".to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (pair.0.clone()).to_string(), + ), + ), ) }, ) @@ -549,14 +554,17 @@ pub fn build_dag_key_to_id(order: Rc>>) -> Rc) -> Rc>> { typed.modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, m: Rc| { v1_rt::rc_map_merge(acc, m.type_env.clone().source_indices.clone()) }, ) } -pub fn serialize_node_ref(node: Rc, key_to_id: Rc>) -> String { +pub fn serialize_node_ref( + node: Rc, + key_to_id: Rc>, +) -> Rc> { match v1_rt::map_get(&key_to_id, dag_node_key(node)) { Some(id) => v1_rt::concat( v1_rt::concat("{\"$ref\": ".to_string(), json_quote(id.clone())), @@ -569,7 +577,7 @@ pub fn serialize_node_ref(node: Rc, key_to_id: Rc> pub fn json_optional_node_ref( value: Option>, key_to_id: Rc>, -) -> String { +) -> Rc> { match value { Some(inner) => serialize_node_ref(inner.clone(), key_to_id), None => "null".to_string(), @@ -579,21 +587,21 @@ pub fn json_optional_node_ref( pub fn json_optional_inferred_node_ref( value: Option>, key_to_id: Rc>, -) -> String { +) -> Rc> { match value { Some(inner) => serialize_inferred_node_ref(inner.clone(), key_to_id), None => "null".to_string(), } } -pub fn json_optional_span(value: Option>) -> String { +pub fn json_optional_span(value: Option>) -> Rc> { match value { Some(inner) => serialize_span(inner.clone()), None => "null".to_string(), } } -pub fn json_bool(value: bool) -> String { +pub fn json_bool(value: bool) -> Rc> { if value { "true".to_string() } else { @@ -601,14 +609,14 @@ pub fn json_bool(value: bool) -> String { } } -pub fn cardinality_name(value: Cardinality) -> String { +pub fn cardinality_name(value: Cardinality) -> Rc> { match value { Cardinality::Required => "Required".to_string(), Cardinality::CardOptional => "CardOptional".to_string(), } } -pub fn field_access_style_name(value: FieldAccessStyle) -> String { +pub fn field_access_style_name(value: FieldAccessStyle) -> Rc> { match value { FieldAccessStyle::StoredField => "StoredField".to_string(), FieldAccessStyle::EnumAccessor => "EnumAccessor".to_string(), @@ -618,14 +626,14 @@ pub fn field_access_style_name(value: FieldAccessStyle) -> String { } } -pub fn field_value_shape_name(value: FieldValueShape) -> String { +pub fn field_value_shape_name(value: FieldValueShape) -> Rc> { match value { FieldValueShape::PlainValue => "PlainValue".to_string(), FieldValueShape::OptionalValue => "OptionalValue".to_string(), } } -pub fn var_binding_kind_name(value: Rc) -> String { +pub fn var_binding_kind_name(value: Rc) -> Rc> { match (*value).clone() { VarBindingKind::LocalValueBinding => "LocalValueBinding".to_string(), VarBindingKind::FunctionValueBinding => "FunctionValueBinding".to_string(), @@ -636,14 +644,14 @@ pub fn var_binding_kind_name(value: Rc) -> String { } } -pub fn call_semantics_name(value: CallSemantics) -> String { +pub fn call_semantics_name(value: CallSemantics) -> Rc> { match value { CallSemantics::PlainCallSemantics => "PlainCallSemantics".to_string(), CallSemantics::LookupCallSemantics => "LookupCallSemantics".to_string(), } } -pub fn expr_error_kind_name(value: ExprErrorKind) -> String { +pub fn expr_error_kind_name(value: ExprErrorKind) -> Rc> { match value { ExprErrorKind::ParseRecoveryError => "ParseRecoveryError".to_string(), ExprErrorKind::SemanticExprError => "SemanticExprError".to_string(), @@ -651,7 +659,7 @@ pub fn expr_error_kind_name(value: ExprErrorKind) -> String { } } -pub fn bin_op_name(value: BinOp) -> String { +pub fn bin_op_name(value: BinOp) -> Rc> { match value { BinOp::Add => "Add".to_string(), BinOp::Sub => "Sub".to_string(), @@ -670,21 +678,26 @@ pub fn bin_op_name(value: BinOp) -> String { } } -pub fn unary_op_name(value: UnaryOpKind) -> String { +pub fn unary_op_name(value: UnaryOpKind) -> Rc> { match value { UnaryOpKind::Not => "Not".to_string(), UnaryOpKind::Neg => "Neg".to_string(), } } -pub fn serialize_span(span: Rc) -> String { +pub fn serialize_span(span: Rc) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("{\"start\": ".to_string(), (span.start.clone()).to_string()), + v1_rt::concat( + "{\"start\": ".to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (span.start.clone()).to_string(), + ), + ), ", \"end\": ".to_string(), ), - (span.end.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host((span.end.clone()).to_string()), ), "}".to_string(), ) @@ -693,7 +706,7 @@ pub fn serialize_span(span: Rc) -> String { pub fn serialize_import_node( imp: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let names_json = if import_is_all(imp.clone()) { "{\"kind\": \"ImportAll\"}".to_string() @@ -737,7 +750,7 @@ pub fn serialize_import_node( } } -pub fn serialize_field_summary(summary: Rc) -> String { +pub fn serialize_field_summary(summary: Rc) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -753,7 +766,7 @@ pub fn serialize_field_summary(summary: Rc) -> String { ) } -pub fn serialize_literal(value: Rc) -> String { +pub fn serialize_literal(value: Rc) -> Rc> { match (*value).clone() { LiteralValue::LitStr { value: inner, .. } => v1_rt::concat( v1_rt::concat( @@ -765,7 +778,7 @@ pub fn serialize_literal(value: Rc) -> String { LiteralValue::LitInt { value: inner, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"LitInt\", \"value\": ".to_string(), - (inner.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host((inner.clone()).to_string()), ), "}".to_string(), ), @@ -797,7 +810,7 @@ pub fn serialize_literal(value: Rc) -> String { pub fn serialize_field_binding( binding: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -822,7 +835,7 @@ pub fn serialize_field_binding( pub fn serialize_match_pattern( pattern: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match (*pattern).clone() { MatchPattern::Bind { name: inner, .. } => v1_rt::concat( v1_rt::concat( @@ -876,7 +889,7 @@ pub fn serialize_named_arg( arg: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -896,7 +909,7 @@ pub fn serialize_match_arm( arm: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -922,7 +935,7 @@ pub fn serialize_field_init( field_init: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -942,7 +955,7 @@ pub fn serialize_string_part( part: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { match (*part).clone() { StringPart::Text { value: inner, .. } => v1_rt::concat( v1_rt::concat( @@ -961,7 +974,7 @@ pub fn serialize_string_part( } } -pub fn serialize_call_semantics(value: Option) -> String { +pub fn serialize_call_semantics(value: Option) -> Rc> { match value { Some(inner) => v1_rt::concat( v1_rt::concat( @@ -978,7 +991,7 @@ pub fn serialize_method_semantics( value: Option>, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { match value.as_deref().cloned() { Some(MethodSemantics::PlainMethodSemantics) => { "{\"kind\": \"PlainMethodSemantics\"}".to_string() @@ -1034,7 +1047,7 @@ pub fn serialize_method_semantics( } } -pub fn serialize_recursion_shape(shape: RecursionShape) -> String { +pub fn serialize_recursion_shape(shape: RecursionShape) -> Rc> { match shape { RecursionShape::DirectRecursion => "{\"_variant\": \"DirectRecursion\"}".to_string(), RecursionShape::ListRecursion => "{\"_variant\": \"ListRecursion\"}".to_string(), @@ -1044,7 +1057,7 @@ pub fn serialize_recursion_shape(shape: RecursionShape) -> String { } } -pub fn serialize_inductive_field(field: Rc) -> String { +pub fn serialize_inductive_field(field: Rc) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1072,7 +1085,7 @@ pub fn serialize_inductive_field(field: Rc) -> String { ) } -pub fn serialize_positive_descent_amount(steps: Rc) -> String { +pub fn serialize_positive_descent_amount(steps: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*steps).clone() { PositiveDescentAmount::OneStep => "{\"_variant\": \"OneStep\"}".to_string(), PositiveDescentAmount::AdditionalStep { previous: p, .. } => v1_rt::concat( @@ -1085,7 +1098,7 @@ pub fn serialize_positive_descent_amount(steps: Rc) -> St }) } -pub fn serialize_proportional_divisor(d: Rc) -> String { +pub fn serialize_proportional_divisor(d: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*d).clone() { ProportionalDivisor::DivideByTwo => "{\"_variant\": \"DivideByTwo\"}".to_string(), ProportionalDivisor::StrictlyLarger { inner: i, .. } => v1_rt::concat( @@ -1098,7 +1111,7 @@ pub fn serialize_proportional_divisor(d: Rc) -> String { }) } -pub fn serialize_shrink_factor(factor: Rc) -> String { +pub fn serialize_shrink_factor(factor: Rc) -> Rc> { match (*factor).clone() { ShrinkFactor::UnitShrink => "{\"_variant\": \"UnitShrink\"}".to_string(), ShrinkFactor::ConstantShrink { steps: s, .. } => v1_rt::concat( @@ -1118,7 +1131,7 @@ pub fn serialize_shrink_factor(factor: Rc) -> String { } } -pub fn serialize_sub_value_relation(rel: Rc) -> String { +pub fn serialize_sub_value_relation(rel: Rc) -> Rc> { match (*rel).clone() { SubValueRelation::StrictSubValue { field: f, @@ -1171,7 +1184,9 @@ pub fn serialize_sub_value_relation(rel: Rc) -> String { } } -pub fn serialize_descent_evidence(de: Option>>>) -> String { +pub fn serialize_descent_evidence( + de: Option>>>, +) -> Rc> { match de { Some(evidence) => json_list(Rc::new({ let mut __result = Vec::new(); @@ -1188,7 +1203,7 @@ pub fn serialize_expr_data( expr_node: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { { let ch = expr_node.children.clone(); let name = authored_name_at(source_indices.clone(), expr_node.clone()); @@ -1659,7 +1674,7 @@ pub fn serialize_expr_data( pub fn serialize_inferred_node_ref( inferred: Rc, key_to_id: Rc>, -) -> String { +) -> Rc> { match (*inferred).clone() { InferredNode::Resolved { node: node, .. } => v1_rt::concat( v1_rt::concat( @@ -1695,7 +1710,7 @@ pub fn serialize_resource_use( resource_use: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1721,7 +1736,7 @@ pub fn serialize_field( field: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1779,7 +1794,7 @@ pub fn serialize_param( param: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1850,7 +1865,7 @@ pub fn serialize_node_params_json( node: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { if is_module_shell_node(node.clone()) { "[]".to_string() } else { @@ -1871,7 +1886,7 @@ pub fn serialize_node_params_json( pub fn serialize_module_imports_json( node: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let imports = module_imports(node); if ((imports.clone().len() as i64) == 0) { @@ -1905,7 +1920,7 @@ pub fn serialize_node_record( node: Rc, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("{\"name\": ".to_string(), json_quote(authored_name_at(source_indices.clone(), node.clone()))), ", \"imports\": ".to_string()), serialize_module_imports_json(node.clone(), source_indices.clone())), ", \"span\": ".to_string()), serialize_span(node.span.clone())), ", \"ident_span\": ".to_string()), json_optional_span(node.ident_span.clone())), ", \"children\": ".to_string()), json_list(Rc::new({ let mut __result = Vec::new(); for child in node.children.clone().iter().cloned() { __result.push(serialize_node_ref(child.clone(), key_to_id.clone())); } __result }))), ", \"connective\": ".to_string()), match node.connective.clone() { Connective::Conj => json_quote(connective_name(Connective::Conj)), Connective::Disj => json_quote(connective_name(Connective::Disj)), @@ -1917,7 +1932,7 @@ pub fn serialize_node_record( pub fn serialize_typed_module( module: Rc, key_to_id: Rc>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1958,7 +1973,7 @@ pub fn serialize_dag_nodes_table( order: Rc>>, source_indices: Rc>>, key_to_id: Rc>, -) -> String { +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -1974,7 +1989,12 @@ pub fn serialize_dag_nodes_table( { __result.push(v1_rt::concat( v1_rt::concat( - json_quote(v1_rt::concat("n".to_string(), (pair.0.clone()).to_string())), + json_quote(v1_rt::concat( + "n".to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (pair.0.clone()).to_string(), + ), + )), ": ".to_string(), ), serialize_node_record(pair.1.clone(), source_indices.clone(), key_to_id.clone()), @@ -1985,7 +2005,7 @@ pub fn serialize_dag_nodes_table( .join(&", ".to_string()) } -pub fn serialize_diagnostic(diagnostic: Rc) -> String { +pub fn serialize_diagnostic(diagnostic: Rc) -> Rc> { { let severity = "error".to_string(); v1_rt::concat( @@ -2107,11 +2127,16 @@ pub fn emit_dag_artifact(typed: Rc) -> Rc { } } -pub fn boundary_ref_error(names: Rc>, ref_name: String) -> Rc>> { +pub fn boundary_ref_error( + names: Rc>, + ref_name: Rc>, +) -> Rc>> { if { let mut __found = false; for n in names.iter().cloned() { - if (n.clone().as_str() == ref_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(ref_name.clone())) + { __found = true; break; } @@ -2246,7 +2271,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc let parsed = parse_with_table( p.tokens.clone(), v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), p.newline_index.clone().file.clone(), p.newline_index.clone(), ), @@ -2296,7 +2321,7 @@ pub fn front_end_sources(sources: Rc>>) -> Rc __result }); let source_indices = newline_indices.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, si: Rc| { v1_rt::rc_map_insert(acc, si.file.clone(), si.clone()) }, @@ -2363,7 +2388,7 @@ pub fn compile_to_resolved_with_options( None => Rc::new(ResolvedPipelineResult { graph: None, diagnostics: frontend.diagnostics.clone(), - source_indices: v1_rt::rc_empty_map::>(), + source_indices: v1_rt::rc_empty_map::>, Rc>(), complexity: empty_complexity_report(), ownership: Rc::new(vec![]), newline_indices: newline_indices.clone(), @@ -2383,14 +2408,15 @@ pub fn compile_to_resolved_with_options( return Rc::new(ResolvedPipelineResult { graph: None, diagnostics: frontend.diagnostics.clone(), - source_indices: v1_rt::rc_empty_map::>(), + source_indices: v1_rt::rc_empty_map::>, Rc>( + ), complexity: empty_complexity_report(), ownership: Rc::new(vec![]), newline_indices: newline_indices.clone(), }); } let source_indices = newline_indices.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, index: Rc| { v1_rt::rc_map_insert(acc, index.file.clone(), index.clone()) }, diff --git a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs index 9ead7dea419..d783f317a48 100644 --- a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs +++ b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs @@ -17,7 +17,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn ct_module_header() -> String { +pub fn ct_module_header() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -30,55 +30,55 @@ pub fn ct_module_header() -> String { ) } -pub fn ct_workspace_helpers() -> String { +pub fn ct_workspace_helpers() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Find workspace root by walking up from the current directory looking for Cargo.toml + dsl/\n".to_string(), " fn workspace_root() -> std::path::PathBuf {\n".to_string()), " let mut dir = std::env::current_dir().expect(\"no current dir\");\n".to_string()), " loop {\n".to_string()), " if dir.join(\"Cargo.toml\").exists() && dir.join(\"dsl\").exists() {\n".to_string()), " return dir;\n".to_string()), " }\n".to_string()), " if !dir.pop() {\n".to_string()), " panic!(\"could not find workspace root (no Cargo.toml + dsl/ found)\");\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " /// Read a .dag file from the workspace\n".to_string()), " fn read_dag(path: &str) -> String {\n".to_string()), " let full = workspace_root().join(path);\n".to_string()), " std::fs::read_to_string(&full)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {}: {}\", full.display(), e))\n".to_string()), " }\n\n".to_string()) } -pub fn ct_file_discovery_helpers() -> String { +pub fn ct_file_discovery_helpers() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Discover all .dag files under a directory, returning (relative_path, content) pairs.\n".to_string(), " /// The relative path is relative to the workspace root.\n".to_string()), " fn discover_dag_files(dir: &str) -> Vec<(String, String)> {\n".to_string()), " let root = workspace_root();\n".to_string()), " let base = root.join(dir);\n".to_string()), " let mut results = Vec::new();\n".to_string()), " collect_dag_recursive(&base, &root, &mut results);\n".to_string()), " results.sort_by(|a, b| a.0.cmp(&b.0));\n".to_string()), " results\n".to_string()), " }\n\n".to_string()), " fn collect_dag_recursive(\n".to_string()), " dir: &std::path::Path,\n".to_string()), " root: &std::path::Path,\n".to_string()), " out: &mut Vec<(String, String)>,\n".to_string()), " ) {\n".to_string()), " if let Ok(entries) = std::fs::read_dir(dir) {\n".to_string()), " for entry in entries.flatten() {\n".to_string()), " let path = entry.path();\n".to_string()), " if path.is_dir() {\n".to_string()), " collect_dag_recursive(&path, root, out);\n".to_string()), " } else if path.extension().map_or(false, |e| e == \"dag\") {\n".to_string()), " let rel = path\n".to_string()), " .strip_prefix(root)\n".to_string()), " .unwrap()\n".to_string()), " .to_string_lossy()\n".to_string()), " .to_string();\n".to_string()), " // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules.\n".to_string()), " if rel.contains(\"/tests/\") {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {}: {}\", path.display(), e));\n".to_string()), " out.push((rel, content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n\n".to_string()) } -pub fn ct_source_builders() -> String { +pub fn ct_source_builders() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Build SourceFile vec from discovered .dag files.\n".to_string(), " fn source_files_from(\n".to_string()), " pairs: &[(String, String)],\n".to_string()), " ) -> Vec> {\n".to_string()), " pairs\n".to_string()), " .iter()\n".to_string()), " .map(|(path, content)| {\n".to_string()), " std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " })\n".to_string()), " })\n".to_string()), " .collect()\n".to_string()), " }\n\n".to_string()), " fn parse_module_or_panic(path: &str, content: &str) -> std::rc::Rc {\n".to_string()), " let tokens = tokenize(content.to_string(), path.to_string());\n".to_string()), " let mut source_indices = HashMap::new();\n".to_string()), " source_indices.insert(\n".to_string()), " path.to_string(),\n".to_string()), " crate::v1_std_core::build_newline_index(path.to_string(), content.to_string()),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " std::rc::Rc::new(source_indices),\n".to_string()), " crate::v1_std_core::empty_intern_table(),\n".to_string()), " );\n".to_string()), " if let Some(err) = parsed.result.error.as_ref() {\n".to_string()), " panic!(\n".to_string()), " \"failed to parse {} while building source closure: {}\",\n".to_string()), " path,\n".to_string()), " crate::v1_std_core::diagnostic_to_message(err.diagnostic.clone())\n".to_string()), " );\n".to_string()), " }\n".to_string()), " parsed.result.module.clone().unwrap_or_else(|| {\n".to_string()), " panic!(\"{} produced no module while building source closure\", path)\n".to_string()), " })\n".to_string()), " }\n\n".to_string()), " fn module_path_from_source(path: &str, content: &str) -> String {\n".to_string()), " parse_module_or_panic(path, content).name.clone()\n".to_string()), " }\n\n".to_string()), " fn import_paths_from_source(path: &str, content: &str) -> Vec {\n".to_string()), " let module = parse_module_or_panic(path, content);\n".to_string()), " crate::v1_std_core::module_imports(module)\n".to_string()), " .iter()\n".to_string()), " .map(|imp| imp.name.clone())\n".to_string()), " .collect()\n".to_string()), " }\n\n".to_string()), " fn build_source_index(\n".to_string()), " roots: &[&str],\n".to_string()), " ) -> HashMap {\n".to_string()), " let mut index = HashMap::new();\n".to_string()), " for root in roots {\n".to_string()), " for (path, content) in discover_dag_files(root) {\n".to_string()), " let module_path = module_path_from_source(&path, &content);\n".to_string()), " if let Some((existing, _)) = index.get(&module_path) {\n".to_string()), " panic!(\n".to_string()), " \"duplicate module path '{}': declared in both {} and {}\",\n".to_string()), " module_path,\n".to_string()), " existing,\n".to_string()), " path\n".to_string()), " );\n".to_string()), " }\n".to_string()), " index.insert(module_path, (path, content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " index\n".to_string()), " }\n\n".to_string()), " fn resolve_source_closure(\n".to_string()), " entry_pairs: Vec<(String, String)>,\n".to_string()), " roots: &[&str],\n".to_string()), " ) -> Vec> {\n".to_string()), " let index = build_source_index(roots);\n".to_string()), " let mut seen = HashMap::>::new();\n".to_string()), " let mut queue = Vec::new();\n\n".to_string()), " for (path, content) in entry_pairs {\n".to_string()), " let module_path = module_path_from_source(&path, &content);\n".to_string()), " seen.insert(\n".to_string()), " module_path,\n".to_string()), " std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " }),\n".to_string()), " );\n".to_string()), " queue.push((path, content));\n".to_string()), " }\n\n".to_string()), " while let Some((_path, content)) = queue.pop() {\n".to_string()), " for module_path in import_paths_from_source(&_path, &content) {\n".to_string()), " if seen.contains_key(&module_path) {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " if let Some((path, file_content)) = index.get(&module_path).cloned() {\n".to_string()), " seen.insert(\n".to_string()), " module_path,\n".to_string()), " std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: file_content.clone(),\n".to_string()), " }),\n".to_string()), " );\n".to_string()), " queue.push((path, file_content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " let mut result: Vec<_> = seen.into_values().collect();\n".to_string()), " result.sort_by(|a, b| a.path.cmp(&b.path));\n".to_string()), " result\n".to_string()), " }\n\n".to_string()), ct_self_compile_sources()) } -pub fn ct_self_compile_sources() -> String { +pub fn ct_self_compile_sources() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Build the self-compile source closure from src/v1 entry modules with dsl as a dependency pool.\n".to_string(), " fn self_compile_sources() -> Vec> {\n".to_string()), " resolve_source_closure(discover_dag_files(\"src/v1\"), &[\"src/v1\", \"dsl\"])\n".to_string()), " }\n\n".to_string()) } -pub fn ct_tokenizer_tests() -> String { +pub fn ct_tokenizer_tests() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn tokenize_produces_tokens() {\n".to_string()), " let tokens = tokenize(\"fn foo() -> Int { 42 }\".to_string(), \"test.dag\".to_string());\n".to_string()), " assert!(\n".to_string()), " !tokens.is_empty(),\n".to_string()), " \"tokenize should produce at least one token\"\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn tokenize_ends_with_eof() {\n".to_string()), " let tokens = tokenize(\"type Foo { x: Int }\".to_string(), \"test.dag\".to_string());\n".to_string()), " let last = tokens.last().expect(\"should have tokens\");\n".to_string()), " assert!(\n".to_string()), " matches!(last.shape, crate::v1_std_core::TokenShape::ShEof),\n".to_string()), " \"last token should be Eof, got {:?}\",\n".to_string()), " last.shape\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn tokenize_fn_keyword() {\n".to_string()), " let tokens = tokenize(\"fn\".to_string(), \"test.dag\".to_string());\n".to_string()), " assert!(\n".to_string()), " tokens.len() >= 2,\n".to_string()), " \"expected at least 2 tokens, got {}\",\n".to_string()), " tokens.len()\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " matches!(tokens[0].shape, crate::v1_std_core::TokenShape::ShKeyword),\n".to_string()), " \"first token should be KwFn, got {:?}\",\n".to_string()), " tokens[0].shape\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn tokenize_count_stable() {\n".to_string()), " let tokens = tokenize(\n".to_string()), " \"module test\\ntype Foo { x: Int }\".to_string(),\n".to_string()), " \"test.dag\".to_string(),\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " tokens.len() > 5,\n".to_string()), " \"non-trivial input should produce multiple tokens, got {}\",\n".to_string()), " tokens.len()\n".to_string()), " );\n".to_string()), " }\n\n".to_string()) } -pub fn ct_parse_tests() -> String { +pub fn ct_parse_tests() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn parse_trivial_module() {\n".to_string()), " let tokens = tokenize(\n".to_string()), " \"module test\\ntype Foo { x: Int }\\n\".to_string(),\n".to_string()), " \"test.dag\".to_string(),\n".to_string()), " );\n".to_string()), " let result = crate::v1_compiler_parse::parse(tokens, std::rc::Rc::new(std::collections::HashMap::new()));\n".to_string()), " assert!(\n".to_string()), " result.module.is_some(),\n".to_string()), " \"valid module should parse successfully\"\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn self_parse_tokenize_dag() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(16 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let source = read_dag(\"src/v1/01_tokenize.dag\");\n".to_string()), " let tokens = tokenize(source, \"src/v1/01_tokenize.dag\".to_string());\n\n".to_string()), " assert!(\n".to_string()), " !tokens.is_empty(),\n".to_string()), " \"tokenizing 01_tokenize.dag should produce tokens\"\n".to_string()), " );\n\n".to_string()), " let last = tokens.last().expect(\"should have tokens\");\n".to_string()), " assert!(\n".to_string()), " matches!(last.shape, crate::v1_std_core::TokenShape::ShEof),\n".to_string()), " \"last token should be Eof, got {:?}\",\n".to_string()), " last.shape\n".to_string()), " );\n\n".to_string()), " let result = crate::v1_compiler_parse::parse(tokens, std::rc::Rc::new(std::collections::HashMap::new()));\n\n".to_string()), " assert!(\n".to_string()), " result.module.is_some(),\n".to_string()), " \"parsing 01_tokenize.dag should produce a module\"\n".to_string()), " );\n\n".to_string()), " let module = result.module.as_ref().unwrap();\n".to_string()), " assert_eq!(\n".to_string()), " module.name, \"v1.compiler.tokenize\",\n".to_string()), " \"module name should be v1.compiler.tokenize, got {}\",\n".to_string()), " module.name\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-parse test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_pipeline_test() -> String { +pub fn ct_pipeline_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn pipeline_trivial_module() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(16 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let source = std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: \"test.dag\".to_string(),\n".to_string()), " content: \"module test\\ntype Foo { x: Int, name: String }\\nfn add(a: Int, b: Int) -> Int { a + b }\\n\".to_string(),\n".to_string()), " });\n".to_string()), " let result = crate::v1_compiler_compile::compile_sources(std::rc::Rc::new(vec![source]), crate::v1_compiler_artifact::RenderTarget::Rust);\n\n".to_string()), " assert!(\n".to_string()), " !result.files.is_empty(),\n".to_string()), " \"compile_sources should produce output files, got none\"\n".to_string()), " );\n\n".to_string()), " let errors: Vec<_> = result.diagnostics.iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .collect();\n".to_string()), " assert!(\n".to_string()), " errors.is_empty(),\n".to_string()), " \"compile_sources should produce no errors, got {:?}\",\n".to_string()), " errors\n".to_string()), " );\n\n".to_string()), " let has_content = result.files.iter().any(|f| !f.content.is_empty());\n".to_string()), " assert!(\n".to_string()), " has_content,\n".to_string()), " \"at least one output file should have non-empty content\"\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"pipeline_trivial_module test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_parse_all_test() -> String { +pub fn ct_self_parse_all_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn self_parse_all_modules() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let v1_files = discover_dag_files(\"src/v1\");\n".to_string()), " assert!(\n".to_string()), " !v1_files.is_empty(),\n".to_string()), " \"should discover at least one .dag file in src/v1/\"\n".to_string()), " );\n\n".to_string()), " for (file, source) in &v1_files {\n".to_string()), " let tokens = tokenize(source.to_string(), file.to_string());\n".to_string()), " assert!(!tokens.is_empty(), \"{} should produce tokens\", file);\n".to_string()), " assert!(\n".to_string()), " matches!(\n".to_string()), " tokens.last().unwrap().shape,\n".to_string()), " crate::v1_std_core::TokenShape::ShEof\n".to_string()), " ),\n".to_string()), " \"{} should end with Eof\",\n".to_string()), " file\n".to_string()), " );\n".to_string()), " let result = crate::v1_compiler_parse::parse(tokens, std::rc::Rc::new(std::collections::HashMap::new()));\n".to_string()), " assert!(\n".to_string()), " result.module.is_some(),\n".to_string()), " \"{} should parse successfully, error: {:?}\",\n".to_string()), " file,\n".to_string()), " result.error\n".to_string()), " );\n".to_string()), " let module = result.module.as_ref().unwrap();\n".to_string()), " assert!(\n".to_string()), " !module.name.is_empty(),\n".to_string()), " \"{} should have a non-empty module name\",\n".to_string()), " file\n".to_string()), " );\n".to_string()), " }\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-parse-all test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_resolve_test() -> String { +pub fn ct_self_resolve_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn self_resolve_all_modules() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let sources = std::rc::Rc::new(self_compile_sources());\n".to_string()), " let result = crate::v1_compiler_compile::resolve_sources(sources);\n\n".to_string()), " let errors: Vec<_> = result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .collect();\n".to_string()), " let error_count = errors.len();\n\n".to_string()), " eprintln!(\"self-resolve error count: {}\", error_count);\n".to_string()), " for e in &errors {\n".to_string()), " eprintln!(\" {:?}\", e.diagnostic);\n".to_string()), " }\n\n".to_string()), " assert!(\n".to_string()), " error_count == 0,\n".to_string()), " \"self-resolve errors: {} errors (expected 0): {:?}\",\n".to_string()), " error_count,\n".to_string()), " errors\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-resolve-all test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_compile_test() -> String { +pub fn ct_self_compile_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn self_compile_all_modules() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let sources = std::rc::Rc::new(self_compile_sources());\n".to_string()), " let source_count = sources.len();\n".to_string()), " let result = crate::v1_compiler_compile::compile_sources(\n".to_string()), " sources,\n".to_string()), " crate::v1_compiler_artifact::RenderTarget::Rust,\n".to_string()), " );\n\n".to_string()), " let errors: Vec<_> = result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .collect();\n".to_string()), " let error_count = errors.len();\n\n".to_string()), " eprintln!(\n".to_string()), " \"self-compile completed: {} errors, {} files emitted from {} sources\",\n".to_string()), " error_count,\n".to_string()), " result.files.len(),\n".to_string()), " source_count\n".to_string()), " );\n".to_string()), " for (i, e) in errors.iter().enumerate() {\n".to_string()), " eprintln!(\" error[{}]: {:?}\", i, e.diagnostic);\n".to_string()), " }\n\n".to_string()), " assert!(\n".to_string()), " source_count >= 13,\n".to_string()), " \"self-compile should process at least 13 sources, got {}\",\n".to_string()), " source_count\n".to_string()), " );\n\n".to_string()), " if !result.files.is_empty() {\n".to_string()), " assert!(\n".to_string()), " result.files.iter().all(|f| !f.content.is_empty()),\n".to_string()), " \"all self-compiled output files must have non-empty content\"\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " const SELF_COMPILE_ERROR_RATCHET: usize = 2700;\n".to_string()), " assert!(\n".to_string()), " error_count <= SELF_COMPILE_ERROR_RATCHET,\n".to_string()), " \"self-compile error count regression: {} > {} ratchet\",\n".to_string()), " error_count,\n".to_string()), " SELF_COMPILE_ERROR_RATCHET\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-compile-all test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_compile_cargo_check_test() -> String { +pub fn ct_self_compile_cargo_check_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn self_compile_cargo_check() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let sources = std::rc::Rc::new(self_compile_sources());\n\n".to_string()), " let result = crate::v1_compiler_compile::compile_sources(\n".to_string()), " sources,\n".to_string()), " crate::v1_compiler_artifact::RenderTarget::Rust,\n".to_string()), " );\n\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"self-compile-cargo-check: 0 files emitted (resolve errors gate emission), skipping cargo check\");\n".to_string()), " return;\n".to_string()), " }\n\n".to_string()), " let tmp_dir = std::env::temp_dir().join(\"v2-self-compile-check\");\n".to_string()), " let _ = std::fs::remove_dir_all(&tmp_dir);\n".to_string()), " std::fs::create_dir_all(tmp_dir.join(\"src\"))\n".to_string()), " .expect(\"failed to create temp src dir\");\n\n".to_string()), " for file in result.files.iter() {\n".to_string()), " let dest = tmp_dir.join(&file.path);\n".to_string()), " if let Some(parent) = dest.parent() {\n".to_string()), " std::fs::create_dir_all(parent).expect(\"failed to create parent dir\");\n".to_string()), " }\n".to_string()), " std::fs::write(&dest, &file.content)\n".to_string()), " .expect(&format!(\"failed to write {}\", file.path));\n".to_string()), " }\n\n".to_string()), " let cargo_toml = tmp_dir.join(\"Cargo.toml\");\n".to_string()), " if !cargo_toml.exists() {\n".to_string()), " std::fs::write(&cargo_toml,\n".to_string()), " \"[package]\\nname = \\\"v2-self-compile-check\\\"\\nversion = \\\"0.1.0\\\"\\nedition = \\\"2021\\\"\\n\"\n".to_string()), " ).expect(\"failed to write Cargo.toml\");\n".to_string()), " }\n\n".to_string()), " eprintln!(\"self-compile-cargo-check: wrote {} files to {}\",\n".to_string()), " result.files.len(), tmp_dir.display());\n\n".to_string()), " let output = std::process::Command::new(\"cargo\")\n".to_string()), " .arg(\"check\")\n".to_string()), " .current_dir(&tmp_dir)\n".to_string()), " .output()\n".to_string()), " .expect(\"failed to run cargo check\");\n\n".to_string()), " let stderr = String::from_utf8_lossy(&output.stderr);\n".to_string()), " eprintln!(\"cargo check stderr:\\n{}\", stderr);\n\n".to_string()), " if !output.status.success() {\n".to_string()), " panic!(\n".to_string()), " \"cargo check failed on self-compiled output (dir: {}):\\n{}\",\n".to_string()), " tmp_dir.display(),\n".to_string()), " stderr\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " let _ = std::fs::remove_dir_all(&tmp_dir);\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-compile-cargo-check test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_type_size_test() -> String { +pub fn ct_type_size_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn type_size_regression_check() {\n".to_string()), " let node_size = std::mem::size_of::();\n".to_string()), " let expr_size = std::mem::size_of::();\n".to_string()), " eprintln!(\" Node: {} bytes\", node_size);\n".to_string()), " eprintln!(\" Expr: {} bytes\", expr_size);\n".to_string()), " assert!(\n".to_string()), " node_size <= 192,\n".to_string()), " \"Node size regression: {} bytes (limit: 192). Check for unboxed rare fields.\",\n".to_string()), " node_size\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " expr_size <= 800,\n".to_string()), " \"ExprData size regression: {} bytes (limit: 800). Node size likely regressed.\",\n".to_string()), " expr_size\n".to_string()), " );\n".to_string()), " }\n\n".to_string()) } -pub fn ct_coercion_tests() -> String { +pub fn ct_coercion_tests() -> Rc> { { let entries = extract_coercion_tests(); let test_fns = Rc::new({ @@ -92,11 +92,11 @@ pub fn ct_coercion_tests() -> String { } } -pub fn ct_rust_btree_set_ord_eligibility_test() -> String { +pub fn ct_rust_btree_set_ord_eligibility_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" fn shaped_type_node(name: &str, children: Vec>) -> std::rc::Rc {\n".to_string(), " let span = crate::v1_std_core::make_span(0, name.len() as i64);\n".to_string()), " std::rc::Rc::new(crate::v1_std_core::Node {\n".to_string()), " name: name.to_string(),\n".to_string()), " ident: None,\n".to_string()), " span: span.clone(),\n".to_string()), " ident_span: Some(span),\n".to_string()), " children: std::rc::Rc::new(children),\n".to_string()), " connective: crate::v1_std_core::Connective::NoConnective,\n".to_string()), " params: std::rc::Rc::new(Vec::new()),\n".to_string()), " inferred: None,\n".to_string()), " return_cardinality: crate::v1_std_core::Cardinality::Required,\n".to_string()), " uses: std::rc::Rc::new(Vec::new()),\n".to_string()), " body: None,\n".to_string()), " transport: None,\n".to_string()), " properties: std::rc::Rc::new(Vec::new()),\n".to_string()), " type_annotation: None,\n".to_string()), " is_self_recursive: false,\n".to_string()), " has_non_tail_self_call: false,\n".to_string()), " match_pattern: None,\n".to_string()), " expr_data: std::rc::Rc::new(crate::v1_std_core::ExprData::NoExprData),\n".to_string()), " })\n".to_string()), " }\n\n".to_string()), " fn named_type_node(name: &str) -> std::rc::Rc {\n".to_string()), " shaped_type_node(name, Vec::new())\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn rust_btree_set_ord_eligibility_requires_nominal_carrier_shape() {\n".to_string()), " let source_indices = std::rc::Rc::new(HashMap::new());\n".to_string()), " let symbol = named_type_node(\"Symbol\");\n".to_string()), " let diff_id = shaped_type_node(\"DiffId\", vec![symbol.clone()]);\n".to_string()), " assert!(\n".to_string()), " crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " symbol.clone(),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " diff_id.clone(),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " !crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " shaped_type_node(\"Symbol\", vec![named_type_node(\"Float\")]),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " !crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " shaped_type_node(\"DiffId\", vec![named_type_node(\"Float\")]),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " !crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " named_type_node(\"TestClaimId\"),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " }\n\n".to_string()) } -pub fn render_target_rust_enum(target: RenderTarget) -> String { +pub fn render_target_rust_enum(target: RenderTarget) -> Rc> { match target { RenderTarget::Rust => "RenderTarget::Rust".to_string(), RenderTarget::Python => "RenderTarget::Python".to_string(), @@ -105,7 +105,7 @@ pub fn render_target_rust_enum(target: RenderTarget) -> String { } } -pub fn render_coercion_test_rust(entry: Rc) -> String { +pub fn render_coercion_test_rust(entry: Rc) -> Rc> { { let assertions = Rc::new({ let mut __result = Vec::new(); @@ -133,21 +133,21 @@ pub fn render_coercion_test_rust(entry: Rc) -> String { } } -pub fn first_or_empty(items: Rc>) -> String { +pub fn first_or_empty(items: Rc>) -> Rc> { match items.first().cloned() { Some(v) => v.clone(), None => "".to_string(), } } -pub fn second_or_empty(items: Rc>) -> String { +pub fn second_or_empty(items: Rc>) -> Rc> { match items.get(1 as usize).cloned() { Some(v) => v.clone(), None => "".to_string(), } } -pub fn render_coercion_assertion_rust(a: Rc) -> String { +pub fn render_coercion_assertion_rust(a: Rc) -> Rc> { match (*a).clone() { CoercionAssertion::CheckpointAssertion { target: t, @@ -270,27 +270,27 @@ pub fn render_coercion_assertion_rust(a: Rc) -> String { } } -pub fn ct_profile_helpers() -> String { +pub fn ct_profile_helpers() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Return current process RSS in bytes (macOS via mach_task_basic_info).\n".to_string(), " fn get_rss_bytes() -> u64 {\n".to_string()), " #[cfg(target_os = \"macos\")]\n".to_string()), " {\n".to_string()), " #[allow(non_camel_case_types)]\n".to_string()), " #[repr(C)]\n".to_string()), " struct mach_task_basic_info {\n".to_string()), " virtual_size: u64,\n".to_string()), " resident_size: u64,\n".to_string()), " resident_size_max: u64,\n".to_string()), " user_time: [u64; 2],\n".to_string()), " system_time: [u64; 2],\n".to_string()), " policy: i32,\n".to_string()), " suspend_count: i32,\n".to_string()), " }\n".to_string()), " extern \"C\" {\n".to_string()), " fn mach_task_self() -> u32;\n".to_string()), " fn task_info(\n".to_string()), " target_task: u32,\n".to_string()), " flavor: u32,\n".to_string()), " task_info_out: *mut mach_task_basic_info,\n".to_string()), " task_info_count: *mut u32,\n".to_string()), " ) -> i32;\n".to_string()), " }\n".to_string()), " const MACH_TASK_BASIC_INFO: u32 = 20;\n".to_string()), " const MACH_TASK_BASIC_INFO_COUNT: u32 =\n".to_string()), " (std::mem::size_of::() / std::mem::size_of::()) as u32;\n".to_string()), " let mut info: mach_task_basic_info = unsafe { std::mem::zeroed() };\n".to_string()), " let mut count = MACH_TASK_BASIC_INFO_COUNT;\n".to_string()), " let kr = unsafe {\n".to_string()), " task_info(\n".to_string()), " mach_task_self(),\n".to_string()), " MACH_TASK_BASIC_INFO,\n".to_string()), " &mut info,\n".to_string()), " &mut count,\n".to_string()), " )\n".to_string()), " };\n".to_string()), " if kr == 0 {\n".to_string()), " info.resident_size\n".to_string()), " } else {\n".to_string()), " 0\n".to_string()), " }\n".to_string()), " }\n".to_string()), " #[cfg(not(target_os = \"macos\"))]\n".to_string()), " {\n".to_string()), " 0\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " fn format_bytes(bytes: u64) -> String {\n".to_string()), " if bytes >= 1_073_741_824 {\n".to_string()), " format!(\"{:.1} GB\", bytes as f64 / 1_073_741_824.0)\n".to_string()), " } else if bytes >= 1_048_576 {\n".to_string()), " format!(\"{:.1} MB\", bytes as f64 / 1_048_576.0)\n".to_string()), " } else if bytes >= 1024 {\n".to_string()), " format!(\"{:.1} KB\", bytes as f64 / 1024.0)\n".to_string()), " } else {\n".to_string()), " format!(\"{} B\", bytes)\n".to_string()), " }\n".to_string()), " }\n\n".to_string()) } -pub fn ct_profile_self_compile_test() -> String { +pub fn ct_profile_self_compile_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn profile_self_compile() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " use std::collections::HashMap;\n".to_string()), " use std::time::Instant;\n\n".to_string()), " let sources = self_compile_sources();\n\n".to_string()), " let source_count = sources.len();\n".to_string()), " let rss_start = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \"\\n=== SELF-COMPILE PIPELINE PROFILE ({} sources) ===\",\n".to_string()), " source_count\n".to_string()), " );\n".to_string()), " eprintln!(\" RSS at start: {}\\n\", format_bytes(rss_start));\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let mut token_lists = Vec::new();\n".to_string()), " let phase1_diags = 0usize;\n".to_string()), " for source in &sources {\n".to_string()), " let t = Instant::now();\n".to_string()), " let tokens = crate::v1_compiler_tokenize::tokenize(\n".to_string()), " source.content.clone(),\n".to_string()), " source.path.clone(),\n".to_string()), " );\n".to_string()), " let elapsed = t.elapsed();\n".to_string()), " eprintln!(\n".to_string()), " \" tokenize {:>40}: {:>8.2?} ({:>5} tokens, {:>6} chars)\",\n".to_string()), " source.path,\n".to_string()), " elapsed,\n".to_string()), " tokens.len(),\n".to_string()), " source.content.len()\n".to_string()), " );\n".to_string()), " token_lists.push(tokens);\n".to_string()), " }\n".to_string()), " let tokenize_total = t_stage.elapsed();\n".to_string()), " let rss_after_tokenize = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" TOKENIZE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " tokenize_total,\n".to_string()), " format_bytes(rss_after_tokenize),\n".to_string()), " phase1_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let mut modules = Vec::new();\n".to_string()), " let mut intern_table_p = crate::v1_std_core::empty_intern_table();\n".to_string()), " let mut phase2_diags = 0usize;\n".to_string()), " for (i, tokens) in token_lists.iter().enumerate() {\n".to_string()), " let t = Instant::now();\n".to_string()), " let si = crate::v1_std_core::build_newline_index(\n".to_string()), " sources[i].path.clone(),\n".to_string()), " sources[i].content.clone(),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " crate::v1_rt::rc_map_insert(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " si.file.clone(),\n".to_string()), " si.clone(),\n".to_string()), " ),\n".to_string()), " intern_table_p.clone(),\n".to_string()), " );\n".to_string()), " let result = parsed.result.clone();\n".to_string()), " intern_table_p = parsed.intern_table.clone();\n".to_string()), " let elapsed = t.elapsed();\n".to_string()), " let ok = result.module.is_some();\n".to_string()), " if result.error.is_some() {\n".to_string()), " phase2_diags += 1;\n".to_string()), " }\n".to_string()), " eprintln!(\n".to_string()), " \" parse {:>40}: {:>8.2?} (ok={})\",\n".to_string()), " sources[i].path, elapsed, ok\n".to_string()), " );\n".to_string()), " let m = result.module.clone()\n".to_string()), " .unwrap_or_else(|| panic!(\"parse failed for source {}\", sources[i].path));\n".to_string()), " modules.push(m);\n".to_string()), " }\n".to_string()), " let parse_total = t_stage.elapsed();\n".to_string()), " let rss_after_parse = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" PARSE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " parse_total,\n".to_string()), " format_bytes(rss_after_parse),\n".to_string()), " phase2_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let resolve_si = sources.iter().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, s| crate::v1_rt::rc_map_insert(acc, s.path.clone(), crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())),\n".to_string()), " );\n".to_string()), " let graph = crate::v1_compiler_resolve::resolve_modules(std::rc::Rc::new(modules), resolve_si);\n".to_string()), " let resolve_total = t_stage.elapsed();\n".to_string()), " let phase3_diags: usize = graph\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " let rss_after_resolve = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" RESOLVE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " resolve_total,\n".to_string()), " format_bytes(rss_after_resolve),\n".to_string()), " phase3_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let source_indices = sources.iter().fold(\n".to_string()), " HashMap::>::new(),\n".to_string()), " |mut acc, source| {\n".to_string()), " acc.insert(\n".to_string()), " source.path.clone(),\n".to_string()), " crate::v1_std_core::build_newline_index(\n".to_string()), " source.path.clone(),\n".to_string()), " source.content.clone(),\n".to_string()), " ),\n".to_string()), " );\n".to_string()), " acc\n".to_string()), " },\n".to_string()), " );\n".to_string()), " let typed = crate::v1_compiler_infer::reconcile(graph, std::rc::Rc::new(source_indices), intern_table_p.clone());\n".to_string()), " let reconcile_total = t_stage.elapsed();\n".to_string()), " let phase4_diags: usize = typed\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " let rss_after_reconcile = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" RECONCILE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " reconcile_total,\n".to_string()), " format_bytes(rss_after_reconcile),\n".to_string()), " phase4_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let emit_result = crate::v1_compiler_emit_rust::emit_rust(typed);\n".to_string()), " let emit_total = t_stage.elapsed();\n".to_string()), " let phase5_diags: usize = emit_result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " let emitted_files = emit_result.files.len();\n".to_string()), " let emitted_bytes: usize = emit_result.files.iter().map(|f| f.content.len()).sum();\n".to_string()), " let rss_after_emit = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" EMIT TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " emit_total,\n".to_string()), " format_bytes(rss_after_emit),\n".to_string()), " phase5_diags\n".to_string()), " );\n\n".to_string()), " let total =\n".to_string()), " tokenize_total + parse_total + resolve_total + reconcile_total + emit_total;\n".to_string()), " let total_diags =\n".to_string()), " phase1_diags + phase2_diags + phase3_diags + phase4_diags + phase5_diags;\n".to_string()), " eprintln!(\"=== SUMMARY ===\");\n".to_string()), " eprintln!(\" Tokenize: {:?}\", tokenize_total);\n".to_string()), " eprintln!(\" Parse: {:?}\", parse_total);\n".to_string()), " eprintln!(\" Resolve: {:?}\", resolve_total);\n".to_string()), " eprintln!(\" Reconcile: {:?}\", reconcile_total);\n".to_string()), " eprintln!(\" Emit: {:?}\", emit_total);\n".to_string()), " eprintln!(\" Total: {:?}\", total);\n".to_string()), " eprintln!(\" Diagnostics: {}\", total_diags);\n".to_string()), " eprintln!(\n".to_string()), " \" Emitted: {} files, {}\",\n".to_string()), " emitted_files,\n".to_string()), " format_bytes(emitted_bytes as u64)\n".to_string()), " );\n".to_string()), " eprintln!(\"\");\n".to_string()), " eprintln!(\"=== RSS CHECKPOINTS ===\");\n".to_string()), " eprintln!(\" Start: {}\", format_bytes(rss_start));\n".to_string()), " eprintln!(\" After tokenize: {}\", format_bytes(rss_after_tokenize));\n".to_string()), " eprintln!(\" After parse: {}\", format_bytes(rss_after_parse));\n".to_string()), " eprintln!(\" After resolve: {}\", format_bytes(rss_after_resolve));\n".to_string()), " eprintln!(\" After reconcile:{}\", format_bytes(rss_after_reconcile));\n".to_string()), " eprintln!(\" After emit: {}\", format_bytes(rss_after_emit));\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"profile_self_compile test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_profile_full_pipeline_test() -> String { +pub fn ct_profile_full_pipeline_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn profile_full_pipeline() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " use std::time::Instant;\n\n".to_string()), " let sources = self_compile_sources();\n".to_string()), " let source_count = sources.len();\n".to_string()), " let total_chars: usize = sources.iter().map(|s| s.content.len()).sum();\n\n".to_string()), " eprintln!(\"\\n=== FULL PIPELINE PROFILE ({} sources, {} chars) ===\\n\", source_count, total_chars);\n\n".to_string()), " // 1a. Tokenize + parse\n".to_string()), " let t = Instant::now();\n".to_string()), " let mut token_lists = Vec::new();\n".to_string()), " for source in &sources {\n".to_string()), " let tokens = crate::v1_compiler_tokenize::tokenize(\n".to_string()), " source.content.clone(), source.path.clone(),\n".to_string()), " );\n".to_string()), " token_lists.push(tokens);\n".to_string()), " }\n".to_string()), " let tokenize_elapsed = t.elapsed();\n\n".to_string()), " let t = Instant::now();\n".to_string()), " let mut modules = Vec::new();\n".to_string()), " let mut intern_table_fp = crate::v1_std_core::empty_intern_table();\n".to_string()), " for (i, tokens) in token_lists.iter().enumerate() {\n".to_string()), " let si = crate::v1_std_core::build_newline_index(\n".to_string()), " sources[i].path.clone(),\n".to_string()), " sources[i].content.clone(),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " crate::v1_rt::rc_map_insert(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " si.file.clone(),\n".to_string()), " si.clone(),\n".to_string()), " ),\n".to_string()), " intern_table_fp.clone(),\n".to_string()), " );\n".to_string()), " let result = parsed.result.clone();\n".to_string()), " intern_table_fp = parsed.intern_table.clone();\n".to_string()), " let m = result.module.clone()\n".to_string()), " .unwrap_or_else(|| panic!(\"parse failed for source {}\", sources[i].path));\n".to_string()), " modules.push(m);\n".to_string()), " }\n".to_string()), " let parse_elapsed = t.elapsed();\n".to_string()), " // 1b. Resolve\n".to_string()), " let t = Instant::now();\n".to_string()), " let resolve_si = sources.iter().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, s| crate::v1_rt::rc_map_insert(acc, s.path.clone(), crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())),\n".to_string()), " );\n".to_string()), " let graph = crate::v1_compiler_resolve::resolve_modules(std::rc::Rc::new(modules), resolve_si);\n".to_string()), " let resolve_elapsed = t.elapsed();\n".to_string()), " let resolve_errors: usize = graph.diagnostics.iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n\n".to_string()), " // 1c. Newline indices\n".to_string()), " let t = Instant::now();\n".to_string()), " let newline_indices: Vec<_> = sources.iter().map(|s| {\n".to_string()), " crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())\n".to_string()), " }).collect();\n".to_string()), " let newline_elapsed = t.elapsed();\n\n".to_string()), " let frontend_elapsed = tokenize_elapsed + parse_elapsed + resolve_elapsed + newline_elapsed;\n".to_string()), " eprintln!(\" Tokenize: {:>8.2?}\", tokenize_elapsed);\n".to_string()), " eprintln!(\" Parse: {:>8.2?}\", parse_elapsed);\n".to_string()), " eprintln!(\" Resolve: {:>8.2?} ({} resolve errors)\", resolve_elapsed, resolve_errors);\n".to_string()), " eprintln!(\" Newline indices: {:>8.2?}\", newline_elapsed);\n".to_string()), " eprintln!(\" Frontend total: {:>8.2?}\", frontend_elapsed);\n\n".to_string()), " // 2. Normalize\n".to_string()), " let t = Instant::now();\n".to_string()), " let source_indices = newline_indices.iter().cloned().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, index| crate::v1_rt::rc_map_insert(acc, index.file.clone(), index.clone()),\n".to_string()), " );\n".to_string()), " let norm = crate::v1_compiler_normalize::normalize_graph(graph.clone(), source_indices.clone());\n".to_string()), " let normalize_elapsed = t.elapsed();\n".to_string()), " eprintln!(\" Normalize: {:>8.2?}\", normalize_elapsed);\n\n".to_string()), " // 3. Reconcile\n".to_string()), " let t = Instant::now();\n".to_string()), " let typed = crate::v1_compiler_infer::reconcile(norm.graph.clone(), source_indices.clone(), intern_table_fp.clone());\n".to_string()), " let reconcile_elapsed = t.elapsed();\n".to_string()), " let type_errors: usize = typed.diagnostics.iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " eprintln!(\" Reconcile: {:>8.2?} ({} type errors)\", reconcile_elapsed, type_errors);\n\n".to_string()), " // 4. Complexity\n".to_string()), " let t = Instant::now();\n".to_string()), " let func_entries = crate::v1_compiler_compile::extract_func_entries(typed.clone());\n".to_string()), " let func_count = func_entries.len();\n".to_string()), " let recursion_ctx = crate::v1_compiler_compile::build_recursion_context(typed.clone());\n".to_string()), " let complexity = crate::v1_compiler_complexity::build_complexity_report(\n".to_string()), " func_entries, recursion_ctx, source_indices.clone(),\n".to_string()), " );\n".to_string()), " let complexity_elapsed = t.elapsed();\n".to_string()), " let cx_diags = crate::v1_compiler_compile::complexity_diagnostics(complexity.clone());\n".to_string()), " eprintln!(\" Complexity: {:>8.2?} ({} funcs, {} diagnostics)\", complexity_elapsed, func_count, cx_diags.len());\n\n".to_string()), " // 5. Ownership\n".to_string()), " let t = Instant::now();\n".to_string()), " let ownership = crate::v1_compiler_compile::extract_ownership_proofs(typed.clone());\n".to_string()), " let ownership_elapsed = t.elapsed();\n".to_string()), " let own_diags = crate::v1_compiler_compile::ownership_diagnostics(ownership.clone());\n".to_string()), " eprintln!(\" Ownership: {:>8.2?} ({} proofs, {} diagnostics)\", ownership_elapsed, ownership.len(), own_diags.len());\n\n".to_string()), " // 6. Emit\n".to_string()), " let artifact_plan = crate::v1_compiler_compile::default_artifact_plan(\n".to_string()), " std::rc::Rc::new(typed.modules.iter().map(|m| m.module.clone().name.clone()).collect()),\n".to_string()), " crate::v1_compiler_artifact::RenderTarget::Rust,\n".to_string()), " );\n".to_string()), " let t = Instant::now();\n".to_string()), " let emit_result = crate::v1_compiler_compile::emit_from_artifact_plan(typed.clone(), artifact_plan);\n".to_string()), " let emit_elapsed = t.elapsed();\n".to_string()), " let emitted_files = emit_result.files.len();\n".to_string()), " let emitted_bytes: usize = emit_result.files.iter().map(|f| f.content.len()).sum();\n".to_string()), " eprintln!(\" Emit: {:>8.2?} ({} files, {} bytes)\", emit_elapsed, emitted_files, emitted_bytes);\n\n".to_string()), " let total = frontend_elapsed + normalize_elapsed + reconcile_elapsed\n".to_string()), " + complexity_elapsed + ownership_elapsed + emit_elapsed;\n".to_string()), " eprintln!(\"\\n=== SUMMARY ===\");\n".to_string()), " eprintln!(\" Tokenize: {:>8.2?} ({:.0}%)\", tokenize_elapsed, tokenize_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Parse: {:>8.2?} ({:.0}%)\", parse_elapsed, parse_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Resolve: {:>8.2?} ({:.0}%)\", resolve_elapsed, resolve_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Newline: {:>8.2?} ({:.0}%)\", newline_elapsed, newline_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Normalize: {:>8.2?} ({:.0}%)\", normalize_elapsed, normalize_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Reconcile: {:>8.2?} ({:.0}%)\", reconcile_elapsed, reconcile_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Complexity: {:>8.2?} ({:.0}%)\", complexity_elapsed, complexity_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Ownership: {:>8.2?} ({:.0}%)\", ownership_elapsed, ownership_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Emit: {:>8.2?} ({:.0}%)\", emit_elapsed, emit_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" TOTAL: {:>8.2?}\", total);\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"profile_full_pipeline panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_profile_reconcile_test() -> String { +pub fn ct_profile_reconcile_test() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn profile_reconcile_per_module() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " use std::collections::HashMap;\n".to_string()), " use std::time::Instant;\n\n".to_string()), " let sources = self_compile_sources();\n\n".to_string()), " eprintln!(\n".to_string()), " \"\\n=== PER-MODULE RECONCILE PROFILE ({} sources) ===\",\n".to_string()), " sources.len()\n".to_string()), " );\n\n".to_string()), " let t0 = Instant::now();\n".to_string()), " let mut modules = Vec::new();\n".to_string()), " let mut intern_table = crate::v1_std_core::empty_intern_table();\n".to_string()), " for source in &sources {\n".to_string()), " let tokens = crate::v1_compiler_tokenize::tokenize(\n".to_string()), " source.content.clone(),\n".to_string()), " source.path.clone(),\n".to_string()), " );\n".to_string()), " let si = crate::v1_std_core::build_newline_index(\n".to_string()), " source.path.clone(),\n".to_string()), " source.content.clone(),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " crate::v1_rt::rc_map_insert(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " si.file.clone(),\n".to_string()), " si.clone(),\n".to_string()), " ),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let result = parsed.result.clone();\n".to_string()), " intern_table = parsed.intern_table.clone();\n".to_string()), " let m = result.module.clone()\n".to_string()), " .unwrap_or_else(|| panic!(\"parse failed for source {}\", source.path));\n".to_string()), " modules.push(m);\n".to_string()), " }\n".to_string()), " let resolve_si = sources.iter().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, s| crate::v1_rt::rc_map_insert(acc, s.path.clone(), crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())),\n".to_string()), " );\n".to_string()), " let graph = crate::v1_compiler_resolve::resolve_modules(std::rc::Rc::new(modules), resolve_si);\n".to_string()), " let setup_time = t0.elapsed();\n".to_string()), " let rss_baseline = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" Setup (tok+parse+resolve): {:?} | RSS: {}\",\n".to_string()), " setup_time,\n".to_string()), " format_bytes(rss_baseline)\n".to_string()), " );\n".to_string()), " eprintln!(\" Modules to reconcile: {}\\n\", graph.modules.len());\n\n".to_string()), " let mut mi_raw = HashMap::<\n".to_string()), " String,\n".to_string()), " std::rc::Rc,\n".to_string()), " >::new();\n".to_string()), " let source_indices = std::rc::Rc::new(sources.iter().fold(\n".to_string()), " HashMap::>::new(),\n".to_string()), " |mut acc, source| {\n".to_string()), " acc.insert(\n".to_string()), " source.path.clone(),\n".to_string()), " crate::v1_std_core::build_newline_index(\n".to_string()), " source.path.clone(),\n".to_string()), " source.content.clone(),\n".to_string()), " ),\n".to_string()), " );\n".to_string()), " acc\n".to_string()), " },\n".to_string()), " ));\n\n".to_string()), " for resolved in graph.modules.iter() {\n".to_string()), " let name = resolved.module.name.to_string();\n".to_string()), " let item_count =\n".to_string()), " crate::v1_std_core::module_items(resolved.module.clone()).len();\n".to_string()), " let rss_before = get_rss_bytes();\n\n".to_string()), " eprint!(\" {:>35} ({:>3} items) ... \", name, item_count);\n\n".to_string()), " let module_index = std::rc::Rc::new(mi_raw.clone());\n\n".to_string()), " let t_unres = Instant::now();\n".to_string()), " let _unres = crate::v1_compiler_infer::build_type_env_unresolved(\n".to_string()), " resolved.clone(),\n".to_string()), " module_index.clone(),\n".to_string()), " source_indices.clone(),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let unres_elapsed = t_unres.elapsed();\n".to_string()), " let rss_after_unres = get_rss_bytes();\n".to_string()), " let unres_delta = rss_after_unres.saturating_sub(rss_before);\n\n".to_string()), " eprint!(\n".to_string()), " \"cycles={:>8.2?}(+{}) \",\n".to_string()), " unres_elapsed,\n".to_string()), " format_bytes(unres_delta)\n".to_string()), " );\n\n".to_string()), " if unres_delta > 256 * 1024 * 1024 {\n".to_string()), " eprintln!(\"\");\n".to_string()), " panic!(\n".to_string()), " \"ABORT: '{}' cycle detection grew RSS by {}\",\n".to_string()), " name,\n".to_string()), " format_bytes(unres_delta)\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " let t_env = Instant::now();\n".to_string()), " let env_result = crate::v1_compiler_infer::build_type_env(\n".to_string()), " resolved.clone(),\n".to_string()), " module_index.clone(),\n".to_string()), " source_indices.clone(),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let env_elapsed = t_env.elapsed();\n".to_string()), " let rss_after_env = get_rss_bytes();\n".to_string()), " let env_delta = rss_after_env.saturating_sub(rss_before);\n".to_string()), " let env_errs: usize = env_result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n\n".to_string()), " eprint!(\n".to_string()), " \"env={:>8.2?}(+{},e={}) \",\n".to_string()), " env_elapsed,\n".to_string()), " format_bytes(env_delta),\n".to_string()), " env_errs\n".to_string()), " );\n\n".to_string()), " if env_delta > 512 * 1024 * 1024 {\n".to_string()), " eprintln!(\"\");\n".to_string()), " panic!(\n".to_string()), " \"ABORT: '{}' build_type_env grew RSS by {}\",\n".to_string()), " name,\n".to_string()), " format_bytes(env_delta)\n".to_string()), " );\n".to_string()), " }\n".to_string()), " if env_elapsed.as_secs() > 10 {\n".to_string()), " eprintln!(\"\");\n".to_string()), " panic!(\"ABORT: '{}' build_type_env took {:?}\", name, env_elapsed);\n".to_string()), " }\n\n".to_string()), " let t_full = Instant::now();\n".to_string()), " let tc_result = crate::v1_compiler_infer::typecheck_module(\n".to_string()), " resolved.clone(),\n".to_string()), " module_index.clone(),\n".to_string()), " source_indices.clone(),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let full_elapsed = t_full.elapsed();\n".to_string()), " let rss_after = get_rss_bytes();\n".to_string()), " let delta = rss_after.saturating_sub(rss_before);\n".to_string()), " let diag_count: usize = tc_result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n\n".to_string()), " eprintln!(\n".to_string()), " \"full={:>8.2?} | RSS: {} (+{}) | errs: {}\",\n".to_string()), " full_elapsed,\n".to_string()), " format_bytes(rss_after),\n".to_string()), " format_bytes(delta),\n".to_string()), " diag_count\n".to_string()), " );\n\n".to_string()), " if delta > 512 * 1024 * 1024 {\n".to_string()), " panic!(\n".to_string()), " \"ABORT: '{}' grew RSS by {} (>512MB)\",\n".to_string()), " name,\n".to_string()), " format_bytes(delta)\n".to_string()), " );\n".to_string()), " }\n".to_string()), " if full_elapsed.as_secs() > 10 {\n".to_string()), " panic!(\"ABORT: '{}' took {:?} (>10s)\", name, full_elapsed);\n".to_string()), " }\n\n".to_string()), " let typed = tc_result.typed.clone();\n".to_string()), " mi_raw.insert(name, typed);\n".to_string()), " }\n\n".to_string()), " let rss_final = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \"\\n RSS final: {} (from baseline: +{})\",\n".to_string()), " format_bytes(rss_final),\n".to_string()), " format_bytes(rss_final.saturating_sub(rss_baseline))\n".to_string()), " );\n".to_string()), " eprintln!(\"=== DONE ===\\n\");\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"profile_reconcile_per_module panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_module_footer() -> String { +pub fn ct_module_footer() -> Rc> { "}\n".to_string() } -pub fn compiler_tests_source() -> String { +pub fn compiler_tests_source() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index b1397c9cf29..95b931b1f67 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -103,10 +103,10 @@ pub enum SizeExpr { value: i64, }, SizeVar { - name: String, + name: Rc>, }, SizeLen { - collection: String, + collection: Rc>, }, SizeAdd { left: Rc, @@ -137,7 +137,7 @@ pub enum CostExpr { right: Rc, }, CostSum { - binder: String, + binder: Rc>, upper: Rc, body: Rc, }, @@ -146,10 +146,10 @@ pub enum CostExpr { argument: Rc, }, CostExtern { - name: String, + name: Rc>, }, CostUnknown { - reason: String, + reason: Rc>, }, } @@ -177,13 +177,13 @@ pub struct CostInternTable { pub fn empty_intern_table() -> Rc { Rc::new(CostInternTable { - summaries: v1_rt::rc_empty_map::>(), + summaries: v1_rt::rc_empty_map::>, Rc>(), }) } pub fn cache_summary( table: Rc, - func_name: String, + func_name: Rc>, summary: Rc, ) -> Rc { Rc::new(CostInternTable { @@ -193,19 +193,22 @@ pub fn cache_summary( pub fn lookup_summary( table: Rc, - func_name: String, + func_name: Rc>, ) -> Option> { v1_rt::map_get(&table.summaries.clone(), func_name) } -pub fn evict_summary(table: Rc, func_name: String) -> Rc { +pub fn evict_summary( + table: Rc, + func_name: Rc>, +) -> Rc { cache_summary( table, func_name, Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), ) @@ -213,8 +216,8 @@ pub fn evict_summary(table: Rc, func_name: String) -> Rc>, + pub callee: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -240,7 +243,7 @@ pub struct SccResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ParserStateParam { - pub name: String, + pub name: Rc>, pub index: i64, } @@ -258,7 +261,7 @@ pub enum ParserResultSource { }, ParserResultCall { input: DescentEvidence, - callee: String, + callee: Rc>, }, ParserResultDirectState { input: DescentEvidence, @@ -280,8 +283,8 @@ impl ParserResultSource { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ParserProgressEdge { - pub caller: String, - pub callee: String, + pub caller: Rc>, + pub callee: Rc>, pub progress: DescentEvidence, } @@ -352,7 +355,7 @@ pub fn iteration_element_name( method_semantics: Option>, lambda: Rc, si: Rc>>, -) -> Option { +) -> Rc> { { let params = lambda_param_names_at(lambda, si); match method_callback_element_position(method_semantics) { @@ -370,7 +373,7 @@ pub fn proof_has_non_descending_cycle( (is_valid_proof(proof, edges) == false) } -pub fn set_has(m: Rc>, key: String) -> bool { +pub fn set_has(m: Rc>, key: Rc>) -> bool { (v1_rt::map_get(&m, key) != None) } @@ -383,8 +386,8 @@ pub fn strict_after_parser_witness(input: DescentEvidence) -> DescentEvidence { pub fn empty_parser_progress_env() -> Rc { Rc::new(ParserProgressEnv { - state_aliases: v1_rt::rc_empty_map::(), - result_sources: v1_rt::rc_empty_map::>(), + state_aliases: v1_rt::rc_empty_map::>, DescentEvidence>(), + result_sources: v1_rt::rc_empty_map::>, Rc>(), }) } @@ -409,9 +412,12 @@ pub fn parser_state_param( { let idx = pair.0.clone(); let param = pair.1.clone(); - if (authored_name_at(si.clone(), param_node_type_expr(param.clone())).as_str() - == "ParserState".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + si.clone(), + param_node_type_expr(param.clone()), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "ParserState".to_string(), + )) { Some(Rc::new(ParserStateParam { name: param_node_name_at(param.clone(), si.clone()), index: idx.clone(), @@ -427,7 +433,7 @@ pub fn parser_state_param( pub fn parser_state_base_var( expr: Rc, si: Rc>>, -) -> Option { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => match expr.children.clone().first().cloned() { Some(base) => match (*base.expr_data.clone()).clone() { @@ -446,7 +452,7 @@ pub fn parser_result_state_progress( source: Rc, parser_always_advancing: Rc>, consumed_true_set: Rc>, - result_name: String, + result_name: Rc>, ) -> DescentEvidence { match (*source).clone() { ParserResultSource::ParserResultAdvance { input, .. } => { @@ -501,10 +507,13 @@ pub fn parser_state_arg_expr( let idx = pair.0.clone(); let arg_node = pair.1.clone(); let matches_state = if (arg_name_at(arg_node.clone(), si.clone()).as_deref() - != Some("".to_string().as_str())) - { + != Some(crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + ))) { (arg_name_at(arg_node.clone(), si.clone()).as_deref() - == Some(state_param.name.clone().as_str())) + == Some(crate::v2_std_text::host_string_text_to_rust_host( + state_param.name.clone(), + ))) } else { (idx.clone() == state_param.index.clone()) }; @@ -532,7 +541,9 @@ pub fn parser_state_expr_progress( binding_kind: _, .. } => { let name = expr_var_name_at(expr.clone(), si.clone()); - if (name.clone().as_str() == state_param.name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(state_param.name.clone())) + { DescentEvidence::NonIncreasing } else { match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { @@ -542,8 +553,10 @@ pub fn parser_state_expr_progress( } } ExprData::ExprFieldAccess { .. } => { - if (field_access_field_at(expr.clone(), si.clone()).as_str() - == "state".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_access_field_at( + expr.clone(), + si.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("state".to_string())) { match parser_state_base_var(expr.clone(), si.clone()) { Some(result_name) => { @@ -797,7 +810,7 @@ pub fn parser_result_source_for_expr( } pub fn parser_env_with_binding( - name: String, + name: Rc>, value_expr: Rc, env: Rc, state_param: Rc, @@ -869,7 +882,7 @@ pub fn parser_call_edge_progress( } pub fn collect_parser_progress_block_edges( - caller: String, + caller: Rc>, stmts: Rc>>, state_param: Rc, scc_name_set: Rc>, @@ -952,7 +965,7 @@ pub fn collect_parser_progress_block_edges( } pub fn collect_parser_progress_edges( - caller: String, + caller: Rc>, body: Rc, state_param: Rc, scc_name_set: Rc>, @@ -1153,7 +1166,7 @@ pub fn collect_parser_progress_edges( pub fn parser_record_field_value( expr: Rc, - field_name: String, + field_name: Rc>, si: Rc>>, ) -> Option> { Rc::new({ @@ -1161,8 +1174,10 @@ pub fn parser_record_field_value( for child in Rc::new({ let mut __result = Vec::new(); for child in expr.children.clone().iter().cloned() { - if (field_init_node_name_at(child.clone(), si.clone()).as_str() - == field_name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + child.clone(), + si.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone())) { __result.push(child); } @@ -1381,7 +1396,7 @@ pub fn parser_member_is_always_advancing( parser_name_set, empty_parser_progress_env(), proven.clone(), - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), si.clone(), ); ({ @@ -1401,7 +1416,7 @@ pub fn parser_member_is_always_advancing( state_param.clone(), empty_parser_progress_env(), proven.clone(), - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), si.clone(), ) == DescentEvidence::Strict)) } @@ -1484,8 +1499,8 @@ pub fn infer_parser_always_advancing_members( ) -> Rc> { { let parser_name_set = members.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -1510,7 +1525,7 @@ pub fn infer_parser_always_advancing_members( func_index.clone(), parser_name_set, reverse_graph, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), si.clone(), ) } @@ -1544,23 +1559,45 @@ pub fn infer_all_parser_always_advancing( } } -pub fn seed_string_map(key: String, value: String) -> Rc> { - v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, value) +pub fn seed_string_map( + key: Rc>, + value: Rc>, +) -> Rc> { + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, Rc>>(), + key, + value, + ) } -pub fn seed_bool_map(key: String) -> Rc> { - v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, true) +pub fn seed_bool_map(key: Rc>) -> Rc> { + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, bool>(), + key, + true, + ) } -pub fn seed_cost_map(key: String, value: Rc) -> Rc>> { - v1_rt::rc_map_insert(v1_rt::rc_empty_map::>(), key, value) +pub fn seed_cost_map( + key: Rc>, + value: Rc, +) -> Rc>> { + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, Rc>(), + key, + value, + ) } pub fn seed_func_entry_map( - key: String, + key: Rc>, value: Rc, ) -> Rc>> { - v1_rt::rc_map_insert(v1_rt::rc_empty_map::>(), key, value) + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, Rc>(), + key, + value, + ) } pub fn build_call_graph_from_parser_edges( @@ -1573,7 +1610,9 @@ pub fn build_call_graph_from_parser_edges( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(edge.callee.clone())) + { __result.push(edge); } } @@ -1609,7 +1648,9 @@ pub fn same_progress_subgraph_has_cycle( let has_self_cycle = { let mut __found = false; for edge in same_edges.clone().iter().cloned() { - if (edge.caller.clone().as_str() == edge.callee.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(edge.callee.clone())) + { __found = true; break; } @@ -1623,7 +1664,11 @@ pub fn same_progress_subgraph_has_cycle( let same_cross_edges = Rc::new({ let mut __result = Vec::new(); for edge in same_edges.clone().iter().cloned() { - if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + edge.callee.clone(), + )) + { __result.push(edge); } } @@ -1680,7 +1725,7 @@ pub fn collect_parser_edges_for_scc( scc_name_set.clone(), empty_parser_progress_env(), parser_always_advancing.clone(), - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), si.clone(), ), None => Rc::new(vec![]), @@ -1706,8 +1751,8 @@ pub fn classify_parser_scc_recursion_pattern( ) -> Option> { { let scc_name_set = members.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -1744,14 +1789,16 @@ pub fn classify_parser_scc_recursion_pattern( pub fn count_self_calls( body: Rc, - func_name: String, + func_name: Rc>, si: Rc>>, ) -> i64 { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let own = match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - if (f.as_str() == func_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(f) + == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) + { 1 } else { 0 @@ -1773,7 +1820,7 @@ pub fn count_self_calls( pub fn max_path_self_calls( body: Rc, - func_name: String, + func_name: Rc>, si: Rc>>, ) -> i64 { max_path_self_calls_with_cont(body, func_name, 0, si) @@ -1781,7 +1828,7 @@ pub fn max_path_self_calls( pub fn max_path_self_calls_with_cont( body: Rc, - func_name: String, + func_name: Rc>, continue_calls: i64, si: Rc>>, ) -> i64 { @@ -1789,7 +1836,9 @@ pub fn max_path_self_calls_with_cont( match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - let own = if (f.as_str() == func_name.clone().as_str()) { + let own = if (crate::v2_std_text::host_string_text_to_rust_host(f) + == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) + { 1 } else { 0 @@ -1976,7 +2025,7 @@ pub fn max_path_self_calls_with_cont( pub fn max_path_self_calls_block( stmts: Rc>>, - func_name: String, + func_name: Rc>, continue_calls: i64, si: Rc>>, ) -> i64 { @@ -2207,17 +2256,20 @@ pub fn build_scc_measure_params( si: Rc>>, ) -> Rc>>> { members.iter().cloned().fold( - v1_rt::rc_empty_map::>>(), - |acc: Rc>>>, name: String| match v1_rt::map_get( - &func_index, - name.clone(), - ) { - Some(entry) => v1_rt::rc_map_insert( - acc.clone(), - name.clone(), - recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), - ), - None => acc.clone(), + v1_rt::rc_empty_map::>, Rc>>(), + |acc: Rc>>>, name: Rc>| { + match v1_rt::map_get(&func_index, name.clone()) { + Some(entry) => v1_rt::rc_map_insert( + acc.clone(), + name.clone(), + recursive_measure_param_names( + entry.body.clone(), + entry.params.clone(), + si.clone(), + ), + ), + None => acc.clone(), + } }, ) } @@ -2239,7 +2291,9 @@ pub fn target_call_has_arithmetic_descent( let callee_measure_params = match v1_rt::map_get(&scc_measure_params, callee.clone()) { Some(params) => params.clone(), - None => v1_rt::rc_empty_map::(), + None => { + v1_rt::rc_empty_map::>, Rc>>() + } }; { let mut __found = false; @@ -2347,12 +2401,14 @@ pub fn scc_calls_have_arithmetic_descent( pub fn descending_name_set_without_key( names: Rc>, - key: String, + key: Rc>, ) -> Rc> { Rc::new(v1_rt::map_keys(&names)).iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { - if (name.clone().as_str() == key.clone().as_str()) { + v1_rt::rc_empty_map::>, Rc>>(), + |acc: Rc>, name: Rc>| { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(key.clone())) + { acc.clone() } else { match v1_rt::map_get(&names, name.clone()) { @@ -2368,7 +2424,7 @@ pub fn expr_descending_witness_source( mut expr: Rc, mut descending_witness_names: Rc>, mut si: Rc>>, -) -> Option { +) -> Rc> { loop { match (*expr.expr_data.clone()).clone() { ExprData::ExprVar { @@ -2414,11 +2470,11 @@ pub fn condition_param_names( let name = expr_var_name_at(expr.clone(), si.clone()); match v1_rt::map_get(¶m_set, name.clone()) { Some(_) => seed_string_map(name.clone(), name.clone()), - None => v1_rt::rc_empty_map::(), + None => v1_rt::rc_empty_map::>, Rc>>(), } } _ => expr.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, child: Rc| { v1_rt::rc_map_merge( acc, @@ -2437,7 +2493,7 @@ pub fn recursive_measure_param_names( ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let param_set = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, param: Rc| { v1_rt::rc_map_insert( acc, @@ -2457,7 +2513,7 @@ pub fn recursive_measure_param_names( Some(eb) => { recursive_measure_param_names(eb.clone(), params.clone(), si.clone()) } - None => v1_rt::rc_empty_map::(), + None => v1_rt::rc_empty_map::>, Rc>>(), }; v1_rt::rc_map_merge( v1_rt::rc_map_merge( @@ -2471,7 +2527,7 @@ pub fn recursive_measure_param_names( let scrut_names = condition_param_names(match_scrutinee(body.clone()), param_set, si.clone()); let arm_names = match_arm_nodes(body.clone()).iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, arm_node: Rc| { v1_rt::rc_map_merge( acc, @@ -2487,10 +2543,10 @@ pub fn recursive_measure_param_names( } ExprData::ExprLet => match let_body(body.clone()) { Some(b) => recursive_measure_param_names(b.clone(), params.clone(), si.clone()), - None => v1_rt::rc_empty_map::(), + None => v1_rt::rc_empty_map::>, Rc>>(), }, ExprData::ExprBlock => body.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, stmt: Rc| { v1_rt::rc_map_merge( acc, @@ -2499,7 +2555,7 @@ pub fn recursive_measure_param_names( }, ), _ => body.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, child: Rc| { v1_rt::rc_map_merge( acc, @@ -2516,7 +2572,7 @@ pub fn recursive_param_name_for_arg( arg_node: Rc, params: Rc>>, si: Rc>>, -) -> Option { +) -> Rc> { match arg_name_at(arg_node, si.clone()) { Some(name) => Some(name.clone()), None => Rc::new({ @@ -2575,15 +2631,17 @@ pub fn is_descending_expr(expr: Rc) -> bool { pub fn has_arithmetic_descent( body: Rc, - func_name: String, + func_name: Rc>, si: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let own_ok = if (expr_call_func_at(body.clone(), si.clone()).as_str() - == func_name.clone().as_str()) - { + let own_ok = if (crate::v2_std_text::host_string_text_to_rust_host( + expr_call_func_at(body.clone(), si.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + )) { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -2628,7 +2686,7 @@ pub fn has_arithmetic_descent( pub fn is_accessor_of_param( expr: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, si: Rc>>, ) -> bool { @@ -2643,7 +2701,10 @@ pub fn is_accessor_of_param( binding_kind: _, .. } => { let vname = expr_var_name_at(arg_value(arg_node.clone()), si.clone()); - ((vname.clone().as_str() == param_name.clone().as_str()) + ((crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), vname.clone())) } _ => false, @@ -2661,7 +2722,7 @@ pub fn is_accessor_of_param( pub fn is_children_of_param( mut expr: Rc, - mut param_name: String, + mut param_name: Rc>, mut vars: Rc>, mut si: Rc>>, ) -> bool { @@ -2675,8 +2736,10 @@ pub fn is_children_of_param( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(base.clone(), si.clone()).as_str() - == param_name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + base.clone(), + si.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) } _ => false, }); @@ -2708,7 +2771,7 @@ pub fn is_children_of_param( pub fn is_structural_children( expr: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, si: Rc>>, ) -> bool { @@ -2751,7 +2814,7 @@ pub fn is_structural_children( pub fn is_child_descent_expr( expr: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, si: Rc>>, ) -> bool { @@ -2815,7 +2878,7 @@ pub fn extractor_inner_arg(expr: Rc) -> Rc { pub fn is_list_shrink_expr( expr: Rc, - param_name: String, + param_name: Rc>, si: Rc>>, ) -> bool { match (*expr.expr_data.clone()).clone() { @@ -2832,8 +2895,10 @@ pub fn is_list_shrink_expr( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(method_receiver(expr.clone()), si).as_str() - == param_name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + method_receiver(expr.clone()), + si, + )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) } _ => false, }) @@ -2906,7 +2971,7 @@ pub fn list_passthrough_inner_arg( pub fn is_tokens_consuming_call( expr: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, si: Rc>>, ) -> bool { @@ -2933,7 +2998,9 @@ pub fn consuming_tokens_arg( Some(_) => acc.clone(), None => match arg_name_at(child.clone(), si.clone()) { Some(name) => { - if (name.clone().as_str() == "tokens".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("tokens".to_string())) + { Some(arg_value(child.clone())) } else { None @@ -2946,7 +3013,7 @@ pub fn consuming_tokens_arg( pub fn is_tokens_input_expr( mut expr: Rc, - mut param_name: String, + mut param_name: Rc>, mut vars: Rc>, mut si: Rc>>, ) -> bool { @@ -2956,12 +3023,15 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((vname.clone().as_str() == param_name.clone().as_str()) + break ((crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) || set_has(vars, vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (field.as_str() == param_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(field) + == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) + { break true; } else { let base = field_access_base(expr.clone()); @@ -2970,8 +3040,11 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - break ((bname.clone().as_str() == param_name.clone().as_str()) - || set_has(vars, bname.clone())); + break ((crate::v2_std_text::host_string_text_to_rust_host( + bname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars, bname.clone())); } _ => { break false; @@ -3026,7 +3099,7 @@ pub fn is_tokens_input_expr( pub fn is_descent_arg( expr: Rc, - param_name: String, + param_name: Rc>, descent_vars: Rc>, check_child: bool, check_list: bool, @@ -3055,7 +3128,7 @@ pub fn is_descent_arg( pub fn expr_contains_descent( expr: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, check_child: bool, check_list: bool, @@ -3113,7 +3186,10 @@ pub fn expr_contains_descent( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) + ((crate::v2_std_text::host_string_text_to_rust_host(bname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3185,7 +3261,7 @@ pub fn collect_field_binding_names( pub fn is_if_option_descent( val: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, check_child: bool, check_list: bool, @@ -3207,8 +3283,12 @@ pub fn is_if_option_descent( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(eb.clone(), si.clone()).as_str() - == "none".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + eb.clone(), + si.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "none".to_string(), + )) } ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, @@ -3226,7 +3306,7 @@ pub fn is_if_option_descent( pub fn is_match_option_descent( val: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, check_child: bool, check_list: bool, @@ -3254,7 +3334,7 @@ pub fn is_match_option_descent( .. } => { let binding_names = bindings.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, fb: Rc| { collect_field_binding_names(fb.clone(), acc) }, @@ -3287,8 +3367,11 @@ pub fn is_match_option_descent( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(arm_b.clone(), si.clone()).as_str() - != param_name.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at(arm_b.clone(), si.clone()), + ) != crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) } _ => true, } @@ -3311,7 +3394,7 @@ pub fn is_match_option_descent( pub fn collect_descent_vars( body: Rc, - param_name: String, + param_name: Rc>, vars: Rc>, check_child: bool, check_list: bool, @@ -3406,8 +3489,11 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()).as_str() - == param_name.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at(inner.clone(), si.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) } _ => false, }; @@ -3426,8 +3512,11 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) - || set_has(vars.clone(), bname.clone())) + ((crate::v2_std_text::host_string_text_to_rust_host( + bname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3516,7 +3605,10 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone().as_str() == param_name.clone().as_str()) + ((crate::v2_std_text::host_string_text_to_rust_host(sname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3621,8 +3713,8 @@ pub fn collect_descent_vars( pub fn all_self_calls_descend( body: Rc, - func_name: String, - param_name: String, + func_name: Rc>, + param_name: Rc>, check_child: bool, check_list: bool, si: Rc>>, @@ -3631,7 +3723,7 @@ pub fn all_self_calls_descend( body, func_name, param_name, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), check_child, check_list, si, @@ -3640,8 +3732,8 @@ pub fn all_self_calls_descend( pub fn all_self_calls_descend_inc( body: Rc, - func_name: String, - param_name: String, + func_name: Rc>, + param_name: Rc>, vars: Rc>, check_child: bool, check_list: bool, @@ -3694,8 +3786,11 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) - || set_has(vars.clone(), bname.clone())) + ((crate::v2_std_text::host_string_text_to_rust_host( + bname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3749,7 +3844,10 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone().as_str() == param_name.clone().as_str()) + ((crate::v2_std_text::host_string_text_to_rust_host(sname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3878,7 +3976,9 @@ pub fn all_self_calls_descend_inc( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_ok = if (callee.as_str() == func_name.clone().as_str()) { + let own_ok = if (crate::v2_std_text::host_string_text_to_rust_host(callee) + == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) + { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -4076,7 +4176,7 @@ pub fn unwrap_to_match(mut body: Rc) -> Option> { pub fn matches_on_sub_value_field( body: Rc, - param_name: String, + param_name: Rc>, si: Rc>>, ) -> bool { match unwrap_to_match(body) { @@ -4091,8 +4191,9 @@ pub fn matches_on_sub_value_field( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(base.clone(), si.clone()).as_str() - == param_name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at(base.clone(), si.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) } _ => false, }) @@ -4106,7 +4207,7 @@ pub fn matches_on_sub_value_field( pub fn is_container_child_descent( body: Rc, - func_name: String, + func_name: Rc>, params: Rc>>, si: Rc>>, ) -> bool { @@ -4135,7 +4236,7 @@ pub fn is_container_child_descent( pub fn is_list_shrinkage_descent( body: Rc, - func_name: String, + func_name: Rc>, params: Rc>>, si: Rc>>, ) -> bool { @@ -4163,7 +4264,7 @@ pub fn is_list_shrinkage_descent( pub fn is_arithmetic_descent_expr( expr: Rc, - param_name: String, + param_name: Rc>, si: Rc>>, ) -> bool { match (*expr.expr_data.clone()).clone() { @@ -4174,7 +4275,10 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at(left.clone(), si).as_str() == param_name.as_str()) + ((crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + left.clone(), + si, + )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { @@ -4194,7 +4298,7 @@ pub fn is_arithmetic_descent_expr( pub fn classify_self_call_evidence( arg_expr: Rc, - param_name: String, + param_name: Rc>, descent_vars: Rc>, check_child: bool, check_list: bool, @@ -4229,7 +4333,11 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + vname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4294,18 +4402,22 @@ pub fn classify_self_call_evidence( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone().as_str() == param_name.clone().as_str())) + || (crate::v2_std_text::host_string_text_to_rust_host( + bname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + ))) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (field.as_str() == param_name.clone().as_str()) { - DescentEvidence::NonIncreasing - } else { - DescentEvidence::DescentUnknown - } + if (crate::v2_std_text::host_string_text_to_rust_host(field) == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) { + DescentEvidence::NonIncreasing + } else { + DescentEvidence::DescentUnknown + } } } } @@ -4349,8 +4461,8 @@ pub fn classify_self_call_evidence( pub fn try_dimension_for_param( body: Rc, - func_name: String, - param_name: String, + func_name: Rc>, + param_name: Rc>, check_child: bool, check_list: bool, si: Rc>>, @@ -4359,7 +4471,7 @@ pub fn try_dimension_for_param( body, func_name, param_name, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), check_child, check_list, false, @@ -4369,8 +4481,8 @@ pub fn try_dimension_for_param( pub fn try_branching_dimension_for_param( body: Rc, - func_name: String, - param_name: String, + func_name: Rc>, + param_name: Rc>, check_child: bool, check_list: bool, si: Rc>>, @@ -4379,7 +4491,7 @@ pub fn try_branching_dimension_for_param( body, func_name, param_name, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), check_child, check_list, true, @@ -4396,8 +4508,8 @@ pub fn merge_optional_evidence( pub fn collect_evidence_incremental( body: Rc, - func_name: String, - param_name: String, + func_name: Rc>, + param_name: Rc>, vars: Rc>, check_child: bool, check_list: bool, @@ -4503,8 +4615,11 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()).as_str() - == param_name.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at(inner.clone(), si.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) } _ => false, }; @@ -4523,8 +4638,11 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) - || set_has(vars.clone(), bname.clone())) + ((crate::v2_std_text::host_string_text_to_rust_host( + bname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -4625,7 +4743,10 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((sname.clone().as_str() == param_name.clone().as_str()) + ((crate::v2_std_text::host_string_text_to_rust_host(sname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -4754,7 +4875,9 @@ pub fn collect_evidence_incremental( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_evidence = if (callee.as_str() == func_name.clone().as_str()) { + let own_evidence = if (crate::v2_std_text::host_string_text_to_rust_host(callee) + == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) + { { let arg_evidence = body.children.clone().iter().cloned().fold( DescentEvidence::DescentUnknown, @@ -4949,8 +5072,8 @@ pub fn collect_evidence_incremental( pub fn try_type_directed_dimension( body: Rc, - func_name: String, - param_name: String, + func_name: Rc>, + param_name: Rc>, dim: IterationDimension, si: Rc>>, ) -> Option> { @@ -4989,7 +5112,7 @@ pub fn try_type_directed_dimension( } pub fn construct_termination_proof( - func_name: String, + func_name: Rc>, body: Rc, params: Rc>>, parser_always_advancing: Rc>, @@ -5090,7 +5213,7 @@ pub fn construct_termination_proof( self_set.clone(), empty_parser_progress_env(), parser_always_advancing, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), si.clone(), ); if (((edges.clone().len() as i64) > 0) && { @@ -5139,7 +5262,7 @@ pub fn construct_termination_proof( } pub fn construct_branching_termination_proof( - func_name: String, + func_name: Rc>, body: Rc, params: Rc>>, si: Rc>>, @@ -5264,7 +5387,7 @@ pub fn proof_to_call_pattern(proof: Rc) -> Rc { } pub fn classify_recursion_pattern( - func_name: String, + func_name: Rc>, body: Rc, params: Rc>>, parser_always_advancing: Rc>, @@ -5578,7 +5701,7 @@ pub fn classify_recursion_pattern( pub fn bounded_recursive_cost( target: Rc, per_iter: Rc, - func_name: String, + func_name: Rc>, ) -> Rc { { let p = size_bound_param(target.bound.clone()); @@ -5644,7 +5767,7 @@ pub fn is_unknown_cost(expr: Rc) -> bool { }) } -pub fn extract_unknown_reason(mut expr: Rc) -> String { +pub fn extract_unknown_reason(mut expr: Rc) -> Rc> { loop { match (*expr).clone() { CostExpr::CostUnknown { reason: r, .. } => { @@ -5714,7 +5837,7 @@ pub fn extract_unknown_reason(mut expr: Rc) -> String { } pub fn collect_local_call_edges_in_expr( - caller: String, + caller: Rc>, body: Rc, local_func_set: Rc>, si: Rc>>, @@ -5767,8 +5890,8 @@ pub fn build_call_graph( __result }); let local_func_set = names.iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -5794,7 +5917,11 @@ pub fn build_call_graph( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + edge.callee.clone(), + )) + { __result.push(edge); } } @@ -5814,7 +5941,7 @@ pub fn build_call_graph( } } -pub fn scc_label(members: Rc>) -> String { +pub fn scc_label(members: Rc>) -> Rc> { match members.first().cloned() { Some(name) => name.clone(), None => "scc".to_string(), @@ -5823,7 +5950,7 @@ pub fn scc_label(members: Rc>) -> String { pub fn classify_scc_call_progress( arg_expr: Rc, - param_name: String, + param_name: Rc>, descent_vars: Rc>, si: Rc>>, ) -> DescentEvidence { @@ -5847,7 +5974,11 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) + { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5901,14 +6032,22 @@ pub fn classify_scc_call_progress( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (bname.clone().as_str() == param_name.clone().as_str())) + || (crate::v2_std_text::host_string_text_to_rust_host( + bname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + ))) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (field.as_str() == param_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + field, + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -5953,8 +6092,8 @@ pub fn classify_scc_call_progress( pub fn collect_scc_child_edges( body: Rc, - caller: String, - param_name: String, + caller: Rc>, + param_name: Rc>, descent_vars: Rc>, target_set: Rc>, check_child: bool, @@ -5972,7 +6111,10 @@ pub fn collect_scc_child_edges( let callee_params = match v1_rt::map_get(&scc_measure_params, callee.clone()) { Some(p) => p.clone(), - None => v1_rt::rc_empty_map::(), + None => { + v1_rt::rc_empty_map::>, Rc>>( + ) + } }; let progress = body.children.clone().iter().cloned().fold( DescentEvidence::DescentUnknown, @@ -6246,8 +6388,11 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(inner.clone(), si.clone()).as_str() - == param_name.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at(inner.clone(), si.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) } _ => false, }; @@ -6266,8 +6411,11 @@ pub fn collect_scc_child_edges( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((bname.clone().as_str() == param_name.clone().as_str()) - || set_has(descent_vars.clone(), bname.clone())) + ((crate::v2_std_text::host_string_text_to_rust_host( + bname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || set_has(descent_vars.clone(), bname.clone())) } _ => false, }) @@ -6502,7 +6650,7 @@ pub fn is_scc_container_child_descent( let descent_vars = collect_descent_vars( entry.body.clone(), pname.clone(), - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), true, true, si.clone(), @@ -6599,11 +6747,11 @@ pub fn collect_scc_proof_edges_for_dim( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { + let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); +let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), check_child.clone(), check_list.clone(), si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); Rc::new({ let mut __result = Vec::new(); for callee in Rc::new(v1_rt::map_keys(&best_map)).iter().cloned() { __result.push({ @@ -6674,22 +6822,22 @@ pub fn collect_scc_independent_dim_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { + let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), true, false, si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); -let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { +let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); +let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), false, true, si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let all_keys = v1_rt::concat(Rc::new(v1_rt::map_keys(&tree_edge_map)), Rc::new(v1_rt::map_keys(&list_edge_map))); -let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |acc: Rc>, k: String| v1_rt::rc_map_insert(acc, k.clone(), true)); +let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, k: Rc>| v1_rt::rc_map_insert(acc, k.clone(), true)); Rc::new({ let mut __result = Vec::new(); for callee in Rc::new(v1_rt::map_keys(&unique_keys)).iter().cloned() { __result.push({ let tree_ev = match v1_rt::map_get(&tree_edge_map, callee.clone()) { Some(ev) => ev.clone(), @@ -6756,17 +6904,17 @@ pub fn collect_scc_tree_parser_dim_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { + let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), true, false, si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); -let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (pe.caller.clone().as_str() == name.clone().as_str()) { __result.push(pe); } } __result }); -let parser_edge_map = my_parser_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(pe.caller.clone()) == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { __result.push(pe); } } __result }); +let parser_edge_map = my_parser_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); let all_keys = v1_rt::concat(Rc::new(v1_rt::map_keys(&tree_edge_map)), Rc::new(v1_rt::map_keys(&parser_edge_map))); -let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |acc: Rc>, k: String| v1_rt::rc_map_insert(acc, k.clone(), true)); +let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, k: Rc>| v1_rt::rc_map_insert(acc, k.clone(), true)); Rc::new({ let mut __result = Vec::new(); for callee in Rc::new(v1_rt::map_keys(&unique_keys)).iter().cloned() { __result.push({ let tree_ev = match v1_rt::map_get(&tree_edge_map, callee.clone()) { Some(ev) => ev.clone(), @@ -6816,7 +6964,7 @@ let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for _ => false, } { __found = true; break; } } __found }) { __all = false; break; } } __all }); let descending_param = match self_evidence.clone().first().cloned() { - Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: String, rel: Rc| if (found.clone().as_str() != "".to_string().as_str()) { + Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: Rc>, rel: Rc| if (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { found.clone() } else { match (*rel.clone()).clone() { @@ -6860,7 +7008,7 @@ Rc::new(vec![Rc::new(ProofEdge { } else { Rc::new(vec![]) }; -let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone().as_str() != name.clone().as_str()) { __result.push(m); } } __result }); +let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(m.clone()) != crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { @@ -6890,12 +7038,13 @@ pub fn scc_descending_param( members: Rc>, func_index: Rc>>, si: Rc>>, -) -> String { - members - .iter() - .cloned() - .fold("".to_string(), |found: String, name: String| { - if (found.clone().as_str() != "".to_string().as_str()) { +) -> Rc> { + members.iter().cloned().fold( + "".to_string(), + |found: Rc>, name: Rc>| { + if (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { found.clone() } else { match v1_rt::map_get(&func_index, name.clone()) { @@ -6908,8 +7057,12 @@ pub fn scc_descending_param( match evidence.clone().first().cloned() { Some(call_ev) => call_ev.clone().iter().cloned().fold( "".to_string(), - |p: String, rel: Rc| { - if (p.clone().as_str() != "".to_string().as_str()) { + |p: Rc>, rel: Rc| { + if (crate::v2_std_text::host_string_text_to_rust_host( + p.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { p.clone() } else { match (*rel.clone()).clone() { @@ -6934,7 +7087,8 @@ pub fn scc_descending_param( None => "".to_string(), } } - }) + }, + ) } pub fn construct_scc_termination_proof( @@ -6966,7 +7120,9 @@ pub fn construct_scc_termination_proof( let cx_l2_param = scc_descending_param(members.clone(), func_index.clone(), si.clone()); let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { - param: if (cx_l2_param.clone().as_str() != "".to_string().as_str()) { + param: if (crate::v2_std_text::host_string_text_to_rust_host(cx_l2_param.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { cx_l2_param.clone() } else { "scc".to_string() @@ -7209,8 +7365,8 @@ pub fn classify_scc_recursion_pattern( ) -> Rc { { let scc_name_set = members.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -7311,78 +7467,46 @@ pub fn build_scc_index( visited: v1_rt::rc_empty_set::(), order: Rc::new(vec![]), }), - |acc: Rc, name: String| { + |acc: Rc, name: Rc>| { dfs_finish_order(name.clone(), adjacency.clone(), acc) }, ); let topo_order = v1_rt::reverse(finish.order.clone()); - let result = topo_order.clone().iter().cloned().fold( - Rc::new(SccBuildAcc { - assigned: v1_rt::rc_empty_set::(), - index: v1_rt::rc_empty_map::>(), - }), - |acc: Rc, name: String| { - if v1_rt::set_contains(&acc.assigned.clone(), name.clone()) { - acc.clone() - } else { + let result = topo_order.clone().iter().cloned().fold(Rc::new(SccBuildAcc { + assigned: v1_rt::rc_empty_set::(), + index: v1_rt::rc_empty_map::>, Rc>(), +}), |acc: Rc, name: Rc>| if v1_rt::set_contains(&acc.assigned.clone(), name.clone()) { + acc.clone() + } else { + { + let component = dfs_collect_component(name.clone(), reverse_graph.clone(), Rc::new(SccComponentAcc { + visited: acc.assigned.clone(), + members: Rc::new(vec![]), +})); +let member_set = component.members.clone().iter().cloned().fold(v1_rt::rc_empty_set::<_>(), |inner: _, member: Rc>| v1_rt::rc_set_insert(inner, member.clone())); +let members = Rc::new({ let mut __result = Vec::new(); for member in names.clone().iter().cloned() { if v1_rt::set_contains(&member_set, member.clone()) { __result.push(member); } } __result }); +let next_assigned = component.visited.clone(); +if ((members.clone().len() as i64) > 1) { { - let component = dfs_collect_component( - name.clone(), - reverse_graph.clone(), - Rc::new(SccComponentAcc { - visited: acc.assigned.clone(), - members: Rc::new(vec![]), - }), - ); - let member_set = - component.members.clone().iter().cloned().fold( - v1_rt::rc_empty_set::<_>(), - |inner: _, member: String| { - v1_rt::rc_set_insert(inner, member.clone()) - }, - ); - let members = Rc::new({ - let mut __result = Vec::new(); - for member in names.clone().iter().cloned() { - if v1_rt::set_contains(&member_set, member.clone()) { - __result.push(member); - } - } - __result - }); - let next_assigned = component.visited.clone(); - if ((members.clone().len() as i64) > 1) { - { - let info = Rc::new(SccInfo { - members: members.clone(), - member_set: member_set.clone(), - pattern: classify_scc_recursion_pattern( - members.clone(), - func_index.clone(), - si.clone(), - ), - }); - let next_index = members.clone().iter().cloned().fold( - acc.index.clone(), - |inner: Rc>>, member: String| { - v1_rt::rc_map_insert(inner, member.clone(), info.clone()) - }, - ); - Rc::new(SccBuildAcc { - assigned: next_assigned.clone(), - index: next_index.clone(), - }) - } - } else { - Rc::new(SccBuildAcc { - assigned: next_assigned.clone(), - index: acc.index.clone(), - }) - } - } + let info = Rc::new(SccInfo { + members: members.clone(), + member_set: member_set.clone(), + pattern: classify_scc_recursion_pattern(members.clone(), func_index.clone(), si.clone()), +}); +let next_index = members.clone().iter().cloned().fold(acc.index.clone(), |inner: Rc>>, member: Rc>| v1_rt::rc_map_insert(inner, member.clone(), info.clone())); +Rc::new(SccBuildAcc { + assigned: next_assigned.clone(), + index: next_index.clone(), +}) +} + } else { + Rc::new(SccBuildAcc { + assigned: next_assigned.clone(), + index: acc.index.clone(), +}) } - }, - ); +} + }); Rc::new(SccResult { index: result.index.clone(), topo_order: topo_order.clone(), @@ -7418,7 +7542,11 @@ pub fn cost_par(a: Rc, b: Rc) -> Rc { } } -pub fn cost_loop(binder: String, iterations: Rc, body: Rc) -> Rc { +pub fn cost_loop( + binder: Rc>, + iterations: Rc, + body: Rc, +) -> Rc { match (*body.clone()).clone() { CostExpr::CostConst { value: 0, .. } => Rc::new(CostExpr::CostConst { value: 0 }), _ => Rc::new(CostExpr::CostSum { @@ -7439,7 +7567,10 @@ pub fn cost_conditional(condition: Rc, branches: Rc>> } } -pub fn collection_output(binder: String, size: Rc) -> Rc>> { +pub fn collection_output( + binder: Rc>, + size: Rc, +) -> Rc>> { { let result = seed_cost_map( "result".to_string(), @@ -7450,7 +7581,7 @@ pub fn collection_output(binder: String, size: Rc) -> Rc Rc>> { - v1_rt::rc_empty_map::>() + v1_rt::rc_empty_map::>, Rc>() } pub fn method_preserves_collection_size(method_semantics: Option>) -> bool { @@ -7515,7 +7646,7 @@ pub fn receiver_size_var( } } -pub fn size_binder_name(size: Rc) -> String { +pub fn size_binder_name(size: Rc) -> Rc> { match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => v1_rt::concat("_".to_string(), c.clone()), SizeExpr::SizeVar { name: n, .. } => n.clone(), @@ -7531,7 +7662,11 @@ pub fn resolve_lambda_arg( let f_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_arg_nodes.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() == "f".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + si.clone(), + a.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("f".to_string())) + { __result.push(a); } } @@ -7602,7 +7737,7 @@ pub fn resolve_callback_cost( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Conservative, }), table: recv_r.table.clone(), @@ -7616,7 +7751,7 @@ pub fn cost_of_method_by_shape( recv_r: Rc, mc_args: Rc>>, size: Rc, - binder: String, + binder: Rc>, func_index: Rc>>, scc_index: Rc>>, parser_always_advancing: Rc>, @@ -7681,7 +7816,7 @@ pub fn cost_of_method_by_shape( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: recv_r.table.clone(), @@ -7730,7 +7865,7 @@ pub fn cost_of_method_by_shape( ), ) } else { - v1_rt::rc_empty_map::>() + v1_rt::rc_empty_map::>, Rc>() }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { @@ -7752,7 +7887,7 @@ pub fn cost_of_method_by_shape( recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: recv_r.summary.clone().certainty.clone(), }), table: recv_r.table.clone(), @@ -7762,15 +7897,15 @@ pub fn cost_of_method_by_shape( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ComplexityViolation { - pub func_name: String, - pub reason: String, + pub func_name: Rc>, + pub reason: Rc>, pub span: Rc, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StructuralBoundResult { - pub func_name: String, - pub param: String, + pub func_name: Rc>, + pub param: Rc>, pub recurrence_bound: Rc, pub stack_bound: Rc, pub span: Rc, @@ -7785,7 +7920,7 @@ pub struct ComplexityReport { pub fn empty_complexity_report() -> Rc { Rc::new(ComplexityReport { - function_classes: v1_rt::rc_empty_map::(), + function_classes: v1_rt::rc_empty_map::>, Rc>>(), violations: Rc::new(vec![]), structural_bounds: Rc::new(vec![]), }) @@ -7908,13 +8043,15 @@ pub fn simplify_cost(expr: Rc) -> Rc { }) } -pub fn format_size(size: Rc) -> String { +pub fn format_size(size: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { v1_rt::concat(v1_rt::concat("|".to_string(), c.clone()), "|".to_string()) } SizeExpr::SizeVar { name: n, .. } => n.clone(), - SizeExpr::SizeConst { value: v, .. } => (v.clone()).to_string(), + SizeExpr::SizeConst { value: v, .. } => { + crate::v2_std_text::host_string_text_from_rust_host((v.clone()).to_string()) + } SizeExpr::SizeAdd { left: l, right: r, .. } => v1_rt::concat( @@ -8059,7 +8196,7 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { }) } -pub fn format_cost_class(expr: Rc) -> String { +pub fn format_cost_class(expr: Rc) -> Rc> { match (*expr).clone() { CostExpr::CostConst { value: _, .. } => "O(1)".to_string(), CostExpr::CostExtern { name: n, .. } => v1_rt::concat( @@ -8128,7 +8265,7 @@ pub fn format_cost_class(expr: Rc) -> String { } } -pub fn format_cost_inner(expr: Rc) -> String { +pub fn format_cost_inner(expr: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*expr).clone() { CostExpr::CostConst { value: _, .. } => "1".to_string(), CostExpr::CostSum { @@ -8188,7 +8325,7 @@ pub fn format_cost_inner(expr: Rc) -> String { }) } -pub fn parenthesize_additive_cost(expr: Rc) -> String { +pub fn parenthesize_additive_cost(expr: Rc) -> Rc> { match (*expr.clone()).clone() { CostExpr::CostAdd { .. } => v1_rt::concat( v1_rt::concat("(".to_string(), format_cost_inner(expr.clone())), @@ -8198,7 +8335,7 @@ pub fn parenthesize_additive_cost(expr: Rc) -> String { } } -pub fn short_var_name(index: i64) -> String { +pub fn short_var_name(index: i64) -> Rc> { if (index.clone() == 0) { "n".to_string() } else { @@ -8231,7 +8368,9 @@ pub fn short_var_name(index: i64) -> String { } else { v1_rt::concat( "x".to_string(), - (index.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (index.clone()).to_string(), + ), ) } } @@ -8248,7 +8387,7 @@ pub fn short_var_name(index: i64) -> String { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Legend { pub substitution: Rc>, - pub suffix: String, + pub suffix: Rc>, } pub fn build_legend(size_names: Rc>) -> Rc { @@ -8256,7 +8395,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { let unique = deduplicate(size_names); if ((unique.clone().len() as i64) == 0) { Rc::new(Legend { - substitution: v1_rt::rc_empty_map::(), + substitution: v1_rt::rc_empty_map::>, Rc>>(), suffix: "".to_string(), }) } else { @@ -8264,14 +8403,15 @@ pub fn build_legend(size_names: Rc>) -> Rc { match unique.clone().first().cloned() { Some(name) => Rc::new(Legend { substitution: v1_rt::rc_map_insert( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), name.clone(), "n".to_string(), ), suffix: "".to_string(), }), None => Rc::new(Legend { - substitution: v1_rt::rc_empty_map::(), + substitution: v1_rt::rc_empty_map::>, Rc>>( + ), suffix: "".to_string(), }), } @@ -8279,10 +8419,13 @@ pub fn build_legend(size_names: Rc>) -> Rc { { let indexed = unique.clone().iter().cloned().fold( Rc::new(Legend { - substitution: v1_rt::rc_empty_map::(), + substitution: v1_rt::rc_empty_map::< + Rc>, + Rc>, + >(), suffix: "".to_string(), }), - |acc: Rc, name: String| { + |acc: Rc, name: Rc>| { let idx = (Rc::new(v1_rt::map_keys(&acc.substitution.clone())).len() as i64); let short = short_var_name(idx.clone()); @@ -8292,8 +8435,11 @@ pub fn build_legend(size_names: Rc>) -> Rc { name.clone(), short.clone(), ), - suffix: if (acc.suffix.clone().as_str() == "".to_string().as_str()) - { + suffix: if (crate::v2_std_text::host_string_text_to_rust_host( + acc.suffix.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { v1_rt::concat( v1_rt::concat( v1_rt::concat(" where ".to_string(), short.clone()), @@ -8401,7 +8547,7 @@ pub fn substitute_cost(expr: Rc, legend: Rc>) }) } -pub fn classify_complexity(expr: Rc) -> String { +pub fn classify_complexity(expr: Rc) -> Rc> { { let normalized = normalize_asymptotic(simplify_cost(expr)); let size_names = collect_size_vars(normalized.clone()); @@ -8414,14 +8560,18 @@ pub fn classify_complexity(expr: Rc) -> String { pub fn collect_size_vars_from_size(size: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { - if (c.clone().as_str() == "__expr".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(c.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("__expr".to_string())) + { Rc::new(vec![]) } else { Rc::new(vec![c.clone()]) } } SizeExpr::SizeVar { name: n, .. } => { - if (n.clone().as_str() == "__k".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("__k".to_string())) + { Rc::new(vec![]) } else { Rc::new(vec![n.clone()]) @@ -8475,10 +8625,10 @@ pub fn deduplicate(items: Rc>) -> Rc> { { let result = items.iter().cloned().fold( Rc::new(DeduplicateAcc { - seen: v1_rt::rc_empty_map::(), + seen: v1_rt::rc_empty_map::>, bool>(), out: Rc::new(vec![]), }), - |acc: Rc, item: String| match v1_rt::map_get( + |acc: Rc, item: Rc>| match v1_rt::map_get( &acc.seen.clone(), item.clone(), ) { @@ -8495,7 +8645,7 @@ pub fn deduplicate(items: Rc>) -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FuncEntry { - pub name: String, + pub name: Rc>, pub body: Rc, pub params: Rc>>, pub span: Rc, @@ -8541,7 +8691,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: table, @@ -8550,7 +8700,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: table, @@ -8559,7 +8709,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: table, @@ -8601,7 +8751,7 @@ pub fn cost_of_expr( rr.summary.clone().span.clone(), ), ), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: rr.table.clone(), @@ -8623,49 +8773,36 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: table, }), }; - let args_result = texpr.children.clone().iter().cloned().fold( - Rc::new(SummaryResult { - summary: Rc::new(ComplexitySummary { - work: Rc::new(CostExpr::CostConst { value: 0 }), - span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), - certainty: Certainty::Proven, - }), - table: callee_result.table.clone(), - }), - |acc: Rc, a: Rc| { - let ar = cost_of_expr( - arg_value(a.clone()), - func_index.clone(), - scc_index.clone(), - acc.table.clone(), - parser_always_advancing.clone(), - recursion_ctx.clone(), - si.clone(), - ); - Rc::new(SummaryResult { - summary: Rc::new(ComplexitySummary { - work: cost_seq( - acc.summary.clone().work.clone(), - ar.summary.clone().work.clone(), - ), - span: cost_seq( - acc.summary.clone().span.clone(), - ar.summary.clone().span.clone(), - ), - output_size: v1_rt::rc_empty_map::>(), - certainty: Certainty::Proven, - }), - table: ar.table.clone(), - }) - }, - ); + let args_result = texpr.children.clone().iter().cloned().fold(Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: Rc::new(CostExpr::CostConst { + value: 0, +}), + span: Rc::new(CostExpr::CostConst { + value: 0, +}), + output_size: v1_rt::rc_empty_map::>, Rc>(), + certainty: Certainty::Proven, +}), + table: callee_result.table.clone(), +}), |acc: Rc, a: Rc| { + let ar = cost_of_expr(arg_value(a.clone()), func_index.clone(), scc_index.clone(), acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone()); +Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: cost_seq(acc.summary.clone().work.clone(), ar.summary.clone().work.clone()), + span: cost_seq(acc.summary.clone().span.clone(), ar.summary.clone().span.clone()), + output_size: v1_rt::rc_empty_map::>, Rc>(), + certainty: Certainty::Proven, +}), + table: ar.table.clone(), +}) +}); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( @@ -8733,7 +8870,10 @@ pub fn cost_of_expr( recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), certainty: recv_r.summary.clone().certainty.clone(), }), table: recv_r.table.clone(), @@ -8751,7 +8891,10 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), certainty: Certainty::Proven, }), table: recv_r.table.clone(), @@ -8776,7 +8919,10 @@ pub fn cost_of_expr( acc.summary.clone().span.clone(), ar.summary.clone().span.clone(), ), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), certainty: Certainty::Proven, }), table: ar.table.clone(), @@ -8799,7 +8945,8 @@ pub fn cost_of_expr( args_result.summary.clone().span.clone(), ), ), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>( + ), certainty: Certainty::Proven, }), table: args_result.table.clone(), @@ -8819,52 +8966,56 @@ pub fn cost_of_expr( recursion_ctx.clone(), si.clone(), ); - let arms_accum = arm_nodes.iter().cloned().fold( - Rc::new(MatchCostAccum { - result: Rc::new(SummaryResult { - summary: Rc::new(ComplexitySummary { - work: Rc::new(CostExpr::CostConst { value: 0 }), - span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), - certainty: Certainty::Proven, - }), - table: s_r.table.clone(), - }), - branch_costs: Rc::new(vec![]), - }), - |acc: Rc, arm_node: Rc| { - let ar = cost_of_expr( - arm_body(arm_node.clone()), - func_index.clone(), - scc_index.clone(), - acc.result.clone().table.clone(), - parser_always_advancing.clone(), - recursion_ctx.clone(), - si.clone(), - ); + let arms_accum = + arm_nodes.iter().cloned().fold( Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: cost_par( - acc.result.clone().summary.clone().work.clone(), - ar.summary.clone().work.clone(), - ), - span: cost_par( - acc.result.clone().summary.clone().span.clone(), - ar.summary.clone().span.clone(), - ), - output_size: ar.summary.clone().output_size.clone(), - certainty: ar.summary.clone().certainty.clone(), + work: Rc::new(CostExpr::CostConst { value: 0 }), + span: Rc::new(CostExpr::CostConst { value: 0 }), + output_size: v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), + certainty: Certainty::Proven, }), - table: ar.table.clone(), + table: s_r.table.clone(), }), - branch_costs: v1_rt::concat( - acc.branch_costs.clone(), - Rc::new(vec![ar.summary.clone().work.clone()]), - ), - }) - }, - ); + branch_costs: Rc::new(vec![]), + }), + |acc: Rc, arm_node: Rc| { + let ar = cost_of_expr( + arm_body(arm_node.clone()), + func_index.clone(), + scc_index.clone(), + acc.result.clone().table.clone(), + parser_always_advancing.clone(), + recursion_ctx.clone(), + si.clone(), + ); + Rc::new(MatchCostAccum { + result: Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: cost_par( + acc.result.clone().summary.clone().work.clone(), + ar.summary.clone().work.clone(), + ), + span: cost_par( + acc.result.clone().summary.clone().span.clone(), + ar.summary.clone().span.clone(), + ), + output_size: ar.summary.clone().output_size.clone(), + certainty: ar.summary.clone().certainty.clone(), + }), + table: ar.table.clone(), + }), + branch_costs: v1_rt::concat( + acc.branch_costs.clone(), + Rc::new(vec![ar.summary.clone().work.clone()]), + ), + }) + }, + ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( @@ -8928,7 +9079,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: t_r.table.clone(), @@ -9002,7 +9153,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: table, @@ -9062,7 +9213,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: bd_r.summary.clone().certainty.clone(), }), table: bd_r.table.clone(), @@ -9073,7 +9224,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: table, @@ -9110,7 +9261,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Proven, }), table: table, @@ -9164,7 +9315,7 @@ pub fn estimate_expr_size(texpr: Rc, budget: i64) -> i64 { } pub fn get_or_compute_summary( - func_name: String, + func_name: Rc>, func_index: Rc>>, scc_index: Rc>>, table: Rc, @@ -9187,7 +9338,7 @@ pub fn get_or_compute_summary( let zero_placeholder = Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Conservative, }); let table_prepped = if is_recursive { @@ -9275,7 +9426,7 @@ pub fn get_or_compute_summary( func_name.clone(), ), }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Conservative, }); Rc::new(SummaryResult { @@ -9292,7 +9443,7 @@ pub fn get_or_compute_summary( span: Rc::new(CostExpr::CostExtern { name: func_name.clone(), }), - output_size: v1_rt::rc_empty_map::>(), + output_size: v1_rt::rc_empty_map::>, Rc>(), certainty: Certainty::Conservative, }); Rc::new(SummaryResult { @@ -9352,24 +9503,32 @@ pub fn collect_call_evidence( pub fn collect_self_call_evidence( body: Rc, - fn_name: String, + fn_name: Rc>, si: Rc>>, ) -> Rc>>>> { collect_call_evidence( body, - v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), fn_name, true), + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, bool>(), + fn_name, + true, + ), si, ) } pub fn collect_callee_evidence( body: Rc, - callee_name: String, + callee_name: Rc>, si: Rc>>, ) -> Rc>>>> { collect_call_evidence( body, - v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), callee_name, true), + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, bool>(), + callee_name, + true, + ), si, ) } @@ -9466,7 +9625,7 @@ pub fn extract_shrink_factor( pub fn max_path_descending( body: Rc, - fn_name: String, + fn_name: Rc>, param_index: i64, si: Rc>>, ) -> i64 { @@ -9477,7 +9636,9 @@ pub fn max_path_descending( .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own = if (callee.as_str() == fn_name.clone().as_str()) { + let own = if (crate::v2_std_text::host_string_text_to_rust_host(callee) + == crate::v2_std_text::host_string_text_to_rust_host(fn_name.clone())) + { match de.clone() { Some(evidence) => { match evidence.clone().get(param_index.clone() as usize).cloned() { @@ -9586,7 +9747,7 @@ pub fn distinct_descended_fields( ) -> i64 { { let field_set = all_calls.iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, call_evidence: Rc>>| { match call_evidence .clone() @@ -9731,7 +9892,7 @@ pub fn build_complexity_report( { let si = source_indices; let func_index = func_entries.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), entry.clone()) }, @@ -9784,21 +9945,21 @@ pub fn build_complexity_report( scc_result.call_graph.clone(), ); let fan_in = func_entries.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, i64>(), |acc: Rc>, entry: Rc| { let callees = match v1_rt::map_get(&call_forward, entry.name.clone()) { Some(cs) => cs.clone(), None => Rc::new(vec![]), }; let unique_set = callees.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |s: Rc>, c: String| { + v1_rt::rc_empty_map::>, bool>(), + |s: Rc>, c: Rc>| { v1_rt::rc_map_insert(s, c.clone(), true) }, ); Rc::new(v1_rt::map_keys(&unique_set)).iter().cloned().fold( acc, - |inner: Rc>, callee: String| { + |inner: Rc>, callee: Rc>| { let current = match v1_rt::map_get(&inner, callee.clone()) { Some(v) => v.clone(), None => 0, @@ -9811,12 +9972,12 @@ pub fn build_complexity_report( let result = scc_result.processing_order.clone().iter().cloned().fold( Rc::new(TopoBuildAcc { table: empty_intern_table(), - classes: v1_rt::rc_empty_map::(), + classes: v1_rt::rc_empty_map::>, Rc>>(), violations: Rc::new(vec![]), fan_in: fan_in, - processed: v1_rt::rc_empty_map::(), + processed: v1_rt::rc_empty_map::>, bool>(), }), - |acc: Rc, func_name: String| match v1_rt::map_get( + |acc: Rc, func_name: Rc>| match v1_rt::map_get( &func_index, func_name.clone(), ) { @@ -9855,15 +10016,15 @@ pub fn build_complexity_report( None => Rc::new(vec![]), }; let unique_set = callees.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |s: Rc>, c: String| { + v1_rt::rc_empty_map::>, bool>(), + |s: Rc>, c: Rc>| { v1_rt::rc_map_insert(s, c.clone(), true) }, ); let unique_callees = Rc::new(v1_rt::map_keys(&unique_set)); let new_fan_in = unique_callees.clone().iter().cloned().fold( acc.fan_in.clone(), - |fi: Rc>, callee: String| { + |fi: Rc>, callee: Rc>| { let current = match v1_rt::map_get(&fi, callee.clone()) { Some(v) => v.clone(), None => 0, @@ -9873,7 +10034,7 @@ pub fn build_complexity_report( ); let evicted_table = unique_callees.clone().iter().cloned().fold( sr.table.clone(), - |t: Rc, callee: String| { + |t: Rc, callee: Rc>| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), None => 0, diff --git a/src/v1/stage0/src/v1_compiler_effect_derivation.rs b/src/v1/stage0/src/v1_compiler_effect_derivation.rs index 3c53f8f8d38..f16d2ef4b17 100644 --- a/src/v1/stage0/src/v1_compiler_effect_derivation.rs +++ b/src/v1/stage0/src/v1_compiler_effect_derivation.rs @@ -34,7 +34,7 @@ use std::collections::HashMap; use std::rc::Rc; pub fn re_export_derive_op_effect( - operation_name: String, + operation_name: Rc>, method: HttpMethod, path: Rc, ) -> Rc { @@ -49,7 +49,7 @@ pub fn re_export_check_modifier( check_modifier_vs_derivation(op, declared_idempotent, declared_readonly) } -pub fn re_export_parse_path_template(raw: String) -> Rc { +pub fn re_export_parse_path_template(raw: Rc>) -> Rc { parse_path_template(raw) } diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index e49c1480475..a698fa9d958 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -159,7 +159,7 @@ pub enum BackendCapability { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct BackendInfo { - pub target_name: String, + pub target_name: Rc>, pub capabilities: Rc>, } @@ -192,7 +192,11 @@ pub fn derive_module_imports( ImportTrigger::TypeUsageTrigger { type_name: t, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (n.clone().as_str() == t.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + n.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + t.clone(), + )) { __found = true; break; } @@ -204,7 +208,11 @@ pub fn derive_module_imports( ImportTrigger::ContainerUsageTrigger { container: c, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (n.clone().as_str() == c.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + n.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + c.clone(), + )) { __found = true; break; } @@ -228,7 +236,9 @@ pub fn derive_module_imports( .iter() .cloned() { - if (path.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(path.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(path); } } @@ -281,15 +291,15 @@ pub fn collect_type_names_from_node( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct InterpPart { - pub format_segment: String, - pub arg_expr: String, + pub format_segment: Rc>, + pub arg_expr: Rc>, } pub fn emit_simple_expr( expr: Rc, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => emit_literal(v.clone(), target.clone()), @@ -443,7 +453,7 @@ pub fn emit_simple_string_interp( parts: Rc>>, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); let interp = spec.string_interp.clone(); @@ -512,7 +522,9 @@ pub fn emit_simple_string_interp( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(a.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(a); } } @@ -570,19 +582,20 @@ pub fn empty_emit_scope() -> Rc { bindings: v1_rt::rc_empty_map::>(), recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), - source_indices: v1_rt::rc_empty_map::>(), + inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( + ), + source_indices: v1_rt::rc_empty_map::>, Rc>(), intern_table: empty_intern_table(), }), func_env: Rc::new(ResolvedFuncEnv { - signatures: v1_rt::rc_empty_map::>(), + signatures: v1_rt::rc_empty_map::>, Rc>(), }), - locals: v1_rt::rc_empty_map::>(), - match_bound_names: v1_rt::rc_empty_map::(), + locals: v1_rt::rc_empty_map::>, Rc>(), + match_bound_names: v1_rt::rc_empty_map::>, bool>(), module_name: "".to_string(), - service_registry: v1_rt::rc_empty_map::>>>(), - item_registry: v1_rt::rc_empty_map::>(), - lambda_param_provenance: v1_rt::rc_empty_map::>(), + service_registry: v1_rt::rc_empty_map::>, Rc>>>(), + item_registry: v1_rt::rc_empty_map::>, Rc>(), + lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>(), }) } @@ -590,15 +603,15 @@ pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { type_env: typed_module.type_env.clone(), func_env: typed_module.func_env.clone(), - locals: v1_rt::rc_empty_map::>(), - match_bound_names: v1_rt::rc_empty_map::(), + locals: v1_rt::rc_empty_map::>, Rc>(), + match_bound_names: v1_rt::rc_empty_map::>, bool>(), module_name: authored_name_at( typed_module.type_env.clone().source_indices.clone(), typed_module.module.clone(), ), - service_registry: v1_rt::rc_empty_map::>>>(), + service_registry: v1_rt::rc_empty_map::>, Rc>>>(), item_registry: typed_module.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::>(), + lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>(), }) } @@ -630,21 +643,21 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc>>, - name: String, + name: Rc>, ) -> Option> { v1_rt::map_get(®istry, name) } pub fn lookup_func_sig_in_scope( scope: Rc, - name: String, + name: Rc>, ) -> Option> { v1_rt::map_get(&scope.func_env.clone().signatures.clone(), name) } pub fn typed_named_arg_matches( arg: Rc, - name: String, + name: Rc>, source_indices: Rc>>, ) -> bool { { @@ -652,14 +665,15 @@ pub fn typed_named_arg_matches( if (n.clone() == None) { false } else { - (n.clone().unwrap().as_str() == name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(n.clone().unwrap()) + == crate::v2_std_text::host_string_text_to_rust_host(name)) } } } pub fn order_typed_call_args( args: Rc>>, - func: String, + func: Rc>, scope: Rc, ) -> Rc>> { { @@ -681,7 +695,7 @@ pub fn order_typed_call_args( None => args.clone(), Some(sig) => { let arg_map = args.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), @@ -695,7 +709,7 @@ pub fn order_typed_call_args( }, ); let param_name_set = sig.params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, param: Rc| { v1_rt::rc_map_insert( acc, @@ -812,7 +826,7 @@ pub fn has_nested_records_node( pub fn emit_data_value_json( value: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*value.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { @@ -824,7 +838,9 @@ pub fn emit_data_value_json( v1_rt::concat("\"".to_string(), escape_json_string(s.clone())), "\"".to_string(), ), - LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), + LiteralValue::LitInt { value: i, .. } => { + crate::v2_std_text::host_string_text_from_rust_host((i.clone()).to_string()) + } LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { if b.clone() { @@ -897,7 +913,7 @@ pub fn emit_data_value_json( }) } -pub fn to_camel(name: String) -> String { +pub fn to_camel(name: Rc>) -> Rc> { { let parts = Rc::new( name.clone() @@ -958,7 +974,7 @@ pub fn to_camel(name: String) -> String { } } -pub fn apply_naming_case(name: String, case_style: NamingCase) -> String { +pub fn apply_naming_case(name: Rc>, case_style: NamingCase) -> Rc> { match case_style { NamingCase::PascalCase => { let parts = Rc::new( @@ -981,7 +997,10 @@ pub fn apply_naming_case(name: String, case_style: NamingCase) -> String { } } -pub fn test_file_path(module_name: String, target: RenderTarget) -> String { +pub fn test_file_path( + module_name: Rc>, + target: RenderTarget, +) -> Rc> { { let conventions = test_conventions_for_target(target.clone()); let file_dir = match conventions.file_dir.clone() { @@ -1006,7 +1025,7 @@ pub fn test_file_path(module_name: String, target: RenderTarget) -> String { } } -pub fn reserved_prefix(target: RenderTarget) -> String { +pub fn reserved_prefix(target: RenderTarget) -> Rc> { match (*language_spec(target) .reserved_words .clone() @@ -1019,7 +1038,7 @@ pub fn reserved_prefix(target: RenderTarget) -> String { } } -pub fn reserved_suffix(target: RenderTarget) -> String { +pub fn reserved_suffix(target: RenderTarget) -> Rc> { match (*language_spec(target) .reserved_words .clone() @@ -1032,7 +1051,7 @@ pub fn reserved_suffix(target: RenderTarget) -> String { } } -pub fn escape_rust_interp_text(s: String) -> String { +pub fn escape_rust_interp_text(s: Rc>) -> Rc> { { let escaped = Rc::new( escape_string_literal_body(s) @@ -1051,7 +1070,7 @@ pub fn escape_rust_interp_text(s: String) -> String { } } -pub fn escape_go_interp_text(s: String) -> String { +pub fn escape_go_interp_text(s: Rc>) -> Rc> { Rc::new( escape_string_literal_body(s) .split(&"%".to_string()) @@ -1061,7 +1080,7 @@ pub fn escape_go_interp_text(s: String) -> String { .join(&"%%".to_string()) } -pub fn escape_python_interp_text(s: String) -> String { +pub fn escape_python_interp_text(s: Rc>) -> Rc> { { let escaped = Rc::new( escape_string_literal_body(s) @@ -1080,21 +1099,27 @@ pub fn escape_python_interp_text(s: String) -> String { } } -pub fn apply_escape_pairs(s: String, pairs: Rc>>) -> String { - pairs - .iter() - .cloned() - .fold(s.clone(), |acc: String, pair: Rc| { +pub fn apply_escape_pairs( + s: Rc>, + pairs: Rc>>, +) -> Rc> { + pairs.iter().cloned().fold( + s.clone(), + |acc: Rc>, pair: Rc| { Rc::new( acc.split(&pair.from.clone()) .map(|s| s.to_string()) .collect::>(), ) .join(&pair.to.clone()) - }) + }, + ) } -pub fn emit_string_literal(s: String, suffix: String) -> String { +pub fn emit_string_literal( + s: Rc>, + suffix: Rc>, +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat("\"".to_string(), escape_string_literal_body(s)), @@ -1111,13 +1136,15 @@ pub fn is_null_coalesce(op: BinOp) -> bool { } } -pub fn rust_literal_for_pattern(value: Rc) -> String { +pub fn rust_literal_for_pattern(value: Rc) -> Rc> { match (*value).clone() { LiteralValue::LitStr { value: s, .. } => emit_string_literal(s.clone(), "".to_string()), LiteralValue::LitSymbol { value: s, .. } => { emit_string_literal(s.clone(), ".to_string()".to_string()) } - LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), + LiteralValue::LitInt { value: i, .. } => { + crate::v2_std_text::host_string_text_from_rust_host((i.clone()).to_string()) + } LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { if b.clone() { @@ -1130,11 +1157,11 @@ pub fn rust_literal_for_pattern(value: Rc) -> String { } } -pub fn emit_keyword(key: String, target: RenderTarget) -> String { +pub fn emit_keyword(key: Rc>, target: RenderTarget) -> Rc> { target_keyword(target, key) } -pub fn emit_literal(value: Rc, target: RenderTarget) -> String { +pub fn emit_literal(value: Rc, target: RenderTarget) -> Rc> { match (*value).clone() { LiteralValue::LitStr { value: s, .. } => { let suffix = match literal_suffix(target.clone(), "String".to_string()) { @@ -1146,7 +1173,9 @@ pub fn emit_literal(value: Rc, target: RenderTarget) -> String { }; emit_string_literal(s.clone(), suffix) } - LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), + LiteralValue::LitInt { value: i, .. } => { + crate::v2_std_text::host_string_text_from_rust_host((i.clone()).to_string()) + } LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { if b.clone() { @@ -1176,7 +1205,7 @@ pub fn emit_bin_op_symbol( op: BinOp, target: RenderTarget, algebra_field: Option, -) -> String { +) -> Rc> { match binop_symbol(target.clone(), op, algebra_field) { Some(sym) => sym.clone(), None => emit_error_expr( @@ -1186,8 +1215,14 @@ pub fn emit_bin_op_symbol( } } -pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> String { - if (kind.clone().as_str() == "optional".to_string().as_str()) { +pub fn emit_container( + kind: Rc>, + inner: Rc>, + target: RenderTarget, +) -> Rc> { + if (crate::v2_std_text::host_string_text_to_rust_host(kind.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("optional".to_string())) + { apply_type_template1(target_optional_template(target.clone()), inner) } else { match coerce_container_template(target.clone(), kind.clone()) { @@ -1206,7 +1241,11 @@ pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> Stri } } -pub fn emit_map_type(key_type: String, val_type: String, target: RenderTarget) -> String { +pub fn emit_map_type( + key_type: Rc>, + val_type: Rc>, + target: RenderTarget, +) -> Rc> { match coerce_container_template(target, "map".to_string()) { Some(template) => apply_type_template2(template.clone(), key_type, val_type), None => v1_rt::concat( @@ -1226,7 +1265,7 @@ pub fn emit_node_type( n: Rc, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { render_node_type(n, target, v1_rt::rc_empty_set::(), source_indices) } @@ -1270,7 +1309,7 @@ pub fn render_named_type_base( n: Rc, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { { let tn = authored_name_at(source_indices.clone(), n.clone()); let base = coerce_primitive_type(target.clone(), tn); @@ -1314,7 +1353,7 @@ pub fn render_node_type( target: RenderTarget, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tn = authored_name_at(source_indices.clone(), n.clone()); let n_is_error = if (n.inferred.clone() != None) { @@ -1333,8 +1372,12 @@ pub fn render_node_type( { let is_named_type_var = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { - ((tn.clone().as_str() != "".to_string().as_str()) - && (tn.clone().as_str() == var_id.clone().as_str())) + ((crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + var_id.clone(), + ))) } _ => false, }; @@ -1388,7 +1431,9 @@ pub fn render_node_type( ret_str.clone(), ), None => { - if (ret_str.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(ret_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { { let void_template = v1_rt::replace( repr.template.clone(), @@ -1530,8 +1575,12 @@ pub fn render_node_type( }; if has_template { { - let base = if (snake.clone().as_str() == "map".to_string().as_str()) - { + let base = if (crate::v2_std_text::host_string_text_to_rust_host( + snake.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "map".to_string(), + )) { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { emit_container(snake.clone(), "_".to_string(), target.clone()) @@ -1576,7 +1625,8 @@ pub fn render_node_type( if ((n.children.clone().len() as i64) == 0) { { let bare_is_map = (is_container_type(tn.clone()) - && (to_snake(tn.clone()).as_str() == "map".to_string().as_str())); + && (crate::v2_std_text::host_string_text_to_rust_host(to_snake(tn.clone())) + == crate::v2_std_text::host_string_text_to_rust_host("map".to_string()))); let bare_is_collection = (is_declared_container_alias_spelling(tn.clone()) && !bare_is_map.clone()); let has_container_template = match container_template_algebra(to_snake(tn.clone())) @@ -1632,7 +1682,11 @@ pub fn render_node_type( ) } } else { - if (tn.clone().as_str() == tuple_type_name().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + tuple_type_name(), + )) + { render_tuple_parts(Rc::new(vec![]), target.clone()) } else { coerce_primitive_type(target.clone(), tn.clone()) @@ -1726,7 +1780,9 @@ pub fn render_node_type( } __result }); - if (tn.clone().as_str() == tuple_type_name().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(tuple_type_name())) + { { let multi_tuple_str = render_tuple_parts(child_strs.clone(), target.clone()); return multi_tuple_str; @@ -1750,7 +1806,7 @@ pub fn render_node_type( }) } -pub fn render_tuple_parts(parts: Rc>, target: RenderTarget) -> String { +pub fn render_tuple_parts(parts: Rc>, target: RenderTarget) -> Rc> { { let spec = language_spec(target); let ts = spec.tuple_syntax.clone(); @@ -2044,16 +2100,27 @@ pub fn service_field_ctors(fs: ServiceFieldSet, t: Rc) -> pub fn emit_unified_transport_dispatch( transport: Rc, - op_name: String, + op_name: Rc>, source_indices: Rc>>, depth: i64, target: RenderTarget, - render_rest: impl Fn(String, Rc, i64, Rc>>) -> String + Clone, - render_shell: impl Fn(String, Rc, i64, Rc>>) -> String + render_rest: impl Fn( + Rc>, + Rc, + i64, + Rc>>, + ) -> Rc> + Clone, - render_file: impl Fn(String, i64) -> String + Clone, - render_local: impl Fn(String, i64) -> String + Clone, -) -> String { + render_shell: impl Fn( + Rc>, + Rc, + i64, + Rc>>, + ) -> Rc> + + Clone, + render_file: impl Fn(Rc>, i64) -> Rc> + Clone, + render_local: impl Fn(Rc>, i64) -> Rc> + Clone, +) -> Rc> { if is_rest_transport(transport.clone(), source_indices.clone()) { render_rest(op_name, transport.clone(), depth, source_indices.clone()) } else { @@ -2074,25 +2141,34 @@ pub fn emit_unified_transport_dispatch( } pub fn emit_unified_operation_method( - service_name: String, + service_name: Rc>, fallback_transport: Rc, op_node: Rc, target: RenderTarget, registry: Rc>>, env: Rc, - render_transport_body: impl Fn(Rc, String, Rc>>, i64) -> String + render_transport_body: impl Fn( + Rc, + Rc>, + Rc>>, + i64, + ) -> Rc> + Clone, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); let si = env.source_indices.clone(); let op_text = authored_name(env.clone(), op_node.clone()); let params_str = emit_params_shared(op_node.params.clone(), target.clone(), si.clone()); let sp = service_self_param(spec.clone()); - let all_params = if (sp.clone().as_str() == "".to_string().as_str()) { + let all_params = if (crate::v2_std_text::host_string_text_to_rust_host(sp.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { params_str.clone() } else { - if (params_str.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(params_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { sp.clone() } else { v1_rt::concat( @@ -2174,11 +2250,21 @@ pub fn emit_unified_service_def( target: RenderTarget, registry: Rc>>, env: Rc, - render_service_fields: impl Fn(String, Rc, Rc>>, Rc>>) -> String + render_service_fields: impl Fn( + Rc>, + Rc, + Rc>>, + Rc>>, + ) -> Rc> + Clone, - render_transport_body: impl Fn(Rc, String, Rc>>, i64) -> String + render_transport_body: impl Fn( + Rc, + Rc>, + Rc>>, + i64, + ) -> Rc> + Clone, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); let safe_name = sanitize_service_name(authored_name(env.clone(), item.clone())); @@ -2288,7 +2374,7 @@ pub fn classify_expr(texpr: Rc) -> ExprCategory { #[serde(tag = "_variant")] pub enum FuncBodyShape { FuncBodyLet { - name: String, + name: Rc>, value: Rc, rest: Option>, }, @@ -2326,7 +2412,7 @@ pub fn classify_func_body( #[serde(tag = "_variant")] pub enum TcoExprShape { TcoCall { - func: String, + func: Rc>, args: Rc>>, }, TcoIf { @@ -2339,7 +2425,7 @@ pub enum TcoExprShape { arms: Rc>>, }, TcoLet { - name: String, + name: Rc>, value: Rc, body: Option>, }, @@ -2413,7 +2499,7 @@ pub fn block_stmts_init(stmts: Rc>>) -> Rc>> { } pub fn is_tco_eligible( - name: String, + name: Rc>, body: Rc, registry: Rc>>, source_indices: Rc>>, @@ -2435,7 +2521,7 @@ pub fn is_tco_eligible( } pub fn is_self_recursive( - name: String, + name: Rc>, body: Rc, registry: Rc>>, source_indices: Rc>>, @@ -2449,12 +2535,12 @@ pub fn is_self_recursive( pub fn tco_reassign_core( ordered_args: Rc>, param_names: Rc>, - temp_var_prefix: String, - temp_decl_prefix: String, - temp_assign_op: String, - stmt_terminator: String, - continue_str: String, - line_prefix: String, + temp_var_prefix: Rc>, + temp_decl_prefix: Rc>, + temp_assign_op: Rc>, + stmt_terminator: Rc>, + continue_str: Rc>, + line_prefix: Rc>, ) -> Rc> { { let temp_lets = Rc::new({ @@ -2478,7 +2564,9 @@ pub fn tco_reassign_core( v1_rt::concat(line_prefix.clone(), temp_decl_prefix.clone()), temp_var_prefix.clone(), ), - (pair.0.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (pair.0.clone()).to_string(), + ), ), temp_assign_op.clone(), ), @@ -2511,7 +2599,9 @@ pub fn tco_reassign_core( ), temp_var_prefix.clone(), ), - (pair.0.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (pair.0.clone()).to_string(), + ), ), stmt_terminator.clone(), )); @@ -2527,20 +2617,24 @@ pub fn tco_reassign_core( pub fn emit_shared_tco_expr( mut frame: Rc, - mut fn_name: String, - mut emit_self_call_reassign: impl Fn(Rc) -> String + Clone, - mut emit_non_self_call: impl Fn(Rc) -> String + Clone, - mut emit_if: impl Fn(Rc) -> String + Clone, - mut emit_match: impl Fn(Rc) -> String + Clone, - mut emit_let: impl Fn(Rc) -> String + Clone, - mut emit_block: impl Fn(Rc) -> String + Clone, - mut emit_default_return: impl Fn(Rc) -> String + Clone, -) -> String { + mut fn_name: Rc>, + mut emit_self_call_reassign: impl Fn(Rc) -> Rc> + Clone, + mut emit_non_self_call: impl Fn(Rc) -> Rc> + Clone, + mut emit_if: impl Fn(Rc) -> Rc> + Clone, + mut emit_match: impl Fn(Rc) -> Rc> + Clone, + mut emit_let: impl Fn(Rc) -> Rc> + Clone, + mut emit_block: impl Fn(Rc) -> Rc> + Clone, + mut emit_default_return: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { loop { let si = frame.scope.clone().type_env.clone().source_indices.clone(); match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(frame.expr.clone(), si).as_str() == fn_name.as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(expr_call_func_at( + frame.expr.clone(), + si, + )) == crate::v2_std_text::host_string_text_to_rust_host(fn_name)) + { break emit_self_call_reassign(Rc::new(TcoReassignInput { args: frame.expr.clone().children.clone(), scope: frame.scope.clone(), @@ -2581,7 +2675,11 @@ pub fn emit_shared_tco_expr( } } -pub fn shared_tco_body(inner: String, depth: i64, spec: Rc) -> String { +pub fn shared_tco_body( + inner: Rc>, + depth: i64, + spec: Rc, +) -> Rc> { { let syntax = spec.block_syntax.clone(); let tco = spec.tco.clone(); @@ -2614,8 +2712,8 @@ pub fn shared_tco_body(inner: String, depth: i64, spec: Rc) -> Str pub fn shared_tco_default_return( frame: Rc, spec: Rc, - recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, -) -> String { + recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, +) -> Rc> { { let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); v1_rt::concat( @@ -2629,8 +2727,9 @@ pub fn shared_tco_non_self_call( frame: Rc, target: RenderTarget, spec: Rc, - recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, -) -> String { + recurse_call: impl Fn(Rc>, Rc>>, Rc, i64) -> Rc> + + Clone, +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( @@ -2657,13 +2756,13 @@ pub fn shared_tco_non_self_call( pub fn shared_tco_if( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, spec: Rc, - recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, - recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, -) -> String { + recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + recurse_tco: impl Fn(Rc, Rc, i64) -> Rc> + Clone, +) -> Rc> { { let syntax = spec.block_syntax.clone(); match (*frame.expr.clone().expr_data.clone()).clone() { @@ -2785,12 +2884,12 @@ pub fn shared_tco_if( pub fn shared_tco_let( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, - recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, - recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, -) -> String { + recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + recurse_tco: impl Fn(Rc, Rc, i64) -> Rc> + Clone, +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( @@ -2821,13 +2920,13 @@ pub fn shared_tco_let( pub fn shared_tco_block( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, spec: Rc, emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, - recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, -) -> String { + recurse_tco: impl Fn(Rc, Rc, i64) -> Rc> + Clone, +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { let ss = frame.expr.clone().children.clone(); @@ -2867,7 +2966,7 @@ pub fn shared_tco_reassign( ordered_args: Rc>, param_names: Rc>, spec: Rc, -) -> String { +) -> Rc> { { let all_lines = tco_reassign_core( ordered_args, @@ -2887,14 +2986,14 @@ pub fn unified_tco_recurse( expr: Rc, scope: Rc, depth: i64, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, registry: Rc>>, - recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, - render_match: impl Fn(Rc) -> String + Clone, + recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + render_match: impl Fn(Rc) -> Rc> + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> String { +) -> Rc> { emit_unified_tco_expr( Rc::new(TcoFrame { expr: expr, @@ -2913,14 +3012,14 @@ pub fn unified_tco_recurse( pub fn emit_unified_tco_expr( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, registry: Rc>>, - recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, - render_match: impl Fn(Rc) -> String + Clone, + recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + render_match: impl Fn(Rc) -> Rc> + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); emit_shared_tco_expr( @@ -3031,16 +3130,16 @@ pub fn emit_unified_tco_expr( pub fn emit_unified_tco_body( texpr: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, - render_match: impl Fn(Rc) -> String + Clone, + recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + render_match: impl Fn(Rc) -> Rc> + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); let inner = emit_unified_tco_expr( @@ -3068,7 +3167,7 @@ pub fn emit_unified_init_block_stmts( depth: i64, target: RenderTarget, registry: Rc>>, - render_pattern: impl Fn(Rc) -> String + Clone, + render_pattern: impl Fn(Rc) -> Rc> + Clone, ) -> Rc { { let prepend = if language_spec(target.clone()) @@ -3096,16 +3195,16 @@ pub fn emit_unified_init_block_stmts( } pub fn emit_tco_match_go( - scrutinee_str: String, + scrutinee_str: Rc>, arms: Rc>>, depth: i64, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, scope: Rc, - render_pattern: impl Fn(Rc) -> String + Clone, + render_pattern: impl Fn(Rc) -> Rc> + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> String { +) -> Rc> { { let si = scope.type_env.clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); @@ -3200,13 +3299,13 @@ pub fn emit_tco_match_go( pub fn emit_unified_tco_match( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, registry: Rc>>, - render_pattern: impl Fn(Rc) -> String + Clone, + render_pattern: impl Fn(Rc) -> Rc> + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> String { +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); @@ -3252,7 +3351,9 @@ pub fn emit_unified_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let bs = language_spec(target.clone()).block_syntax.clone(); - if (bs.block_close.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(bs.block_close.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrut_str), @@ -3287,15 +3388,15 @@ pub fn emit_unified_tco_match( pub fn emit_unified_tco_match_arm( arm: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - render_pattern: impl Fn(Rc) -> String + Clone, + render_pattern: impl Fn(Rc) -> Rc> + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> String { +) -> Rc> { { let bs = language_spec(target.clone()).block_syntax.clone(); let case_depth = if bs.significant_whitespace.clone() { @@ -3366,14 +3467,14 @@ pub fn emit_unified_tco_match_arm( pub fn emit_tco_unified( texpr: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - render_pattern: impl Fn(Rc) -> String + Clone, -) -> String { + render_pattern: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { emit_unified_tco_body( texpr, fn_name.clone(), @@ -3434,7 +3535,7 @@ pub fn emit_unified_typed_func_body( registry: Rc>>, scope: Rc, depth: i64, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); @@ -3588,14 +3689,16 @@ pub fn emit_unified_typed_func_body( pub fn is_tco_candidate( texpr: Rc, - func_name: String, + func_name: Rc>, source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() - == func_name.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(expr_call_func_at( + texpr.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) } ExprData::ExprReturn => is_tco_candidate( return_value(texpr.clone()), @@ -3660,8 +3763,8 @@ pub fn is_tco_candidate( } pub fn suffix_escape_collides_with_reserved_chain( - mut name: String, - mut suffix: String, + mut name: Rc>, + mut suffix: Rc>, mut keywords: Rc>, ) -> bool { loop { @@ -3670,13 +3773,11 @@ pub fn suffix_escape_collides_with_reserved_chain( if ((suffix_len.clone() == 0) || (name_len.clone() < suffix_len.clone())) { break false; } else { - if (v1_rt::substring( + if (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( &name, (name_len.clone() - suffix_len.clone()), name_len.clone(), - ) - .as_str() - != suffix.clone().as_str()) + )) != crate::v2_std_text::host_string_text_to_rust_host(suffix.clone())) { break false; } else { @@ -3684,7 +3785,9 @@ pub fn suffix_escape_collides_with_reserved_chain( if { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (r.clone().as_str() == base.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(base.clone())) + { __found = true; break; } @@ -3705,15 +3808,17 @@ pub fn suffix_escape_collides_with_reserved_chain( } pub fn emit_suffix_escape_ident( - converted: String, - suffix: String, + converted: Rc>, + suffix: Rc>, keywords: Rc>, -) -> String { +) -> Rc> { { let is_reserved = { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (r.clone().as_str() == converted.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(converted.clone())) + { __found = true; break; } @@ -3734,7 +3839,7 @@ pub fn emit_suffix_escape_ident( } } -pub fn emit_ident(name: String, target: RenderTarget) -> String { +pub fn emit_ident(name: Rc>, target: RenderTarget) -> Rc> { { let spec = language_spec(target); let converted = match spec.naming_case.clone() { @@ -3746,7 +3851,9 @@ pub fn emit_ident(name: String, target: RenderTarget) -> String { let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { - if (r.clone().as_str() == converted.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(converted.clone())) + { __found = true; break; } @@ -3778,7 +3885,7 @@ pub fn emit_ident(name: String, target: RenderTarget) -> String { } } -pub fn emit_export_ident(name: String, target: RenderTarget) -> String { +pub fn emit_export_ident(name: Rc>, target: RenderTarget) -> Rc> { { let spec = language_spec(target.clone()); match (*spec.visibility.clone()).clone() { @@ -3789,7 +3896,9 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { - if (r.clone().as_str() == result.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(result.clone())) + { __found = true; break; } @@ -3829,9 +3938,9 @@ pub fn emit_export_ident(name: String, target: RenderTarget) -> String { } pub fn apply_bridge_method_overrides( - name: String, + name: Rc>, overrides: Rc>, -) -> String { +) -> Rc> { match v1_rt::lookup(&overrides, name.clone()) { v1_rt::Witness::Holds { value: replacement, .. @@ -3840,7 +3949,11 @@ pub fn apply_bridge_method_overrides( } } -pub fn emit_let_binding(name: String, value: String, target: RenderTarget) -> String { +pub fn emit_let_binding( + name: Rc>, + value: Rc>, + target: RenderTarget, +) -> Rc> { { let spec = language_spec(target.clone()); apply_type_template2( @@ -3852,11 +3965,11 @@ pub fn emit_let_binding(name: String, value: String, target: RenderTarget) -> St } pub fn emit_let_binding_annotated( - name: String, - type_str: String, - value: String, + name: Rc>, + type_str: Rc>, + value: Rc>, target: RenderTarget, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); apply_type_template3( @@ -3868,11 +3981,15 @@ pub fn emit_let_binding_annotated( } } -pub fn emit_return(value: String, target: RenderTarget) -> String { +pub fn emit_return(value: Rc>, target: RenderTarget) -> Rc> { v1_rt::concat("return ".to_string(), value) } -pub fn emit_unary_op(op: UnaryOpKind, operand_str: String, target: RenderTarget) -> String { +pub fn emit_unary_op( + op: UnaryOpKind, + operand_str: Rc>, + target: RenderTarget, +) -> Rc> { match op { UnaryOpKind::Not => v1_rt::concat(emit_keyword("not".to_string(), target), operand_str), UnaryOpKind::Neg => v1_rt::concat("-".to_string(), operand_str), @@ -3886,14 +4003,18 @@ pub fn go_lambda_emits_statement_body(body: Rc) -> bool { } } -pub fn emit_lambda(params_str: String, body_str: String, target: RenderTarget) -> String { +pub fn emit_lambda( + params_str: Rc>, + body_str: Rc>, + target: RenderTarget, +) -> Rc> { { let spec = language_spec(target); apply_type_template2(spec.lambda_template.clone(), params_str, body_str) } } -pub fn emit_error_expr(message: String, target: RenderTarget) -> String { +pub fn emit_error_expr(message: Rc>, target: RenderTarget) -> Rc> { { let msg = emit_string_literal(message, "".to_string()); let spec = language_spec(target); @@ -3901,7 +4022,10 @@ pub fn emit_error_expr(message: String, target: RenderTarget) -> String { } } -pub fn emit_lambda_params(param_names: Rc>, target: RenderTarget) -> String { +pub fn emit_lambda_params( + param_names: Rc>, + target: RenderTarget, +) -> Rc> { { let spec = language_spec(target.clone()); let param_strs = Rc::new({ @@ -3918,7 +4042,10 @@ pub fn emit_lambda_params(param_names: Rc>, target: RenderTarget) -> } } -pub fn emit_list_lit_expr(element_strs: Rc>, target: RenderTarget) -> String { +pub fn emit_list_lit_expr( + element_strs: Rc>, + target: RenderTarget, +) -> Rc> { { let spec = language_spec(target); if ((element_strs.clone().len() as i64) == 0) { @@ -3932,7 +4059,11 @@ pub fn emit_list_lit_expr(element_strs: Rc>, target: RenderTarget) - } } -pub fn emit_null_coalesce(l_str: String, r_str: String, target: RenderTarget) -> String { +pub fn emit_null_coalesce( + l_str: Rc>, + r_str: Rc>, + target: RenderTarget, +) -> Rc> { { let spec = language_spec(target); apply_type_template2(spec.null_coalesce_template.clone(), l_str, r_str) @@ -3943,14 +4074,18 @@ pub fn emit_expr_var_shared( expr: Rc, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { { let n = expr_var_name_at(expr, source_indices); - if (n.clone().as_str() == "none".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("none".to_string())) + { emit_keyword("null".to_string(), target) } else { - if ((n.clone().as_str() == "true".to_string().as_str()) - || (n.clone().as_str() == "false".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("true".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("false".to_string()))) { emit_keyword(n.clone(), target) } else { @@ -3963,9 +4098,9 @@ pub fn emit_expr_var_shared( pub fn emit_expr_field_access_shared( expr: Rc, target: RenderTarget, - emit_field: impl Fn(Rc) -> String + Clone, + emit_field: impl Fn(Rc) -> Rc> + Clone, source_indices: Rc>>, -) -> String { +) -> Rc> { if is_typed_service_call_receiver(expr.clone(), source_indices.clone()) { match extract_typed_service_name(expr.clone(), source_indices.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), @@ -4002,9 +4137,9 @@ pub fn emit_typed_cast_shared( expr: Rc, cast_target_node: Rc, target: RenderTarget, - recurse: impl Fn(Rc) -> String + Clone, + recurse: impl Fn(Rc) -> Rc> + Clone, source_indices: Rc>>, -) -> String { +) -> Rc> { { let expr_str = recurse(expr.clone()); let ty_str = emit_node_type(cast_target_node, target.clone(), source_indices.clone()); @@ -4014,8 +4149,10 @@ pub fn emit_typed_cast_shared( } _ => "".to_string(), }; - if ((src_ty.clone().as_str() != "".to_string().as_str()) - && (src_ty.clone().as_str() == ty_str.clone().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(src_ty.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(src_ty.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(ty_str.clone()))) { expr_str } else { @@ -4038,15 +4175,15 @@ pub fn emit_typed_cast_shared( } pub fn emit_typed_for_each_shared( - variable: String, + variable: Rc>, collection: Rc, body: Rc, target: RenderTarget, depth: i64, source_indices: Rc>>, - recurse: impl Fn(Rc, Rc, i64) -> String + Clone, + recurse: impl Fn(Rc, Rc, i64) -> Rc> + Clone, scope: Rc, -) -> String { +) -> Rc> { { let coll_str = recurse(collection.clone(), scope.clone(), depth.clone()); let elem_type = @@ -4117,9 +4254,9 @@ pub fn emit_typed_index_shared( base: Rc, index: Rc, target: RenderTarget, - recurse: impl Fn(Rc) -> String + Clone, + recurse: impl Fn(Rc) -> Rc> + Clone, source_indices: Rc>>, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); let base_str = recurse(base.clone()); @@ -4154,9 +4291,9 @@ pub fn emit_typed_slice_shared( start: Rc, end: Rc, target: RenderTarget, - recurse: impl Fn(Rc) -> String + Clone, + recurse: impl Fn(Rc) -> Rc> + Clone, source_indices: Rc>>, -) -> String { +) -> Rc> { { let spec = language_spec(target.clone()); let base_str = recurse(base.clone()); @@ -4184,24 +4321,24 @@ pub fn emit_shared_expr( texpr: Rc, target: RenderTarget, source_indices: Rc>>, - wrap_result: impl Fn(String) -> String + Clone, - recurse: impl Fn(Rc) -> String + Clone, - emit_var: impl Fn(Rc) -> String + Clone, - emit_field_access: impl Fn(Rc) -> String + Clone, - emit_call: impl Fn(Rc) -> String + Clone, - emit_method_call: impl Fn(Rc) -> String + Clone, - emit_match: impl Fn(Rc) -> String + Clone, - emit_if: impl Fn(Rc) -> String + Clone, - emit_let: impl Fn(Rc) -> String + Clone, - emit_record_lit: impl Fn(Rc) -> String + Clone, - emit_string_interp: impl Fn(Rc) -> String + Clone, - emit_block: impl Fn(Rc) -> String + Clone, - emit_cast: impl Fn(Rc) -> String + Clone, - emit_for_each: impl Fn(Rc) -> String + Clone, - emit_index: impl Fn(Rc) -> String + Clone, - emit_slice: impl Fn(Rc) -> String + Clone, - emit_bin_op: impl Fn(Rc) -> String + Clone, -) -> String { + wrap_result: impl Fn(Rc>) -> Rc> + Clone, + recurse: impl Fn(Rc) -> Rc> + Clone, + emit_var: impl Fn(Rc) -> Rc> + Clone, + emit_field_access: impl Fn(Rc) -> Rc> + Clone, + emit_call: impl Fn(Rc) -> Rc> + Clone, + emit_method_call: impl Fn(Rc) -> Rc> + Clone, + emit_match: impl Fn(Rc) -> Rc> + Clone, + emit_if: impl Fn(Rc) -> Rc> + Clone, + emit_let: impl Fn(Rc) -> Rc> + Clone, + emit_record_lit: impl Fn(Rc) -> Rc> + Clone, + emit_string_interp: impl Fn(Rc) -> Rc> + Clone, + emit_block: impl Fn(Rc) -> Rc> + Clone, + emit_cast: impl Fn(Rc) -> Rc> + Clone, + emit_for_each: impl Fn(Rc) -> Rc> + Clone, + emit_index: impl Fn(Rc) -> Rc> + Clone, + emit_slice: impl Fn(Rc) -> Rc> + Clone, + emit_bin_op: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => { wrap_result(emit_literal(v.clone(), target.clone())) @@ -4277,9 +4414,9 @@ pub fn emit_default_bin_op( texpr: Rc, target: RenderTarget, source_indices: Rc>>, - recurse: impl Fn(Rc) -> String + Clone, - wrap_result: impl Fn(String) -> String + Clone, -) -> String { + recurse: impl Fn(Rc) -> Rc> + Clone, + wrap_result: impl Fn(Rc>) -> Rc> + Clone, +) -> Rc> { match (*texpr.expr_data.clone()).clone() { ExprData::ExprBinOp { op, @@ -4327,7 +4464,7 @@ pub fn emit_block_stmts_shared( mut scope: Rc, mut depth: i64, mut prepend_indent: bool, - mut emit_expr: impl Fn(Rc, Rc, i64) -> String + Clone, + mut emit_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, ) -> Rc { loop { match remaining.clone().first().cloned() { @@ -4371,7 +4508,7 @@ pub fn emit_init_block_stmts_shared( mut scope: Rc, mut depth: i64, mut prepend_indent: bool, - mut emit_expr: impl Fn(Rc, Rc, i64) -> String + Clone, + mut emit_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, ) -> Rc { loop { match remaining.clone().first().cloned() { @@ -4422,14 +4559,14 @@ pub fn emit_init_block_stmts_shared( } pub fn emit_typed_let_shared( - name: String, - value_str: String, + name: Rc>, + value_str: Rc>, body: Option>, target: RenderTarget, - recurse: impl Fn(Rc, Rc) -> String + Clone, + recurse: impl Fn(Rc, Rc) -> Rc> + Clone, scope: Rc, value_node: Rc, -) -> String { +) -> Rc> { { let let_line = emit_let_binding(name.clone(), value_str, target); match body { @@ -4451,15 +4588,15 @@ pub fn emit_typed_let_shared( } pub fn emit_typed_if_shared( - cond_str: String, + cond_str: Rc>, then_branch: Rc, else_branch: Option>, if_result_type: Option>, depth: i64, target: RenderTarget, source_indices: Rc>>, - recurse: impl Fn(Rc, i64) -> String + Clone, -) -> String { + recurse: impl Fn(Rc, i64) -> Rc> + Clone, +) -> Rc> { { let spec = language_spec(target.clone()); let es = spec.expression_semantics.clone(); @@ -4589,7 +4726,7 @@ pub fn emit_param_shared( param: Rc, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { { let ty = emit_node_type( param_node_type_expr(param.clone()), @@ -4617,7 +4754,7 @@ pub fn emit_params_shared( params: Rc>>, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { { let strs = Rc::new({ let mut __result = Vec::new(); @@ -4644,7 +4781,7 @@ pub fn emit_inferred_shared( inferred: Rc, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { if language_spec(target.clone()) .expression_semantics .clone() @@ -4680,7 +4817,7 @@ pub fn emit_typed_block_join( scope: Rc, depth: i64, emit_block_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> String { +) -> Rc> { { let state = emit_block_stmts(stmts, scope, depth); state.text.clone().join(&"\n".to_string()) @@ -4699,11 +4836,11 @@ pub fn method_template_emit_for_target( } pub fn emit_algebra_method_template( - method_name: String, - recv_str: String, - first_arg_str: String, + method_name: Rc>, + recv_str: Rc>, + first_arg_str: Rc>, target: RenderTarget, -) -> Option { +) -> Rc> { match method_template_emit_for_target(target) { Some(templates) => match v1_rt::map_get(&templates, method_name) { Some(tmpl) => { @@ -4723,8 +4860,8 @@ pub fn emit_algebra_method_template( pub fn emit_typed_first_arg_shared( args: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> String + Clone, -) -> String { + recurse: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { match args.first().cloned() { Some(a) => recurse(arg_value(a.clone())), None => emit_error_expr("missing method argument".to_string(), target), @@ -4734,8 +4871,8 @@ pub fn emit_typed_first_arg_shared( pub fn emit_typed_string_interp_unified( parts: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> String + Clone, -) -> String { + recurse: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let spec = language_spec(target); let interp = spec.string_interp.clone(); @@ -4800,7 +4937,9 @@ pub fn emit_typed_string_interp_unified( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(a.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(a); } } @@ -4846,12 +4985,12 @@ pub fn emit_typed_string_interp_unified( } pub fn emit_typed_record_lit_unified( - type_name: Option, + type_name: Rc>, fields: Rc>>, target: RenderTarget, source_indices: Rc>>, - recurse: impl Fn(Rc) -> String + Clone, -) -> String { + recurse: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let rls = language_spec(target.clone()).record_lit.clone(); match type_name { @@ -4935,7 +5074,7 @@ pub fn emit_typed_record_lit_unified( } } -pub fn is_go_v2rt_free_function(name: String) -> bool { +pub fn is_go_v2rt_free_function(name: Rc>) -> bool { match name.as_str() { "concat" => true, "to_string" => true, @@ -4944,7 +5083,10 @@ pub fn is_go_v2rt_free_function(name: String) -> bool { } } -pub fn emit_go_v2rt_free_call(func: String, arg_strs: Rc>) -> String { +pub fn emit_go_v2rt_free_call( + func: Rc>, + arg_strs: Rc>, +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -4964,13 +5106,13 @@ pub fn emit_go_v2rt_free_call(func: String, arg_strs: Rc>) -> String } pub fn emit_typed_call_unified( - func: String, + func: Rc>, args: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, - recurse: impl Fn(Rc) -> String + Clone, -) -> String { + recurse: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let spec = language_spec(target.clone()); let ordered_args = order_typed_call_args(args, func.clone(), scope); @@ -5055,7 +5197,10 @@ pub fn emit_typed_call_unified( } } -pub fn bridge_method_name_unified(method_name: String, target: RenderTarget) -> String { +pub fn bridge_method_name_unified( + method_name: Rc>, + target: RenderTarget, +) -> Rc> { { let spec = language_spec(target); let overridden = @@ -5065,13 +5210,13 @@ pub fn bridge_method_name_unified(method_name: String, target: RenderTarget) -> } pub fn emit_algebra_method_call_unified( - method_name: String, + method_name: Rc>, receiver: Rc, args: Rc>>, target: RenderTarget, - first_arg_str: String, - recurse: impl Fn(Rc) -> String + Clone, -) -> String { + first_arg_str: Rc>, + recurse: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let spec = language_spec(target.clone()); let recv_str = recurse(receiver); @@ -5112,11 +5257,11 @@ pub fn emit_algebra_method_call_unified( pub fn emit_plain_method_call_unified( receiver: Rc, - method: String, + method: Rc>, args: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> String + Clone, -) -> String { + recurse: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let recv_str = recurse(receiver); let arg_strs = Rc::new({ @@ -5145,15 +5290,15 @@ pub fn emit_plain_method_call_unified( pub fn emit_typed_method_call_unified( receiver: Rc, - method: String, + method: Rc>, args: Rc>>, method_semantics: Option>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - recurse: impl Fn(Rc) -> String + Clone, -) -> String { + recurse: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let spec = language_spec(target.clone()); let source_indices = scope.type_env.clone().source_indices.clone(); @@ -5261,7 +5406,7 @@ pub fn emit_unified_pattern( pattern: Rc, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { match (*pattern).clone() { MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), target), MatchPattern::LitPattern { value: v, .. } => emit_literal(v.clone(), target), @@ -5277,7 +5422,10 @@ pub fn emit_unified_pattern( } } -pub fn go_variant_case_type(name: String, parent_enum: Option) -> String { +pub fn go_variant_case_type( + name: Rc>, + parent_enum: Rc>, +) -> Rc> { match parent_enum { Some(parent) => v1_rt::concat(parent.clone(), name), None => name, @@ -5285,12 +5433,12 @@ pub fn go_variant_case_type(name: String, parent_enum: Option) -> String } pub fn emit_unified_variant_pattern( - name: String, - parent_enum: Option, + name: Rc>, + parent_enum: Rc>, field_bindings: Rc>>, target: RenderTarget, source_indices: Rc>>, -) -> String { +) -> Rc> { { let es = language_spec(target.clone()).expression_semantics.clone(); match es.variant_pattern.clone() { @@ -5349,7 +5497,10 @@ pub fn emit_unified_variant_pattern( } } -pub fn emit_match_arm_body_stmt(target: RenderTarget, body_str: String) -> String { +pub fn emit_match_arm_body_stmt( + target: RenderTarget, + body_str: Rc>, +) -> Rc> { match language_spec(target) .expression_semantics .clone() @@ -5366,10 +5517,10 @@ pub fn emit_match_arm_line( target: RenderTarget, case_depth: i64, body_depth: i64, - body_str: String, - guard_str: String, - render_pattern: impl Fn(Rc) -> String + Clone, -) -> String { + body_str: Rc>, + guard_str: Rc>, + render_pattern: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let spec = language_spec(target); let bs = spec.block_syntax.clone(); @@ -5398,8 +5549,8 @@ pub fn emit_match_arm_line( pub fn emit_arm_guard( arm: Rc, target: RenderTarget, - render_guard_expr: impl Fn(Rc) -> String + Clone, -) -> String { + render_guard_expr: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { { let es = language_spec(target.clone()).expression_semantics.clone(); match arm_guard(arm) { @@ -5419,7 +5570,7 @@ pub fn emit_go_match_arm_bindings( arm: Rc, indent_level: i64, source_indices: Rc>>, -) -> String { +) -> Rc> { match (*arm_pattern(arm)).clone() { MatchPattern::VariantPattern { field_bindings: fbs, @@ -5464,13 +5615,13 @@ pub fn emit_go_match_arm_bindings( } pub fn emit_typed_match_go( - scrutinee_str: String, + scrutinee_str: Rc>, arms: Rc>>, depth: i64, - recurse: impl Fn(Rc, i64) -> String + Clone, - render_pattern: impl Fn(Rc) -> String + Clone, + recurse: impl Fn(Rc, i64) -> Rc> + Clone, + render_pattern: impl Fn(Rc) -> Rc> + Clone, source_indices: Rc>>, -) -> String { +) -> Rc> { { let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); @@ -5527,14 +5678,14 @@ pub fn emit_typed_match_go( } pub fn emit_typed_match_unified( - scrutinee_str: String, + scrutinee_str: Rc>, arms: Rc>>, target: RenderTarget, depth: i64, - recurse: impl Fn(Rc, i64) -> String + Clone, - render_pattern: impl Fn(Rc) -> String + Clone, + recurse: impl Fn(Rc, i64) -> Rc> + Clone, + render_pattern: impl Fn(Rc) -> Rc> + Clone, source_indices: Rc>>, -) -> String { +) -> Rc> { match target.clone() { RenderTarget::Go => emit_typed_match_go( scrutinee_str, @@ -5577,7 +5728,9 @@ pub fn emit_typed_match_unified( __result }); let arms_str = arm_strs.join(&"\n".to_string()); - if (bs.block_close.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(bs.block_close.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrutinee_str), @@ -5608,11 +5761,11 @@ pub fn emit_typed_match_unified( } pub fn emit_field_access_unified( - base_str: String, - field: String, + base_str: Rc>, + field: Rc>, summary: Option>, target: RenderTarget, -) -> String { +) -> Rc> { { let ts = language_spec(target.clone()).tuple_syntax.clone(); match summary { @@ -5641,8 +5794,8 @@ pub fn emit_unified_typed_expr( scope: Rc, depth: i64, fuel: i64, - render_pattern: impl Fn(Rc) -> String + Clone, -) -> String { + render_pattern: impl Fn(Rc) -> Rc> + Clone, +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let si = scope.type_env.clone().source_indices.clone(); let spec = language_spec(target.clone()); @@ -6017,13 +6170,18 @@ pub fn emit_unified_typed_expr( pub fn is_tco_identity_passthrough( arg_val: Rc, - param_name: String, + param_name: Rc>, si: Rc>>, ) -> bool { match (*arg_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => (expr_var_name_at(arg_val.clone(), si).as_str() == param_name.as_str()), + } => { + (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + arg_val.clone(), + si, + )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) + } _ => false, } } @@ -6032,9 +6190,9 @@ pub fn emit_typed_tco_reassign_shared( args: Rc>>, params: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> String + Clone, + recurse: impl Fn(Rc) -> Rc> + Clone, source_indices: Rc>>, -) -> String { +) -> Rc> { { let arg_values = Rc::new({ let mut __result = Vec::new(); @@ -6102,8 +6260,15 @@ pub fn emit_typed_tco_reassign_shared( } } -pub fn seed_bindings(key: String, value: String) -> Rc> { - v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, value) +pub fn seed_bindings( + key: Rc>, + value: Rc>, +) -> Rc> { + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, Rc>>(), + key, + value, + ) } pub struct CapServiceEmit; diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index 35da76811db..0a0d5edf8b0 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -29,16 +29,16 @@ pub struct EmitResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TestProjection { - pub module_name: String, - pub service_name: String, - pub operation_name: String, + pub module_name: Rc>, + pub service_name: Rc>, + pub operation_name: Rc>, pub inferred: Rc, pub params: Rc>>, pub mock_field_inits: Rc>>, pub source_indices: Rc>>, } -pub fn escape_json_string(s: String) -> String { +pub fn escape_json_string(s: Rc>) -> Rc> { Rc::new( Rc::new( Rc::new( @@ -65,7 +65,7 @@ pub fn escape_json_string(s: String) -> String { .join(&"\\t".to_string()) } -pub fn module_to_filename(name: String) -> String { +pub fn module_to_filename(name: Rc>) -> Rc> { Rc::new( name.split(&".".to_string()) .map(|s| s.to_string()) @@ -74,7 +74,7 @@ pub fn module_to_filename(name: String) -> String { .join(&"_".to_string()) } -pub fn make_indent(level: i64) -> String { +pub fn make_indent(level: i64) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if (level.clone() <= 0) { "".to_string() @@ -88,10 +88,10 @@ pub fn unique_strings(items: Rc>) -> Rc> { { let result = items.iter().cloned().fold( Rc::new(UniqueAccum { - seen: v1_rt::rc_empty_map::(), + seen: v1_rt::rc_empty_map::>, bool>(), result: Rc::new(vec![]), }), - |acc: Rc, item: String| { + |acc: Rc, item: Rc>| { if emit_map_has(acc.seen.clone(), item.clone()) { acc.clone() } else { @@ -106,10 +106,15 @@ pub fn unique_strings(items: Rc>) -> Rc> { } } -pub fn to_string(value: i64) -> String { +pub fn to_string(value: i64) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if (value.clone() < 0) { - v1_rt::concat("-".to_string(), (0 - value.clone()).to_string()) + v1_rt::concat( + "-".to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (0 - value.clone()).to_string(), + ), + ) } else { if (value.clone() == 0) { "0".to_string() @@ -189,7 +194,7 @@ pub fn to_string_helper(mut value: i64, mut acc: Rc>) -> Rc String { +pub fn to_snake(name: Rc>) -> Rc> { { let chars_list = Rc::new(name.chars().map(|c| c as i64).collect::>()); let result = Rc::new({ @@ -225,7 +230,7 @@ pub fn to_snake(name: String) -> String { } } -pub fn to_screaming_snake(name: String) -> String { +pub fn to_screaming_snake(name: Rc>) -> Rc> { { let snake = to_snake(name); Rc::new({ @@ -246,7 +251,7 @@ pub fn is_upper(ch: i64) -> bool { ((ch.clone() >= 65) && (ch.clone() <= 90)) } -pub fn to_lower_char(ch: i64) -> String { +pub fn to_lower_char(ch: i64) -> Rc> { { let cp = ch.clone(); if ((cp.clone() >= 65) && (cp.clone() <= 90)) { @@ -260,7 +265,7 @@ pub fn to_lower_char(ch: i64) -> String { } } -pub fn to_upper_char(ch: i64) -> String { +pub fn to_upper_char(ch: i64) -> Rc> { { let cp = ch.clone(); if ((cp.clone() >= 97) && (cp.clone() <= 122)) { @@ -274,7 +279,7 @@ pub fn to_upper_char(ch: i64) -> String { } } -pub fn sanitize_service_name(name: String) -> String { +pub fn sanitize_service_name(name: Rc>) -> Rc> { { let parts = Rc::new( name.split(&".".to_string()) @@ -292,7 +297,7 @@ pub fn sanitize_service_name(name: String) -> String { } } -pub fn capitalize_first(s: String) -> String { +pub fn capitalize_first(s: Rc>) -> Rc> { { let chars_list = Rc::new(s.chars().map(|c| c as i64).collect::>()); if ((chars_list.clone().len() as i64) == 0) { @@ -325,11 +330,11 @@ pub fn capitalize_first(s: String) -> String { } } -pub fn service_var_name(service_name: String) -> String { +pub fn service_var_name(service_name: Rc>) -> Rc> { to_snake(sanitize_service_name(service_name)) } -pub fn to_pascal(name: String) -> String { +pub fn to_pascal(name: Rc>) -> Rc> { { let snake = to_snake(name); let parts = Rc::new( @@ -349,7 +354,10 @@ pub fn to_pascal(name: String) -> String { } } -pub fn test_function_name(projection: Rc, target: RenderTarget) -> String { +pub fn test_function_name( + projection: Rc, + target: RenderTarget, +) -> Rc> { { let conventions = test_conventions_for_target(target); let formatted = match conventions.name_style.clone() { @@ -369,7 +377,10 @@ pub fn test_function_name(projection: Rc, target: RenderTarget) } } -pub fn apply_type_template1(template: String, arg0: String) -> String { +pub fn apply_type_template1( + template: Rc>, + arg0: Rc>, +) -> Rc> { Rc::new( template .split(&"{0}".to_string()) @@ -379,7 +390,11 @@ pub fn apply_type_template1(template: String, arg0: String) -> String { .join(&arg0) } -pub fn apply_type_template2(template: String, arg0: String, arg1: String) -> String { +pub fn apply_type_template2( + template: Rc>, + arg0: Rc>, + arg1: Rc>, +) -> Rc> { { let parts = Rc::new( template @@ -406,7 +421,12 @@ pub fn apply_type_template2(template: String, arg0: String, arg1: String) -> Str } } -pub fn apply_type_template3(template: String, arg0: String, arg1: String, arg2: String) -> String { +pub fn apply_type_template3( + template: Rc>, + arg0: Rc>, + arg1: Rc>, + arg2: Rc>, +) -> Rc> { { let parts0 = Rc::new( template @@ -448,7 +468,10 @@ pub fn apply_type_template3(template: String, arg0: String, arg1: String, arg2: } } -pub fn apply_named_template(template: String, bindings: Rc>) -> String { +pub fn apply_named_template( + template: Rc>, + bindings: Rc>, +) -> Rc> { apply_named_template_nested( template, bindings.clone(), @@ -457,10 +480,10 @@ pub fn apply_named_template(template: String, bindings: Rc>, bindings: Rc>, keys: Rc>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match keys.clone().first().cloned() { None => template, @@ -508,7 +531,7 @@ pub fn language_spec(target: RenderTarget) -> Rc { language_spec_for_target(target) } -pub fn escape_string_literal_body(s: String) -> String { +pub fn escape_string_literal_body(s: Rc>) -> Rc> { { let escaped_backslash = Rc::new( s.split(&"\\".to_string()) @@ -547,11 +570,12 @@ pub fn escape_string_literal_body(s: String) -> String { } } -pub fn has_mock_prefix(name: String) -> bool { +pub fn has_mock_prefix(name: Rc>) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5).as_str() == "mock_".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring(&name, 0, 5)) + == crate::v2_std_text::host_string_text_to_rust_host("mock_".to_string())) } } @@ -651,7 +675,8 @@ pub fn is_type_alias_return_node( n: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, n).as_str() != "Unit".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at(source_indices, n)) + != crate::v2_std_text::host_string_text_to_rust_host("Unit".to_string())) } pub fn is_service_item(item: Rc) -> bool { diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index fb593f98367..1ab0fd176f2 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -103,11 +103,11 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn go_emit_module_root() -> String { +pub fn go_emit_module_root() -> Rc> { "generated".to_string() } -pub fn go_v2rt_import_path() -> String { +pub fn go_v2rt_import_path() -> Rc> { v1_rt::concat(go_emit_module_root(), "/v2rt".to_string()) } @@ -135,13 +135,14 @@ pub fn emit_go(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone().as_str() - == authored_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host( + p.module_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ) - .as_str()) - { + ), + )) { __result.push(p); } } @@ -154,7 +155,9 @@ pub fn emit_go(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(f.path.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(f); } } @@ -180,7 +183,7 @@ pub fn emit_go_v2rt_module() -> Rc { }) } -pub fn emit_go_mod(module_name: String) -> Rc { +pub fn emit_go_mod(module_name: Rc>) -> Rc { { let manifest_path = match scaffold_for_target(RenderTarget::Go).manifest_file.clone() { Some(path) => path.clone(), @@ -214,7 +217,7 @@ pub fn go_mock_expr_uses_fmt( } } -pub fn go_test_import_block(projections: Rc>>) -> String { +pub fn go_test_import_block(projections: Rc>>) -> Rc> { { let needs_fmt = { let mut __found = false; @@ -246,7 +249,7 @@ pub fn go_test_import_block(projections: Rc>>) -> String } } -pub fn go_test_signature_comment(projection: Rc) -> String { +pub fn go_test_signature_comment(projection: Rc) -> Rc> { { let params_str = Rc::new({ let mut __result = Vec::new(); @@ -296,7 +299,7 @@ pub fn go_test_signature_comment(projection: Rc) -> String { } pub fn emit_go_test_file( - module_name: String, + module_name: Rc>, projections: Rc>>, ) -> Rc { if ((projections.clone().len() as i64) == 0) { @@ -359,7 +362,7 @@ pub fn emit_go_test_file( } } -pub fn emit_go_operation_test(projection: Rc, depth: i64) -> String { +pub fn emit_go_operation_test(projection: Rc, depth: i64) -> Rc> { { let test_name = test_function_name(projection.clone(), RenderTarget::Go); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -441,7 +444,7 @@ pub fn emit_go_mock_prop_setup( mock_prop: Rc, depth: i64, source_indices: Rc>>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( emit_ident( @@ -484,11 +487,14 @@ pub fn emit_go_module( module_imports(m.clone()), si.clone(), ); - let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { - "".to_string() - } else { - v1_rt::concat("\n\n".to_string(), imports_str.clone()) - }; + let imports_section = + if (crate::v2_std_text::host_string_text_to_rust_host(imports_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + "".to_string() + } else { + v1_rt::concat("\n\n".to_string(), imports_str.clone()) + }; let items_str = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -549,7 +555,7 @@ pub fn emit_go_module( } } -pub fn go_package_name(module_name: String) -> String { +pub fn go_package_name(module_name: Rc>) -> Rc> { { let parts = Rc::new( module_name @@ -584,7 +590,7 @@ pub fn emit_go_imports( items: Rc>>, imports: Rc>>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let has_services = { let mut __found = false; @@ -694,7 +700,7 @@ pub fn emit_go_typed_item( item: Rc, registry: Rc>>, scope: Rc, -) -> String { +) -> Rc> { { let env = scope.type_env.clone(); let item_text = authored_name(env.clone(), item.clone()); @@ -774,7 +780,7 @@ pub fn emit_go_typed_item( } } -pub fn emit_go_type_def_from_connective(item: Rc, env: Rc) -> String { +pub fn emit_go_type_def_from_connective(item: Rc, env: Rc) -> Rc> { { let item_text = authored_name(env.clone(), item.clone()); let is_product = (item.connective.clone() == Connective::Conj); @@ -787,10 +793,10 @@ pub fn emit_go_type_def_from_connective(item: Rc, env: Rc) -> Str } pub fn emit_go_struct_from_children( - name: String, + name: Rc>, children: Rc>>, env: Rc, -) -> String { +) -> Rc> { if ((children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat( @@ -860,7 +866,7 @@ pub fn emit_go_struct_from_children( } } -pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> String { +pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> Rc> { { let child_text = authored_name(env.clone(), child.clone()); let ty = emit_node_type( @@ -886,10 +892,10 @@ pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> Str } pub fn emit_go_sum_from_children( - name: String, + name: Rc>, children: Rc>>, env: Rc, -) -> String { +) -> Rc> { { let has_data = { let mut __found = false; @@ -1007,7 +1013,11 @@ pub fn emit_go_sum_from_children( } } -pub fn emit_go_variant_struct(parent_name: String, child: Rc, env: Rc) -> String { +pub fn emit_go_variant_struct( + parent_name: Rc>, + child: Rc, + env: Rc, +) -> Rc> { { let struct_name = v1_rt::concat( parent_name.clone(), @@ -1110,10 +1120,10 @@ pub fn emit_go_variant_struct(parent_name: String, child: Rc, env: Rc>, base: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1134,13 +1144,13 @@ pub fn emit_go_type_alias( } pub fn emit_go_fn_def( - name: String, + name: Rc>, params: Rc>>, inferred: Rc, body: Rc, registry: Rc>>, scope: Rc, -) -> String { +) -> Rc> { { let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); @@ -1239,14 +1249,14 @@ pub fn emit_go_fn_def( } pub fn emit_go_func_def( - name: String, + name: Rc>, params: Rc>>, inferred: Rc, uses: Rc>>, body: Rc, registry: Rc>>, scope: Rc, -) -> String { +) -> Rc> { { let service_names = match lookup_item(registry.clone(), name.clone()) { Some(info) => info.service_names.clone(), @@ -1323,7 +1333,7 @@ pub fn emit_go_func_params( uses: Rc>>, service_names: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let param_strs = Rc::new({ let mut __result = Vec::new(); @@ -1377,7 +1387,7 @@ pub fn emit_go_typed_expr( scope: Rc, depth: i64, fuel: i64, -) -> String { +) -> Rc> { emit_unified_typed_expr( texpr, RenderTarget::Go, @@ -1397,10 +1407,10 @@ pub fn emit_go_typed_expr( pub fn emit_go_transport_body( transport: Rc, - op_name: String, + op_name: Rc>, source_indices: Rc>>, depth: i64, -) -> String { +) -> Rc> { emit_unified_transport_dispatch( transport, op_name, @@ -1418,7 +1428,7 @@ pub fn emit_go_service_def( item: Rc, registry: Rc>>, env: Rc, -) -> String { +) -> Rc> { emit_unified_service_def( item, RenderTarget::Go, @@ -1439,11 +1449,11 @@ pub fn emit_go_service_def( } pub fn emit_go_service_struct( - name: String, + name: Rc>, fallback_transport: Rc, op_children: Rc>>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let fs = compute_service_fields(fallback_transport, op_children, source_indices); let decls = service_field_decls(fs, language_spec(RenderTarget::Go).service_fields.clone()); @@ -1508,11 +1518,11 @@ pub fn emit_go_service_struct( } pub fn emit_go_rest_call( - op_name: String, + op_name: Rc>, transport: Rc, depth: i64, source_indices: Rc>>, -) -> String { +) -> Rc> { { let prefix = make_indent(depth); let url_line = v1_rt::concat( @@ -1581,7 +1591,9 @@ pub fn emit_go_rest_call( v1_rt::concat( v1_rt::concat( Rc::new(vec![url_line, body_line, req_line]), - if (auth_line.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(auth_line.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { Rc::new(vec![]) } else { Rc::new(vec![auth_line.clone()]) @@ -1596,11 +1608,11 @@ pub fn emit_go_rest_call( } pub fn emit_go_shell_call( - op_name: String, + op_name: Rc>, transport: Rc, depth: i64, source_indices: Rc>>, -) -> String { +) -> Rc> { { let prefix = make_indent(depth); let cmd_line = v1_rt::concat( @@ -1654,7 +1666,7 @@ pub fn emit_go_shell_call( } } -pub fn emit_go_file_call(op_name: String, depth: i64) -> String { +pub fn emit_go_file_call(op_name: Rc>, depth: i64) -> Rc> { { let prefix = make_indent(depth); v1_rt::concat( @@ -1677,7 +1689,7 @@ pub fn emit_go_file_call(op_name: String, depth: i64) -> String { } } -pub fn emit_go_local_call(op_name: String, depth: i64) -> String { +pub fn emit_go_local_call(op_name: Rc>, depth: i64) -> Rc> { { let prefix = make_indent(depth); v1_rt::concat( @@ -1696,7 +1708,7 @@ pub fn emit_go_local_call(op_name: String, depth: i64) -> String { } } -pub fn emit_go_resource_def(item: Rc, env: Rc) -> String { +pub fn emit_go_resource_def(item: Rc, env: Rc) -> Rc> { { let item_text = authored_name(env.clone(), item.clone()); let cap_children = Rc::new({ @@ -1739,7 +1751,11 @@ pub fn emit_go_resource_def(item: Rc, env: Rc) -> String { } } -pub fn emit_go_capability_method(cap_node: Rc, depth: i64, env: Rc) -> String { +pub fn emit_go_capability_method( + cap_node: Rc, + depth: i64, + env: Rc, +) -> Rc> { { let input_params = Rc::new({ let mut __result = Vec::new(); @@ -1790,13 +1806,13 @@ pub fn emit_go_capability_method(cap_node: Rc, depth: i64, env: Rc>, type_node: Rc, value: Rc, registry: Rc>>, scope: Rc, depth: i64, -) -> String { +) -> Rc> { { let ty_str = emit_node_type( type_node, @@ -1820,7 +1836,7 @@ pub fn emit_go_data_def( } } -pub fn go_export_ident(name: String) -> String { +pub fn go_export_ident(name: Rc>) -> Rc> { match (*language_spec(RenderTarget::Go).visibility.clone()).clone() { VisibilitySpec::CaseVisibility { export_case: ec, .. @@ -1829,7 +1845,9 @@ pub fn go_export_ident(name: String) -> String { if { let mut __found = false; for r in go_reserved().iter().cloned() { - if (r.clone().as_str() == result.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(result.clone())) + { __found = true; break; } diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index 6c00b21f8fb..e0f79c73835 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -123,13 +123,14 @@ pub fn emit_python(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone().as_str() - == authored_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host( + p.module_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ) - .as_str()) - { + ), + )) { __result.push(p); } } @@ -142,7 +143,9 @@ pub fn emit_python(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(f.path.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(f); } } @@ -161,7 +164,7 @@ pub fn emit_python(typed: Rc) -> Rc { } } -pub fn py_derive_attribute() -> String { +pub fn py_derive_attribute() -> Rc> { match serialization_for_target(RenderTarget::Python) .derive_attribute .clone() @@ -171,7 +174,7 @@ pub fn py_derive_attribute() -> String { } } -pub fn py_default_value() -> String { +pub fn py_default_value() -> Rc> { match serialization_for_target(RenderTarget::Python) .default_value .clone() @@ -227,7 +230,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { } } -pub fn python_test_signature_comment(projection: Rc) -> String { +pub fn python_test_signature_comment(projection: Rc) -> Rc> { { let params_str = Rc::new({ let mut __result = Vec::new(); @@ -277,7 +280,7 @@ pub fn python_test_signature_comment(projection: Rc) -> String { } pub fn emit_py_test_file( - module_name: String, + module_name: Rc>, projections: Rc>>, ) -> Rc { if ((projections.clone().len() as i64) == 0) { @@ -319,7 +322,7 @@ pub fn emit_py_test_file( } } -pub fn emit_py_operation_test(projection: Rc, depth: i64) -> String { +pub fn emit_py_operation_test(projection: Rc, depth: i64) -> Rc> { { let test_name = test_function_name(projection.clone(), RenderTarget::Python); let indent = make_indent((depth.clone() + 1)); @@ -343,7 +346,7 @@ pub fn emit_py_mock_prop_setup( mock_prop: Rc, depth: i64, source_indices: Rc>>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( emit_ident( @@ -371,11 +374,14 @@ pub fn emit_py_module( let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); - let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { - "".to_string() - } else { - v1_rt::concat("\n".to_string(), imports_str.clone()) - }; + let imports_section = + if (crate::v2_std_text::host_string_text_to_rust_host(imports_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + "".to_string() + } else { + v1_rt::concat("\n".to_string(), imports_str.clone()) + }; let items_str = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -429,7 +435,7 @@ pub fn emit_py_module( pub fn emit_py_imports( imports: Rc>>, source_indices: Rc>>, -) -> String { +) -> Rc> { if ((imports.clone().len() as i64) == 0) { "".to_string() } else { @@ -500,7 +506,9 @@ pub fn emit_py_imports( Rc::new({ let mut __result = Vec::new(); for line in import_lines.iter().cloned() { - if (line.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(line.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(line); } } @@ -511,7 +519,7 @@ pub fn emit_py_imports( } } -pub fn emit_py_prelude(typed_module: Rc) -> String { +pub fn emit_py_prelude(typed_module: Rc) -> Rc> { { let items = typed_module.items.clone(); let has_structs = { @@ -581,7 +589,7 @@ pub fn emit_py_typed_item( item: Rc, registry: Rc>>, scope: Rc, -) -> String { +) -> Rc> { { let env = scope.type_env.clone(); let item_text = authored_name(env.clone(), item.clone()); @@ -649,7 +657,7 @@ pub fn emit_py_typed_item( } } -pub fn emit_py_type_def_from_connective(item: Rc, env: Rc) -> String { +pub fn emit_py_type_def_from_connective(item: Rc, env: Rc) -> Rc> { { let item_text = authored_name(env.clone(), item.clone()); let is_product = (item.connective.clone() == Connective::Conj); @@ -662,10 +670,10 @@ pub fn emit_py_type_def_from_connective(item: Rc, env: Rc) -> Str } pub fn emit_py_dataclass_from_children( - name: String, + name: Rc>, children: Rc>>, env: Rc, -) -> String { +) -> Rc> { if ((children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat( @@ -701,7 +709,10 @@ pub fn emit_py_dataclass_from_children( } } -pub fn emit_py_dataclass_field_from_child(child: Rc, env: Rc) -> String { +pub fn emit_py_dataclass_field_from_child( + child: Rc, + env: Rc, +) -> Rc> { { let ty = emit_node_type( resolved_type(child.clone()), @@ -735,10 +746,10 @@ pub fn emit_py_dataclass_field_from_child(child: Rc, env: Rc) -> } pub fn emit_py_enum_from_children( - name: String, + name: Rc>, children: Rc>>, env: Rc, -) -> String { +) -> Rc> { { let has_data = { let mut __found = false; @@ -828,10 +839,10 @@ pub fn emit_py_enum_from_children( } pub fn emit_py_variant_class_from_child( - parent_name: String, + parent_name: Rc>, child: Rc, env: Rc, -) -> String { +) -> Rc> { { let class_name = v1_rt::concat(parent_name, authored_name(env.clone(), child.clone())); if ((child.children.clone().len() as i64) == 0) { @@ -868,13 +879,13 @@ pub fn emit_py_variant_class_from_child( } pub fn emit_py_fn_def( - name: String, + name: Rc>, params: Rc>>, inferred: Rc, body: Rc, registry: Rc>>, scope: Rc, -) -> String { +) -> Rc> { { let depth = 0; let si = scope.type_env.clone().source_indices.clone(); @@ -973,14 +984,14 @@ pub fn emit_py_fn_def( } pub fn emit_py_func_def( - name: String, + name: Rc>, params: Rc>>, inferred: Rc, uses: Rc>>, body: Rc, registry: Rc>>, scope: Rc, -) -> String { +) -> Rc> { { let depth = 0; let service_names = match lookup_item(registry.clone(), name.clone()) { @@ -1058,7 +1069,7 @@ pub fn emit_py_func_params( uses: Rc>>, service_names: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let param_strs = Rc::new({ let mut __result = Vec::new(); @@ -1112,7 +1123,7 @@ pub fn emit_py_typed_expr( scope: Rc, depth: i64, fuel: i64, -) -> String { +) -> Rc> { emit_unified_typed_expr( texpr, RenderTarget::Python, @@ -1132,10 +1143,10 @@ pub fn emit_py_typed_expr( pub fn emit_py_transport_body( transport: Rc, - op_name: String, + op_name: Rc>, source_indices: Rc>>, depth: i64, -) -> String { +) -> Rc> { emit_unified_transport_dispatch( transport, op_name, @@ -1153,7 +1164,7 @@ pub fn emit_py_service_def( item: Rc, registry: Rc>>, env: Rc, -) -> String { +) -> Rc> { emit_unified_service_def( item, RenderTarget::Python, @@ -1175,7 +1186,7 @@ pub fn emit_py_service_init( fallback_transport: Rc, op_children: Rc>>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let fs = compute_service_fields(fallback_transport, op_children, source_indices); let params = service_field_decls( @@ -1213,10 +1224,10 @@ pub fn emit_py_service_init( } pub fn emit_py_rest_call( - op_name: String, + op_name: Rc>, transport: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let self_base_url = v1_rt::concat( v1_rt::concat("{".to_string(), "self.base_url".to_string()), @@ -1253,7 +1264,7 @@ pub fn emit_py_rest_call( pub fn emit_py_headers_dict( transport: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let auth_entry = if transport_has_auth(transport.clone(), source_indices.clone()) { { @@ -1291,7 +1302,9 @@ pub fn emit_py_headers_dict( } __result }); - let all_entries = if (auth_entry.clone().as_str() == "".to_string().as_str()) { + let all_entries = if (crate::v2_std_text::host_string_text_to_rust_host(auth_entry.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { header_entries.join(&", ".to_string()) } else { v1_rt::concat(auth_entry.clone(), header_entries.join(&", ".to_string())) @@ -1304,10 +1317,10 @@ pub fn emit_py_headers_dict( } pub fn emit_py_shell_call( - op_name: String, + op_name: Rc>, transport: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let envs = transport_env(transport, source_indices.clone()); let env_dict_entries = Rc::new({ @@ -1371,7 +1384,7 @@ pub fn emit_py_shell_call( } } -pub fn emit_py_file_call(op_name: String) -> String { +pub fn emit_py_file_call(op_name: Rc>) -> Rc> { { let self_base_path = v1_rt::concat( v1_rt::concat("{".to_string(), "self.base_path".to_string()), @@ -1396,7 +1409,7 @@ pub fn emit_py_file_call(op_name: String) -> String { } } -pub fn emit_py_local_call(op_name: String) -> String { +pub fn emit_py_local_call(op_name: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1409,7 +1422,7 @@ pub fn emit_py_local_call(op_name: String) -> String { ) } -pub fn emit_py_resource_def(item: Rc, env: Rc) -> String { +pub fn emit_py_resource_def(item: Rc, env: Rc) -> Rc> { { let item_text = authored_name(env.clone(), item.clone()); let depth = 0; @@ -1448,7 +1461,7 @@ pub fn emit_py_resource_def(item: Rc, env: Rc) -> String { } } -pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String { +pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> Rc> { { let input_params = Rc::new({ let mut __result = Vec::new(); @@ -1471,7 +1484,9 @@ pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (crate::v2_std_text::host_string_text_to_rust_host(params_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { "self".to_string() } else { v1_rt::concat("self, ".to_string(), params_str.clone()) @@ -1527,12 +1542,12 @@ pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String } pub fn emit_py_data_def( - name: String, + name: Rc>, type_node: Rc, value: Rc, registry: Rc>>, scope: Rc, -) -> String { +) -> Rc> { { let ty_str = emit_node_type( type_node, diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 2f8e0f1abed..484fa256019 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -1,6 +1,7 @@ // Generated by v1 compiler -- do not edit. // Source module: v1.compiler.emit_rust +pub use crate::extdeps_cargo_version::render_cargo_package_header_prefix; pub use crate::extdeps_languages_rust_emit::HigherOrderMethodSpec; pub use crate::extdeps_languages_rust_emit::{ rt_bridge_function_names, rt_functions, rt_ref_map_functions, rt_wraps_result, @@ -83,7 +84,6 @@ pub use crate::v1_compiler_runtime_rust::rust_runtime_source; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; -use crate::v1_std_core::empty_intern_table; use crate::v1_std_core::AlgebraFieldKind::*; use crate::v1_std_core::BinOp::*; use crate::v1_std_core::CallSemantics::{LookupCallSemantics, PlainCallSemantics}; @@ -145,7 +145,7 @@ pub fn render_rust_type( n: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), _ => match find_property( @@ -160,6 +160,18 @@ pub fn render_rust_type( Rc::new(vec![]), shared_types, source_indices.clone(), + v1_rt::rc_empty_map::>, Rc>>(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + Rc>, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { render_rust_type_without_applied_binding( @@ -182,7 +194,7 @@ pub fn render_rust_type_without_applied_binding( n: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) && !is_container_type(authored_name_at(source_indices.clone(), n.clone()))) @@ -192,6 +204,18 @@ pub fn render_rust_type_without_applied_binding( Rc::new(vec![]), shared_types, source_indices.clone(), + v1_rt::rc_empty_map::>, Rc>>(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + Rc>, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), ) } else { if node_is_set_collection(n.clone(), source_indices.clone()) { @@ -231,33 +255,39 @@ pub fn render_rust_type_without_applied_binding( None => emit_rust_compile_error_expr("Set missing element type".to_string()), } } else { - let tn = authored_name_at(source_indices.clone(), n.clone()); - if (tn.clone().as_str() == "String".to_string().as_str() - && ((n.children.clone().len() as i64) == 0)) { - render_rust_text_carrier(shared_types.clone()) - } else { - render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types, - source_indices.clone(), - ) + let tn = authored_name_at(source_indices.clone(), n.clone()); + if ((crate::v2_std_text::host_string_text_to_rust_host(tn) + == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())) + && ((n.children.clone().len() as i64) == 0)) + { + render_rust_text_carrier(shared_types) + } else { + render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types, + source_indices.clone(), + ) + } } } } } pub fn empty_string_bool_map() -> Rc> { - v1_rt::rc_empty_map::() + v1_rt::rc_empty_map::>, bool>() } -pub fn rust_type_is_rc_wrapped(type_name: String) -> bool { +pub fn rust_type_is_rc_wrapped(type_name: Rc>) -> bool { ((v1_rt::string_length(&type_name) >= 3) - && (v1_rt::substring(&type_name, 0, 3).as_str() == "Rc<".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring(&type_name, 0, 3)) + == crate::v2_std_text::host_string_text_to_rust_host("Rc<".to_string()))) } -pub fn render_rust_text_carrier(shared_types: Rc>) -> String { +pub fn render_rust_text_carrier( + shared_types: Rc>, +) -> Rc> { render_rust_shared_type_if_needed( "FreeMonoid".to_string(), "FreeMonoid".to_string(), @@ -265,7 +295,9 @@ pub fn render_rust_text_carrier(shared_types: Rc String { +pub fn emit_rust_host_to_dag_string_via_seam( + host_expr: Rc>, +) -> Rc> { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_from_rust_host(".to_string(), @@ -275,7 +307,7 @@ pub fn emit_rust_host_to_dag_string_via_seam(host_expr: String) -> String { ) } -pub fn emit_rust_dag_string_to_host_via_seam(dag_expr: String) -> String { +pub fn emit_rust_dag_string_to_host_via_seam(dag_expr: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat( "crate::v2_std_text::host_string_text_to_rust_host(".to_string(), @@ -285,37 +317,31 @@ pub fn emit_rust_dag_string_to_host_via_seam(dag_expr: String) -> String { ) } -pub fn rust_host_string_seam_fn_emit(name: String) -> Option { - if name.as_str() == "host_string_text_from_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), - " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string(), - ), - "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string(), - ), - "}\n".to_string(), - )) - } else if name.as_str() == "host_string_text_to_rust_host" { - Some(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), - " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string(), - ), - "}\n".to_string(), - ), - "".to_string(), +pub fn rust_host_string_seam_fn_emit(name: Rc>) -> Rc> { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "host_string_text_from_rust_host".to_string(), )) + { + Some(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn host_string_text_from_rust_host(host: String) -> String {\n".to_string(), " host.chars().fold(crate::v2_std_algebra::freemonoid_empty::(), ".to_string()), "|acc, ch| crate::v2_std_algebra::list_snoc_item(acc, v1_rt::code_point(ch.to_string())))\n".to_string()), "}\n".to_string())) } else { - None + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "host_string_text_to_rust_host".to_string(), + )) + { + Some(v1_rt::concat(v1_rt::concat("pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), " crate::v2_std_algebra::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string()), "}\n".to_string())) + } else { + None + } } } -pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { - if (name.clone().as_str() == "Json".to_string().as_str()) - || (name.clone().as_str() == "Bytes".to_string().as_str()) +pub fn rust_opaque_kernel_alias_carrier(name: Rc>) -> Rc> { + if ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Json".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Bytes".to_string()))) { Some(coerce_primitive_type(RenderTarget::Rust, name.clone())) } else { @@ -323,19 +349,25 @@ pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { } } -pub fn rust_named_type_base(name: String) -> String { - if ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) +pub fn rust_named_type_base(name: Rc>) -> Rc> { + if ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("witness".to_string()))) { "Witness".to_string() - } else if name.clone().as_str() == "String".to_string().as_str() { - "FreeMonoid".to_string() } else { - coerce_primitive_type(RenderTarget::Rust, name.clone()) + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())) + { + "FreeMonoid".to_string() + } else { + coerce_primitive_type(RenderTarget::Rust, name.clone()) + } } } -pub fn rust_normalize_witness_type_text(rendered: String) -> String { +pub fn rust_normalize_witness_type_text(rendered: Rc>) -> Rc> { v1_rt::replace( rendered, "witness<".to_string(), @@ -343,7 +375,9 @@ pub fn rust_normalize_witness_type_text(rendered: String) -> String { ) } -pub fn rust_normalize_partial_function_field_type_text(rendered: String) -> String { +pub fn rust_normalize_partial_function_field_type_text( + rendered: Rc>, +) -> Rc> { v1_rt::replace( v1_rt::replace( v1_rt::replace( @@ -364,10 +398,19 @@ pub fn render_rust_applied_type_arg( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, -) -> String { + variant_to_enum: Rc>, + env: Rc, +) -> Rc> { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: tv, .. }) => tv.clone(), - _ => render_rust_decl_type(n.clone(), generic_param_names, shared_types, source_indices), + _ => render_rust_decl_type( + n.clone(), + generic_param_names, + shared_types, + source_indices, + variant_to_enum, + env, + ), } } @@ -376,7 +419,9 @@ pub fn render_rust_applied_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, -) -> String { + variant_to_enum: Rc>, + env: Rc, +) -> Rc> { { let base = rust_named_type_base(authored_name_at(source_indices.clone(), n.clone())); if ((n.children.clone().len() as i64) == 0) { @@ -391,6 +436,8 @@ pub fn render_rust_applied_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), )); } __result @@ -406,10 +453,10 @@ pub fn render_rust_applied_type( } pub fn render_rust_shared_type_if_needed( - type_name: String, - rendered: String, + type_name: Rc>, + rendered: Rc>, shared_types: Rc>, -) -> String { +) -> Rc> { if (v1_rt::set_contains(&shared_types, type_name) && !rust_type_is_rc_wrapped(rendered.clone())) { wrap_shared_type(RenderTarget::Rust, rendered.clone()) @@ -423,13 +470,17 @@ pub fn render_rust_applied_type_shared( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, -) -> String { + variant_to_enum: Rc>, + env: Rc, +) -> Rc> { { let rendered = render_rust_applied_type( n.clone(), generic_param_names, shared_types.clone(), source_indices.clone(), + variant_to_enum, + env, ); let type_name = authored_name_at(source_indices.clone(), n.clone()); render_rust_shared_type_if_needed(type_name, rendered, shared_types.clone()) @@ -441,15 +492,16 @@ pub fn render_rust_decl_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, -) -> String { + variant_to_enum: Rc>, + env: Rc, +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let applied_prop = find_property( n.properties.clone(), "__applied_type_args".to_string(), source_indices.clone(), ); - let has_applied_prop = applied_prop.is_some(); - let applied_overlay = match applied_prop { + let applied_overlay = match applied_prop.clone() { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { Some(applied.clone()) @@ -465,6 +517,8 @@ pub fn render_rust_decl_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), + env.clone(), ), None => { let name = authored_name_at(source_indices.clone(), n.clone()); @@ -473,7 +527,9 @@ pub fn render_rust_decl_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(g.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -482,64 +538,86 @@ pub fn render_rust_decl_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0) - && !has_applied_prop - && v1_rt::set_contains(&shared_types, name.clone())) - { - let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), - recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), - source_indices: source_indices.clone(), - intern_table: empty_intern_table(), - }); - let rendered = rust_render_type_leaf_name( - name.clone(), - v1_rt::rc_empty_map::(), - stub_env, - ); - render_rust_shared_type_if_needed( - name.clone(), - rendered, - shared_types.clone(), - ) } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "String".to_string(), + ))) { + render_rust_text_carrier(shared_types.clone()) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && v1_rt::set_contains(&shared_types, name.clone())) { - let base = rust_named_type_base(name.clone()); - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_decl_type( - arg.clone(), - generic_param_names.clone(), + { + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) + } + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + if (!is_container_type(name.clone()) + && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) + { + render_rust_shared_type_if_needed( + name.clone(), + name.clone(), shared_types.clone(), - source_indices.clone(), - )); + ) + } else { + { + let base = rust_named_type_base(name.clone()); + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_decl_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + )); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base, "<".to_string()), + args, + ), + ">".to_string(), + ); + render_rust_shared_type_if_needed( + name.clone(), + applied_ty, + shared_types.clone(), + ) + } } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - render_rust_shared_type_if_needed( - name.clone(), - applied_ty, - shared_types.clone(), - ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types.clone(), + source_indices.clone(), + ) + } } - } else { - render_rust_type_with_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - ) } } } @@ -548,21 +626,25 @@ pub fn render_rust_decl_type( } pub fn rust_fn_sig_peel_closed_alias(env: Rc, n: Rc) -> bool { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - if name.clone().as_str() == "String".to_string().as_str() { - return false; - } - let binding = match lookup_type_for(env.clone(), n.clone()) { - Some(b) => b, - None => { - let name = authored_name_at(env.source_indices.clone(), n.clone()); - match lookup_type_by_name(env.clone(), name) { - Some(b) => b, - None => return false, - } + { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())) + { + return false; } - }; - (binding.params.clone().len() as i64) == 0 + let binding = match lookup_type_for(env.clone(), n.clone()) { + Some(b) => b.clone(), + None => { + let name = authored_name_at(env.source_indices.clone(), n.clone()); + match lookup_type_by_name(env.clone(), name.clone()) { + Some(b) => b.clone(), + None => return false, + } + } + }; + ((binding.params.clone().len() as i64) == 0) + } } pub fn render_rust_fn_sig_type( @@ -570,19 +652,36 @@ pub fn render_rust_fn_sig_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, -) -> String { - let name = authored_name_at(source_indices.clone(), n.clone()); - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0) - && !is_container_type(name.clone()) - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) +) -> Rc> { { - render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types.clone()) - } else if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type(n, generic_param_names.clone(), shared_types, source_indices) - } else { - render_rust_fn_sig_type_applied_binding(n, shared_types, source_indices, env) + let name = authored_name_at(source_indices.clone(), n.clone()); + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !is_container_type(name.clone())) + && rust_fn_sig_peel_closed_alias(env.clone(), n.clone())) + { + render_rust_shared_type_if_needed(name.clone(), name.clone(), shared_types) + } else { + if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type( + n.clone(), + generic_param_names.clone(), + shared_types, + source_indices.clone(), + variant_to_enum, + env.clone(), + ) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types, + source_indices.clone(), + env.clone(), + ) + } + } } } @@ -591,7 +690,7 @@ pub fn render_rust_fn_sig_type_applied_binding( shared_types: Rc>, source_indices: Rc>>, env: Rc, -) -> String { +) -> Rc> { match find_property( n.properties.clone(), "__applied_type_args".to_string(), @@ -599,25 +698,38 @@ pub fn render_rust_fn_sig_type_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - if outer_name.as_str() != "" - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 - && rust_fn_sig_peel_closed_alias(env.clone(), n.clone()) { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name, - shared_types.clone(), - ) - } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + if ((((crate::v2_std_text::host_string_text_to_rust_host(outer_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + && rust_fn_sig_peel_closed_alias(env, n.clone())) + { + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name.clone(), + shared_types, + ) + } else { + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + source_indices.clone(), + ) + } } } else { - render_rust_type_with_applied_binding(n, shared_types, source_indices) + render_rust_type_with_applied_binding( + n.clone(), + shared_types, + source_indices.clone(), + ) } } - None => render_rust_type_with_applied_binding(n, shared_types, source_indices), + None => { + render_rust_type_with_applied_binding(n.clone(), shared_types, source_indices.clone()) + } } } @@ -629,12 +741,12 @@ pub fn render_rust_alias_rhs_type( scope: Rc, imports: Rc>>, registry: Rc>>, - module_name: String, + module_name: Rc>, export_sets: Rc>>>, typed_modules: Rc>>, module_index: Rc, variant_to_enum: Rc>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let name = authored_name_at(source_indices.clone(), n.clone()); if (((n.connective.clone() == Connective::NoConnective) @@ -642,7 +754,9 @@ pub fn render_rust_alias_rhs_type( && { let mut __found = false; for g in generic_param_names.clone().iter().cloned() { - if (g.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(g.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -651,100 +765,121 @@ pub fn render_rust_alias_rhs_type( }) { name.clone() - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - { - if name.clone().as_str() == "String".to_string().as_str() { - render_rust_text_carrier(shared_types.clone()) - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier - } else { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - scope.type_env.clone(), - ); - render_rust_shared_type_if_needed(name.clone(), rendered, shared_types.clone()) - } - } else if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - { + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) { - let local_mod = module_to_filename(module_name.clone()); - let def_mod = alias_rhs_rust_qualify_module_filename( - name.clone(), - module_name.clone(), - imports.clone(), - scope.clone(), - registry.clone(), - export_sets.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ); - let base = if (def_mod.clone().as_str() != local_mod.as_str()) { - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("crate::".to_string(), def_mod.clone()), - "::".to_string(), - ), - name.clone(), - ) - } else { - name.clone() - }; - if !is_container_type(name.clone()) - && rust_fn_sig_peel_closed_alias(scope.type_env.clone(), n.clone()) + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())) { - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(base.clone())) - { - wrap_shared_type(RenderTarget::Rust, base.clone()) - } else { - base.clone() - } + render_rust_text_carrier(shared_types.clone()) } else { - let args = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push(render_rust_alias_rhs_type( - arg.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - scope.clone(), - imports.clone(), - registry.clone(), - module_name.clone(), - export_sets.clone(), - typed_modules.clone(), - module_index.clone(), + match rust_opaque_kernel_alias_carrier(name.clone()) { + Some(carrier) => carrier.clone(), + None => { + let rendered = rust_render_type_leaf_name( + name.clone(), variant_to_enum.clone(), - )); + scope.type_env.clone(), + ); + render_rust_shared_type_if_needed( + name.clone(), + rendered, + shared_types.clone(), + ) } - __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat(v1_rt::concat(base, "<".to_string()), args), - ">".to_string(), - ); - if (v1_rt::set_contains(&shared_types, name.clone()) - && !rust_type_is_rc_wrapped(applied_ty.clone())) + } + } + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { { - wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) - } else { - applied_ty.clone() + let local_mod = module_to_filename(module_name.clone()); + let def_mod = alias_rhs_rust_qualify_module_filename( + name.clone(), + module_name.clone(), + imports.clone(), + scope.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); + let base = + if (crate::v2_std_text::host_string_text_to_rust_host(def_mod.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(local_mod)) + { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("crate::".to_string(), def_mod.clone()), + "::".to_string(), + ), + name.clone(), + ) + } else { + name.clone() + }; + if (!is_container_type(name.clone()) + && rust_fn_sig_peel_closed_alias(scope.type_env.clone(), n.clone())) + { + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(base.clone())) + { + wrap_shared_type(RenderTarget::Rust, base.clone()) + } else { + base.clone() + } + } else { + { + let args = Rc::new({ + let mut __result = Vec::new(); + for arg in n.children.clone().iter().cloned() { + __result.push(render_rust_alias_rhs_type( + arg.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + scope.clone(), + imports.clone(), + registry.clone(), + module_name.clone(), + export_sets.clone(), + typed_modules.clone(), + module_index.clone(), + variant_to_enum.clone(), + )); + } + __result + }) + .join(&", ".to_string()); + let applied_ty = v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + args, + ), + ">".to_string(), + ); + if (v1_rt::set_contains(&shared_types, name.clone()) + && !rust_type_is_rc_wrapped(applied_ty.clone())) + { + wrap_shared_type(RenderTarget::Rust, applied_ty.clone()) + } else { + applied_ty.clone() + } + } + } } + } else { + render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } } - } else { - render_rust_type(n.clone(), shared_types.clone(), source_indices.clone()) } }) } -pub fn type_variable_node(id: String) -> Rc { +pub fn type_variable_node(id: Rc>) -> Rc { Rc::new(Node { name: "".to_string(), span: make_span(0, 0), @@ -797,20 +932,20 @@ pub fn is_rust_string_like( } } -pub fn rust_source_root() -> String { +pub fn rust_source_root() -> Rc> { match scaffold_for_target(RenderTarget::Rust).source_dir.clone() { Some(dir) => dir.clone(), None => "".to_string(), } } -pub fn rust_source_ext() -> String { +pub fn rust_source_ext() -> Rc> { scaffold_for_target(RenderTarget::Rust) .source_file_extension .clone() } -pub fn rust_visibility_prefix() -> String { +pub fn rust_visibility_prefix() -> Rc> { match (*visibility_for_target(RenderTarget::Rust)).clone() { VisibilitySpec::KeywordVisibility { prefix: p, .. } => p.clone(), _ => "__VISIBILITY_SPEC_MISMATCH__".to_string(), @@ -821,32 +956,32 @@ pub fn rust_items() -> Rc { language_spec(RenderTarget::Rust).items.clone() } -pub fn rust_struct_derives_text() -> String { +pub fn rust_struct_derives_text() -> Rc> { rust_struct_derives() } -pub fn rust_struct_derives_copy_text() -> String { +pub fn rust_struct_derives_copy_text() -> Rc> { rust_struct_derives_copy() } -pub fn rust_enum_derives_text() -> String { +pub fn rust_enum_derives_text() -> Rc> { rust_enum_derives() } -pub fn rust_enum_derives_copy_text() -> String { +pub fn rust_enum_derives_copy_text() -> Rc> { rust_enum_derives_copy() } -pub fn rust_ord_derives_text() -> String { +pub fn rust_ord_derives_text() -> Rc> { "#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]" .to_string() } -pub fn rust_ord_derives_copy_text() -> String { +pub fn rust_ord_derives_copy_text() -> Rc> { "#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]".to_string() } -pub fn rust_nominal_identity_carrier_def(name: String) -> String { +pub fn rust_nominal_identity_carrier_def(name: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -865,26 +1000,32 @@ pub fn rust_nominal_identity_carrier_def(name: String) -> String { ) } -pub fn rust_nominal_identity_carrier_type_eligible(type_name: String) -> bool { - (type_name.as_str() == "Symbol".to_string().as_str()) +pub fn rust_nominal_identity_carrier_type_eligible(type_name: Rc>) -> bool { + (crate::v2_std_text::host_string_text_to_rust_host(type_name) + == crate::v2_std_text::host_string_text_to_rust_host("Symbol".to_string())) } pub fn rust_nominal_identity_carrier_shape_eligible( n: Rc, source_indices: Rc>>, ) -> bool { - ((((authored_name_at(source_indices, n.clone()).as_str() == "Symbol".to_string().as_str()) + ((((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices, + n.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("Symbol".to_string())) && ((n.children.clone().len() as i64) == 0)) && ((n.params.clone().len() as i64) == 0)) && (n.connective.clone() == Connective::NoConnective)) } pub fn rust_diff_id_ord_carrier_shape_eligible( - name: String, + name: Rc>, children: Rc>>, source_indices: Rc>>, ) -> bool { - if ((name.as_str() != "DiffId".to_string().as_str()) || ((children.clone().len() as i64) != 1)) + if ((crate::v2_std_text::host_string_text_to_rust_host(name) + != crate::v2_std_text::host_string_text_to_rust_host("DiffId".to_string())) + || ((children.clone().len() as i64) != 1)) { false } else { @@ -899,10 +1040,10 @@ pub fn rust_diff_id_ord_carrier_shape_eligible( } pub fn rust_nominal_ord_derives_for_shape( - name: String, + name: Rc>, children: Rc>>, source_indices: Rc>>, -) -> String { +) -> Rc> { if rust_diff_id_ord_carrier_shape_eligible(name, children, source_indices) { rust_ord_derives_text() } else { @@ -919,8 +1060,10 @@ pub fn rust_nominal_ord_type_ref_eligible( (((((elem_node.children.clone().len() as i64) == 0) && ((elem_node.params.clone().len() as i64) == 0)) && (elem_node.connective.clone() == Connective::NoConnective)) - && ((type_name.clone().as_str() == "Symbol".to_string().as_str()) - || (type_name.clone().as_str() == "DiffId".to_string().as_str()))) + && ((crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Symbol".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("DiffId".to_string())))) } } @@ -937,7 +1080,7 @@ pub fn rust_nominal_ord_type_eligible( )) } -pub fn rust_serde_tag_attr() -> String { +pub fn rust_serde_tag_attr() -> Rc> { match serialization_for_target(RenderTarget::Rust) .tag_attribute .clone() @@ -952,18 +1095,18 @@ pub fn rust_serde_tag_attr() -> String { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RustEnumWireSerde { - pub enum_attr: String, - pub rename_prefix: Option, - pub rename_suffix: Option, - pub rename_style: Option, - pub error_message: Option, + pub enum_attr: Rc>, + pub rename_prefix: Rc>, + pub rename_suffix: Rc>, + pub rename_style: Rc>, + pub error_message: Rc>, } pub fn rust_serde_policy( - enum_attr: String, - rename_prefix: Option, - rename_suffix: Option, - rename_style: Option, + enum_attr: Rc>, + rename_prefix: Rc>, + rename_suffix: Rc>, + rename_style: Rc>, ) -> Rc { Rc::new(RustEnumWireSerde { enum_attr: enum_attr, @@ -974,7 +1117,7 @@ pub fn rust_serde_policy( }) } -pub fn rust_serde_policy_error(message: String) -> Rc { +pub fn rust_serde_policy_error(message: Rc>) -> Rc { Rc::new(RustEnumWireSerde { enum_attr: "".to_string(), rename_prefix: None, @@ -992,7 +1135,7 @@ pub fn rust_untagged_policy() -> Rc { rust_serde_policy("#[serde(untagged)]".to_string(), None, None, None) } -pub fn rust_serde_error_policy(message: String) -> Rc { +pub fn rust_serde_error_policy(message: Rc>) -> Rc { rust_serde_policy_error(message) } @@ -1015,14 +1158,16 @@ pub fn rust_screaming_snake_string_policy() -> Rc { pub fn field_value_by_name( record: Rc, - field_name: String, + field_name: Rc>, source_indices: Rc>>, ) -> Option> { match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (field_init_node_name_at(fi.clone(), source_indices.clone()).as_str() - == field_name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + fi.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone())) { __result.push(fi); } @@ -1037,7 +1182,7 @@ pub fn field_value_by_name( } } -pub fn literal_string_value(n: Rc) -> Option { +pub fn literal_string_value(n: Rc) -> Rc> { match (*n.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lv, .. } => match (*lv.clone()).clone() { LiteralValue::LitStr { value: s, .. } => Some(s.clone()), @@ -1049,9 +1194,9 @@ pub fn literal_string_value(n: Rc) -> Option { pub fn record_string_field( record: Rc, - field_name: String, + field_name: Rc>, source_indices: Rc>>, -) -> Option { +) -> Rc> { match field_value_by_name(record, field_name, source_indices) { Some(value_node) => literal_string_value(value_node.clone()), None => None, @@ -1067,9 +1212,9 @@ pub fn naming_policy_node( pub fn optional_string_record_field( record: Rc, - field_name: String, + field_name: Rc>, source_indices: Rc>>, -) -> Option { +) -> Rc> { match field_value_by_name(record, field_name, source_indices) { Some(n) => literal_string_value(n.clone()), None => None, @@ -1078,9 +1223,9 @@ pub fn optional_string_record_field( pub fn required_literal_string_policy_field( record: Rc, - field_name: String, + field_name: Rc>, source_indices: Rc>>, -) -> Option { +) -> Rc> { match field_value_by_name(record, field_name, source_indices) { Some(n) => literal_string_value(n.clone()), None => None, @@ -1093,17 +1238,27 @@ pub fn rust_string_policy_for_naming( ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("AsAuthored".to_string())) + { rust_string_as_authored_policy() } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("SnakeCase".to_string())) + { rust_snake_string_policy() } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "ScreamingSnakeCase".to_string(), + )) + { rust_screaming_snake_string_policy() } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "StripPrefixAndSnakeCase".to_string(), + )) { match required_literal_string_policy_field( naming.clone(), @@ -1121,8 +1276,10 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "StripSuffixAndSnakeCase".to_string(), + )) { match required_literal_string_policy_field( naming.clone(), @@ -1140,35 +1297,18 @@ pub fn rust_string_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) - { - match required_literal_string_policy_field( - naming.clone(), - "prefix".to_string(), - source_indices.clone(), - ) { - Some(prefix) => match required_literal_string_policy_field( - naming.clone(), - "suffix".to_string(), - source_indices.clone(), - ) { - Some(suffix) => rust_serde_policy( - "".to_string(), - Some(prefix.clone()), - Some(suffix.clone()), - Some("StripAffixAndSnakeCase".to_string()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + if (crate::v2_std_text::host_string_text_to_rust_host( + naming_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "StripPrefixSuffixAndSnakeCase".to_string(), + )) { + match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { + Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { + Some(suffix) => rust_serde_policy("".to_string(), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1184,13 +1324,15 @@ pub fn rust_string_policy_for_naming( } pub fn rust_internal_policy_for_naming( - tag_field: String, + tag_field: Rc>, naming: Rc, source_indices: Rc>>, ) -> Rc { { let naming_name = authored_name_at(source_indices.clone(), naming.clone()); - if (naming_name.clone().as_str() == "AsAuthored".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("AsAuthored".to_string())) + { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1201,7 +1343,9 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "SnakeCase".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("SnakeCase".to_string())) + { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1212,7 +1356,11 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() == "ScreamingSnakeCase".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "ScreamingSnakeCase".to_string(), + )) + { rust_serde_policy( v1_rt::concat( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), @@ -1223,8 +1371,10 @@ pub fn rust_internal_policy_for_naming( None, ) } else { - if (naming_name.clone().as_str() - == "StripPrefixAndSnakeCase".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "StripPrefixAndSnakeCase".to_string(), + )) { match required_literal_string_policy_field( naming.clone(), @@ -1245,8 +1395,10 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripSuffixAndSnakeCase".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(naming_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "StripSuffixAndSnakeCase".to_string(), + )) { match required_literal_string_policy_field( naming.clone(), @@ -1267,41 +1419,18 @@ pub fn rust_internal_policy_for_naming( ), } } else { - if (naming_name.clone().as_str() - == "StripPrefixSuffixAndSnakeCase".to_string().as_str()) - { - match required_literal_string_policy_field( - naming.clone(), - "prefix".to_string(), - source_indices.clone(), - ) { - Some(prefix) => match required_literal_string_policy_field( - naming.clone(), - "suffix".to_string(), - source_indices.clone(), - ) { - Some(suffix) => rust_serde_policy( - v1_rt::concat( - v1_rt::concat( - "#[serde(tag = \"".to_string(), - tag_field, - ), - "\")]".to_string(), - ), - Some(prefix.clone()), - Some(suffix.clone()), - Some("StripAffixAndSnakeCase".to_string()), - ), - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal suffix" - .to_string(), - ), - }, - None => rust_serde_error_policy( - "StripPrefixSuffixAndSnakeCase requires a literal prefix" - .to_string(), - ), - } + if (crate::v2_std_text::host_string_text_to_rust_host( + naming_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "StripPrefixSuffixAndSnakeCase".to_string(), + )) { + match required_literal_string_policy_field(naming.clone(), "prefix".to_string(), source_indices.clone()) { + Some(prefix) => match required_literal_string_policy_field(naming.clone(), "suffix".to_string(), source_indices.clone()) { + Some(suffix) => rust_serde_policy(v1_rt::concat(v1_rt::concat("#[serde(tag = \"".to_string(), tag_field), "\")]".to_string()), Some(prefix.clone()), Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string())), + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal suffix".to_string()), +}, + None => rust_serde_error_policy("StripPrefixSuffixAndSnakeCase requires a literal prefix".to_string()), +} } else { rust_serde_error_policy(v1_rt::concat( "unsupported VariantNaming: ".to_string(), @@ -1347,10 +1476,16 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ) -> Rc { { let encoding_name = authored_name_at(source_indices.clone(), ve.clone()); - if (encoding_name.clone().as_str() == "InternallyTaggedObject".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(encoding_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "InternallyTaggedObject".to_string(), + )) + { rust_internal_policy_for_encoding(ve.clone(), source_indices.clone()) } else { - if (encoding_name.clone().as_str() == "StringVariant".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(encoding_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("StringVariant".to_string())) + { match naming_policy_node(ve.clone(), source_indices.clone()) { Some(nv) => rust_string_policy_for_naming(nv.clone(), source_indices.clone()), None => rust_serde_error_policy( @@ -1358,10 +1493,18 @@ pub fn resolve_wire_serde_policy_from_encoding_node( ), } } else { - if (encoding_name.clone().as_str() == "UntaggedVariant".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(encoding_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "UntaggedVariant".to_string(), + )) + { rust_untagged_policy() } else { - if (encoding_name.clone().as_str() == "TaggedVariant".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(encoding_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "TaggedVariant".to_string(), + )) + { rust_tagged_object_policy() } else { rust_serde_error_policy(v1_rt::concat( @@ -1390,9 +1533,11 @@ pub fn resolve_wire_serde_policy( } } -pub fn item_binding_is_named(env: Rc, node: Rc, name: String) -> bool { - ((authored_name(env, node.clone()).as_str() == name.clone().as_str()) - || (node.name.clone().as_str() == name.clone().as_str())) +pub fn item_binding_is_named(env: Rc, node: Rc, name: Rc>) -> bool { + ((crate::v2_std_text::host_string_text_to_rust_host(authored_name(env, node.clone())) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + || (crate::v2_std_text::host_string_text_to_rust_host(node.name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone()))) } pub fn resolve_wire_serde_policy_for_coproduct( @@ -1404,7 +1549,7 @@ pub fn resolve_wire_serde_policy_for_coproduct( wire_contract_item, source_indices, data_items, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), 32, ) } @@ -1585,18 +1730,22 @@ pub fn variant_encoding_is_string_variant( encoding: Rc, source_indices: Rc>>, ) -> bool { - (authored_name_at(source_indices, encoding).as_str() == "StringVariant".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at(source_indices, encoding)) + == crate::v2_std_text::host_string_text_to_rust_host("StringVariant".to_string())) } pub fn coproduct_wire_contract_targets( contract_item: Rc, - coproduct_name: String, + coproduct_name: Rc>, source_indices: Rc>>, ) -> bool { match contract_item.body.clone() { Some(body) => { match record_string_field(body.clone(), "coproduct".to_string(), source_indices) { - Some(target_name) => (target_name.clone().as_str() == coproduct_name.as_str()), + Some(target_name) => { + (crate::v2_std_text::host_string_text_to_rust_host(target_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(coproduct_name)) + } None => false, } } @@ -1604,14 +1753,14 @@ pub fn coproduct_wire_contract_targets( } } -pub fn emit_rust_compile_error_item(message: String) -> String { +pub fn emit_rust_compile_error_item(message: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat("compile_error!(\"".to_string(), message), "\");".to_string(), ) } -pub fn emit_rust_compile_error_expr(message: String) -> String { +pub fn emit_rust_compile_error_expr(message: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat("compile_error!(\"".to_string(), message), "\")".to_string(), @@ -1625,22 +1774,28 @@ pub fn module_imports_std_serialization_coproduct_wire_contract( { let mut __found = false; for imp in imports.iter().cloned() { - if ((authored_name_at(source_indices.clone(), imp.clone()).as_str() - == "std.serialization".to_string().as_str()) - && (import_is_all(imp.clone()) || { - let mut __found = false; - for name in import_specific_names_at(imp.clone(), source_indices.clone()) - .iter() - .cloned() + if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + imp.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "std.serialization".to_string(), + )) && (import_is_all(imp.clone()) || { + let mut __found = false; + for name in import_specific_names_at(imp.clone(), source_indices.clone()) + .iter() + .cloned() + { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "CoproductWireContract".to_string(), + )) { - if (name.clone().as_str() == "CoproductWireContract".to_string().as_str()) { - __found = true; - break; - } + __found = true; + break; } - __found - })) - { + } + __found + })) { __found = true; break; } @@ -1656,12 +1811,15 @@ pub fn data_item_type_is_coproduct_wire_contract( ) -> bool { match item.type_annotation.clone() { Some(type_node) => { - ((authored_name_at(source_indices.clone(), type_node.clone()).as_str() - == "CoproductWireContract".to_string().as_str()) - && module_imports_std_serialization_coproduct_wire_contract( - imports, - source_indices.clone(), - )) + ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + type_node.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "CoproductWireContract".to_string(), + )) && module_imports_std_serialization_coproduct_wire_contract( + imports, + source_indices.clone(), + )) } None => false, } @@ -1677,8 +1835,12 @@ pub fn module_defines_local_coproduct_wire_contract_type( if (((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), item.clone()).as_str() - == "CoproductWireContract".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + item.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "CoproductWireContract".to_string(), + ))) { __found = true; break; @@ -1731,7 +1893,7 @@ pub fn emit_coproduct_wire_contract_target_validation( contract_item: Rc, local_coproduct_names: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match contract_item.body.clone() { Some(body) => { match record_string_field(body.clone(), "coproduct".to_string(), source_indices) { @@ -1739,7 +1901,11 @@ pub fn emit_coproduct_wire_contract_target_validation( if { let mut __found = false; for name in local_coproduct_names.iter().cloned() { - if (name.clone().as_str() == target_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + target_name.clone(), + )) + { __found = true; break; } @@ -1771,7 +1937,7 @@ pub fn emit_coproduct_wire_contract_validations( imports: Rc>>, local_coproduct_names: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for text in Rc::new({ @@ -1804,7 +1970,9 @@ pub fn emit_coproduct_wire_contract_validations( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(text.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(text); } } @@ -1814,7 +1982,7 @@ pub fn emit_coproduct_wire_contract_validations( } pub fn resolve_local_coproduct_wire_policy( - coproduct_name: String, + coproduct_name: Rc>, all_unit_variants: bool, module_items: Rc>>, imports: Rc>>, @@ -1881,7 +2049,7 @@ pub fn resolve_local_coproduct_wire_policy( pub fn build_data_item_index(modules: Rc>>) -> Rc>> { modules.iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, tm: Rc| { let module_name = authored_name_at( tm.type_env.clone().source_indices.clone(), @@ -1916,7 +2084,7 @@ pub fn build_data_item_index(modules: Rc>>) -> Rc>>>>, - name: String, + name: Rc>, item: Rc, ) -> Rc>>>> { { @@ -1953,7 +2121,7 @@ pub fn build_scoped_data_item_index( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |acc: Rc>>>>, item: Rc| { insert_scoped_data_item( acc, @@ -1987,7 +2155,7 @@ pub fn build_scoped_data_item_index( .fold( acc.clone(), |inner: Rc>>>>, - imported_name: String| { + imported_name: Rc>| { let qualified = v1_rt::concat( v1_rt::concat(import_path.clone(), ".".to_string()), imported_name.clone(), @@ -2008,7 +2176,7 @@ pub fn build_scoped_data_item_index( } } -pub fn rust_serde_rename_template_text() -> String { +pub fn rust_serde_rename_template_text() -> Rc> { match serialization_for_target(RenderTarget::Rust) .rename_attribute_template .clone() @@ -2021,7 +2189,7 @@ pub fn rust_serde_rename_template_text() -> String { } } -pub fn rust_test_file_path(module_name: String) -> String { +pub fn rust_test_file_path(module_name: Rc>) -> Rc> { { let conventions = test_conventions_for_target(RenderTarget::Rust); let file_dir = match conventions.file_dir.clone() { @@ -2042,11 +2210,11 @@ pub fn rust_test_file_path(module_name: String) -> String { } } -pub fn rust_test_name(projection: Rc) -> String { +pub fn rust_test_name(projection: Rc) -> Rc> { test_function_name(projection, RenderTarget::Rust) } -pub fn rust_async_test_decorator() -> String { +pub fn rust_async_test_decorator() -> Rc> { match test_conventions_for_target(RenderTarget::Rust) .async_decorator .clone() @@ -2171,9 +2339,188 @@ pub fn emit_rust_init_block_stmts( } } } - } + } + } + } +} + +pub fn rust_qualify_type_leaf_name( + name: Rc>, + variant_to_enum: Rc>, +) -> Rc> { + match v1_rt::map_get(&variant_to_enum, name.clone()) { + Some(parent) => { + if (crate::v2_std_text::host_string_text_to_rust_host(parent.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat( + v1_rt::concat(parent.clone(), "::".to_string()), + name.clone(), + ) + } else { + name.clone() + } + } + None => name.clone(), + } +} + +pub fn rust_render_type_leaf_name( + name: Rc>, + variant_to_enum: Rc>, + env: Rc, +) -> Rc> { + if is_phantom_unit_variant_type_arg(env, name.clone()) { + name.clone() + } else { + match rust_opaque_kernel_alias_carrier(name.clone()) { + Some(carrier) => carrier.clone(), + None => rust_qualify_type_leaf_name(name.clone(), variant_to_enum), + } + } +} + +pub fn emit_phantom_zst_markers_for_enum( + children: Rc>>, + env: Rc, +) -> Rc> { + { + let markers = Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in Rc::new({ + let mut __result = Vec::new(); + for child in children.iter().cloned() { + if ((child.children.clone().len() as i64) == 0) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + if is_phantom_unit_variant_type_arg( + env.clone(), + authored_name(env.clone(), child.clone()), + ) { + __result.push(child); + } + } + __result + }) + .iter() + .cloned() + { + __result.push({ + let vname = authored_name(env.clone(), child.clone()); + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + vname.clone(), + ), + ";".to_string(), + ) + }); + } + __result + }) + .join(&"\n".to_string()); + markers + } +} + +pub fn collect_phantom_zst_marker_names( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + if (is_type_def_item(item.clone()) && { + let mut __all = true; + for c in item.children.clone().iter().cloned() { + if !((c.children.clone().len() as i64) == 0) { + __all = false; + break; + } + } + __all + }) { + __result.push(item); + } + } + __result + }) + .iter() + .cloned() + .fold(Rc::new(vec![]), |acc: Rc>, item: Rc| { + item.children.clone().iter().cloned().fold( + acc, + |inner: Rc>, child: Rc| { + if ((child.children.clone().len() as i64) == 0) { + { + let vname = authored_name(env.clone(), child.clone()); + if (is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) + && !{ + let mut __found = false; + for n in inner.clone().iter().cloned() { + if (crate::v2_std_text::host_string_text_to_rust_host( + n.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + vname.clone(), + )) { + __found = true; + break; + } + } + __found + }) + { + v1_rt::concat(inner.clone(), Rc::new(vec![vname.clone()])) + } else { + inner.clone() + } + } + } else { + inner.clone() + } + }, + ) + }) +} + +pub fn emit_module_phantom_zst_markers( + items: Rc>>, + env: Rc, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for vname in collect_phantom_zst_marker_names(items, env).iter().cloned() { + __result.push(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + rust_items().struct_keyword.clone(), + ), + " ".to_string(), + ), + vname.clone(), + ), + ";".to_string(), + )); } - } + __result + }) + .join(&"\n".to_string()) } pub fn has_complex_variants(item: Rc) -> bool { @@ -2208,7 +2555,7 @@ pub fn is_simple_disj(item: Rc) -> bool { } } -pub fn is_dag_value_type_name(name: String) -> bool { +pub fn is_dag_value_type_name(name: Rc>) -> bool { match is_copy(RenderTarget::Rust, name) { Some(v) => v.clone(), None => false, @@ -2316,8 +2663,14 @@ pub fn build_shared_types( .cloned() { if ((sharing.needs_sharing.clone() - && (k.clone().as_str() != "optional".to_string().as_str())) - && (k.clone().as_str() != "boolean_algebra".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(k.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "optional".to_string(), + ))) + && (crate::v2_std_text::host_string_text_to_rust_host(k.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "boolean_algebra".to_string(), + ))) { __result.push(k); } @@ -2326,7 +2679,7 @@ pub fn build_shared_types( }); collection_keys.iter().cloned().fold( user_shared.clone(), - |acc: Rc>, key: String| { + |acc: Rc>, key: Rc>| { let pascal = to_pascal(key.clone()); v1_rt::rc_set_insert(acc, pascal.clone()) }, @@ -2336,7 +2689,7 @@ pub fn build_shared_types( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipProofEntry { - pub name: String, + pub name: Rc>, pub proof: Rc, pub param_names: Rc>, } @@ -2436,11 +2789,11 @@ pub fn build_ownership_results(modules: Rc>>) -> Rc>, Rc>, >(), read_only_params_index: v1_rt::rc_empty_map::< - String, + Rc>, Rc>, >(), }), @@ -2512,7 +2865,7 @@ pub fn emit_rust(typed: Rc) -> Rc { }); } let svc_module_map = typed.modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, tm: Rc| { let svc_items = Rc::new({ let mut __result = Vec::new(); @@ -2575,13 +2928,14 @@ pub fn emit_rust(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (p.module_name.clone().as_str() - == authored_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host( + p.module_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ) - .as_str()) - { + ), + )) { __result.push(p); } } @@ -2594,7 +2948,9 @@ pub fn emit_rust(typed: Rc) -> Rc { .iter() .cloned() { - if (f.path.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(f.path.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(f); } } @@ -2604,10 +2960,12 @@ pub fn emit_rust(typed: Rc) -> Rc { let has_pipeline = { let mut __found = false; for m in typed.modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - .as_str() - == "v1.compiler.compile".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + m.type_env.clone().source_indices.clone(), + m.module.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "v1.compiler.compile".to_string(), + )) { __found = true; break; } @@ -2768,7 +3126,7 @@ pub fn emit_module( registry, emit_info.clone(), shared_types, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), build_data_item_index(Rc::new(vec![typed_module.clone()])), export_sets, Rc::new(vec![typed_module.clone()]), @@ -2781,7 +3139,7 @@ pub fn build_module_export_sets( modules: Rc>>, ) -> Rc>>> { modules.iter().cloned().fold( - v1_rt::rc_empty_map::>>(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>>>, tm: Rc| { let m_name = authored_name_at( tm.type_env.clone().source_indices.clone(), @@ -2792,8 +3150,8 @@ pub fn build_module_export_sets( tm.type_env.clone().source_indices.clone(), ); let exported_set = exported.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |inner: Rc>, n: String| { + v1_rt::rc_empty_map::>, bool>(), + |inner: Rc>, n: Rc>| { v1_rt::rc_map_insert(inner, n.clone(), true) }, ); @@ -2855,11 +3213,14 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), module_index.clone(), ); - let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { - "".to_string() - } else { - v1_rt::concat("\n".to_string(), imports_str.clone()) - }; + let imports_section = + if (crate::v2_std_text::host_string_text_to_rust_host(imports_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + "".to_string() + } else { + v1_rt::concat("\n".to_string(), imports_str.clone()) + }; let this_mod_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); let all_svc_names = Rc::new({ @@ -2885,7 +3246,11 @@ pub fn emit_module_full( __result.extend( (*match v1_rt::map_get(&svc_module_map, sn.clone()) { Some(mod_file) => { - if (mod_file.clone().as_str() == this_mod_filename.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(mod_file.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + this_mod_filename.clone(), + )) + { Rc::new(vec![]) } else { Rc::new(vec![v1_rt::concat( @@ -2972,7 +3337,10 @@ pub fn emit_module_full( scope.type_env.clone().source_indices.clone(), ); let coproduct_wire_contract_validation_section = - if (coproduct_wire_contract_validations.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + coproduct_wire_contract_validations.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { "".to_string() } else { v1_rt::concat( @@ -3033,20 +3401,28 @@ pub fn emit_module_full( .join(&"\n\n".to_string()); let phantom_zst_markers = emit_module_phantom_zst_markers(typed_module.items.clone(), scope.type_env.clone()); - let phantom_section = if phantom_zst_markers.as_str() == "" { - "".to_string() - } else { - v1_rt::concat("\n\n".to_string(), phantom_zst_markers) - }; + let phantom_section = + if (crate::v2_std_text::host_string_text_to_rust_host(phantom_zst_markers.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + "".to_string() + } else { + v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) + }; let raw_filename = module_to_filename(authored_name(scope.type_env.clone(), m.clone())); - let filename = if (raw_filename.clone().as_str() == "main".to_string().as_str()) { + let filename = if (crate::v2_std_text::host_string_text_to_rust_host(raw_filename.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("main".to_string())) + { "main_mod".to_string() } else { raw_filename.clone() }; - let module_attrs = if (authored_name(scope.type_env.clone(), m.clone()).as_str() - == "std.error_primitives".to_string().as_str()) - { + let module_attrs = if (crate::v2_std_text::host_string_text_to_rust_host(authored_name( + scope.type_env.clone(), + m.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "std.error_primitives".to_string(), + )) { "#![allow(non_camel_case_types)]\n\n".to_string() } else { "".to_string() @@ -3062,7 +3438,10 @@ pub fn emit_module_full( } } -pub fn emit_import_name(n: String, registry: Rc>>) -> String { +pub fn emit_import_name( + n: Rc>, + registry: Rc>>, +) -> Rc> { { let is_data = match v1_rt::map_get(®istry, n.clone()) { Some(info) => (info.kind.clone() == ItemKind::DataItem), @@ -3077,8 +3456,8 @@ pub fn emit_import_name(n: String, registry: Rc>>) } pub fn is_import_graph_type_name( - name: String, - import_module: String, + name: Rc>, + import_module: Rc>, typed_modules: Rc>>, registry: Rc>>, export_sets: Rc>>>, @@ -3147,10 +3526,10 @@ pub fn is_import_graph_type_name( } pub fn item_defining_module_filename( - name: String, + name: Rc>, registry: Rc>>, - fallback: String, -) -> String { + fallback: Rc>, +) -> Rc> { match lookup_item(registry, name) { Some(info) => module_to_filename(info.module_name.clone()), None => fallback, @@ -3166,7 +3545,7 @@ pub struct ModuleIndex { pub fn build_module_index(modules: Rc>>) -> Rc { { let by_name = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, tm: Rc| { let nm = authored_name_at( tm.type_env.clone().source_indices.clone(), @@ -3179,7 +3558,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc }, ); let by_filename = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |acc: Rc>>>>, tm: Rc| { let fname = module_to_filename(authored_name_at( tm.type_env.clone().source_indices.clone(), @@ -3205,7 +3584,7 @@ pub fn build_module_index(modules: Rc>>) -> Rc } pub fn typed_module_by_name( - module_name: String, + module_name: Rc>, typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, @@ -3214,11 +3593,11 @@ pub fn typed_module_by_name( } pub fn module_name_from_filename( - mod_filename: String, + mod_filename: Rc>, typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, -) -> Option { +) -> Rc> { match v1_rt::map_get(&module_index.by_filename.clone(), mod_filename) { Some(mods) => Rc::new({ let mut __result = Vec::new(); @@ -3234,8 +3613,8 @@ pub fn module_name_from_filename( } pub fn has_physical_type_def_in_module_filename( - rhs_name: String, - mod_filename: String, + rhs_name: Rc>, + mod_filename: Rc>, typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, @@ -3247,11 +3626,14 @@ pub fn has_physical_type_def_in_module_filename( if { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) - && (is_type_def_item(item.clone()) - || is_type_alias_item(item.clone(), source_indices.clone()) - || is_type_decl_item(item.clone(), source_indices.clone()))) + if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + item.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + rhs_name.clone(), + )) && ((is_type_def_item(item.clone()) + || is_type_alias_item(item.clone(), source_indices.clone())) + || is_type_decl_item(item.clone(), source_indices.clone()))) { __found = true; break; @@ -3270,12 +3652,12 @@ pub fn has_physical_type_def_in_module_filename( } pub fn find_variant_parent_in_module( - variant_name: String, - module_name: String, + variant_name: Rc>, + module_name: Rc>, typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, -) -> Option { +) -> Rc> { match typed_module_by_name( module_name, typed_modules, @@ -3302,9 +3684,11 @@ pub fn find_variant_parent_in_module( if { let mut __found = false; for child in item.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), child.clone()).as_str() - == variant_name.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), child.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + )) { __found = true; break; } @@ -3329,8 +3713,8 @@ pub fn find_variant_parent_in_module( } pub fn type_name_is_export_source_in_module( - name: String, - module_name: String, + name: Rc>, + module_name: Rc>, typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, @@ -3345,8 +3729,10 @@ pub fn type_name_is_export_source_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + item.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3361,8 +3747,8 @@ pub fn type_name_is_export_source_in_module( } pub fn type_name_is_rust_importable_in_module( - name: String, - module_name: String, + name: Rc>, + module_name: Rc>, typed_modules: Rc>>, registry: Rc>>, export_sets: Rc>>>, @@ -3379,8 +3765,10 @@ pub fn type_name_is_rust_importable_in_module( Some(tm) => match Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == name.clone().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + item.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -3411,8 +3799,8 @@ pub fn type_name_is_rust_importable_in_module( } pub fn imported_name_is_non_emittable_type( - name: String, - import_module: String, + name: Rc>, + import_module: Rc>, typed_modules: Rc>>, registry: Rc>>, export_sets: Rc>>>, @@ -3450,8 +3838,8 @@ pub fn imported_name_is_non_emittable_type( } pub fn name_in_transitive_export_surface( - name: String, - module_name: String, + name: Rc>, + module_name: Rc>, visited: Rc>, export_sets: Rc>>>, typed_modules: Rc>>, @@ -3462,7 +3850,9 @@ pub fn name_in_transitive_export_surface( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(v.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(module_name.clone())) + { __found = true; break; } @@ -3526,13 +3916,13 @@ pub fn name_in_transitive_export_surface( } pub fn reexport_source_module_name( - name: String, - import_module: String, + name: Rc>, + import_module: Rc>, typed_modules: Rc>>, export_sets: Rc>>>, source_indices: Rc>>, module_index: Rc, -) -> Option { +) -> Rc> { reexport_source_module_name_with_visited( name, import_module, @@ -3545,19 +3935,21 @@ pub fn reexport_source_module_name( } pub fn reexport_source_module_name_with_visited( - mut name: String, - mut import_module: String, + mut name: Rc>, + mut import_module: Rc>, mut visited: Rc>, mut typed_modules: Rc>>, mut export_sets: Rc>>>, mut source_indices: Rc>>, mut module_index: Rc, -) -> Option { +) -> Rc> { loop { if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == import_module.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(v.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(import_module.clone())) + { __found = true; break; } @@ -3585,142 +3977,31 @@ pub fn reexport_source_module_name_with_visited( ) { break Some(import_module.clone()); } else { - match find_variant_parent_in_module( - name.clone(), - import_module.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ) { - Some(_parent) => { - break Some(import_module.clone()); - } - None => { - match Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()).iter().cloned() - { - if ((import_is_all(imp.clone()) == false) && { - let mut __found = false; - for n in import_specific_names_at( - imp.clone(), - source_indices.clone(), - ) - .iter() - .cloned() - { - if (n.clone().as_str() == name.clone().as_str()) - { - __found = true; - break; - } - } - __found - }) { - __result.push(imp); - } - } - __result - }) - .iter() - .cloned() - { - __result.push(authored_name_at( - source_indices.clone(), - imp.clone(), - )); - } - __result - }) - .first() - .cloned() - { - Some(src) => { - let __tco_0 = src.clone(); - let __tco_1 = - v1_rt::concat(visited, Rc::new(vec![import_module])); - import_module = __tco_0; - visited = __tco_1; - continue; - } - None => { - match Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in Rc::new({ - let mut __result = Vec::new(); - for imp in module_imports(tm.module.clone()) - .iter() - .cloned() - { - if import_is_all(imp.clone()) { - __result.push(imp); - } - } - __result - }) - .iter() - .cloned() - { - if { - let src_mod = authored_name_at( - source_indices.clone(), - imp.clone(), - ); - name_in_transitive_export_surface( - name.clone(), - src_mod.clone(), - v1_rt::concat( - visited.clone(), - Rc::new( - vec![import_module.clone()], - ), - ), - export_sets.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ) - } { - __result.push(imp); - } - } - __result - }) - .iter() - .cloned() - { - __result.push(authored_name_at( - source_indices.clone(), - imp.clone(), - )); - } - __result - }) - .first() - .cloned() - { - Some(src) => { - let __tco_0 = src.clone(); - let __tco_1 = v1_rt::concat( - visited, - Rc::new(vec![import_module]), - ); - import_module = __tco_0; - visited = __tco_1; - continue; - } - None => { - break None; - } - } - } - } - } - } + match find_variant_parent_in_module(name.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { + Some(_parent) => { break Some(import_module.clone()); }, + None => { match Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); for imp in module_imports(tm.module.clone()).iter().cloned() { if ((import_is_all(imp.clone()) == false) && { let mut __found = false; for n in import_specific_names_at(imp.clone(), source_indices.clone()).iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { __found = true; break; } } __found }) { __result.push(imp); } } __result }).iter().cloned() { __result.push(authored_name_at(source_indices.clone(), imp.clone())); } __result }).first().cloned() { + Some(src) => { { + let __tco_0 = src.clone(); +let __tco_1 = v1_rt::concat(visited, Rc::new(vec![import_module])); +import_module = __tco_0; +visited = __tco_1; +continue; +} }, + None => { match Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ let mut __result = Vec::new(); for imp in module_imports(tm.module.clone()).iter().cloned() { if import_is_all(imp.clone()) { __result.push(imp); } } __result }).iter().cloned() { if { + let src_mod = authored_name_at(source_indices.clone(), imp.clone()); +name_in_transitive_export_surface(name.clone(), src_mod.clone(), v1_rt::concat(visited.clone(), Rc::new(vec![import_module.clone()])), export_sets.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) +} { __result.push(imp); } } __result }).iter().cloned() { __result.push(authored_name_at(source_indices.clone(), imp.clone())); } __result }).first().cloned() { + Some(src) => { { + let __tco_0 = src.clone(); +let __tco_1 = v1_rt::concat(visited, Rc::new(vec![import_module])); +import_module = __tco_0; +visited = __tco_1; +continue; +} }, + None => { break None; }, +} }, +} }, +} } } } @@ -3729,7 +4010,7 @@ pub fn reexport_source_module_name_with_visited( } pub fn import_module_enum_scope( - import_module: String, + import_module: Rc>, registry: Rc>>, type_summaries: Rc>>, export_sets: Rc>>>, @@ -3786,7 +4067,9 @@ pub fn import_module_enum_scope( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(p.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(p); } } @@ -3799,7 +4082,7 @@ pub fn import_module_enum_scope( } pub fn enum_names_in_module( - module_name: String, + module_name: Rc>, typed_modules: Rc>>, source_indices: Rc>>, type_summaries: Rc>>, @@ -3845,8 +4128,8 @@ pub fn enum_names_in_module( } pub fn enum_physically_defined_in_module( - enum_name: String, - module_name: String, + enum_name: Rc>, + module_name: Rc>, typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, @@ -3861,8 +4144,10 @@ pub fn enum_physically_defined_in_module( Some(tm) => { let mut __found = false; for item in tm.items.clone().iter().cloned() { - if (((authored_name_at(source_indices.clone(), item.clone()).as_str() - == enum_name.clone().as_str()) + if (((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + item.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(enum_name.clone())) && is_type_def_item(item.clone())) && is_coproduct_type(item.clone())) { @@ -3876,7 +4161,7 @@ pub fn enum_physically_defined_in_module( } pub fn wildcard_import_pool_surface_names( - module_name: String, + module_name: Rc>, visited: Rc>, export_sets: Rc>>>, typed_modules: Rc>>, @@ -3887,7 +4172,9 @@ pub fn wildcard_import_pool_surface_names( if { let mut __found = false; for v in visited.clone().iter().cloned() { - if (v.clone().as_str() == module_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(v.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(module_name.clone())) + { __found = true; break; } @@ -3951,7 +4238,7 @@ pub fn wildcard_import_pool_surface_names( } pub fn wildcard_reexport_surface_names( - import_module: String, + import_module: Rc>, export_sets: Rc>>>, typed_modules: Rc>>, source_indices: Rc>>, @@ -3984,7 +4271,12 @@ pub fn wildcard_reexport_surface_names( source_indices.clone(), module_index.clone(), ) { - Some(src) => (src.clone().as_str() != import_module.clone().as_str()), + Some(src) => { + (crate::v2_std_text::host_string_text_to_rust_host(src.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + import_module.clone(), + )) + } None => false, } { __result.push(n); @@ -3996,14 +4288,14 @@ pub fn wildcard_reexport_surface_names( } pub fn graph_type_import_module_filename( - name: String, - import_module: String, - mod_name: String, + name: Rc>, + import_module: Rc>, + mod_name: Rc>, typed_modules: Rc>>, export_sets: Rc>>>, source_indices: Rc>>, module_index: Rc, -) -> String { +) -> Rc> { if has_physical_type_def_in_module_filename( name.clone(), mod_name.clone(), @@ -4028,14 +4320,14 @@ pub fn graph_type_import_module_filename( } pub fn variant_defining_module_filename_for_import( - mut variant_name: String, - mut import_module: String, + mut variant_name: Rc>, + mut import_module: Rc>, mut typed_modules: Rc>>, mut export_sets: Rc>>>, mut source_indices: Rc>>, - mut fallback: String, + mut fallback: Rc>, mut module_index: Rc, -) -> String { +) -> Rc> { loop { match find_variant_parent_in_module( variant_name.clone(), @@ -4057,7 +4349,11 @@ pub fn variant_defining_module_filename_for_import( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != import_module.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(hop.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + import_module.clone(), + )) + { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4077,16 +4373,16 @@ pub fn variant_defining_module_filename_for_import( } pub fn variant_parent_defining_module_filename( - parent_enum: String, - variant_name: String, - import_module: String, + parent_enum: Rc>, + variant_name: Rc>, + import_module: Rc>, typed_modules: Rc>>, export_sets: Rc>>>, source_indices: Rc>>, registry: Rc>>, - fallback: String, + fallback: Rc>, module_index: Rc, -) -> String { +) -> Rc> { match find_variant_parent_in_module( variant_name.clone(), import_module.clone(), @@ -4095,7 +4391,9 @@ pub fn variant_parent_defining_module_filename( module_index.clone(), ) { Some(local_parent) => { - if (local_parent.clone().as_str() == parent_enum.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(local_parent.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(parent_enum.clone())) + { module_to_filename(import_module.clone()) } else { variant_defining_module_filename_for_import( @@ -4122,13 +4420,13 @@ pub fn variant_parent_defining_module_filename( } pub fn explicit_import_source_module_for_name( - name: String, - import_module: String, + name: Rc>, + import_module: Rc>, typed_modules: Rc>>, export_sets: Rc>>>, source_indices: Rc>>, module_index: Rc, -) -> Option { +) -> Rc> { match typed_module_by_name( import_module, typed_modules, @@ -4147,7 +4445,9 @@ pub fn explicit_import_source_module_for_name( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -4218,15 +4518,15 @@ pub fn explicit_import_source_module_for_name( } pub fn reexport_variant_parent_in_import_module( - mut variant_name: String, - mut import_module: String, + mut variant_name: Rc>, + mut import_module: Rc>, mut registry: Rc>>, mut type_summaries: Rc>>, mut typed_modules: Rc>>, mut export_sets: Rc>>>, mut source_indices: Rc>>, mut module_index: Rc, -) -> Option { +) -> Rc> { loop { match reexport_source_module_name( variant_name.clone(), @@ -4260,7 +4560,11 @@ pub fn reexport_variant_parent_in_import_module( module_index.clone(), ) { Some(hop) => { - if (hop.clone().as_str() != src_mod.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(hop.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + src_mod.clone(), + )) + { { let __tco_0 = hop.clone(); import_module = __tco_0; @@ -4282,8 +4586,8 @@ pub fn reexport_variant_parent_in_import_module( } pub fn alias_rhs_rust_qualify_module_filename( - name: String, - alias_module: String, + name: Rc>, + alias_module: Rc>, imports: Rc>>, scope: Rc, registry: Rc>>, @@ -4291,7 +4595,7 @@ pub fn alias_rhs_rust_qualify_module_filename( typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, -) -> String { +) -> Rc> { { let spell_mod = alias_rhs_base_module_filename( name.clone(), @@ -4337,8 +4641,8 @@ pub fn alias_rhs_rust_qualify_module_filename( } pub fn alias_rhs_base_module_filename( - name: String, - alias_module: String, + name: Rc>, + alias_module: Rc>, imports: Rc>>, source_indices: Rc>>, scope: Rc, @@ -4346,12 +4650,13 @@ pub fn alias_rhs_base_module_filename( export_sets: Rc>>>, typed_modules: Rc>>, module_index: Rc, -) -> String { +) -> Rc> { { let local_mod = module_to_filename(alias_module.clone()); match lookup_item(scope.item_registry.clone(), name.clone()) { Some(info) => { - if ((info.module_name.clone().as_str() == alias_module.clone().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(info.module_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(alias_module.clone())) && ((info.kind.clone() == ItemKind::TypeItem) || (info.kind.clone() == ItemKind::OtherItem))) { @@ -4384,15 +4689,15 @@ pub fn alias_rhs_base_module_filename( } pub fn alias_rhs_base_module_from_import_or_registry( - name: String, + name: Rc>, imports: Rc>>, source_indices: Rc>>, registry: Rc>>, - local_mod: String, + local_mod: Rc>, export_sets: Rc>>>, typed_modules: Rc>>, module_index: Rc, -) -> String { +) -> Rc> { match Rc::new({ let mut __result = Vec::new(); for imp in Rc::new({ @@ -4404,7 +4709,9 @@ pub fn alias_rhs_base_module_from_import_or_registry( .iter() .cloned() { - if (n.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -4490,8 +4797,8 @@ pub fn item_generic_param_names( } pub fn type_item_by_name_in_module_filename( - rhs_name: String, - mod_filename: String, + rhs_name: Rc>, + mod_filename: Rc>, typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, @@ -4511,8 +4818,10 @@ pub fn type_item_by_name_in_module_filename( Some(tm) => Rc::new({ let mut __result = Vec::new(); for item in tm.items.clone().iter().cloned() { - if ((authored_name_at(source_indices.clone(), item.clone()).as_str() - == rhs_name.clone().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + item.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(rhs_name.clone())) && ((is_type_def_item(item.clone()) || is_type_alias_item(item.clone(), source_indices.clone())) || is_type_decl_item(item.clone(), source_indices.clone()))) @@ -4532,8 +4841,8 @@ pub fn type_item_by_name_in_module_filename( pub fn type_item_has_rust_nominal_shell_authority( item: Rc, - item_text: String, - module_name: String, + item_text: Rc>, + module_name: Rc>, imports: Rc>>, scope: Rc, registry: Rc>>, @@ -4586,7 +4895,10 @@ pub fn type_item_has_rust_nominal_shell_authority( } } -pub fn is_phantom_unit_variant_type_arg(env: Rc, variant_name: String) -> bool { +pub fn is_phantom_unit_variant_type_arg( + env: Rc, + variant_name: Rc>, +) -> bool { match lookup_unit_variant_phantom_type(env, variant_name) { Some(_) => true, None => false, @@ -4594,9 +4906,9 @@ pub fn is_phantom_unit_variant_type_arg(env: Rc, variant_name: String) } pub fn rhs_base_has_rust_type_authority_in_module( - mut rhs_name: String, - mut def_mod_filename: String, - mut module_name: String, + mut rhs_name: Rc>, + mut def_mod_filename: Rc>, + mut module_name: Rc>, mut imports: Rc>>, mut scope: Rc, mut registry: Rc>>, @@ -4701,7 +5013,7 @@ pub fn rhs_base_has_rust_type_authority_in_module( pub fn alias_rhs_nominal_shell_has_rust_authority( n: Rc, - module_name: String, + module_name: Rc>, imports: Rc>>, scope: Rc, registry: Rc>>, @@ -4770,7 +5082,8 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( } else { { let name = authored_name_at(source_indices.clone(), n.clone()); - if ((name.clone().as_str() == "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) || is_kernel_type(name.clone())) { true @@ -4819,9 +5132,9 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( pub fn is_emittable_parametric_type_alias_item( item: Rc, - item_text: String, + item_text: Rc>, source_indices: Rc>>, - module_name: String, + module_name: Rc>, imports: Rc>>, scope: Rc, registry: Rc>>, @@ -4844,7 +5157,8 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs_name = authored_name_at(source_indices.clone(), rhs.clone()); - (((rhs_name.as_str() != item_text.as_str()) + (((crate::v2_std_text::host_string_text_to_rust_host(rhs_name) + != crate::v2_std_text::host_string_text_to_rust_host(item_text)) && ((rhs.children.clone().len() as i64) > 0)) && alias_rhs_nominal_shell_has_rust_authority( rhs.clone(), @@ -4865,8 +5179,8 @@ pub fn is_emittable_parametric_type_alias_item( } pub fn emit_specific_import_block( - import_module: String, - mod_name: String, + import_module: Rc>, + mod_name: Rc>, filtered_names: Rc>, emit_info: Rc, registry: Rc>>, @@ -4875,7 +5189,7 @@ pub fn emit_specific_import_block( typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, -) -> String { +) -> Rc> { { let type_summaries = emit_info.type_summaries.clone(); let deduped_names = unique_strings(Rc::new({ @@ -4884,7 +5198,9 @@ pub fn emit_specific_import_block( if { let mut __all = true; for ln in local_names.clone().iter().cloned() { - if !(ln.clone().as_str() != n.clone().as_str()) { + if !(crate::v2_std_text::host_string_text_to_rust_host(ln.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(n.clone())) + { __all = false; break; } @@ -5026,7 +5342,9 @@ pub fn emit_specific_import_block( .iter() .cloned() { - if (p.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(p.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(p); } } @@ -5060,7 +5378,13 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => { + (crate::v2_std_text::host_string_text_to_rust_host( + found.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + p.clone(), + )) + } None => false, } { __found = true; @@ -5082,7 +5406,11 @@ pub fn emit_specific_import_block( if { let mut __all = true; for n in direct_names.clone().iter().cloned() { - if !(n.clone().as_str() != p.clone().as_str()) { + if !(crate::v2_std_text::host_string_text_to_rust_host( + n.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + p.clone(), + )) { __all = false; break; } @@ -5107,7 +5435,13 @@ pub fn emit_specific_import_block( source_indices.clone(), module_index.clone(), ) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => { + (crate::v2_std_text::host_string_text_to_rust_host( + found.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + p.clone(), + )) + } None => false, } { __found = true; @@ -5183,18 +5517,19 @@ pub fn emit_specific_import_block( let group = Rc::new({ let mut __result = Vec::new(); for n in type_direct_names.clone().iter().cloned() { - if (graph_type_import_module_filename( - n.clone(), - import_module.clone(), - mod_name.clone(), - typed_modules.clone(), - export_sets.clone(), - source_indices.clone(), - module_index.clone(), - ) - .as_str() - == def_mod.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + graph_type_import_module_filename( + n.clone(), + import_module.clone(), + mod_name.clone(), + typed_modules.clone(), + export_sets.clone(), + source_indices.clone(), + module_index.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + def_mod.clone(), + )) { __result.push(n); } } @@ -5257,91 +5592,55 @@ pub fn emit_specific_import_block( ), mod_name.clone(), ), - "::{".to_string(), - ), - names_str.clone(), - ), - "};".to_string(), - ) - } - } else { - "".to_string() - }; - let direct_lines = v1_rt::concat( - Rc::new({ - let mut __result = Vec::new(); - for l in type_direct_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { - __result.push(l); - } - } - __result - }), - if (other_direct_line.clone().as_str() != "".to_string().as_str()) { - Rc::new(vec![other_direct_line.clone()]) - } else { - Rc::new(vec![]) - }, - ); - let parent_defining_mods = unique_strings(Rc::new({ - let mut __result = Vec::new(); - for p in remote_parent_list.clone().iter().cloned() { - __result.push({ - let rep_variant = Rc::new({ - let mut __result = Vec::new(); - for n in deduped_names.clone().iter().cloned() { - if match find_variant_parent_in_module( - n.clone(), - import_module.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } - None => match reexport_variant_parent_in_import_module( - n.clone(), - import_module.clone(), - registry.clone(), - type_summaries.clone(), - typed_modules.clone(), - export_sets.clone(), - source_indices.clone(), - module_index.clone(), - ) { - Some(found) => { - (found.clone().as_str() == p.clone().as_str()) - } - None => false, - }, - } { - __result.push(n); - } - } - __result - }) - .first() - .cloned(); - match rep_variant.clone() { - Some(v) => variant_parent_defining_module_filename( - p.clone(), - v.clone(), - import_module.clone(), - typed_modules.clone(), - export_sets.clone(), - source_indices.clone(), - registry.clone(), - mod_name.clone(), - module_index.clone(), - ), - None => item_defining_module_filename( - p.clone(), - registry.clone(), - mod_name.clone(), + "::{".to_string(), ), + names_str.clone(), + ), + "};".to_string(), + ) + } + } else { + "".to_string() + }; + let direct_lines = v1_rt::concat( + Rc::new({ + let mut __result = Vec::new(); + for l in type_direct_lines.iter().cloned() { + if (crate::v2_std_text::host_string_text_to_rust_host(l.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) + { + __result.push(l); } - }); + } + __result + }), + if (crate::v2_std_text::host_string_text_to_rust_host( + other_direct_line.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + Rc::new(vec![other_direct_line.clone()]) + } else { + Rc::new(vec![]) + }, + ); + let parent_defining_mods = unique_strings(Rc::new({ + let mut __result = Vec::new(); + for p in remote_parent_list.clone().iter().cloned() { + __result.push({ + let rep_variant = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { + Some(found) => (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) == crate::v2_std_text::host_string_text_to_rust_host(p.clone())), + None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { + Some(found) => (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) == crate::v2_std_text::host_string_text_to_rust_host(p.clone())), + None => false, +}, +} { __result.push(n); } } __result }).first().cloned(); +match rep_variant.clone() { + Some(v) => variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()), + None => item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()), +} +}); } __result })); @@ -5351,15 +5650,15 @@ pub fn emit_specific_import_block( __result.push({ let group = Rc::new({ let mut __result = Vec::new(); for p in remote_parent_list.clone().iter().cloned() { if { let rep_variant = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) == crate::v2_std_text::host_string_text_to_rust_host(p.clone())), None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { - Some(found) => (found.clone().as_str() == p.clone().as_str()), + Some(found) => (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) == crate::v2_std_text::host_string_text_to_rust_host(p.clone())), None => false, }, } { __result.push(n); } } __result }).first().cloned(); match rep_variant.clone() { - Some(v) => (variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()).as_str() == def_mod.clone().as_str()), - None => (item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone()).as_str() == def_mod.clone().as_str()), + Some(v) => (crate::v2_std_text::host_string_text_to_rust_host(variant_parent_defining_module_filename(p.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone())) == crate::v2_std_text::host_string_text_to_rust_host(def_mod.clone())), + None => (crate::v2_std_text::host_string_text_to_rust_host(item_defining_module_filename(p.clone(), registry.clone(), mod_name.clone())) == crate::v2_std_text::host_string_text_to_rust_host(def_mod.clone())), } } { __result.push(p); } } __result }); if ((group.clone().len() as i64) > 0) { @@ -5380,7 +5679,11 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(l.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) + { __result.push(l); } } @@ -5391,7 +5694,11 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in parent_main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(l.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) + { __result.push(l); } } @@ -5402,107 +5709,31 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib let mut __result = Vec::new(); for parent in parent_list.clone().iter().cloned() { __result.push({ - let variants = Rc::new({ - let mut __result = Vec::new(); - for n in deduped_names.clone().iter().cloned() { - if if is_import_graph_type_name( - n.clone(), - import_module.clone(), - typed_modules.clone(), - registry.clone(), - export_sets.clone(), - type_summaries.clone(), - source_indices.clone(), - module_index.clone(), - ) { - false - } else { - if is_enum_in_summaries(type_summaries.clone(), n.clone()) { - false - } else { - match find_variant_parent_in_module( - n.clone(), - import_module.clone(), - typed_modules.clone(), - source_indices.clone(), - module_index.clone(), - ) { - Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) - } - None => { - match reexport_variant_parent_in_import_module( - n.clone(), - import_module.clone(), - registry.clone(), - type_summaries.clone(), - typed_modules.clone(), - export_sets.clone(), - source_indices.clone(), - module_index.clone(), - ) { - Some(found) => { - (found.clone().as_str() - == parent.clone().as_str()) - } - None => match find_variant_parent( - type_summaries.clone(), - n.clone(), - Rc::new(vec![parent.clone()]), - ) { - Some(_) => true, - None => false, - }, - } - } - } - } - } { - __result.push(n); - } - } - __result - }); - let parent_mod = match variants.clone().first().cloned() { - Some(v) => variant_parent_defining_module_filename( - parent.clone(), - v.clone(), - import_module.clone(), - typed_modules.clone(), - export_sets.clone(), - source_indices.clone(), - registry.clone(), - mod_name.clone(), - module_index.clone(), - ), - None => item_defining_module_filename( - parent.clone(), - registry.clone(), - mod_name.clone(), - ), - }; - let vars_str = variants.clone().join(&", ".to_string()); - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "use crate::".to_string(), - parent_mod.clone(), - ), - "::".to_string(), - ), - parent.clone(), - ), - "::{".to_string(), - ), - vars_str.clone(), - ), - "};".to_string(), - ) - }); + let variants = Rc::new({ let mut __result = Vec::new(); for n in deduped_names.clone().iter().cloned() { if if is_import_graph_type_name(n.clone(), import_module.clone(), typed_modules.clone(), registry.clone(), export_sets.clone(), type_summaries.clone(), source_indices.clone(), module_index.clone()) { + false + } else { + if is_enum_in_summaries(type_summaries.clone(), n.clone()) { + false + } else { + match find_variant_parent_in_module(n.clone(), import_module.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { + Some(found) => (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) == crate::v2_std_text::host_string_text_to_rust_host(parent.clone())), + None => match reexport_variant_parent_in_import_module(n.clone(), import_module.clone(), registry.clone(), type_summaries.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), module_index.clone()) { + Some(found) => (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) == crate::v2_std_text::host_string_text_to_rust_host(parent.clone())), + None => match find_variant_parent(type_summaries.clone(), n.clone(), Rc::new(vec![parent.clone()])) { + Some(_) => true, + None => false, +}, +}, +} + } + } { __result.push(n); } } __result }); +let parent_mod = match variants.clone().first().cloned() { + Some(v) => variant_parent_defining_module_filename(parent.clone(), v.clone(), import_module.clone(), typed_modules.clone(), export_sets.clone(), source_indices.clone(), registry.clone(), mod_name.clone(), module_index.clone()), + None => item_defining_module_filename(parent.clone(), registry.clone(), mod_name.clone()), +}; +let vars_str = variants.clone().join(&", ".to_string()); +v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("use crate::".to_string(), parent_mod.clone()), "::".to_string()), parent.clone()), "::{".to_string()), vars_str.clone()), "};".to_string()) +}); } __result }); @@ -5523,7 +5754,11 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib if ({ let mut __found = false; for p in parent_list.clone().iter().cloned() { - if (p.clone().as_str() == en.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + p.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + en.clone(), + )) { __found = true; break; } @@ -5557,7 +5792,11 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in main_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(l.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) + { __result.push(l); } } @@ -5566,7 +5805,11 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib Rc::new({ let mut __result = Vec::new(); for l in variant_lines.iter().cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(l.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) + { __result.push(l); } } @@ -5581,7 +5824,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visib } } -pub fn rust_pub_use_module_name(line: String) -> String { +pub fn rust_pub_use_module_name(line: Rc>) -> Rc> { { let prefix_parts = Rc::new( line.split(&"pub use crate::".to_string()) @@ -5606,7 +5849,7 @@ pub fn rust_pub_use_module_name(line: String) -> String { } } -pub fn rust_pub_use_singleton_name(line: String) -> String { +pub fn rust_pub_use_singleton_name(line: Rc>) -> Rc> { if ((v1_rt::contains(line.clone(), "pub use crate::".to_string()) && !v1_rt::contains(line.clone(), "::{".to_string())) && !v1_rt::contains(line.clone(), "::*;".to_string())) @@ -5651,7 +5894,7 @@ pub fn rust_pub_use_singleton_name(line: String) -> String { } } -pub fn rust_pub_use_braced_names(line: String) -> Rc> { +pub fn rust_pub_use_braced_names(line: Rc>) -> Rc> { if (v1_rt::contains(line.clone(), "pub use crate::".to_string()) && v1_rt::contains(line.clone(), "::{".to_string())) { @@ -5689,8 +5932,13 @@ pub fn rust_pub_use_braced_names(line: String) -> Rc> { } } -pub fn rust_pub_use_braced_line_has_name(line: String, mod_name: String, name: String) -> bool { - (((rust_pub_use_module_name(line.clone()).as_str() == mod_name.as_str()) +pub fn rust_pub_use_braced_line_has_name( + line: Rc>, + mod_name: Rc>, + name: Rc>, +) -> bool { + (((crate::v2_std_text::host_string_text_to_rust_host(rust_pub_use_module_name(line.clone())) + == crate::v2_std_text::host_string_text_to_rust_host(mod_name)) && v1_rt::contains(line.clone(), "::{".to_string())) && (((v1_rt::contains( line.clone(), @@ -5719,12 +5967,14 @@ pub fn rust_pub_use_braced_line_has_name(line: String, mod_name: String, name: S ))) } -pub fn rust_pub_use_singleton_covered(line: String, lines: Rc>) -> bool { +pub fn rust_pub_use_singleton_covered(line: Rc>, lines: Rc>) -> bool { { let mod_name = rust_pub_use_module_name(line.clone()); let name = rust_pub_use_singleton_name(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) - || (name.clone().as_str() == "".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(mod_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) { false } else { @@ -5746,11 +5996,15 @@ pub fn rust_pub_use_singleton_covered(line: String, lines: Rc>) -> b } } -pub fn rust_pub_use_braced_subset_covered(line: String, lines: Rc>) -> bool { +pub fn rust_pub_use_braced_subset_covered( + line: Rc>, + lines: Rc>, +) -> bool { { let mod_name = rust_pub_use_module_name(line.clone()); let names = rust_pub_use_braced_names(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(mod_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) || ((names.clone().len() as i64) == 0)) { false @@ -5758,9 +6012,13 @@ pub fn rust_pub_use_braced_subset_covered(line: String, lines: Rc>) { let mut __found = false; for other in lines.iter().cloned() { - if (((((other.clone().as_str() != line.clone().as_str()) - && (rust_pub_use_module_name(other.clone()).as_str() - == mod_name.clone().as_str())) + if (((((crate::v2_std_text::host_string_text_to_rust_host(other.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(line.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host( + rust_pub_use_module_name(other.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + mod_name.clone(), + ))) && v1_rt::contains(other.clone(), "::{".to_string())) && ((rust_pub_use_braced_names(other.clone()).len() as i64) > (names.clone().len() as i64))) @@ -5795,11 +6053,15 @@ pub struct BracedImportCoverAccum { pub covered: bool, } -pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>) -> bool { +pub fn rust_pub_use_braced_equal_prior_covered( + line: Rc>, + lines: Rc>, +) -> bool { { let mod_name = rust_pub_use_module_name(line.clone()); let names = rust_pub_use_braced_names(line.clone()); - if ((mod_name.clone().as_str() == "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(mod_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) || ((names.clone().len() as i64) == 0)) { false @@ -5810,11 +6072,13 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>| { if (inner.found_current.clone() || inner.covered.clone()) { inner.clone() } else { - if (other.clone().as_str() == line.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(other.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(line.clone())) + { BracedImportCoverAccum { found_current: true, covered: inner.covered.clone(), @@ -5823,8 +6087,11 @@ pub fn rust_pub_use_braced_equal_prior_covered(line: String, lines: Rc>) -> Rc> { let exact = unique_strings(Rc::new({ let mut __result = Vec::new(); for line in lines.iter().cloned() { - if (line.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(line.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(line); } } @@ -5893,7 +6162,7 @@ pub fn emit_imports( typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, -) -> String { +) -> Rc> { if ((imports.clone().len() as i64) == 0) { "".to_string() } else { @@ -5913,10 +6182,11 @@ pub fn emit_imports( let mod_imports = Rc::new({ let mut __result = Vec::new(); for imp in imports.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), imp.clone()) - .as_str() - == import_module.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), imp.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + import_module.clone(), + )) { __result.push(imp); } } @@ -5985,8 +6255,11 @@ pub fn emit_imports( source_indices.clone(), module_index.clone(), ); - if (specific_block.clone().as_str() != "".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + specific_block.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { v1_rt::concat( v1_rt::concat(wildcard_line.clone(), "\n".to_string()), specific_block.clone(), @@ -6045,7 +6318,7 @@ pub fn emit_imports( } } -pub fn emit_prelude() -> String { +pub fn emit_prelude() -> Rc> { { let use_line = v1_rt::concat( v1_rt::concat( @@ -6068,7 +6341,7 @@ pub fn emit_prelude() -> String { } } -pub fn emit_non_empty_wrappers() -> String { +pub fn emit_non_empty_wrappers() -> Rc> { { let vec_wrapper = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Debug, Clone, PartialEq)]\n".to_string(), "pub struct NonEmptyVec(Vec);\n\n".to_string()), "impl NonEmptyVec {\n".to_string()), " pub fn new(items: Vec) -> Result {\n".to_string()), " if items.is_empty() {\n".to_string()), " Err(\"NonEmptyVec requires at least one element\")\n".to_string()), " } else {\n".to_string()), " Ok(Self(items))\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " pub fn as_slice(&self) -> &[T] {\n".to_string()), " &self.0\n".to_string()), " }\n\n".to_string()), " pub fn into_vec(self) -> Vec {\n".to_string()), " self.0\n".to_string()), " }\n".to_string()), "}".to_string()); let set_wrapper = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Debug, Clone, PartialEq)]\n".to_string(), "pub struct NonEmptyBTreeSet(std::collections::BTreeSet);\n\n".to_string()), "impl NonEmptyBTreeSet {\n".to_string()), " pub fn new(items: std::collections::BTreeSet) -> Result {\n".to_string()), " if items.is_empty() {\n".to_string()), " Err(\"NonEmptyBTreeSet requires at least one element\")\n".to_string()), " } else {\n".to_string()), " Ok(Self(items))\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " pub fn as_set(&self) -> &std::collections::BTreeSet {\n".to_string()), " &self.0\n".to_string()), " }\n\n".to_string()), " pub fn into_set(self) -> std::collections::BTreeSet {\n".to_string()), " self.0\n".to_string()), " }\n".to_string()), "}".to_string()); @@ -6078,7 +6351,7 @@ pub fn emit_non_empty_wrappers() -> String { pub fn emit_typed_item( item: Rc, - module_name: String, + module_name: Rc>, registry: Rc>>, scope: Rc, shared_types: Rc>, @@ -6090,7 +6363,7 @@ pub fn emit_typed_item( export_sets: Rc>>>, typed_modules: Rc>>, module_index: Rc, -) -> String { +) -> Rc> { { let env = scope.type_env.clone(); let qualified_name = v1_rt::concat( @@ -6348,8 +6621,10 @@ pub fn needs_box_wrapping( if v1_rt::set_contains(&shared_types, name.clone()) { break false; } else { - if (coerce_primitive_type(RenderTarget::Rust, name.clone()).as_str() - != name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(coerce_primitive_type( + RenderTarget::Rust, + name.clone(), + )) != crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { break false; } else { @@ -6374,7 +6649,7 @@ pub fn needs_box_wrapping( pub fn emit_type_params( params: Rc>>, source_indices: Rc>>, -) -> String { +) -> Rc> { if ((params.clone().len() as i64) == 0) { "".to_string() } else { @@ -6401,12 +6676,17 @@ pub fn is_function_type_param(param: Rc) -> bool { Some(inf) => is_type_variable(inf.clone()), None => false, }; - let same_source_span = (((param.span.clone().file.clone().as_str() - == type_expr.span.clone().file.clone().as_str()) - && (param.span.clone().start.clone() == type_expr.span.clone().start.clone())) + let same_source_span = (((crate::v2_std_text::host_string_text_to_rust_host( + param.span.clone().file.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + type_expr.span.clone().file.clone(), + )) && (param.span.clone().start.clone() + == type_expr.span.clone().start.clone())) && (param.span.clone().end.clone() == type_expr.span.clone().end.clone())); - (((param.name.clone().as_str() != "".to_string().as_str()) - && (param.name.clone().as_str() == type_expr.name.clone().as_str())) + (((crate::v2_std_text::host_string_text_to_rust_host(param.name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(param.name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(type_expr.name.clone()))) && (type_expr_is_var || same_source_span)) } } @@ -6458,7 +6738,7 @@ pub fn emit_type_def_from_connective( data_items: Rc>>>>, module_items: Rc>>, imports: Rc>>, -) -> String { +) -> Rc> { { let type_params = emit_type_params(item.params.clone(), env.source_indices.clone()); let item_text = authored_name(env.clone(), item.clone()); @@ -6527,11 +6807,17 @@ pub fn emit_type_def_from_connective( Some(message) => emit_rust_compile_error_item(message.clone()), None => "".to_string(), }; - let validations = if (policy_validation.clone().as_str() == "".to_string().as_str()) - { + let validations = if (crate::v2_std_text::host_string_text_to_rust_host( + policy_validation.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { rename_validations.clone() } else { - if (rename_validations.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + rename_validations.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { policy_validation.clone() } else { v1_rt::concat( @@ -6558,7 +6844,9 @@ pub fn emit_type_def_from_connective( serde_policy.clone(), emit_info, ); - if (validations.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(validations.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { enum_text } else { v1_rt::concat( @@ -6572,15 +6860,15 @@ pub fn emit_type_def_from_connective( } pub fn emit_struct_from_children( - name: String, - type_params: String, + name: Rc>, + type_params: Rc>, generic_param_names: Rc>, children: Rc>>, recursive_types: Rc>, shared_types: Rc>, env: Rc, emit_info: Rc, -) -> String { +) -> Rc> { { let has_fn_fields = match v1_rt::map_get(&emit_info.type_summaries.clone(), name.clone()) { Some(ts) => ts.has_fn_fields.clone(), @@ -6589,13 +6877,13 @@ pub fn emit_struct_from_children( let derives = if has_fn_fields { "#[derive(Clone)]".to_string() } else { - if (rust_nominal_ord_derives_for_shape( - name.clone(), - children.clone(), - env.source_indices.clone(), - ) - .as_str() - != "".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host( + rust_nominal_ord_derives_for_shape( + name.clone(), + children.clone(), + env.source_indices.clone(), + ), + ) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { rust_nominal_ord_derives_for_shape( name.clone(), @@ -6682,7 +6970,7 @@ pub fn render_rust_type_with_applied_binding( n: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match find_property( n.properties.clone(), "__applied_type_args".to_string(), @@ -6690,25 +6978,42 @@ pub fn render_rust_type_with_applied_binding( ) { Some(applied) => { if ((applied.children.clone().len() as i64) > 0) { - let outer_name = authored_name_at(source_indices.clone(), n.clone()); - let applied_name = authored_name_at(source_indices.clone(), applied.clone()); - if outer_name.as_str() != "" - && outer_name != applied_name - && n.connective.clone() == Connective::NoConnective - && (n.children.clone().len() as i64) == 0 { - render_rust_shared_type_if_needed( - outer_name.clone(), - outer_name, - shared_types.clone(), - ) - } else { - render_rust_applied_type_shared( - applied.clone(), - Rc::new(vec![]), - shared_types, - source_indices.clone(), - ) + let outer_name = authored_name_at(source_indices.clone(), n.clone()); + let applied_name = authored_name_at(source_indices.clone(), applied.clone()); + if ((((crate::v2_std_text::host_string_text_to_rust_host(outer_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host( + outer_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host(applied_name))) + && (n.connective.clone() == Connective::NoConnective)) + && ((n.children.clone().len() as i64) == 0)) + { + render_rust_shared_type_if_needed( + outer_name.clone(), + outer_name.clone(), + shared_types, + ) + } else { + render_rust_applied_type_shared( + applied.clone(), + Rc::new(vec![]), + shared_types, + source_indices.clone(), + v1_rt::rc_empty_map::>, Rc>>(), + Rc::new(TypeEnv { + bindings: v1_rt::rc_empty_map::>(), + recursive_types: Rc::new(vec![]), + recursive_type_set: v1_rt::rc_empty_map::(), + inductive_fields: v1_rt::rc_empty_map::< + Rc>, + Rc>>, + >(), + source_indices: source_indices.clone(), + intern_table: empty_intern_table(), + }), + ) + } } } else { render_rust_type(n.clone(), shared_types, source_indices.clone()) @@ -6722,7 +7027,7 @@ pub fn render_rust_field_type_with_applied_binding( field: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let authored_type = field_node_type_expr(field.clone()); if (find_property( @@ -6766,14 +7071,14 @@ pub fn render_rust_field_type_with_applied_binding( } pub fn emit_struct_field_from_child( - struct_name: String, + struct_name: Rc>, child: Rc, generic_param_names: Rc>, recursive_types: Rc>, shared_types: Rc>, env: Rc, emit_info: Rc, -) -> String { +) -> Rc> { { let rt_child = resolved_type(child.clone()); let authored_child_type = field_node_type_expr(child.clone()); @@ -6886,7 +7191,9 @@ pub fn emit_struct_field_from_child( } } }; - let generic_ty = if (struct_name.as_str() == "PartialFunction".to_string().as_str()) { + let generic_ty = if (crate::v2_std_text::host_string_text_to_rust_host(struct_name) + == crate::v2_std_text::host_string_text_to_rust_host("PartialFunction".to_string())) + { rust_normalize_partial_function_field_type_text(rust_normalize_witness_type_text(ty)) } else { ty @@ -6917,8 +7224,10 @@ pub fn emit_struct_field_from_child( let rename_attr = match Rc::new({ let mut __result = Vec::new(); for p in child.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), env.source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + p.clone(), + env.source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("from_key".to_string())) { __result.push(p); } @@ -6954,28 +7263,31 @@ pub fn emit_struct_field_from_child( } pub fn emit_rust_field_definition( - authored: String, - final_ty: String, - rename_attr: String, - indent: String, - visibility: String, -) -> String { + authored: Rc>, + final_ty: Rc>, + rename_attr: Rc>, + indent: Rc>, + visibility: Rc>, +) -> Rc> { { let snake = to_snake(authored.clone()); let emitted = emit_ident(authored.clone(), RenderTarget::Rust); - let keyword_rename = if ((emitted.clone().as_str() != snake.clone().as_str()) - && (rename_attr.clone().as_str() == "".to_string().as_str())) - { - v1_rt::concat( + let keyword_rename = + if ((crate::v2_std_text::host_string_text_to_rust_host(emitted.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(snake.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host(rename_attr.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + { v1_rt::concat( - v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), - snake.clone(), - ), - "\")]\n".to_string(), - ) - } else { - "".to_string() - }; + v1_rt::concat( + v1_rt::concat(indent.clone(), "#[serde(rename = \"".to_string()), + snake.clone(), + ), + "\")]\n".to_string(), + ) + } else { + "".to_string() + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -6998,7 +7310,7 @@ pub fn emit_rust_field_definition( } } -pub fn enum_derives(name: String, children: Rc>>) -> String { +pub fn enum_derives(name: Rc>, children: Rc>>) -> Rc> { { let complex = Rc::new({ let mut __result = Vec::new(); @@ -7017,8 +7329,8 @@ pub fn enum_derives(name: String, children: Rc>>) -> String { } pub fn emit_enum_from_children( - name: String, - type_params: String, + name: Rc>, + type_params: Rc>, generic_param_names: Rc>, children: Rc>>, recursive_types: Rc>, @@ -7026,7 +7338,7 @@ pub fn emit_enum_from_children( env: Rc, serde_policy: Rc, emit_info: Rc, -) -> String { +) -> Rc> { { let derives = enum_derives(name.clone(), children.clone()); let variant_lines = Rc::new({ @@ -7045,11 +7357,14 @@ pub fn emit_enum_from_children( __result }); let variants_str = variant_lines.join(&"\n".to_string()); - let tag_line = if (serde_policy.enum_attr.clone().as_str() == "".to_string().as_str()) { - "".to_string() - } else { - v1_rt::concat(serde_policy.enum_attr.clone(), "\n".to_string()) - }; + let tag_line = + if (crate::v2_std_text::host_string_text_to_rust_host(serde_policy.enum_attr.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + "".to_string() + } else { + v1_rt::concat(serde_policy.enum_attr.clone(), "\n".to_string()) + }; let enum_def = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7087,7 +7402,9 @@ pub fn emit_enum_from_children( env.clone(), emit_info.clone(), ); - if (accessor_impl.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(accessor_impl.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { enum_def } else { v1_rt::concat( @@ -7136,9 +7453,11 @@ pub fn find_shared_enum_fields(children: Rc>>, env: Rc) -> if !({ let mut __found = false; for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name(env.clone(), f.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + )) { __found = true; break; } @@ -7160,14 +7479,14 @@ pub fn find_shared_enum_fields(children: Rc>>, env: Rc) -> } pub fn emit_enum_shared_accessors( - name: String, - type_params: String, + name: Rc>, + type_params: Rc>, children: Rc>>, recursive_types: Rc>, shared_types: Rc>, env: Rc, emit_info: Rc, -) -> String { +) -> Rc> { { let all_shared = find_shared_enum_fields(children.clone(), env.clone()); if ((all_shared.clone().len() as i64) == 0) { @@ -7202,9 +7521,11 @@ pub fn emit_enum_shared_accessors( match Rc::new({ let mut __result = Vec::new(); for f in variant.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name(env.clone(), f.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + )) { __result.push(f); } } @@ -7231,7 +7552,11 @@ pub fn emit_enum_shared_accessors( { let mut __all = true; for t in types.clone().iter().cloned() { - if !(t.clone().as_str() == first_type.clone().as_str()) { + if !(crate::v2_std_text::host_string_text_to_rust_host(t.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + first_type.clone(), + )) + { __all = false; break; } @@ -7254,9 +7579,12 @@ pub fn emit_enum_shared_accessors( let ty = match Rc::new({ let mut __result = Vec::new(); for f in first_fielded.children.clone().iter().cloned() { - if (authored_name(env.clone(), f.clone()).as_str() - == fname.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name( + env.clone(), + f.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + )) { __result.push(f); } } @@ -7408,13 +7736,19 @@ pub fn emit_enum_shared_accessors( } } -pub fn string_without_prefix(value: String, prefix: String) -> Option { +pub fn string_without_prefix( + value: Rc>, + prefix: Rc>, +) -> Rc> { if (v1_rt::string_length(&prefix) == 0) { None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&prefix)) - && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)).as_str() - == prefix.clone().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( + &value, + 0, + v1_rt::string_length(&prefix), + )) == crate::v2_std_text::host_string_text_to_rust_host(prefix.clone()))) { Some(v1_rt::substring( &value, @@ -7427,18 +7761,19 @@ pub fn string_without_prefix(value: String, prefix: String) -> Option { } } -pub fn string_without_suffix(value: String, suffix: String) -> Option { +pub fn string_without_suffix( + value: Rc>, + suffix: Rc>, +) -> Rc> { if (v1_rt::string_length(&suffix) == 0) { None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&suffix)) - && (v1_rt::substring( + && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( &value, (v1_rt::string_length(&value) - v1_rt::string_length(&suffix)), v1_rt::string_length(&value), - ) - .as_str() - == suffix.clone().as_str())) + )) == crate::v2_std_text::host_string_text_to_rust_host(suffix.clone()))) { Some(v1_rt::substring( &value, @@ -7451,79 +7786,146 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { } } -pub fn wire_variant_tag_for_policy( - authored: String, - policy: Rc, -) -> Option { - if policy.error_message.is_some() { - return None; - } - match policy.rename_style.clone() { - Some(style) => { - if style.as_str() == "StripAffixAndSnakeCase" { - let without_prefix = match policy.rename_prefix.clone() { - Some(prefix) => match string_without_prefix(authored, prefix) { - Some(stripped) => stripped, - None => return None, - }, - None => authored, - }; - let without_suffix = match policy.rename_suffix.clone() { - Some(suffix) => match string_without_suffix(without_prefix, suffix) { - Some(stripped) => stripped, - None => return None, - }, - None => without_prefix, - }; - Some(to_snake(without_suffix)) - } else { - None - } - } - None => { - if policy.enum_attr.contains("rename_all = \"snake_case\"") { - Some(to_snake(authored)) - } else if policy.enum_attr.is_empty() - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - { - Some(authored) - } else { - None +pub fn string_index_of_from( + mut haystack: Rc>, + mut needle: Rc>, + mut pos: i64, +) -> Option { + loop { + if ((pos.clone() + v1_rt::string_length(&needle)) > v1_rt::string_length(&haystack)) { + break None; + } else { + if (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( + &haystack, + pos.clone(), + (pos.clone() + v1_rt::string_length(&needle)), + )) == crate::v2_std_text::host_string_text_to_rust_host(needle.clone())) + { + break Some(pos.clone()); + } else { + { + let __tco_0 = (pos + 1); + pos = __tco_0; + continue; + } + } + } + } +} + +pub fn string_index_of(haystack: Rc>, needle: Rc>) -> Option { + string_index_of_from(haystack, needle, 0) +} + +pub fn wire_variant_tag_for_policy( + authored: Rc>, + policy: Rc, +) -> Rc> { + if (policy.error_message.clone() != None) { + None + } else { + match policy.rename_style.clone() { + Some(style) => { + if (crate::v2_std_text::host_string_text_to_rust_host(style.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "StripAffixAndSnakeCase".to_string(), + )) + { + { + let without_prefix = match policy.rename_prefix.clone() { + Some(prefix) => match string_without_prefix(authored, prefix.clone()) { + Some(stripped) => stripped.clone(), + None => return None, + }, + None => authored, + }; + let without_suffix = match policy.rename_suffix.clone() { + Some(suffix) => { + match string_without_suffix(without_prefix, suffix.clone()) { + Some(stripped) => stripped.clone(), + None => return None, + } + } + None => without_prefix, + }; + Some(to_snake(without_suffix)) + } + } else { + None + } + } + None => { + if v1_rt::contains( + policy.enum_attr.clone(), + "rename_all = \"snake_case\"".to_string(), + ) { + Some(to_snake(authored)) + } else { + if (((crate::v2_std_text::host_string_text_to_rust_host( + policy.enum_attr.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + { + Some(authored) + } else { + None + } + } + } + } + } +} + +pub fn policy_serde_tag_field(policy: Rc) -> Rc> { + { + let needle = "tag = \"".to_string(); + match string_index_of(policy.enum_attr.clone(), needle.clone()) { + Some(start) => { + let after = (start.clone() + v1_rt::string_length(&needle)); + match string_index_of_from( + policy.enum_attr.clone(), + "\"".to_string(), + after.clone(), + ) { + Some(end) => Some(v1_rt::substring( + &policy.enum_attr.clone(), + after.clone(), + end.clone(), + )), + None => None, + } } + None => None, } } } -pub fn policy_serde_tag_field(policy: &RustEnumWireSerde) -> Option { - let needle = "tag = \""; - let start = policy.enum_attr.find(needle)? + needle.len(); - let rest = &policy.enum_attr[start..]; - let end = rest.find('"')?; - Some(rest[..end].to_string()) +pub fn policy_is_untagged(policy: Rc) -> bool { + v1_rt::contains(policy.enum_attr.clone(), "untagged".to_string()) } -pub fn policy_is_untagged(policy: &RustEnumWireSerde) -> bool { - policy.enum_attr.contains("untagged") -} - -pub fn policy_is_string_variant(policy: &RustEnumWireSerde) -> bool { - !policy.enum_attr.contains("tag =") - && policy.rename_prefix.is_none() - && policy.rename_suffix.is_none() - && policy.rename_style.is_none() +pub fn policy_is_string_variant(policy: Rc) -> bool { + (((!v1_rt::contains(policy.enum_attr.clone(), "tag =".to_string()) + && (policy.rename_prefix.clone() == None)) + && (policy.rename_suffix.clone() == None)) + && (policy.rename_style.clone() == None)) } pub fn wire_variant_rename_attr_for_policy( - authored: String, + authored: Rc>, policy: Rc, -) -> String { +) -> Rc> { match wire_variant_tag_for_policy(authored, policy.clone()) { Some(tag) => match policy.rename_style.clone() { Some(style) => { - if style.as_str() == "StripAffixAndSnakeCase" { + if (crate::v2_std_text::host_string_text_to_rust_host(style.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "StripAffixAndSnakeCase".to_string(), + )) + { v1_rt::concat( - v1_rt::concat(" #[serde(rename = \"".to_string(), tag), + v1_rt::concat(" #[serde(rename = \"".to_string(), tag.clone()), "\")]\n".to_string(), ) } else { @@ -7537,12 +7939,16 @@ pub fn wire_variant_rename_attr_for_policy( } pub fn variant_rename_validation_for_policy( - authored: String, + authored: Rc>, policy: Rc, -) -> String { +) -> Rc> { match policy.rename_style.clone() { Some(style) => { - if (style.clone().as_str() == "StripAffixAndSnakeCase".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(style.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "StripAffixAndSnakeCase".to_string(), + )) + { { let without_prefix = match policy.rename_prefix.clone() { Some(prefix) => { @@ -7589,7 +7995,7 @@ pub fn variant_rename_validations_for_policy( children: Rc>>, env: Rc, serde_policy: Rc, -) -> String { +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for text in Rc::new({ @@ -7605,7 +8011,9 @@ pub fn variant_rename_validations_for_policy( .iter() .cloned() { - if (text.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(text.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(text); } } @@ -7616,9 +8024,9 @@ pub fn variant_rename_validations_for_policy( pub fn enum_variant_field_type_node( env: Rc, - enum_name: String, - variant_name: String, - field_name: String, + enum_name: Rc>, + variant_name: Rc>, + field_name: Rc>, fallback: Rc, source_indices: Rc>>, ) -> Rc { @@ -7648,7 +8056,7 @@ pub fn render_variant_payload_type( n: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) { @@ -7691,7 +8099,10 @@ pub fn variant_is_synthetic_positional_payload( } else { match fields.clone().first().cloned() { Some(f) => { - (field_node_name_at(f.clone(), source_indices).as_str() == "0".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(field_node_name_at( + f.clone(), + source_indices, + )) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) } None => false, } @@ -7700,13 +8111,13 @@ pub fn variant_is_synthetic_positional_payload( pub fn emit_variant_from_child( child: Rc, - enum_name: String, + enum_name: Rc>, recursive_types: Rc>, shared_types: Rc>, env: Rc, serde_policy: Rc, emit_info: Rc, -) -> String { +) -> Rc> { { let child_text = authored_name(env.clone(), child.clone()); let rename_attr = @@ -7727,8 +8138,11 @@ pub fn emit_variant_from_child( env.source_indices.clone(), ); let tuple_style = (positional_payload.clone() - || (serde_policy.enum_attr.clone().as_str() - == "#[serde(untagged)]".to_string().as_str())); + || (crate::v2_std_text::host_string_text_to_rust_host( + serde_policy.enum_attr.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "#[serde(untagged)]".to_string(), + ))); if tuple_style { match child.children.clone().first().cloned() { Some(f) => { @@ -7917,7 +8331,7 @@ pub fn emit_variant_from_child( } pub fn emit_fn_def( - name: String, + name: Rc>, params: Rc>>, inferred: Rc, body: Rc, @@ -7925,67 +8339,68 @@ pub fn emit_fn_def( scope: Rc, shared_types: Rc>, emit_info: Rc, -) -> String { - if let Some(seam_fn) = rust_host_string_seam_fn_emit(name.clone()) { - return seam_fn; - } - { - let si = scope.type_env.clone().source_indices.clone(); - let type_params = function_type_params(params.clone()); - let value_params = function_value_params(params.clone()); - if function_type_params_have_collision(type_params.clone()) { - return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); - } - let type_params_str = emit_type_params(type_params.clone(), si.clone()); - let generic_param_names = Rc::new({ - let mut __result = Vec::new(); - for p in type_params.clone().iter().cloned() { - __result.push(generic_param_name_at(p.clone(), si.clone())); - } - __result - }); - let params_str = emit_params( - value_params.clone(), - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - emit_info.read_only_params.clone(), - scope.type_env.clone(), - ); - let ret_str = emit_inferred( - inferred, - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - scope.type_env.clone(), - ); - let body_scope = build_params_scope(scope.clone(), value_params.clone()); - let depth = 0; - let use_tco = is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); - let needs_stacker = - (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) - && (use_tco.clone() == false)); - if use_tco.clone() { - { - let tco_params_str = emit_tco_params( - value_params.clone(), - generic_param_names.clone(), - shared_types.clone(), - si.clone(), - scope.type_env.clone(), - ); - let body_str = emit_typed_tco_body( - body.clone(), - name.clone(), - value_params.clone(), - registry.clone(), - body_scope, - (depth.clone() + 1), - shared_types.clone(), - emit_info.clone(), - ); - let kw = rust_items().func_keyword.clone(); - v1_rt::concat( +) -> Rc> { + match rust_host_string_seam_fn_emit(name.clone()) { + Some(seam_fn) => seam_fn.clone(), + None => { + let si = scope.type_env.clone().source_indices.clone(); + let type_params = function_type_params(params.clone()); + let value_params = function_value_params(params.clone()); + if function_type_params_have_collision(type_params.clone()) { + return v1_rt::concat(v1_rt::concat("compile_error!(\"type param name collides with a value param in fn '".to_string(), name.clone()), "' — a value param shares its name with a declared type param; rename the value param or dissolve via ParamKind/params-slot partition\");\n".to_string()); + } + let type_params_str = emit_type_params(type_params.clone(), si.clone()); + let generic_param_names = Rc::new({ + let mut __result = Vec::new(); + for p in type_params.clone().iter().cloned() { + __result.push(generic_param_name_at(p.clone(), si.clone())); + } + __result + }); + let params_str = emit_params( + value_params.clone(), + generic_param_names.clone(), + shared_types.clone(), + si.clone(), + emit_info.read_only_params.clone(), + emit_info.variant_to_enum.clone(), + scope.type_env.clone(), + ); + let ret_str = emit_inferred( + inferred, + generic_param_names.clone(), + shared_types.clone(), + si.clone(), + emit_info.variant_to_enum.clone(), + scope.type_env.clone(), + ); + let body_scope = build_params_scope(scope.clone(), value_params.clone()); + let depth = 0; + let use_tco = is_tco_eligible(name.clone(), body.clone(), registry.clone(), si.clone()); + let needs_stacker = + (is_self_recursive(name.clone(), body.clone(), registry.clone(), si.clone()) + && (use_tco.clone() == false)); + if use_tco.clone() { + { + let tco_params_str = emit_tco_params( + value_params.clone(), + generic_param_names.clone(), + shared_types.clone(), + si.clone(), + emit_info.variant_to_enum.clone(), + scope.type_env.clone(), + ); + let body_str = emit_typed_tco_body( + body.clone(), + name.clone(), + value_params.clone(), + registry.clone(), + body_scope, + (depth.clone() + 1), + shared_types.clone(), + emit_info.clone(), + ); + let kw = rust_items().func_keyword.clone(); v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -7997,58 +8412,60 @@ pub fn emit_fn_def( v1_rt::concat( v1_rt::concat( v1_rt::concat( - rust_visibility_prefix(), - kw, + v1_rt::concat( + rust_visibility_prefix(), + kw, + ), + " ".to_string(), + ), + emit_ident( + name.clone(), + RenderTarget::Rust, ), - " ".to_string(), - ), - emit_ident( - name.clone(), - RenderTarget::Rust, ), + type_params_str, ), - type_params_str, + "(".to_string(), ), - "(".to_string(), + tco_params_str, ), - tco_params_str, + ")".to_string(), ), - ")".to_string(), + ret_str, ), - ret_str, + " {\n".to_string(), ), - " {\n".to_string(), + make_indent((depth.clone() + 1)), ), - make_indent((depth.clone() + 1)), + body_str, ), - body_str, - ), - "\n}".to_string(), + "\n}".to_string(), + ) + } + } else { + emit_fn_def_non_tco( + name.clone(), + type_params_str, + params_str, + ret_str, + body.clone(), + registry.clone(), + body_scope, + depth.clone(), + shared_types.clone(), + emit_info.clone(), + needs_stacker, ) } - } else { - emit_fn_def_non_tco( - name.clone(), - type_params_str, - params_str, - ret_str, - body.clone(), - registry.clone(), - body_scope, - depth.clone(), - shared_types.clone(), - emit_info.clone(), - needs_stacker, - ) } } } pub fn emit_fn_def_non_tco( - name: String, - type_params_str: String, - params_str: String, - ret_str: String, + name: Rc>, + type_params_str: Rc>, + params_str: Rc>, + ret_str: Rc>, body: Rc, registry: Rc>>, scope: Rc, @@ -8056,7 +8473,7 @@ pub fn emit_fn_def_non_tco( shared_types: Rc>, emit_info: Rc, needs_stacker: bool, -) -> String { +) -> Rc> { if needs_stacker { { let body_str = emit_typed_expr( @@ -8175,7 +8592,7 @@ pub fn emit_fn_def_non_tco( } pub fn emit_func_def( - name: String, + name: Rc>, params: Rc>>, inferred: Rc, uses: Rc>>, @@ -8184,7 +8601,7 @@ pub fn emit_func_def( scope: Rc, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { if ((function_type_params(params.clone()).len() as i64) > 0) { return v1_rt::concat(v1_rt::concat("compile_error!(\"emit_func_def saw type params in `".to_string(), name.clone()), "` — func/pattern/interface don't route through the generic-fn split today; the parser invariant at parse_block_body_from_prefix has changed. Plumb type_params through this path or dissolve via ParamKind/params-slot partition.\");\n".to_string()); @@ -8201,6 +8618,7 @@ pub fn emit_func_def( shared_types.clone(), scope.type_env.clone().source_indices.clone(), emit_info.read_only_params.clone(), + emit_info.variant_to_enum.clone(), scope.type_env.clone(), ); let ret_str = emit_func_inferred( @@ -8277,7 +8695,7 @@ pub fn emit_func_body( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let si = scope.type_env.clone().source_indices.clone(); match (*body.expr_data.clone()).clone() { @@ -8420,8 +8838,9 @@ pub fn emit_tco_params( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { { let strs = Rc::new({ let mut __result = Vec::new(); @@ -8431,6 +8850,7 @@ pub fn emit_tco_params( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8445,8 +8865,9 @@ pub fn emit_tco_param( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { { let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { @@ -8455,7 +8876,8 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( @@ -8463,6 +8885,7 @@ pub fn emit_tco_param( generic_param_names, shared_types, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8489,8 +8912,9 @@ pub fn emit_func_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { { let param_strs = Rc::new({ let mut __result = Vec::new(); @@ -8501,6 +8925,7 @@ pub fn emit_func_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8545,7 +8970,7 @@ pub fn emit_func_inferred( inferred: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { v1_rt::concat( v1_rt::concat( " -> Result<".to_string(), @@ -8561,8 +8986,9 @@ pub fn emit_params( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { { let strs = Rc::new({ let mut __result = Vec::new(); @@ -8573,6 +8999,7 @@ pub fn emit_params( shared_types.clone(), source_indices.clone(), read_only_params.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8587,15 +9014,17 @@ pub fn render_rust_param_sig_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { { - let type_node = resolved_type(param.clone()); + let type_node = resolved_type(param); render_rust_fn_sig_type( type_node, generic_param_names, shared_types, source_indices, + variant_to_enum, env, ) } @@ -8606,8 +9035,9 @@ pub fn emit_rust_param_type( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { if ((n.params.clone().len() as i64) > 0) { { let param_types = Rc::new({ @@ -8618,6 +9048,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), )); } @@ -8630,6 +9061,7 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), + variant_to_enum.clone(), env.clone(), ), _ => "()".to_string(), @@ -8651,7 +9083,8 @@ pub fn emit_rust_param_type( generic_param_names.clone(), shared_types.clone(), source_indices.clone(), - env, + variant_to_enum.clone(), + env.clone(), ) } } @@ -8662,8 +9095,9 @@ pub fn emit_param( shared_types: Rc>, source_indices: Rc>>, read_only_params: Rc>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { { let authored = param_node_type_expr(param.clone()); let ty = if ((authored.params.clone().len() as i64) > 0) { @@ -8672,7 +9106,8 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), - env.clone(), + variant_to_enum, + env, ) } else { render_rust_param_sig_type( @@ -8680,6 +9115,7 @@ pub fn emit_param( generic_param_names, shared_types, source_indices.clone(), + variant_to_enum, env, ) }; @@ -8699,8 +9135,9 @@ pub fn emit_inferred( generic_param_names: Rc>, shared_types: Rc>, source_indices: Rc>>, + variant_to_enum: Rc>, env: Rc, -) -> String { +) -> Rc> { v1_rt::concat( rust_items().return_arrow.clone(), render_rust_fn_sig_type( @@ -8708,6 +9145,7 @@ pub fn emit_inferred( generic_param_names, shared_types, source_indices, + variant_to_enum, env, ), ) @@ -8740,7 +9178,7 @@ pub fn is_string_lit_pattern(p: Rc) -> bool { } } -pub fn pattern_string_binding_name(path: Rc>) -> String { +pub fn pattern_string_binding_name(path: Rc>) -> Rc> { if ((path.clone().len() as i64) == 0) { "__pos0_val".to_string() } else { @@ -8760,7 +9198,10 @@ pub fn pattern_string_binding_name(path: Rc>) -> String { } } -pub fn positional_payload_string_guard(fb_pat: Rc, bind_name: String) -> String { +pub fn positional_payload_string_guard( + fb_pat: Rc, + bind_name: Rc>, +) -> Rc> { match (*fb_pat).clone() { MatchPattern::LitPattern { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { @@ -8779,7 +9220,7 @@ pub fn collect_field_binding_string_guards( field_bindings: Rc>>, path_prefix: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let parts = Rc::new({ let mut __result = Vec::new(); @@ -8791,7 +9232,11 @@ pub fn collect_field_binding_string_guards( if is_string_lit_pattern(fb_pat.clone()) { { let field_path = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + fb_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "0".to_string(), + )) { v1_rt::rc_list_push(path_prefix.clone(), "0".to_string()) } else { v1_rt::rc_list_push(path_prefix.clone(), fb_name.clone()) @@ -8814,7 +9259,11 @@ pub fn collect_field_binding_string_guards( nested_path.clone(), source_indices.clone(), ); - if (nested.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + nested.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { Rc::new(vec![]) } else { Rc::new(vec![nested.clone()]) @@ -8836,7 +9285,7 @@ pub fn collect_pattern_string_guards( mut pattern: Rc, mut path_prefix: Rc>, mut source_indices: Rc>>, -) -> String { +) -> Rc> { loop { match (*pattern).clone() { MatchPattern::VariantPattern { @@ -8845,7 +9294,8 @@ pub fn collect_pattern_string_guards( field_bindings: fbs, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) + if (((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) && (parent.clone().as_deref() == Some("Optional".to_string()).as_deref())) && ((fbs.clone().len() as i64) == 1)) { @@ -8887,10 +9337,11 @@ pub fn collect_pattern_string_guards( if ((fbs.clone().len() as i64) == 1) { match fbs.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()) - .as_str() - == "0".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + field_binding_name_at(fb.clone(), source_indices.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "0".to_string(), + )) { let fb_pat = field_binding_pattern(fb.clone()); let pos_path = v1_rt::rc_list_push( v1_rt::rc_list_push(path_prefix, n.clone()), @@ -8997,10 +9448,10 @@ pub fn emit_pattern( pattern: Rc, path_prefix: Rc>, shared_types: Rc>, - scrut_type: String, + scrut_type: Rc>, source_indices: Rc>>, emit_info: Rc, -) -> String { +) -> Rc> { match (*pattern).clone() { MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), RenderTarget::Rust), MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v.clone()), @@ -9024,14 +9475,16 @@ pub fn emit_pattern( } pub fn pattern_parent_enum( - name: String, - parent_enum: Option, - scrut_type: String, + name: Rc>, + parent_enum: Rc>, + scrut_type: Rc>, type_summaries: Rc>>, -) -> Option { +) -> Rc> { { - let scrut_is_known_enum = ((scrut_type.clone().as_str() != "".to_string().as_str()) - && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); + let scrut_is_known_enum = + ((crate::v2_std_text::host_string_text_to_rust_host(scrut_type.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); if (parent_enum.clone() != None) { parent_enum.clone() } else { @@ -9046,8 +9499,8 @@ pub fn pattern_parent_enum( pub fn unique_variant_parent( type_summaries: Rc>>, - variant_name: String, -) -> Option { + variant_name: Rc>, +) -> Rc> { { let parent_matches = Rc::new({ let mut __result = Vec::new(); @@ -9072,25 +9525,30 @@ pub fn unique_variant_parent( } } -pub fn is_optional_variant_name(name: String) -> bool { - ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str())) +pub fn is_optional_variant_name(name: Rc>) -> bool { + ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Absent".to_string()))) } -pub fn is_optional_parent(parent_enum: Option) -> bool { +pub fn is_optional_parent(parent_enum: Rc>) -> bool { match parent_enum { - Some(parent) => (parent.clone().as_str() == "Optional".to_string().as_str()), + Some(parent) => { + (crate::v2_std_text::host_string_text_to_rust_host(parent.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Optional".to_string())) + } None => false, } } pub fn positional_payload_scrut_type( - parent_enum: Option, - variant_name: String, + parent_enum: Rc>, + variant_name: Rc>, field_binding: Rc, emit_info: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let type_key = match parent_enum { Some(parent) => variant_summary_key(parent.clone(), variant_name), @@ -9118,15 +9576,15 @@ pub fn positional_payload_scrut_type( } pub fn emit_variant_pattern( - name: String, - parent_enum: Option, + name: Rc>, + parent_enum: Rc>, field_bindings: Rc>>, path_prefix: Rc>, shared_types: Rc>, - scrut_type: String, + scrut_type: Rc>, source_indices: Rc>>, emit_info: Rc, -) -> String { +) -> Rc> { { let resolved_parent = pattern_parent_enum( name.clone(), @@ -9137,7 +9595,9 @@ pub fn emit_variant_pattern( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) + { "Some".to_string() } else { "None".to_string() @@ -9150,7 +9610,9 @@ pub fn emit_variant_pattern( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(parent.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) + { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9162,7 +9624,9 @@ pub fn emit_variant_pattern( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() + && (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string()))) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -9193,8 +9657,9 @@ pub fn emit_variant_pattern( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host( + field_binding_name_at(fb.clone(), source_indices.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -9390,101 +9855,40 @@ pub fn emit_variant_pattern( let mut __result = Vec::new(); for fb in effective_bindings.clone().iter().cloned() { __result.push({ - let fb_name = field_binding_name_at( - fb.clone(), - source_indices.clone(), - ); - let fb_pat = field_binding_pattern(fb.clone()); - if is_string_lit_pattern(fb_pat.clone()) { - { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; - let bind_name = pattern_string_binding_name( - field_path.clone(), - ); - v1_rt::concat( - "ref ".to_string(), - bind_name.clone(), - ) - } + let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); +let fb_pat = field_binding_pattern(fb.clone()); +if is_string_lit_pattern(fb_pat.clone()) { + { + let field_path = if (crate::v2_std_text::host_string_text_to_rust_host(fb_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) { + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string()) + } else { + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), fb_name.clone()) + }; +let bind_name = pattern_string_binding_name(field_path.clone()); +v1_rt::concat("ref ".to_string(), bind_name.clone()) +} + } else { + { + let is_shorthand = match (*fb_pat.clone()).clone() { + MatchPattern::Bind { name: n, .. } => (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) == crate::v2_std_text::host_string_text_to_rust_host(fb_name.clone())), + _ => false, +}; +if is_shorthand.clone() { + emit_ident(fb_name.clone(), RenderTarget::Rust) } else { { - let is_shorthand = match (*fb_pat.clone()) - .clone() - { - MatchPattern::Bind { name: n, .. } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } - _ => false, - }; - if is_shorthand.clone() { - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ) + let field_path = if (crate::v2_std_text::host_string_text_to_rust_host(fb_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) { + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string()) } else { - { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; - let pat_str = emit_pattern( - fb_pat.clone(), - field_path.clone(), - shared_types.clone(), - "".to_string(), - source_indices.clone(), - emit_info.clone(), - ); - v1_rt::concat( - v1_rt::concat( - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ), - ": ".to_string(), - ), - pat_str.clone(), - ) - } - } - } + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), fb_name.clone()) + }; +let pat_str = emit_pattern(fb_pat.clone(), field_path.clone(), shared_types.clone(), "".to_string(), source_indices.clone(), emit_info.clone()); +v1_rt::concat(v1_rt::concat(emit_ident(fb_name.clone(), RenderTarget::Rust), ": ".to_string()), pat_str.clone()) +} } - }); +} + } +}); } __result }); @@ -9528,11 +9932,16 @@ pub fn empty_rc_pattern_analysis() -> Rc { }) } -pub fn field_needs_rc_ref(field_name: String, rc_analysis: Rc) -> bool { +pub fn field_needs_rc_ref( + field_name: Rc>, + rc_analysis: Rc, +) -> bool { { let mut __found = false; for name in rc_analysis.ref_bound_fields.clone().iter().cloned() { - if (name.clone().as_str() == field_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone())) + { __found = true; break; } @@ -9543,7 +9952,7 @@ pub fn field_needs_rc_ref(field_name: String, rc_analysis: Rc pub fn analyze_rc_pattern( pattern: Rc, - scrut_type: String, + scrut_type: Rc>, shared_types: Rc>, emit_info: Rc, source_indices: Rc>>, @@ -9568,9 +9977,12 @@ pub fn analyze_rc_pattern( ); Rc::new(RcPatternAnalysis { matches_rc_variant: false, - matches_option_rc_variant: ((n.clone().as_str() - == "Present".to_string().as_str()) - && inner.matches_rc_variant.clone()), + matches_option_rc_variant: + ((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + )) + && inner.matches_rc_variant.clone()), needs_rc_pattern: inner.needs_rc_pattern.clone(), ref_bound_fields: Rc::new(vec![]), }) @@ -9600,7 +10012,11 @@ pub fn analyze_rc_pattern( let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); let inner_scrut = - if (fb_name.clone().as_str() == "0".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + fb_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "0".to_string(), + )) { positional_payload_scrut_type( resolved_parent.clone(), n.clone(), @@ -9648,7 +10064,7 @@ pub fn analyze_rc_pattern( pub fn analyze_rc_match( scrutinee: Rc, arms: Rc>>, - scrut_type: String, + scrut_type: Rc>, shared_types: Rc>, emit_info: Rc, source_indices: Rc>>, @@ -9722,10 +10138,10 @@ pub fn emit_pattern_rc_aware( path_prefix: Rc>, rc_analysis: Rc, shared_types: Rc>, - scrut_type: String, + scrut_type: Rc>, source_indices: Rc>>, emit_info: Rc, -) -> String { +) -> Rc> { match (*pattern).clone() { MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), RenderTarget::Rust), MatchPattern::LitPattern { value: v, .. } => rust_literal_for_pattern(v.clone()), @@ -9750,16 +10166,16 @@ pub fn emit_pattern_rc_aware( } pub fn emit_variant_pattern_rc_aware( - name: String, - parent_enum: Option, + name: Rc>, + parent_enum: Rc>, field_bindings: Rc>>, path_prefix: Rc>, rc_analysis: Rc, shared_types: Rc>, - scrut_type: String, + scrut_type: Rc>, source_indices: Rc>>, emit_info: Rc, -) -> String { +) -> Rc> { { let resolved_parent = pattern_parent_enum( name.clone(), @@ -9770,7 +10186,9 @@ pub fn emit_variant_pattern_rc_aware( let optional_variant = (is_optional_variant_name(name.clone()) && is_optional_parent(resolved_parent.clone())); let rust_name = if optional_variant.clone() { - if (name.clone().as_str() == "Present".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) + { "Some".to_string() } else { "None".to_string() @@ -9783,7 +10201,9 @@ pub fn emit_variant_pattern_rc_aware( } else { match resolved_parent.clone() { Some(parent) => { - if (parent.clone().as_str() == "Witness".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(parent.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) + { v1_rt::concat("v1_rt::Witness::".to_string(), rust_name.clone()) } else { v1_rt::concat( @@ -9795,7 +10215,9 @@ pub fn emit_variant_pattern_rc_aware( None => rust_name.clone(), } }; - if ((optional_variant.clone() && (name.clone().as_str() == "Present".to_string().as_str())) + if ((optional_variant.clone() + && (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string()))) && ((field_bindings.clone().len() as i64) == 1)) { match field_bindings.clone().first().cloned() { @@ -9834,8 +10256,9 @@ pub fn emit_variant_pattern_rc_aware( if ((field_bindings.clone().len() as i64) == 1) { match field_bindings.clone().first().cloned() { Some(fb) => { - if (field_binding_name_at(fb.clone(), source_indices.clone()).as_str() - == "0".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host( + field_binding_name_at(fb.clone(), source_indices.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) { { let fb_pat = field_binding_pattern(fb.clone()); @@ -10063,125 +10486,45 @@ pub fn emit_variant_pattern_rc_aware( let mut __result = Vec::new(); for fb in effective_bindings.clone().iter().cloned() { __result.push({ - let fb_name = field_binding_name_at( - fb.clone(), - source_indices.clone(), - ); - let fb_pat = field_binding_pattern(fb.clone()); - if is_string_lit_pattern(fb_pat.clone()) { - { - let field_path = if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; - let bind_name = pattern_string_binding_name( - field_path.clone(), - ); - v1_rt::concat( - "ref ".to_string(), - bind_name.clone(), - ) - } + let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); +let fb_pat = field_binding_pattern(fb.clone()); +if is_string_lit_pattern(fb_pat.clone()) { + { + let field_path = if (crate::v2_std_text::host_string_text_to_rust_host(fb_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) { + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string()) } else { - if field_needs_rc_ref( - fb_name.clone(), - rc_analysis.clone(), - ) { - v1_rt::concat( - "ref ".to_string(), - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ), - ) + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), fb_name.clone()) + }; +let bind_name = pattern_string_binding_name(field_path.clone()); +v1_rt::concat("ref ".to_string(), bind_name.clone()) +} + } else { + if field_needs_rc_ref(fb_name.clone(), rc_analysis.clone()) { + v1_rt::concat("ref ".to_string(), emit_ident(fb_name.clone(), RenderTarget::Rust)) + } else { + { + let is_shorthand = match (*fb_pat.clone()).clone() { + MatchPattern::Bind { name: n, .. } => (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) == crate::v2_std_text::host_string_text_to_rust_host(fb_name.clone())), + _ => false, +}; +if is_shorthand.clone() { + emit_ident(fb_name.clone(), RenderTarget::Rust) } else { { - let is_shorthand = match (*fb_pat.clone()) - .clone() - { - MatchPattern::Bind { - name: n, .. - } => { - (n.clone().as_str() - == fb_name.clone().as_str()) - } - _ => false, - }; - if is_shorthand.clone() { - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ) + let field_path = if (crate::v2_std_text::host_string_text_to_rust_host(fb_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) { + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), "0".to_string()) } else { - { - let field_path = - if (fb_name.clone().as_str() - == "0".to_string().as_str()) - { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - "0".to_string(), - ) - } else { - v1_rt::rc_list_push( - v1_rt::rc_list_push( - path_prefix.clone(), - name.clone(), - ), - fb_name.clone(), - ) - }; - let inner_analysis = - analyze_rc_pattern( - fb_pat.clone(), - "".to_string(), - shared_types.clone(), - emit_info.clone(), - source_indices.clone(), - ); - let pat_str = emit_pattern_rc_aware( - fb_pat.clone(), - field_path.clone(), - inner_analysis.clone(), - shared_types.clone(), - "".to_string(), - source_indices.clone(), - emit_info.clone(), - ); - v1_rt::concat( - v1_rt::concat( - emit_ident( - fb_name.clone(), - RenderTarget::Rust, - ), - ": ".to_string(), - ), - pat_str.clone(), - ) - } - } - } + v1_rt::rc_list_push(v1_rt::rc_list_push(path_prefix.clone(), name.clone()), fb_name.clone()) + }; +let inner_analysis = analyze_rc_pattern(fb_pat.clone(), "".to_string(), shared_types.clone(), emit_info.clone(), source_indices.clone()); +let pat_str = emit_pattern_rc_aware(fb_pat.clone(), field_path.clone(), inner_analysis.clone(), shared_types.clone(), "".to_string(), source_indices.clone(), emit_info.clone()); +v1_rt::concat(v1_rt::concat(emit_ident(fb_name.clone(), RenderTarget::Rust), ": ".to_string()), pat_str.clone()) +} } - } - }); +} + } + } +}); } __result }); @@ -10208,7 +10551,7 @@ pub fn rc_pattern_preludes( shared_types: Rc>, source_indices: Rc>>, emit_info: Rc, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*pattern).clone() { MatchPattern::VariantPattern { name: n, @@ -10252,78 +10595,27 @@ pub fn rc_pattern_preludes( let preludes = Rc::new({ let mut __result = Vec::new(); for fb in fbs.clone().iter().cloned() { - __result.extend( - (*{ - let fb_name = - field_binding_name_at(fb.clone(), source_indices.clone()); - if (fb_name.clone().as_str() == "0".to_string().as_str()) { - { - let payload_scrut = positional_payload_scrut_type( - resolved_parent.clone(), - n.clone(), - fb.clone(), - emit_info.clone(), - source_indices.clone(), - ); - let inner_analysis = analyze_rc_pattern( - field_binding_pattern(fb.clone()), - payload_scrut.clone(), - shared_types.clone(), - emit_info.clone(), - source_indices.clone(), - ); - let inner_preludes = rc_pattern_preludes( - field_binding_pattern(fb.clone()), - inner_analysis.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ); - if (inner_preludes.clone().as_str() - == "".to_string().as_str()) - { - Rc::new(vec![]) - } else { - Rc::new(vec![inner_preludes.clone()]) - } - } - } else { - if field_needs_rc_ref(fb_name.clone(), rc_analysis.clone()) - { - Rc::new(vec![v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "let ".to_string(), - emit_pattern( - field_binding_pattern(fb.clone()), - v1_rt::rc_list_push( - v1_rt::rc_list_push( - Rc::new(vec![]), - n.clone(), - ), - fb_name.clone(), - ), - shared_types.clone(), - "".to_string(), - source_indices.clone(), - emit_info.clone(), - ), - ), - " = ".to_string(), - ), - emit_ident(fb_name.clone(), RenderTarget::Rust), - ), - ".as_ref() else { unreachable!() };".to_string(), - )]) - } else { - Rc::new(vec![]) - } - } - }) - .iter() - .cloned(), - ); + __result.extend((*{ + let fb_name = field_binding_name_at(fb.clone(), source_indices.clone()); +if (crate::v2_std_text::host_string_text_to_rust_host(fb_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) { + { + let payload_scrut = positional_payload_scrut_type(resolved_parent.clone(), n.clone(), fb.clone(), emit_info.clone(), source_indices.clone()); +let inner_analysis = analyze_rc_pattern(field_binding_pattern(fb.clone()), payload_scrut.clone(), shared_types.clone(), emit_info.clone(), source_indices.clone()); +let inner_preludes = rc_pattern_preludes(field_binding_pattern(fb.clone()), inner_analysis.clone(), shared_types.clone(), source_indices.clone(), emit_info.clone()); +if (crate::v2_std_text::host_string_text_to_rust_host(inner_preludes.clone()) == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + Rc::new(vec![]) + } else { + Rc::new(vec![inner_preludes.clone()]) + } +} + } else { + if field_needs_rc_ref(fb_name.clone(), rc_analysis.clone()) { + Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("let ".to_string(), emit_pattern(field_binding_pattern(fb.clone()), v1_rt::rc_list_push(v1_rt::rc_list_push(Rc::new(vec![]), n.clone()), fb_name.clone()), shared_types.clone(), "".to_string(), source_indices.clone(), emit_info.clone())), " = ".to_string()), emit_ident(fb_name.clone(), RenderTarget::Rust)), ".as_ref() else { unreachable!() };".to_string())]) + } else { + Rc::new(vec![]) + } + } +}).iter().cloned()); } __result }); @@ -10336,11 +10628,11 @@ pub fn rc_pattern_preludes( } pub fn explicit_record_struct_name( - type_name: Option, + type_name: Rc>, inferred_node: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> Option { +) -> Rc> { { let is_optional = (inferred_node.return_cardinality.clone() == Cardinality::CardOptional); if is_optional { @@ -10366,7 +10658,9 @@ pub fn explicit_record_struct_name( false }; let nname = authored_name_at(source_indices, n.clone()); - if (nname.clone().as_str() == "__EmitTypeCacheMiss".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(nname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("__EmitTypeCacheMiss".to_string())) + { type_name.clone() } else { if n_is_error { @@ -10405,7 +10699,7 @@ pub fn is_simple_type_node( pub fn variant_parent_from_binding_kind( binding_kind: Option>, -) -> Option { +) -> Rc> { match binding_kind.as_deref().cloned() { Some(VarBindingKind::VariantValueBinding { parent_enum: parent_enum, @@ -10415,21 +10709,24 @@ pub fn variant_parent_from_binding_kind( } } -pub fn apply_clone(expr: String) -> String { +pub fn apply_clone(expr: Rc>) -> Rc> { apply_type_template1( sharing_for_target(RenderTarget::Rust).clone_value.clone(), expr, ) } -pub fn apply_deref_clone(expr: String) -> String { +pub fn apply_deref_clone(expr: Rc>) -> Rc> { apply_type_template1( sharing_for_target(RenderTarget::Rust).deref_clone.clone(), expr, ) } -pub fn apply_field_clone(expr: String, field: String) -> String { +pub fn apply_field_clone( + expr: Rc>, + field: Rc>, +) -> Rc> { apply_type_template2( sharing_for_target(RenderTarget::Rust).field_clone.clone(), expr, @@ -10437,132 +10734,23 @@ pub fn apply_field_clone(expr: String, field: String) -> String { ) } -pub fn clone_iterator_suffix() -> String { +pub fn clone_iterator_suffix() -> Rc> { sharing_for_target(RenderTarget::Rust).clone_suffix.clone() } -pub fn rust_qualify_type_leaf_name( - name: String, - variant_to_enum: Rc>, -) -> String { - match v1_rt::map_get(&variant_to_enum, name.clone()) { - Some(parent) => { - if parent.as_str() != "" { - v1_rt::concat( - v1_rt::concat(parent.clone(), "::".to_string()), - name.clone(), - ) - } else { - name.clone() - } - } - None => name.clone(), - } -} - -pub fn rust_render_type_leaf_name( - name: String, - variant_to_enum: Rc>, - env: Rc, -) -> String { - if is_phantom_unit_variant_type_arg(env, name.clone()) { - name - } else if let Some(carrier) = rust_opaque_kernel_alias_carrier(name.clone()) { - carrier - } else { - rust_qualify_type_leaf_name(name, variant_to_enum) - } -} - -pub fn emit_phantom_zst_markers_for_enum(children: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for child in children.iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - } - } - __result - }) - .join("\n") -} - -pub fn collect_phantom_zst_marker_names( - items: Rc>>, - env: Rc, -) -> Rc> { - Rc::new({ - let mut names: Vec = Vec::new(); - for item in items.iter().cloned() { - if is_type_def_item(item.clone()) - && item - .children - .clone() - .iter() - .all(|c| c.children.clone().len() as i64 == 0) - { - for child in item.children.clone().iter().cloned() { - if (child.children.clone().len() as i64) == 0 { - let vname = authored_name(env.clone(), child.clone()); - if is_phantom_unit_variant_type_arg(env.clone(), vname.clone()) - && !names.iter().any(|n| n == &vname) - { - names.push(vname); - } - } - } - } - } - names - }) -} - -pub fn emit_module_phantom_zst_markers(items: Rc>>, env: Rc) -> String { - Rc::new({ - let mut __result = Vec::new(); - for vname in collect_phantom_zst_marker_names(items, env.clone()) - .iter() - .cloned() - { - __result.push(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - rust_visibility_prefix(), - rust_items().struct_keyword.clone(), - ), - " ".to_string(), - ), - v1_rt::concat(vname, ";".to_string()), - )); - } - __result - }) - .join("\n") -} - pub fn effective_variant_parent( - name: String, + name: Rc>, binding_kind: Option>, resolved_type: Option>, emit_info: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { { let cached = match v1_rt::map_get(&emit_info.variant_to_enum.clone(), name.clone()) { Some(p) => { - if (p.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(p.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { Some(p.clone()) } else { None @@ -10576,7 +10764,8 @@ pub fn effective_variant_parent( Some(InferredNode::Resolved { node: rt, .. }) => { let rt_name = authored_name_at(source_indices, rt.clone()); if (((rt.ident_span.clone() != None) - && (rt_name.clone().as_str() != name.clone().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(rt_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(name.clone()))) && variant_belongs_to_enum( emit_info.type_summaries.clone(), name.clone(), @@ -10595,21 +10784,25 @@ pub fn effective_variant_parent( } pub fn emit_var_ref( - name: String, + name: Rc>, binding_kind: Option>, resolved_type: Option>, shared_types: Rc>, registry: Rc>>, emit_info: Rc, source_indices: Rc>>, -) -> String { - if ((name.clone().as_str() == "none".to_string().as_str()) - || (name.clone().as_str() == "None".to_string().as_str())) +) -> Rc> { + if ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("none".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("None".to_string()))) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((name.clone().as_str() == "true".to_string().as_str()) - || (name.clone().as_str() == "false".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("true".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("false".to_string()))) { emit_keyword(name.clone(), RenderTarget::Rust) } else { @@ -10626,9 +10819,16 @@ pub fn emit_var_ref( let ref_str = match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(name.clone()) - && (enum_name.clone().as_str() == "Optional".to_string().as_str())) - { - if (name.clone().as_str() == "Present".to_string().as_str()) { + && (crate::v2_std_text::host_string_text_to_rust_host( + enum_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Optional".to_string(), + ))) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + )) + { "Some".to_string() } else { "None".to_string() @@ -10709,7 +10909,7 @@ pub fn emit_typed_expr_base( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let si = scope.type_env.clone().source_indices.clone(); match (*texpr.expr_data.clone()).clone() { @@ -10718,13 +10918,19 @@ pub fn emit_typed_expr_base( .. } => { let n = expr_var_name_at(texpr.clone(), si.clone()); - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("none".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("None".to_string()))) { emit_keyword("null".to_string(), RenderTarget::Rust) } else { - if ((n.clone().as_str() == "true".to_string().as_str()) - || (n.clone().as_str() == "false".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("true".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "false".to_string(), + ))) { emit_keyword(n.clone(), RenderTarget::Rust) } else { @@ -10739,10 +10945,16 @@ pub fn emit_typed_expr_base( match variant_parent { Some(enum_name) => { let qualified = if (is_optional_variant_name(n.clone()) - && (enum_name.clone().as_str() - == "Optional".to_string().as_str())) - { - if (n.clone().as_str() == "Present".to_string().as_str()) { + && (crate::v2_std_text::host_string_text_to_rust_host( + enum_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Optional".to_string(), + ))) { + if (crate::v2_std_text::host_string_text_to_rust_host( + n.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + )) { "Some".to_string() } else { "None".to_string() @@ -10793,14 +11005,14 @@ pub fn emit_typed_expr_base( pub fn emit_typed_field_access( base: Rc, - field: String, + field: Rc>, summary: Option>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let base_str = emit_typed_expr_base( base.clone(), @@ -10850,13 +11062,14 @@ pub fn emit_typed_field_access( .iter() .cloned() { - if (authored_name_at( - scope.type_env.clone().source_indices.clone(), - pair.1.clone(), - ) - .as_str() - == field.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( + scope.type_env.clone().source_indices.clone(), + pair.1.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + field.clone(), + )) { __result.push(pair); } } @@ -10869,7 +11082,9 @@ pub fn emit_typed_field_access( sharing.clone_value.clone(), v1_rt::concat( v1_rt::concat(base_str, ".".to_string()), - (m.0.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (m.0.clone()).to_string(), + ), ), ) } @@ -10961,7 +11176,7 @@ pub fn type_needs_rc( ) -> bool { type_needs_rc_seen( type_node, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), source_indices, ) } @@ -10992,11 +11207,14 @@ pub fn type_needs_rc_seen( } else { let canonical = authored_name_at(source_indices.clone(), normed.clone()); if (normed.inferred.clone() != None) { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { - seen.clone() - } else { - v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) - }; + let next_seen = + if (crate::v2_std_text::host_string_text_to_rust_host(canonical.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + seen.clone() + } else { + v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) + }; { let __tco_0 = resolved_type(normed.clone()); let __tco_1 = next_seen; @@ -11005,12 +11223,17 @@ pub fn type_needs_rc_seen( continue; } } else { - if ((canonical.clone().as_str() != "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(canonical.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) && emit_map_has(seen.clone(), canonical.clone())) { break false; } else { - let next_seen = if (canonical.clone().as_str() == "".to_string().as_str()) { + let next_seen = if (crate::v2_std_text::host_string_text_to_rust_host( + canonical.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) @@ -11034,11 +11257,11 @@ pub fn type_needs_rc_seen( } } -pub fn rust_runtime_bridge_passes_receiver_by_ref(function_name: String) -> bool { +pub fn rust_runtime_bridge_passes_receiver_by_ref(function_name: Rc>) -> bool { v1_rt::map_contains_key(&rt_ref_map_functions(), function_name) } -pub fn rust_runtime_bridge_name(function_name: String) -> String { +pub fn rust_runtime_bridge_name(function_name: Rc>) -> Rc> { match v1_rt::map_get(&rt_bridge_function_names(), function_name.clone()) { Some(runtime_name) => runtime_name.clone(), None => function_name.clone(), @@ -11049,7 +11272,7 @@ pub fn rust_empty_map_value_type_str( map_type: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match map_type.children.clone().get(1 as usize).cloned() { Some(value_child) => { let rendered = render_rust_type( @@ -11057,7 +11280,9 @@ pub fn rust_empty_map_value_type_str( shared_types, source_indices, ); - if (rendered.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(rendered.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { "".to_string() } else { rendered.clone() @@ -11071,7 +11296,7 @@ pub fn rust_empty_map_kv_type_str( map_type: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let key_str = match map_type.children.clone().first().cloned() { Some(key_child) => render_rust_type( @@ -11086,8 +11311,10 @@ pub fn rust_empty_map_kv_type_str( shared_types.clone(), source_indices.clone(), ); - if ((key_str.clone().as_str() != "".to_string().as_str()) - && (val_str.clone().as_str() != "".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(key_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(val_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) { v1_rt::concat( v1_rt::concat(key_str.clone(), ", ".to_string()), @@ -11116,12 +11343,18 @@ pub fn rust_btree_set_element_ord_eligible( ) -> bool { { let elem_name = authored_name_at(source_indices.clone(), elem_node.clone()); - (((((((elem_name.clone().as_str() == "String".to_string().as_str()) - || (elem_name.clone().as_str() == "Int".to_string().as_str())) - || (elem_name.clone().as_str() == "Bool".to_string().as_str())) - || (elem_name.clone().as_str() == "Unit".to_string().as_str())) - || (elem_name.clone().as_str() == "Secret".to_string().as_str())) - || (elem_name.clone().as_str() == "Bytes".to_string().as_str())) + (((((((crate::v2_std_text::host_string_text_to_rust_host(elem_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(elem_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Int".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(elem_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Bool".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(elem_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Unit".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(elem_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Secret".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(elem_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Bytes".to_string()))) || rust_nominal_ord_type_eligible(elem_node.clone(), source_indices.clone())) } } @@ -11130,7 +11363,7 @@ pub fn rust_empty_set_element_type_str( set_type: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); @@ -11167,7 +11400,7 @@ pub fn emit_rust_empty_set_expr( set_type: Rc, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = child_type_node(elem_child.clone()); @@ -11194,7 +11427,9 @@ pub fn emit_rust_empty_set_expr( shared_types, source_indices.clone(), ); - if (elem_str.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(elem_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_set::<".to_string(), @@ -11213,23 +11448,25 @@ pub fn emit_rust_empty_set_expr( } } -pub fn rust_runtime_bridge_wraps_collection_result_in_rc(function_name: String) -> bool { +pub fn rust_runtime_bridge_wraps_collection_result_in_rc( + function_name: Rc>, +) -> bool { (v1_rt::map_contains_key(&rt_wraps_result(), function_name.clone()) || v1_rt::map_contains_key(&rust_method_wraps_result(), function_name.clone())) } pub fn rust_runtime_bridge_collection_result_needs_rc_elements( - function_name: String, + function_name: Rc>, result_type: Option>, ) -> bool { false } pub fn rust_wrap_runtime_collection_result( - call_str: String, - function_name: String, + call_str: Rc>, + function_name: Rc>, result_type: Option>, -) -> String { +) -> Rc> { if rust_runtime_bridge_wraps_collection_result_in_rc(function_name.clone()) { if rust_runtime_bridge_collection_result_needs_rc_elements( function_name.clone(), @@ -11256,7 +11493,7 @@ pub fn emit_rust_expr_var( shared_types: Rc>, emit_info: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: binding_kind, @@ -11287,7 +11524,7 @@ pub fn emit_rust_expr_field_access( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let si = scope.type_env.clone().source_indices.clone(); match (*expr.expr_data.clone()).clone() { @@ -11344,7 +11581,7 @@ pub fn emit_rust_expr_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(expr.clone(), scope.type_env.clone().source_indices.clone()); @@ -11373,7 +11610,7 @@ pub fn emit_rust_expr_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprMethodCall { method_semantics: method_semantics, @@ -11411,7 +11648,7 @@ pub fn emit_rust_expr_match( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(expr.clone()); @@ -11432,7 +11669,7 @@ pub fn emit_rust_expr_if( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprIf => { let c = if_condition(expr.clone()); @@ -11454,7 +11691,7 @@ pub fn emit_rust_expr_let( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprLet => { let n = @@ -11486,7 +11723,7 @@ pub fn emit_rust_expr_record_lit( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: parent_enum, @@ -11515,7 +11752,8 @@ pub fn emit_rust_expr_record_lit( None => "".to_string(), }, }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(rc_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) @@ -11537,7 +11775,7 @@ pub fn emit_rust_expr_string_interp( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprStringInterp => { let ps = Rc::new({ @@ -11575,7 +11813,7 @@ pub fn emit_rust_expr_block( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprBlock => emit_typed_block( expr.children.clone(), @@ -11599,7 +11837,7 @@ pub fn emit_rust_expr_cast( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprCast => emit_typed_cast_shared( cast_expr(expr.clone()), @@ -11632,7 +11870,7 @@ pub fn emit_rust_expr_for_each( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprForEach => { let v = @@ -11664,7 +11902,7 @@ pub fn emit_rust_expr_index( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprIndex => { let b = index_base(expr.clone()); @@ -11685,7 +11923,7 @@ pub fn emit_rust_expr_slice( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprSlice => { let b = slice_base(expr.clone()); @@ -11707,7 +11945,7 @@ pub fn emit_rust_expr_bin_op( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprBinOp { op, @@ -11739,7 +11977,7 @@ pub fn emit_typed_expr( shared_types: Rc>, emit_info: Rc, fuel: i64, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { emit_shared_expr( texpr, @@ -11917,24 +12155,24 @@ pub fn emit_cloned_arg( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { emit_typed_expr(texpr, registry, scope, depth, shared_types, emit_info, 1024) } pub fn is_enum_type_name( - type_name: String, + type_name: Rc>, type_summaries: Rc>>, ) -> bool { is_enum_in_summaries(type_summaries, type_name) } pub fn contextual_variant_parent( - variant_name: String, - parent_enum: Option, + variant_name: Rc>, + parent_enum: Rc>, resolved_type: Rc, emit_info: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { match parent_enum { Some(explicit_parent) => { if variant_belongs_to_enum( @@ -11950,7 +12188,8 @@ pub fn contextual_variant_parent( None => { let rt_name = authored_name_at(source_indices, resolved_type.clone()); if (((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != variant_name.clone().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(rt_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()))) && variant_belongs_to_enum( emit_info.type_summaries.clone(), variant_name.clone(), @@ -11984,7 +12223,7 @@ pub fn emit_discriminant_call_lowering( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let arg = arg_value(value_arg); let scrutinee = emit_typed_expr( @@ -12096,7 +12335,7 @@ pub fn emit_discriminant_call_lowering( } pub fn emit_typed_call_expr( - func: String, + func: Rc>, args: Rc>>, inferred: Option>, registry: Rc>>, @@ -12104,9 +12343,11 @@ pub fn emit_typed_call_expr( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { - let call_str = if (func.clone().as_str() == "empty_map".to_string().as_str()) { + let call_str = if (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("empty_map".to_string())) + { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { let kv_type_str = rust_empty_map_kv_type_str( @@ -12114,7 +12355,9 @@ pub fn emit_typed_call_expr( shared_types, scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kv_type_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -12131,7 +12374,9 @@ pub fn emit_typed_call_expr( .to_string(), } } else { - if (func.clone().as_str() == "empty_set".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("empty_set".to_string())) + { match inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: ret_type, .. }) => { emit_rust_empty_set_expr( @@ -12166,16 +12411,18 @@ pub fn emit_typed_call_expr( } pub fn emit_typed_call( - func: String, + func: Rc>, args: Rc>>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { - if (func.clone().as_str() == "get".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("get".to_string())) + { { let get_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let get_list = get_args.clone().first().cloned(); @@ -12219,7 +12466,9 @@ pub fn emit_typed_call( return get_result; } } - if (func.clone().as_str() == "with".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("with".to_string())) + { { let with_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); if ((with_args.clone().len() as i64) == 0) { @@ -12317,7 +12566,9 @@ pub fn emit_typed_call( } } } - if (func.clone().as_str() == "to_string".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("to_string".to_string())) + { { let to_string_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); @@ -12342,38 +12593,21 @@ pub fn emit_typed_call( return ts_result; } } - if (func.clone().as_str() == "utf8_decode_bytes".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("utf8_decode_bytes".to_string())) + { { let decode_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let decode_result = match decode_args.first().cloned() { - Some(value_arg) => v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "String::from_utf8(".to_string(), - emit_typed_expr( - arg_value(value_arg.clone()), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ), - ), - ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {e}\"))?" - .to_string(), - ), - "".to_string(), - ), - None => { - "compile_error!(\"utf8_decode_bytes call missing value argument\")" - .to_string() - } - }; + Some(value_arg) => v1_rt::concat(v1_rt::concat("String::from_utf8(".to_string(), emit_typed_expr(arg_value(value_arg.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)), ".clone()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))?".to_string()), + None => "compile_error!(\"utf8_decode_bytes call missing value argument\")".to_string(), +}; return decode_result; } } - if (func.clone().as_str() == "discriminant".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("discriminant".to_string())) + { { let disc_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); let disc_result = match disc_args.first().cloned() { @@ -12392,42 +12626,48 @@ pub fn emit_typed_call( return disc_result; } } - let collection_scope = if ((((func.clone().as_str() == "map".to_string().as_str()) - || (func.clone().as_str() == "filter".to_string().as_str())) - || (func.clone().as_str() == "flat_map".to_string().as_str())) - || (func.clone().as_str() == "fold".to_string().as_str())) - { + let collection_scope = + if ((((crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("map".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("filter".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("flat_map".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("fold".to_string()))) { - let call_args = order_typed_call_args(args.clone(), func.clone(), scope.clone()); - match call_args.last().cloned() { - Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { - ExprData::ExprLambda => { - let lps = lambda_param_names_at( - arg_value(a.clone()), - scope.type_env.clone().source_indices.clone(), - ); - lambda_scope_from_children( - scope.clone(), - lps, - Rc::new( - arg_value(a.clone()) - .children - .clone() - .iter() - .cloned() - .skip(1 as usize) - .collect::>(), - ), - ) - } - _ => scope.clone(), - }, - None => scope.clone(), + { + let call_args = + order_typed_call_args(args.clone(), func.clone(), scope.clone()); + match call_args.last().cloned() { + Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { + ExprData::ExprLambda => { + let lps = lambda_param_names_at( + arg_value(a.clone()), + scope.type_env.clone().source_indices.clone(), + ); + lambda_scope_from_children( + scope.clone(), + lps, + Rc::new( + arg_value(a.clone()) + .children + .clone() + .iter() + .cloned() + .skip(1 as usize) + .collect::>(), + ), + ) + } + _ => scope.clone(), + }, + None => scope.clone(), + } } - } - } else { - scope.clone() - }; + } else { + scope.clone() + }; let ordered_args = order_typed_call_args(args.clone(), func.clone(), collection_scope.clone()); let callee = lookup_item(registry.clone(), func.clone()); @@ -12475,7 +12715,9 @@ pub fn emit_typed_call( } else { if v1_rt::map_contains_key( &callee_borrow_positions, - (idx.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (idx.clone()).to_string(), + ), ) { { let base = emit_typed_expr_base( @@ -12571,7 +12813,8 @@ pub fn emit_typed_call( func_ident }; let call_str = if ((is_rt.clone() - && (func.clone().as_str() == "concat".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("concat".to_string()))) && ((all_args.clone().len() as i64) > 2)) { emit_nested_rt_concat(all_args.clone(), "".to_string(), shared_types.clone()) @@ -12627,12 +12870,13 @@ pub fn fill_default_args( let is_provided = { let mut __found = false; for n in provided_names.clone().iter().cloned() { - if (n.clone().as_str() - == param_node_name_at( - p.clone(), - scope.type_env.clone().source_indices.clone(), - ) - .as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + param_node_name_at( + p.clone(), + scope.type_env.clone().source_indices.clone(), + ), + )) { __found = true; break; @@ -12684,7 +12928,7 @@ pub fn fill_op_default_args( { let si = scope.type_env.clone().source_indices.clone(); let arg_map = ordered.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, a: Rc| match arg_name_at( a.clone(), si.clone(), @@ -12736,16 +12980,18 @@ pub fn fill_op_default_args( pub fn emit_nested_rt_concat( mut remaining: Rc>, - mut acc: String, + mut acc: Rc>, mut shared_types: Rc>, -) -> String { +) -> Rc> { loop { match remaining.clone().first().cloned() { None => { break acc.clone(); } Some(arg) => { - let next_acc = if (acc.clone().as_str() == "".to_string().as_str()) { + let next_acc = if (crate::v2_std_text::host_string_text_to_rust_host(acc.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { arg.clone() } else { v1_rt::concat( @@ -12778,7 +13024,7 @@ pub fn emit_nested_rt_concat( } pub fn emit_typed_for_each( - variable: String, + variable: Rc>, collection: Rc, body: Rc, registry: Rc>>, @@ -12786,7 +13032,7 @@ pub fn emit_typed_for_each( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let coll_str = emit_typed_expr( @@ -12833,7 +13079,7 @@ pub fn emit_typed_index( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let spec = language_spec(RenderTarget::Rust); let base_str = emit_typed_expr( @@ -12891,7 +13137,7 @@ pub fn emit_typed_slice( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let spec = language_spec(RenderTarget::Rust); let base_str = emit_typed_expr( @@ -12946,7 +13192,7 @@ pub fn collection_element_type( receiver_type: Option>, shared_types: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match receiver_type.as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { let __rt_is_container = node_is_element_collection(rt.clone(), source_indices.clone()); @@ -13100,13 +13346,13 @@ pub fn lambda_param_type_strs( pub fn emit_typed_collection_lambda( lambda_expr: Rc, - elem_type_str: String, + elem_type_str: Rc>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*lambda_expr.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( @@ -13160,14 +13406,14 @@ pub fn emit_typed_collection_lambda( pub fn emit_typed_fold_lambda( lambda_expr: Rc, - acc_type_str: String, - elem_type_str: String, + acc_type_str: Rc>, + elem_type_str: Rc>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*lambda_expr.expr_data.clone()).clone() { ExprData::ExprLambda => { let ps = lambda_param_names_at( @@ -13184,15 +13430,24 @@ pub fn emit_typed_fold_lambda( .skip(1 as usize) .collect::>(), ); - let safe_acc_type = if (((acc_type_str.clone().as_str() - == "Rc>".to_string().as_str()) - || (acc_type_str.clone().as_str() == "Vec<()>".to_string().as_str())) - || (acc_type_str.clone().as_str() == "Option<()>".to_string().as_str())) - { - "_".to_string() - } else { - acc_type_str.clone() - }; + let safe_acc_type = + if (((crate::v2_std_text::host_string_text_to_rust_host(acc_type_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Rc>".to_string(), + )) + || (crate::v2_std_text::host_string_text_to_rust_host(acc_type_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Vec<()>".to_string(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host(acc_type_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Option<()>".to_string(), + ))) + { + "_".to_string() + } else { + acc_type_str.clone() + }; let fallback_types = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -13236,8 +13491,10 @@ pub fn emit_typed_fold_lambda( Some(n) => n.clone(), None => "".to_string(), }; - let needs_unwrap = ((acc_name.clone().as_str() != "".to_string().as_str()) - && v1_rt::set_contains(&emit_info.owned_bindings.clone(), acc_name.clone())); + let needs_unwrap = + ((crate::v2_std_text::host_string_text_to_rust_host(acc_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && v1_rt::set_contains(&emit_info.owned_bindings.clone(), acc_name.clone())); if needs_unwrap { { let acc_ident = emit_ident(acc_name.clone(), RenderTarget::Rust); @@ -13294,7 +13551,7 @@ pub fn emit_rust_fold_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let recv_str = emit_typed_expr( receiver.clone(), @@ -13564,9 +13821,20 @@ pub fn emit_rust_fold_method_call( arg_value(init_arg.clone()), scope.type_env.clone().source_indices.clone(), ); - if ((((init_func.clone().as_str() == "empty_map".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) + if ((((crate::v2_std_text::host_string_text_to_rust_host(init_func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "empty_map".to_string(), + )) + && (crate::v2_std_text::host_string_text_to_rust_host( + acc_type_str.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "_".to_string(), + ))) + && (crate::v2_std_text::host_string_text_to_rust_host( + acc_type_str.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + ))) && !acc_has_unit_child.clone()) { { @@ -13575,7 +13843,11 @@ pub fn emit_rust_fold_method_call( shared_types.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + kv_type_str.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { v1_rt::concat( v1_rt::concat( "v1_rt::rc_empty_map::<".to_string(), @@ -13588,14 +13860,26 @@ pub fn emit_rust_fold_method_call( } } } else { - if (init_func.clone().as_str() == "empty_map".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(init_func.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "empty_map".to_string(), + )) + { "Rc::new(HashMap::new()) /* BRIDGE: fold empty_map accumulator type unresolved */".to_string() } else { - if ((((init_func.clone().as_str() - == "empty_set".to_string().as_str()) - && (acc_type_str.clone().as_str() != "_".to_string().as_str())) - && (acc_type_str.clone().as_str() != "".to_string().as_str())) - && !acc_has_unit_child.clone()) + if ((((crate::v2_std_text::host_string_text_to_rust_host( + init_func.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "empty_set".to_string(), + )) && (crate::v2_std_text::host_string_text_to_rust_host( + acc_type_str.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "_".to_string(), + ))) && (crate::v2_std_text::host_string_text_to_rust_host( + acc_type_str.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + ))) && !acc_has_unit_child.clone()) { emit_rust_empty_set_expr( acc_type_node.clone(), @@ -13603,8 +13887,11 @@ pub fn emit_rust_fold_method_call( scope.type_env.clone().source_indices.clone(), ) } else { - if (init_func.clone().as_str() == "empty_set".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + init_func.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "empty_set".to_string(), + )) { "v1_rt::rc_empty_set::<_>()".to_string() } else { emit_typed_expr( @@ -13674,7 +13961,7 @@ pub fn emit_rust_sort_by_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let recv_str = emit_typed_expr( receiver.clone(), @@ -13725,7 +14012,9 @@ pub fn emit_rust_sort_by_method_call( let iter_str = apply_type_template1(sharing.iter_owned.clone(), recv_str); let a_clone = apply_type_template1(sharing.clone_value.clone(), "a".to_string()); let b_clone = apply_type_template1(sharing.clone_value.clone(), "b".to_string()); - if (elem_type_str.clone().as_str() == "_".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(elem_type_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("_".to_string())) + { v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a, b| { a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) } else { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Rc::new({ let mut __sorted: Vec<_> = ".to_string(), iter_str), ".collect(); __sorted.sort_by(|a: &".to_string()), elem_type_str.clone()), ", b: &".to_string()), elem_type_str.clone()), "| { let __ka = (".to_string()), sort_key_fn.clone()), ")(".to_string()), a_clone), "); let __kb = (".to_string()), sort_key_fn.clone()), ")(".to_string()), b_clone), "); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted })".to_string()) @@ -13741,7 +14030,7 @@ pub fn emit_rust_map_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let recv_str = emit_typed_expr( receiver.clone(), @@ -13909,7 +14198,7 @@ pub fn emit_rust_higher_order_method( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let sharing = language_spec(RenderTarget::Rust).sharing.clone(); let recv_str = emit_typed_expr( @@ -14034,7 +14323,7 @@ pub fn emit_rust_get_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let recv_str = emit_typed_expr( receiver.clone(), @@ -14099,7 +14388,7 @@ pub fn emit_rust_with_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let base_str = emit_typed_expr( receiver.clone(), @@ -14203,18 +14492,16 @@ pub fn emit_rust_first_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*receiver.expr_data.clone()).clone() { ExprData::ExprMethodCall { method_semantics: _, .. } => { - if (expr_method_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host(expr_method_name_at( receiver.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "skip".to_string().as_str()) + )) == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string())) { { let skip_recv = method_receiver(receiver.clone()); @@ -14272,7 +14559,7 @@ pub fn emit_rust_first_method_call( } pub fn emit_rust_generic_method_call( - method_name: String, + method_name: Rc>, receiver: Rc, args: Rc>>, result_type: Option>, @@ -14281,7 +14568,7 @@ pub fn emit_rust_generic_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let function_name = method_name; if rust_receiver_has_callable_method_field( @@ -14399,7 +14686,7 @@ pub fn emit_rust_generic_method_call( pub fn emit_typed_method_call( method_call_node: Rc, receiver: Rc, - method: String, + method: Rc>, args: Rc>>, result_type: Option>, method_semantics: Option>, @@ -14408,7 +14695,7 @@ pub fn emit_typed_method_call( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { if (method_semantics.clone() != None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { @@ -14441,7 +14728,7 @@ pub fn emit_typed_method_call( .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, p: Rc| { v1_rt::rc_map_insert(acc, param_node_name_at(p.clone(), si.clone()), true) }, @@ -14449,13 +14736,14 @@ pub fn emit_typed_method_call( let json_param_set = Rc::new({ let mut __result = Vec::new(); for p in op_params.clone().iter().cloned() { - if (coerce_primitive_type( - RenderTarget::Rust, - authored_name_at(si.clone(), param_node_type_expr(p.clone())), - ) - .as_str() - == "serde_json::Value".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + coerce_primitive_type( + RenderTarget::Rust, + authored_name_at(si.clone(), param_node_type_expr(p.clone())), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "serde_json::Value".to_string(), + )) { __result.push(p); } } @@ -14464,7 +14752,7 @@ pub fn emit_typed_method_call( .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, p: Rc| { v1_rt::rc_map_insert(acc, param_node_name_at(p.clone(), si.clone()), true) }, @@ -14551,7 +14839,9 @@ pub fn emit_typed_method_call( scope.type_env.clone().source_indices.clone(), method_def.clone(), ); - if (method_name.clone().as_str() == "fold".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("fold".to_string())) + { emit_rust_fold_method_call( method_call_node, fold_accumulator_type.clone(), @@ -14565,7 +14855,9 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "sort_by".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("sort_by".to_string())) + { emit_rust_sort_by_method_call( receiver.clone(), args.clone(), @@ -14576,7 +14868,9 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() == "map".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("map".to_string())) + { emit_rust_map_method_call( receiver.clone(), args.clone(), @@ -14590,9 +14884,11 @@ pub fn emit_typed_method_call( match Rc::new({ let mut __result = Vec::new(); for s in rust_higher_order_methods().iter().cloned() { - if (s.method_name.clone().as_str() - == method_name.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + s.method_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + method_name.clone(), + )) { __result.push(s); } } @@ -14612,8 +14908,11 @@ pub fn emit_typed_method_call( emit_info.clone(), ), None => { - if (method_name.clone().as_str() == "get".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + method_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "get".to_string(), + )) { emit_rust_get_method_call( receiver.clone(), args.clone(), @@ -14624,9 +14923,11 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "with".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + method_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "with".to_string(), + )) { emit_rust_with_method_call( receiver.clone(), args.clone(), @@ -14637,133 +14938,39 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone().as_str() - == "string_contains".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("string_contains".to_string())) { + emit_rust_generic_method_call("string_contains".to_string(), receiver.clone(), args.clone(), result_type, registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone()) + } else { + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("concat".to_string())) { + { + let recv_str = emit_typed_expr(receiver.clone(), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024); +let arg_strs = Rc::new({ let mut __result = Vec::new(); for a in args.clone().iter().cloned() { __result.push(emit_typed_expr(arg_value(a.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)); } __result }); +let all_arg_strs = v1_rt::concat(Rc::new(vec![recv_str]), arg_strs); +emit_nested_rt_concat(all_arg_strs, "".to_string(), shared_types.clone()) +} + } else { + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("first".to_string())) { + emit_rust_first_method_call(receiver.clone(), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone()) + } else { { - emit_rust_generic_method_call( - "string_contains".to_string(), - receiver.clone(), - args.clone(), - result_type, - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ) - } else { - if (method_name.clone().as_str() - == "concat".to_string().as_str()) - { - { - let recv_str = emit_typed_expr( - receiver.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ); - let arg_strs = Rc::new({ - let mut __result = Vec::new(); - for a in args.clone().iter().cloned() { - __result.push(emit_typed_expr( - arg_value(a.clone()), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - )); - } - __result - }); - let all_arg_strs = v1_rt::concat( - Rc::new(vec![recv_str]), - arg_strs, - ); - emit_nested_rt_concat( - all_arg_strs, - "".to_string(), - shared_types.clone(), - ) - } - } else { - if (method_name.clone().as_str() - == "first".to_string().as_str()) - { - emit_rust_first_method_call( - receiver.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ) - } else { - { - let recv_str = emit_typed_expr( - receiver.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ); - let first_arg_str = - emit_typed_first_arg( - args.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ); - match v1_rt::map_get( - &rust_method_templates(), - method_name.clone(), - ) { - Some(tmpl) => { - let bindings = - v1_rt::rc_map_insert( - seed_bindings( - "recv".to_string(), - recv_str, - ), - "arg".to_string(), - first_arg_str, - ); - let raw = apply_named_template( - tmpl.clone(), - bindings, - ); - if rust_runtime_bridge_wraps_collection_result_in_rc(method_name.clone()) { + let recv_str = emit_typed_expr(receiver.clone(), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024); +let first_arg_str = emit_typed_first_arg(args.clone(), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone()); +match v1_rt::map_get(&rust_method_templates(), method_name.clone()) { + Some(tmpl) => { + let bindings = v1_rt::rc_map_insert(seed_bindings("recv".to_string(), recv_str), "arg".to_string(), first_arg_str); +let raw = apply_named_template(tmpl.clone(), bindings); +if rust_runtime_bridge_wraps_collection_result_in_rc(method_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { raw } - } - None => { - emit_rust_generic_method_call( - method_name.clone(), - receiver.clone(), - args.clone(), - result_type, - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ) - } - } - } - } - } - } +}, + None => emit_rust_generic_method_call(method_name.clone(), receiver.clone(), args.clone(), result_type, registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone()), +} +} + } + } + } } } } @@ -14825,7 +15032,7 @@ pub fn emit_typed_first_arg( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match args.first().cloned() { Some(a) => emit_typed_expr( arg_value(a.clone()), @@ -14848,7 +15055,7 @@ pub fn emit_typed_match( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let scrut_str = emit_typed_expr( scrutinee.clone(), @@ -15010,10 +15217,10 @@ pub fn emit_typed_match_arm( depth: i64, shared_types: Rc>, emit_info: Rc, - scrut_type: String, + scrut_type: Rc>, match_result_type: Rc, string_from_mode: bool, -) -> String { +) -> Rc> { { let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); @@ -15083,27 +15290,34 @@ pub fn emit_typed_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) - { - v1_rt::concat( + let guard_str = + if ((crate::v2_std_text::host_string_text_to_rust_host(field_guards.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(arm_guard_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + { v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards.clone()), - " && ".to_string(), - ), - arm_guard_str.clone(), - ) - } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { - v1_rt::concat(" if ".to_string(), field_guards.clone()) + v1_rt::concat( + v1_rt::concat(" if ".to_string(), field_guards.clone()), + " && ".to_string(), + ), + arm_guard_str.clone(), + ) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { - v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_guards.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - "".to_string() + if (crate::v2_std_text::host_string_text_to_rust_host(arm_guard_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + } else { + "".to_string() + } } - } - }; + }; let body_str = match (*arm_b.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: body_binding_kind, @@ -15197,7 +15411,7 @@ pub fn emit_typed_if( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let cond_str = emit_typed_expr( condition, @@ -15232,7 +15446,7 @@ pub fn emit_typed_if( } pub fn emit_typed_let( - name: String, + name: Rc>, value: Rc, body: Option>, registry: Rc>>, @@ -15240,7 +15454,7 @@ pub fn emit_typed_let( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let val_str = emit_typed_expr( value.clone(), @@ -15275,8 +15489,8 @@ pub fn emit_typed_let( pub fn is_optional_struct_field( emit_info: Rc, - struct_name: String, - field_name: String, + struct_name: Rc>, + field_name: Rc>, ) -> bool { match lookup_emit_type_summary(emit_info, struct_name) { Some(summary) => match v1_rt::map_get(&summary.field_summaries.clone(), field_name) { @@ -15292,8 +15506,8 @@ pub fn is_optional_struct_field( pub fn rust_struct_field_type_node( scope: Rc, - struct_name: String, - field_name: String, + struct_name: Rc>, + field_name: Rc>, ) -> Option> { match lookup_type_by_name(scope.type_env.clone(), struct_name) { Some(struct_node) => match find_child_named( @@ -15310,8 +15524,8 @@ pub fn rust_struct_field_type_node( pub fn rust_record_field_needs_fn_rc( scope: Rc, - struct_name: String, - field_name: String, + struct_name: Rc>, + field_name: Rc>, ) -> bool { match rust_struct_field_type_node(scope, struct_name, field_name) { Some(field_type) => (field_type.connective.clone() == Connective::Arrow), @@ -15321,7 +15535,7 @@ pub fn rust_record_field_needs_fn_rc( pub fn rust_receiver_has_callable_method_field( receiver: Rc, - method_name: String, + method_name: Rc>, scope: Rc, ) -> bool { { @@ -15336,8 +15550,8 @@ pub fn rust_record_field_needs_box( scope: Rc, emit_info: Rc, shared_types: Rc>, - struct_name: String, - field_name: String, + struct_name: Rc>, + field_name: Rc>, ) -> bool { match rust_struct_field_type_node(scope.clone(), struct_name, field_name) { Some(field_type) => needs_box_wrapping( @@ -15351,22 +15565,25 @@ pub fn rust_record_field_needs_box( } pub fn wrap_rust_record_field_value( - raw: String, + raw: Rc>, scope: Rc, emit_info: Rc, shared_types: Rc>, - struct_name: String, - field_name: String, -) -> String { + struct_name: Rc>, + field_name: Rc>, +) -> Rc> { { let is_bounded_lattice_field = - (struct_name.clone().as_str() == "BoundedLattice".to_string().as_str()); + (crate::v2_std_text::host_string_text_to_rust_host(struct_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("BoundedLattice".to_string())); if rust_record_field_needs_fn_rc(scope.clone(), struct_name.clone(), field_name.clone()) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "meet".to_string().as_str()) - || (field_name.clone().as_str() == "join".to_string().as_str()))) + && ((crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("meet".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("join".to_string())))) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) } else { @@ -15380,8 +15597,15 @@ pub fn wrap_rust_record_field_value( v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { if (is_bounded_lattice_field.clone() - && ((field_name.clone().as_str() == "top".to_string().as_str()) - || (field_name.clone().as_str() == "bottom".to_string().as_str()))) + && ((crate::v2_std_text::host_string_text_to_rust_host( + field_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "top".to_string(), + )) || (crate::v2_std_text::host_string_text_to_rust_host( + field_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "bottom".to_string(), + )))) { v1_rt::concat(v1_rt::concat("Box::new(".to_string(), raw), ")".to_string()) } else { @@ -15412,15 +15636,23 @@ pub fn is_already_optional( binding_kind: binding_kind, .. } => { - if (((n.clone().as_str() == "Present".to_string().as_str()) - || (n.clone().as_str() == "Absent".to_string().as_str())) + if (((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Absent".to_string(), + ))) && (variant_parent_from_binding_kind(binding_kind.clone()).as_deref() == Some("Optional".to_string()).as_deref())) { true } else { - if ((n.clone().as_str() == "none".to_string().as_str()) - || (n.clone().as_str() == "None".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("none".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "None".to_string(), + ))) { true } else { @@ -15445,8 +15677,14 @@ pub fn is_already_optional( } => match tn { Some(name) => { ((parent.clone().as_deref() == Some("Optional".to_string()).as_deref()) - && ((name.clone().as_str() == "Present".to_string().as_str()) - || (name.clone().as_str() == "Absent".to_string().as_str()))) + && ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + )) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Absent".to_string(), + )))) } None => false, }, @@ -15509,10 +15747,10 @@ pub fn is_already_optional( pub fn lookup_struct_field_type_name( struct_node: Rc, - field_name: String, - variant_name: Option, + field_name: Rc>, + variant_name: Rc>, source_indices: Rc>>, -) -> Option { +) -> Rc> { { let direct = match find_child_named( struct_node.clone(), @@ -15592,14 +15830,14 @@ pub fn lookup_struct_field_type_name( pub fn emit_field_value_with_context( field_value: Rc, struct_node: Rc, - outer_type_name: Option, - field_name: String, + outer_type_name: Rc>, + field_name: Rc>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*field_value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: pe, .. @@ -15668,7 +15906,8 @@ pub fn emit_field_value_with_context( Some(en) => en.clone(), None => variant_name.clone(), }; - if ((rc_name.clone().as_str() != "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(rc_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) && v1_rt::set_contains(&shared_types, rc_name.clone())) { v1_rt::concat(v1_rt::concat("Rc::new(".to_string(), raw), ")".to_string()) @@ -15702,7 +15941,7 @@ pub fn emit_field_value_with_context( pub fn find_struct_name_by_fields( field_names: Rc>, type_summaries: Rc>>, -) -> Option { +) -> Rc> { { let n_fields = (field_names.clone().len() as i64); if (n_fields.clone() == 0) { @@ -15747,16 +15986,16 @@ pub fn find_struct_name_by_fields( } pub fn emit_typed_record_lit( - type_name: Option, + type_name: Rc>, fields: Rc>>, - parent_enum: Option, + parent_enum: Rc>, resolved_type: Rc, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let struct_name = explicit_record_struct_name( type_name.clone(), @@ -15921,9 +16160,16 @@ pub fn emit_typed_record_lit( }; let rt_name = authored_name_at(si.clone(), resolved_type.clone()); if ((((resolved_type.ident_span.clone() != None) - && (rt_name.clone().as_str() != tn.clone().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host( + rt_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + tn.clone(), + ))) && !rt_is_type_var) - && (rt_name.clone().as_str() != "Error".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(rt_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "Error".to_string(), + ))) { Some(rt_name.clone()) } else { @@ -15935,7 +16181,9 @@ pub fn emit_typed_record_lit( && (is_optional_parent(parent_enum.clone()) || is_optional_parent(effective_parent.clone()))); let rust_tn = if optional_variant.clone() { - if (tn.clone().as_str() == "Present".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) + { "Some".to_string() } else { "None".to_string() @@ -15955,7 +16203,10 @@ pub fn emit_typed_record_lit( } }; if ((optional_variant.clone() - && (tn.clone().as_str() == "Present".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + ))) && ((fields.clone().len() as i64) == 1)) { match fields.clone().first().cloned() { @@ -15995,8 +16246,11 @@ pub fn emit_typed_record_lit( let is_positional_ctor = (((fields.clone().len() as i64) == 1) && match fields.clone().first().cloned() { Some(f) => { - (field_init_node_name_at(f.clone(), si.clone()).as_str() - == "0".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host( + field_init_node_name_at(f.clone(), si.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "0".to_string(), + )) } None => false, }); @@ -16123,8 +16377,8 @@ pub fn emit_typed_record_lit( __result }); let provided_set = provided_names.iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, n: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, n: Rc>| { v1_rt::rc_map_insert(acc, n.clone(), true) }, ); @@ -16223,14 +16477,20 @@ pub fn emit_typed_record_lit( } } -pub fn rust_zero_value(type_name: String) -> Option { - if (type_name.clone().as_str() == "Int".to_string().as_str()) { +pub fn rust_zero_value(type_name: Rc>) -> Rc> { + if (crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Int".to_string())) + { Some("0".to_string()) } else { - if (type_name.clone().as_str() == "Bool".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Bool".to_string())) + { Some("false".to_string()) } else { - if (type_name.clone().as_str() == "String".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())) + { Some( "crate::v2_std_algebra::freemonoid_empty::()" .to_string(), @@ -16252,7 +16512,7 @@ pub fn emit_typed_bin_op( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let l_str = emit_typed_expr( left.clone(), @@ -16294,7 +16554,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( v1_rt::concat( "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(l_str.clone()), + emit_rust_dag_string_to_host_via_seam(l_str), ), ")".to_string(), ) @@ -16305,7 +16565,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( v1_rt::concat( "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), + emit_rust_dag_string_to_host_via_seam(r_str), ), ")".to_string(), ) @@ -16335,9 +16595,7 @@ pub fn emit_typed_bin_op( v1_rt::concat( v1_rt::concat( "(".to_string(), - emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - ), + emit_rust_dag_string_to_host_via_seam(l_str), ), " ".to_string(), ), @@ -16345,7 +16603,7 @@ pub fn emit_typed_bin_op( ), " ".to_string(), ), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), + emit_rust_dag_string_to_host_via_seam(r_str), ), ")".to_string(), ) @@ -16427,7 +16685,7 @@ pub fn emit_typed_string_interp( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let has_interpolations = { let mut __found = false; @@ -16477,7 +16735,9 @@ pub fn emit_typed_string_interp( .iter() .cloned() { - if (a.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(a.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(a); } } @@ -16549,7 +16809,7 @@ pub fn emit_typed_block( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let state = emit_rust_block_stmts( stmts, @@ -16639,7 +16899,7 @@ pub fn emit_tco_init_stmt( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*stmt.expr_data.clone()).clone() { ExprData::ExprLet => { let n = @@ -16657,12 +16917,10 @@ pub fn emit_tco_init_stmt( let is_param = { let mut __found = false; for p in params.iter().cloned() { - if (param_node_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host(param_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + )) == crate::v2_std_text::host_string_text_to_rust_host(n.clone())) { __found = true; break; @@ -16696,14 +16954,14 @@ pub fn emit_tco_init_stmt( pub fn emit_typed_tco_body( texpr: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let inner = emit_typed_tco_expr( texpr, @@ -16730,7 +16988,7 @@ pub fn emit_rust_tco_non_self_call( registry: Rc>>, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( @@ -16760,12 +17018,12 @@ pub fn emit_rust_tco_non_self_call( pub fn emit_rust_tco_if( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprIf => { let c = if_condition(frame.expr.clone()); @@ -16849,12 +17107,12 @@ pub fn emit_rust_tco_if( pub fn emit_rust_tco_match( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); @@ -16987,12 +17245,12 @@ pub fn emit_rust_tco_match( pub fn emit_rust_tco_let( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( @@ -17013,12 +17271,10 @@ pub fn emit_rust_tco_let( let is_param = { let mut __found = false; for p in params.clone().iter().cloned() { - if (param_node_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host(param_node_name_at( p.clone(), frame.scope.clone().type_env.clone().source_indices.clone(), - ) - .as_str() - == n.clone().as_str()) + )) == crate::v2_std_text::host_string_text_to_rust_host(n.clone())) { __found = true; break; @@ -17081,12 +17337,12 @@ pub fn emit_rust_tco_let( pub fn emit_rust_tco_block( frame: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { let ss = frame.expr.clone().children.clone(); @@ -17143,7 +17399,7 @@ pub fn emit_rust_tco_default_return( registry: Rc>>, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let val_str = emit_typed_expr( frame.expr.clone(), @@ -17163,14 +17419,14 @@ pub fn emit_rust_tco_default_return( pub fn emit_typed_tco_expr( texpr: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { emit_shared_tco_expr( Rc::new(TcoFrame { expr: texpr, @@ -17250,15 +17506,15 @@ pub fn emit_typed_tco_expr( pub fn emit_typed_tco_match_arm( arm: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, registry: Rc>>, scope: Rc, depth: i64, shared_types: Rc>, emit_info: Rc, - scrut_type: String, -) -> String { + scrut_type: Rc>, +) -> Rc> { { let arm_pat = arm_pattern(arm.clone()); let arm_g = arm_guard(arm.clone()); @@ -17305,27 +17561,34 @@ pub fn emit_typed_tco_match_arm( ), None => "".to_string(), }; - let guard_str = if ((field_guards.clone().as_str() != "".to_string().as_str()) - && (arm_guard_str.clone().as_str() != "".to_string().as_str())) - { - v1_rt::concat( + let guard_str = + if ((crate::v2_std_text::host_string_text_to_rust_host(field_guards.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(arm_guard_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + { v1_rt::concat( - v1_rt::concat(" if ".to_string(), field_guards.clone()), - " && ".to_string(), - ), - arm_guard_str.clone(), - ) - } else { - if (field_guards.clone().as_str() != "".to_string().as_str()) { - v1_rt::concat(" if ".to_string(), field_guards.clone()) + v1_rt::concat( + v1_rt::concat(" if ".to_string(), field_guards.clone()), + " && ".to_string(), + ), + arm_guard_str.clone(), + ) } else { - if (arm_guard_str.clone().as_str() != "".to_string().as_str()) { - v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_guards.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat(" if ".to_string(), field_guards.clone()) } else { - "".to_string() + if (crate::v2_std_text::host_string_text_to_rust_host(arm_guard_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat(" if ".to_string(), arm_guard_str.clone()) + } else { + "".to_string() + } } - } - }; + }; let body_str = emit_typed_tco_expr( arm_b, fn_name, @@ -17382,7 +17645,7 @@ pub fn emit_typed_tco_match_arm( pub fn expr_references_var( node: Rc, - var_name: String, + var_name: Rc>, source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -17390,8 +17653,10 @@ pub fn expr_references_var( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(node.clone(), source_indices.clone()).as_str() - == var_name.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + node.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(var_name.clone())) } _ => { let mut __found = false; @@ -17415,7 +17680,7 @@ pub fn emit_typed_tco_reassign( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let si = scope.type_env.clone().source_indices.clone(); let arg_values = Rc::new({ @@ -17437,7 +17702,7 @@ pub fn emit_typed_tco_reassign( .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |m: Rc>, pair: (i64, Rc)| { let pname = param_node_name_at(pair.1.clone(), si.clone()); let av = match arg_values.clone().get(pair.0.clone() as usize).cloned() { @@ -17580,7 +17845,7 @@ pub fn emit_service_def( registry: Rc>>, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { { let safe_name = sanitize_service_name(authored_name(env.clone(), item.clone())); let fallback_transport = service_fallback_transport(item.clone()); @@ -17606,12 +17871,12 @@ pub fn emit_service_def( } pub fn emit_service_struct( - name: String, + name: Rc>, fallback_transport: Rc, op_children: Rc>>, service_item: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let derives = "#[derive(Debug, Clone)]".to_string(); let config_fields = emit_service_config_fields( @@ -17642,7 +17907,7 @@ pub fn emit_service_config_fields( op_children: Rc>>, service_item: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let fs = compute_service_fields(fallback_transport, op_children, source_indices.clone()); let has_svc_auth = match service_config_auth_source(service_item, source_indices.clone()) { @@ -17672,14 +17937,14 @@ pub fn emit_service_config_fields( } pub fn emit_service_impl( - name: String, + name: Rc>, transport: Rc, op_children: Rc>>, registry: Rc>>, shared_types: Rc>, env: Rc, service_item: Rc, -) -> String { +) -> Rc> { { let depth = 0; let new_method = emit_service_new_method( @@ -17724,12 +17989,12 @@ pub fn emit_service_impl( } pub fn emit_service_new_method( - name: String, + name: Rc>, fallback_transport: Rc, op_children: Rc>>, service_item: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let fs = compute_service_fields( fallback_transport.clone(), @@ -17764,41 +18029,49 @@ pub fn emit_service_new_method( }, None => "".to_string(), }; - let base_url_default = if (from_config.clone().as_str() != "".to_string().as_str()) { - from_config.clone() - } else { - if fs.has_rest.clone() { - { - let fallback_is_rest = - is_rest_transport(fallback_transport.clone(), source_indices.clone()); - let from_fallback = if fallback_is_rest { - match transport_base_url(fallback_transport.clone(), source_indices.clone()) + let base_url_default = + if (crate::v2_std_text::host_string_text_to_rust_host(from_config.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + from_config.clone() + } else { + if fs.has_rest.clone() { + { + let fallback_is_rest = + is_rest_transport(fallback_transport.clone(), source_indices.clone()); + let from_fallback = if fallback_is_rest { + match transport_base_url( + fallback_transport.clone(), + source_indices.clone(), + ) { + Some(bu) => match (*bu.expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitStr { value: s, .. } = value.as_ref() + else { + unreachable!() + }; + s.clone() + } + _ => "".to_string(), + }, + None => "".to_string(), + } + } else { + "".to_string() + }; + if (crate::v2_std_text::host_string_text_to_rust_host( + from_fallback.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - Some(bu) => match (*bu.expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitStr { value: s, .. } = value.as_ref() - else { - unreachable!() - }; - s.clone() - } - _ => "".to_string(), - }, - None => "".to_string(), + from_fallback.clone() + } else { + "http://localhost".to_string() } - } else { - "".to_string() - }; - if (from_fallback.clone().as_str() != "".to_string().as_str()) { - from_fallback.clone() - } else { - "http://localhost".to_string() } + } else { + "".to_string() } - } else { - "".to_string() - } - }; + }; let ctors = service_field_ctors( fs.clone(), language_spec(RenderTarget::Rust).service_fields.clone(), @@ -17854,10 +18127,10 @@ pub fn emit_service_new_method( pub fn emit_auth_source_ctor( source_expr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match (*source_expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => match record_lit_type_name_at(source_expr.clone(), source_indices) { - Some(variant) => if (variant.clone().as_str() == "EnvVar".to_string().as_str()) { + Some(variant) => if (crate::v2_std_text::host_string_text_to_rust_host(variant.clone()) == crate::v2_std_text::host_string_text_to_rust_host("EnvVar".to_string())) { match source_expr.children.clone().first().cloned() { Some(fi) => match (*field_init_node_value(fi.clone()).expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: env_name, .. } = value.as_ref() else { unreachable!() }; v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" auth_token: std::env::var(\"".to_string(), env_name.clone()), "\").expect(\"missing credential: ".to_string()), env_name.clone()), "\"),\n".to_string()) }, @@ -17877,7 +18150,7 @@ pub fn emit_auth_source_ctor( pub fn emit_modifier_doc_from_props( properties: Rc>>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let names = extract_modifier_names(properties, source_indices); if ((names.clone().len() as i64) == 0) { @@ -17895,7 +18168,7 @@ pub fn emit_modifier_doc_from_props( } pub fn emit_operation_method( - service_name: String, + service_name: Rc>, transport: Rc, op_node: Rc, registry: Rc>>, @@ -17903,7 +18176,7 @@ pub fn emit_operation_method( shared_types: Rc>, env: Rc, service_item: Rc, -) -> String { +) -> Rc> { { let op_text = authored_name(env.clone(), op_node.clone()); let input_params = Rc::new({ @@ -17922,14 +18195,17 @@ pub fn emit_operation_method( Rc::new(vec![]), shared_types.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::>, Rc>>(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (crate::v2_std_text::host_string_text_to_rust_host(params_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -18047,7 +18323,7 @@ pub fn emit_operation_method( } pub fn emit_dry_run_branch_from_props( - op_name: String, + op_name: Rc>, inferred: Rc, mock_props: Rc>>, registry: Rc>>, @@ -18055,7 +18331,7 @@ pub fn emit_dry_run_branch_from_props( op_node: Rc, env: Rc, shared_types: Rc>, -) -> String { +) -> Rc> { { let log_line = v1_rt::concat( v1_rt::concat("eprintln!(\"[dry-run] ".to_string(), op_name.clone()), @@ -18151,7 +18427,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn emit_transport_call( transport: Rc, - op_name: String, + op_name: Rc>, registry: Rc>>, depth: i64, inferred: Rc, @@ -18160,7 +18436,7 @@ pub fn emit_transport_call( source_indices: Rc>>, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { if is_rest_transport(transport.clone(), source_indices.clone()) { emit_rest_call( op_name, @@ -18195,7 +18471,7 @@ pub fn emit_transport_call( } pub fn emit_rest_call( - op_name: String, + op_name: Rc>, transport: Rc, registry: Rc>>, depth: i64, @@ -18204,7 +18480,7 @@ pub fn emit_rest_call( source_indices: Rc>>, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { { let client_init = "let client = reqwest::Client::builder().user_agent(\"gunbc/1.0\").build()?;" @@ -18264,7 +18540,9 @@ pub fn emit_rest_call( .iter() .cloned() { - if (l.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(l.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(l); } } @@ -18277,7 +18555,7 @@ pub fn emit_rest_call( pub fn emit_rest_http_method( transport: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match transport_method(transport, source_indices.clone()) { Some(m) => match m.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { @@ -18302,9 +18580,9 @@ pub fn emit_rest_http_method( pub fn emit_rest_url_line( transport: Rc, - op_name: String, + op_name: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match transport_path_template(transport, source_indices.clone()) { Some(path_node) => match (*path_node.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { @@ -18419,9 +18697,9 @@ pub fn emit_rest_url_line( pub fn emit_rest_auth_line( transport: Rc, service_item: Rc, - http_method: String, + http_method: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { { let auth_scheme = service_config_auth(service_item.clone(), source_indices.clone()); let auth_input = service_config_auth_input(service_item.clone(), source_indices.clone()); @@ -18510,7 +18788,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn emit_rest_query_line( transport: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match transport_query(transport, source_indices.clone()) { Some(q) => { let pairs = Rc::new({ @@ -18555,7 +18833,7 @@ pub fn emit_rest_query_line( pub fn emit_rest_body_line( transport: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match transport_request_body(transport, source_indices.clone()) { Some(b) => match (*b.expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => { @@ -18587,23 +18865,26 @@ v1_rt::concat(v1_rt::concat(Rc::new(vec![body_init]), opt_lines), Rc::new(vec![a } } -pub fn has_response_prefix(name: String) -> bool { +pub fn has_response_prefix(name: Rc>) -> bool { if (v1_rt::string_length(&name) < 9) { false } else { - (v1_rt::substring(&name, 0, 9).as_str() == "response_".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring(&name, 0, 9)) + == crate::v2_std_text::host_string_text_to_rust_host("response_".to_string())) } } pub fn child_from_key( ch: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { match Rc::new({ let mut __result = Vec::new(); for p in ch.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "from_key".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + p.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("from_key".to_string())) { __result.push(p); } @@ -18657,8 +18938,10 @@ pub fn has_response_200_property( { let mut __found = false; for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + p.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("response_200".to_string())) { __found = true; break; @@ -18676,8 +18959,10 @@ pub fn operation_response_200_resolved_type( match Rc::new({ let mut __result = Vec::new(); for p in op_node.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "response_200".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + p.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("response_200".to_string())) { __result.push(p); } @@ -18696,7 +18981,9 @@ pub fn operation_response_200_resolved_type( source_indices.clone(), normalize_access_type_node(v.clone()), ); - if (type_name.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { None } else { lookup_type_by_name(env, type_name.clone()) @@ -18714,7 +19001,9 @@ pub fn is_json_wire_declaration_type( ) -> bool { { let n = authored_name_at(source_indices, normalize_access_type_node(t)); - if (n.clone().as_str() == "Json".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Json".to_string())) + { true } else { { @@ -18725,7 +19014,12 @@ pub fn is_json_wire_declaration_type( .collect::>(), ); match parts.last().cloned() { - Some(last) => (last.clone().as_str() == "Json".to_string().as_str()), + Some(last) => { + (crate::v2_std_text::host_string_text_to_rust_host(last.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Json".to_string(), + )) + } None => false, } } @@ -18733,7 +19027,7 @@ pub fn is_json_wire_declaration_type( } } -pub fn path_segment_is_list_index(seg: String) -> bool { +pub fn path_segment_is_list_index(seg: Rc>) -> bool { if (v1_rt::string_length(&seg) == 0) { false } else { @@ -18755,14 +19049,14 @@ pub fn path_segment_is_list_index(seg: String) -> bool { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct WirePathProjection { - pub expr: String, + pub expr: Rc>, pub node: Option>, pub ok: bool, } pub fn wire_child_for_segment( wire_node: Rc, - seg: String, + seg: Rc>, source_indices: Rc>>, ) -> Option> { { @@ -18776,7 +19070,8 @@ pub fn wire_child_for_segment( Some(k) => k.clone(), None => authored.clone(), }; - (wire_key.clone().as_str() == seg.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(wire_key.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(seg.clone())) } { __result.push(ch); } @@ -18794,8 +19089,8 @@ pub fn wire_child_for_segment( pub fn advance_wire_path_projection( state: Rc, - seg: String, - full_path: String, + seg: Rc>, + full_path: Rc>, source_indices: Rc>>, ) -> Rc { if !state.ok.clone() { @@ -18874,9 +19169,9 @@ pub fn advance_wire_path_projection( } pub fn emit_wire_struct_path_chain( - base: String, + base: Rc>, wire_node: Rc, - from_path: String, + from_path: Rc>, source_indices: Rc>>, ) -> Rc { { @@ -18892,7 +19187,9 @@ pub fn emit_wire_struct_path_chain( .iter() .cloned() { - if (s.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(s.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { __result.push(s); } } @@ -18904,7 +19201,7 @@ pub fn emit_wire_struct_path_chain( node: Some(wire_node), ok: true, }), - |acc: Rc, seg: String| { + |acc: Rc, seg: Rc>| { advance_wire_path_projection( acc, seg.clone(), @@ -18917,11 +19214,11 @@ pub fn emit_wire_struct_path_chain( } pub fn emit_typed_wire_field_assign( - field_name: String, - from_path: String, + field_name: Rc>, + from_path: Rc>, wire_node: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let projection = emit_wire_struct_path_chain( "__rest_wire".to_string(), @@ -18946,7 +19243,7 @@ pub fn emit_typed_wire_field_assign( } } -pub fn escape_json_pointer_segment(seg: String) -> String { +pub fn escape_json_pointer_segment(seg: Rc>) -> Rc> { v1_rt::replace( v1_rt::replace(seg, "~".to_string(), "~0".to_string()), "/".to_string(), @@ -18955,10 +19252,10 @@ pub fn escape_json_pointer_segment(seg: String) -> String { } pub fn emit_json_value_extract( - var_name: String, - from_path: String, - dag_type_name: String, -) -> String { + var_name: Rc>, + from_path: Rc>, + dag_type_name: Rc>, +) -> Rc> { { let escaped_path = Rc::new({ let mut __result = Vec::new(); @@ -18978,19 +19275,15 @@ pub fn emit_json_value_extract( }) .join(&"/".to_string()); let pointer = v1_rt::concat("/".to_string(), escaped_path); - let is_dag_string = dag_type_name.as_str() == "String"; - let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name); - let accessor = if is_dag_string { - v1_rt::concat( - v1_rt::concat( - ".and_then(|v| v.as_str()).map(|s| crate::v2_std_text::host_string_text_from_rust_host(s.to_string())).ok_or(\"missing field: " - .to_string(), - from_path.clone(), - ), - "\")?".to_string(), - ) + let rust_type = coerce_primitive_type(RenderTarget::Rust, dag_type_name.clone()); + let accessor = if (crate::v2_std_text::host_string_text_to_rust_host(dag_type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())) + { + v1_rt::concat(v1_rt::concat(".and_then(|v| v.as_str()).map(|s| crate::v2_std_text::host_string_text_from_rust_host(s.to_string())).ok_or(\"missing field: ".to_string(), from_path.clone()), "\")?".to_string()) } else { - if (rust_type.clone().as_str() == "i64".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(rust_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("i64".to_string())) + { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_i64()).ok_or(\"missing field: ".to_string(), @@ -18999,7 +19292,9 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "f64".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(rust_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("f64".to_string())) + { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_f64()).ok_or(\"missing field: ".to_string(), @@ -19008,7 +19303,9 @@ pub fn emit_json_value_extract( "\")?".to_string(), ) } else { - if (rust_type.clone().as_str() == "bool".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(rust_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("bool".to_string())) + { v1_rt::concat( v1_rt::concat( ".and_then(|v| v.as_bool()).ok_or(\"missing field: ".to_string(), @@ -19046,7 +19343,7 @@ pub fn emit_from_key_extraction( source_indices: Rc>>, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { { let rt = resolved_type(op_node.clone()); let children = rt.children.clone(); @@ -19162,12 +19459,14 @@ pub fn emit_plain_response_body( op_node: Rc, transport: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let is_text = match transport_response_format(transport, source_indices.clone()) { Some(fmt) => { - (authored_name_at(source_indices.clone(), fmt.clone()).as_str() - == "Text".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + fmt.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("Text".to_string())) } None => false, }; @@ -19185,7 +19484,7 @@ pub fn emit_response_code_handling( source_indices: Rc>>, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { { let use_from_key = has_from_key_fields(op_node.clone(), source_indices.clone()); let response_props = Rc::new({ @@ -19252,20 +19551,25 @@ pub fn emit_response_arm( source_indices: Rc>>, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 9, v1_rt::string_length(&name)); let is_success = if (v1_rt::string_length(&code_str) >= 1) { - (v1_rt::substring(&code_str, 0, 1).as_str() == "2".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring(&code_str, 0, 1)) + == crate::v2_std_text::host_string_text_to_rust_host("2".to_string())) } else { false }; - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (crate::v2_std_text::host_string_text_to_rust_host(code_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("nonzero".to_string())) + { "_".to_string() } else { if ((v1_rt::string_length(&code_str) == 3) - && (v1_rt::substring(&code_str, 1, 3).as_str() == "xx".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( + &code_str, 1, 3, + )) == crate::v2_std_text::host_string_text_to_rust_host("xx".to_string()))) { { let prefix = v1_rt::substring(&code_str, 0, 1); @@ -19316,11 +19620,12 @@ pub fn emit_response_arm( } } -pub fn has_exit_prefix(name: String) -> bool { +pub fn has_exit_prefix(name: Rc>) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (v1_rt::substring(&name, 0, 5).as_str() == "exit_".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring(&name, 0, 5)) + == crate::v2_std_text::host_string_text_to_rust_host("exit_".to_string())) } } @@ -19328,7 +19633,7 @@ pub fn emit_exit_code_handling( op_node: Rc, inferred: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let exit_props = Rc::new({ let mut __result = Vec::new(); @@ -19346,9 +19651,11 @@ pub fn emit_exit_code_handling( let has_nonzero = { let mut __found = false; for p in exit_props.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "exit_nonzero".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + field_init_node_name_at(p.clone(), source_indices.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "exit_nonzero".to_string(), + )) { __found = true; break; } @@ -19393,16 +19700,19 @@ pub fn emit_exit_arm( prop: Rc, inferred: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let name = field_init_node_name_at(prop, source_indices.clone()); let code_str = v1_rt::substring(&name, 5, v1_rt::string_length(&name)); - let pattern = if (code_str.clone().as_str() == "nonzero".to_string().as_str()) { + let pattern = if (crate::v2_std_text::host_string_text_to_rust_host(code_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("nonzero".to_string())) + { "_".to_string() } else { code_str.clone() }; - let is_success = (code_str.clone().as_str() == "0".to_string().as_str()); + let is_success = (crate::v2_std_text::host_string_text_to_rust_host(code_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())); if is_success { v1_rt::concat( v1_rt::concat( @@ -19421,14 +19731,14 @@ pub fn emit_exit_arm( } pub fn emit_shell_call( - op_name: String, + op_name: Rc>, transport: Rc, registry: Rc>>, depth: i64, inferred: Rc, op_node: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let argv = transport.children.clone(); let optional_params = Rc::new({ @@ -19445,7 +19755,7 @@ pub fn emit_shell_call( .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, p: Rc| { v1_rt::rc_map_insert( acc, @@ -19609,7 +19919,7 @@ pub fn emit_shell_argv_element( arg: Rc, optional_params: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match (*arg.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitStr { value: s, .. } = value.as_ref() else { @@ -19719,7 +20029,7 @@ pub fn emit_shell_argv_element( pub fn emit_shell_return( inferred: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let effective = unwrap_single_field_product(inferred); let is_product = is_product_type(effective.clone()); @@ -19776,7 +20086,11 @@ pub fn emit_shell_return( } __result }); - let lines = if (stderr_line.clone().as_str() != "".to_string().as_str()) { + let lines = if (crate::v2_std_text::host_string_text_to_rust_host( + stderr_line.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { v1_rt::concat(stderr_line.clone(), "\n".to_string()) } else { "".to_string() @@ -19801,15 +20115,26 @@ pub fn emit_shell_return( } } -pub fn emit_shell_channel_expr(channel: String, is_optional: bool) -> String { +pub fn emit_shell_channel_expr( + channel: Rc>, + is_optional: bool, +) -> Rc> { { - let base = if (channel.clone().as_str() == "exit_success".to_string().as_str()) { + let base = if (crate::v2_std_text::host_string_text_to_rust_host(channel.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("exit_success".to_string())) + { "output.status.success()".to_string() } else { - if (channel.clone().as_str() == "stderr".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(channel.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("stderr".to_string())) + { "stderr.clone()".to_string() } else { - if (channel.clone().as_str() == "stdout_lines".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(channel.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "stdout_lines".to_string(), + )) + { "Rc::new(stdout.lines().filter(|l| !l.is_empty()).map(|l| l.trim().to_string()).collect())".to_string() } else { "stdout.clone()".to_string() @@ -19840,7 +20165,7 @@ pub fn unwrap_single_field_product(n: Rc) -> Rc { } } -pub fn emit_file_call(op_name: String, inferred: Rc) -> String { +pub fn emit_file_call(op_name: Rc>, inferred: Rc) -> Rc> { { let effective = unwrap_single_field_product(inferred); let is_product = is_product_type(effective.clone()); @@ -19865,7 +20190,7 @@ pub fn emit_file_call(op_name: String, inferred: Rc) -> String { } } -pub fn emit_local_call(op_name: String) -> String { +pub fn emit_local_call(op_name: Rc>) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -19882,7 +20207,7 @@ pub fn emit_resource_def( item: Rc, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { { let item_text = authored_name(env.clone(), item.clone()); let cap_children = item.children.clone(); @@ -19934,7 +20259,7 @@ pub fn emit_capability_method( cap_node: Rc, shared_types: Rc>, env: Rc, -) -> String { +) -> Rc> { { let input_params = Rc::new({ let mut __result = Vec::new(); @@ -19952,14 +20277,17 @@ pub fn emit_capability_method( Rc::new(vec![]), shared_types.clone(), env.source_indices.clone(), - env.clone(), + v1_rt::rc_empty_map::>, Rc>>(), + env.clone().clone(), ), )); } __result }); let params_str = input_params.join(&", ".to_string()); - let all_params = if (params_str.clone().as_str() == "".to_string().as_str()) { + let all_params = if (crate::v2_std_text::host_string_text_to_rust_host(params_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { "&self".to_string() } else { v1_rt::concat("&self, ".to_string(), params_str.clone()) @@ -20033,7 +20361,7 @@ pub fn data_value_has_cross_refs(value: Rc) -> bool { } pub fn emit_data_def( - name: String, + name: Rc>, type_node: Rc, value: Rc, registry: Rc>>, @@ -20041,7 +20369,7 @@ pub fn emit_data_def( depth: i64, shared_types: Rc>, emit_info: Rc, -) -> String { +) -> Rc> { { let annotation_type_node = type_node.clone(); let render_type_node = if ((annotation_type_node.children.clone().len() as i64) > 0) { @@ -20057,9 +20385,12 @@ pub fn emit_data_def( shared_types.clone(), scope.type_env.clone().source_indices.clone(), ); - let ty_str = if ((raw_ty_str.clone().as_str() == "BoundedLattice".to_string().as_str()) - || (raw_ty_str.clone().as_str() == "Rc".to_string().as_str())) - { + let ty_str = if ((crate::v2_std_text::host_string_text_to_rust_host(raw_ty_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("BoundedLattice".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(raw_ty_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Rc".to_string(), + ))) { match field_value_by_name( value.clone(), "top".to_string(), @@ -20070,11 +20401,15 @@ pub fn emit_data_def( scope.type_env.clone().source_indices.clone(), resolved_type(top_value.clone()), ); - if (top_type_name.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(top_type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { raw_ty_str.clone() } else { - if (raw_ty_str.clone().as_str() - == "Rc".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(raw_ty_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "Rc".to_string(), + )) { v1_rt::concat( v1_rt::concat( @@ -20180,7 +20515,7 @@ pub fn rust_nominal_identity_data_expr( type_node: Rc, value: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { { let type_name = authored_name_at(source_indices.clone(), type_node.clone()); let is_identity_type = (((rust_nominal_identity_carrier_type_eligible(type_name.clone()) @@ -20218,7 +20553,7 @@ pub fn emit_data_def_body( shared_types: Rc>, emit_info: Rc, needs_rc: bool, -) -> String { +) -> Rc> { { let raw_ty_str = render_rust_type( type_node.clone(), @@ -20229,7 +20564,9 @@ pub fn emit_data_def_body( scope.type_env.clone().source_indices.clone(), type_node.clone(), ); - if (type_name.as_str() == "BoundedLattice".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(type_name) + == crate::v2_std_text::host_string_text_to_rust_host("BoundedLattice".to_string())) + { match (*value.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { let lattice_value = field_value_by_name( @@ -20377,33 +20714,30 @@ pub fn emit_data_def_body( v1_rt::concat( v1_rt::concat( v1_rt::concat( - " __m.insert(".to_string(), - emit_rust_host_to_dag_string_via_seam( - v1_rt::concat( + v1_rt::concat( + " __m.insert(".to_string(), + emit_rust_host_to_dag_string_via_seam( v1_rt::concat( - "\"".to_string(), - field_init_node_name_at( - f.clone(), - scope - .type_env - .clone() - .source_indices - .clone(), + v1_rt::concat( + "\"".to_string(), + field_init_node_name_at( + f.clone(), + scope + .type_env + .clone() + .source_indices + .clone(), + ), ), + "\"".to_string(), ), - "\"".to_string(), ), ), + ", ".to_string(), ), - v1_rt::concat( - v1_rt::concat( - ", ".to_string(), - val_str.clone(), - ), - ");".to_string(), - ), + val_str.clone(), ), - "".to_string(), + ");".to_string(), ) }); } @@ -20477,7 +20811,7 @@ pub fn emit_data_def_body( } pub fn emit_test_file( - module_name: String, + module_name: Rc>, projections: Rc>>, ) -> Rc { { @@ -20536,16 +20870,8 @@ pub fn emit_test_file( } } -pub fn rust_test_signature_comment(projection: Rc) -> String { +pub fn rust_test_signature_comment(projection: Rc) -> Rc> { { - let stub_env = Rc::new(TypeEnv { - bindings: Rc::new(HashMap::new()), - recursive_types: Rc::new(vec![]), - recursive_type_set: Rc::new(HashMap::new()), - inductive_fields: Rc::new(HashMap::new()), - source_indices: projection.source_indices.clone(), - intern_table: empty_intern_table(), - }); let params_str = Rc::new({ let mut __result = Vec::new(); for p in projection.params.clone().iter().cloned() { @@ -20559,7 +20885,7 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { Rc::new(vec![]), v1_rt::rc_empty_set::(), projection.source_indices.clone(), - stub_env.clone(), + v1_rt::rc_empty_map::>, Rc>>(), ), )); } @@ -20595,7 +20921,7 @@ pub fn rust_test_signature_comment(projection: Rc) -> String { } } -pub fn emit_operation_test(projection: Rc, depth: i64) -> String { +pub fn emit_operation_test(projection: Rc, depth: i64) -> Rc> { { let test_name = rust_test_name(projection.clone()); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -20612,7 +20938,9 @@ pub fn emit_operation_test(projection: Rc, depth: i64) -> String __result }); let args_str = param_args.join(&", ".to_string()); - let call_args = if (args_str.clone().as_str() == "".to_string().as_str()) { + let call_args = if (crate::v2_std_text::host_string_text_to_rust_host(args_str.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { "".to_string() } else { args_str.clone() @@ -20624,7 +20952,7 @@ pub fn emit_operation_test(projection: Rc, depth: i64) -> String pub fn emit_rust_default_value( param: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let type_name = authored_name_at(source_indices, param_node_type_expr(param)); match lookup_checkpoint(RenderTarget::Rust, type_name.clone()) { @@ -20653,7 +20981,7 @@ pub fn emit_mock_prop_setup( mock_prop: Rc, depth: i64, source_indices: Rc>>, -) -> String { +) -> Rc> { { let body_str = emit_simple_expr( field_init_node_value(mock_prop.clone()), @@ -20676,7 +21004,11 @@ pub fn emit_mock_prop_setup( } } -pub fn emit_cargo_dep(name: String, version: String, features: Rc>) -> String { +pub fn emit_cargo_dep( + name: Rc>, + version: Rc>, + features: Rc>, +) -> Rc> { if ((features.clone().len() as i64) > 0) { { let feat_strs = Rc::new({ @@ -20711,11 +21043,11 @@ pub fn emit_cargo_dep(name: String, version: String, features: Rc>) } } -pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc { +pub fn emit_cargo_toml(crate_name: Rc>, has_services: bool) -> Rc { { let header = v1_rt::concat( - v1_rt::concat("[package]\nname = \"".to_string(), crate_name), - "\"\nversion = \"0.1.0\"\nedition = \"2021\"\n".to_string(), + render_cargo_package_header_prefix(crate_name), + "\nedition = \"2021\"\n".to_string(), ); let workspace = "\n[workspace]\n".to_string(); let base_deps = Rc::new(vec![ @@ -20770,8 +21102,8 @@ pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct WorkflowFunc { - pub name: String, - pub module_name: String, + pub name: Rc>, + pub module_name: Rc>, pub params: Rc>>, pub inferred: Rc, pub uses: Rc>>, @@ -20781,7 +21113,7 @@ pub struct WorkflowFunc { pub source_indices: Rc>>, } -pub fn extract_literal_string(expr: Rc) -> Option { +pub fn extract_literal_string(expr: Rc) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitStr { value: s, .. } => Some(s.clone()), @@ -20801,7 +21133,7 @@ pub fn resolve_param_default( registry: Rc>>, module_items: Rc>>, source_indices: Rc>>, -) -> Option { +) -> Rc> { match param_node_default_value(param) { Some(dv) => match (*dv.expr_data.clone()).clone() { ExprData::ExprLiteral { value: _, .. } => extract_literal_string(dv.clone()), @@ -20815,9 +21147,11 @@ pub fn resolve_param_default( ItemKind::DataItem => match Rc::new({ let mut __result = Vec::new(); for i in module_items.iter().cloned() { - if (authored_name_at(source_indices.clone(), i.clone()).as_str() - == authored_name_at(source_indices.clone(), dv.clone()).as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), i.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), dv.clone()), + )) { __result.push(i); } } @@ -20844,7 +21178,7 @@ pub fn resolve_param_default( pub fn to_workflow_func( item: Rc, - module_name: String, + module_name: Rc>, registry: Rc>>, module_items: Rc>>, source_indices: Rc>>, @@ -20857,7 +21191,7 @@ pub fn to_workflow_func( None => Rc::new(vec![]), }; let defaults = item.params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, p: Rc| match resolve_param_default( p.clone(), registry.clone(), @@ -20965,11 +21299,13 @@ pub fn collect_workflow_funcs( }) } -pub fn cli_default_literal_value(expr: Rc) -> Option { +pub fn cli_default_literal_value(expr: Rc) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitStr { value: s, .. } => Some(s.clone()), - LiteralValue::LitInt { value: i, .. } => Some((i.clone()).to_string()), + LiteralValue::LitInt { value: i, .. } => Some( + crate::v2_std_text::host_string_text_from_rust_host((i.clone()).to_string()), + ), LiteralValue::LitFloat { value: f, .. } => Some(f.clone()), LiteralValue::LitBool { value: b, .. } => Some(if b.clone() { emit_keyword("true".to_string(), RenderTarget::Rust) @@ -21015,7 +21351,10 @@ if resolved.clone() { }) } -pub fn find_resource_module(resource_name: String, modules: Rc>>) -> String { +pub fn find_resource_module( + resource_name: Rc>, + modules: Rc>>, +) -> Rc> { { let matching = Rc::new({ let mut __result = Vec::new(); @@ -21023,13 +21362,12 @@ pub fn find_resource_module(resource_name: String, modules: Rc>>, modules: Rc>>, has_services: bool, - crate_name: String, + crate_name: Rc>, svc_module_map: Rc>, ) -> Rc { { let has_pipeline = { let mut __found = false; for m in modules.clone().iter().cloned() { - if (authored_name_at(m.type_env.clone().source_indices.clone(), m.module.clone()) - .as_str() - == "v1.compiler.compile".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + m.type_env.clone().source_indices.clone(), + m.module.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "v1.compiler.compile".to_string(), + )) { __found = true; break; } @@ -21100,7 +21440,9 @@ pub fn emit_main_rs( __result.extend( (*{ let mod_name = find_resource_module(rname.clone(), modules.clone()); - if (mod_name.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(mod_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { Rc::new(vec![v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -21199,16 +21541,22 @@ pub fn emit_main_rs( } else { "".to_string() }; - let resource_use = if (resource_imports_str.clone().as_str() != "".to_string().as_str()) { - v1_rt::concat(resource_imports_str.clone(), "\n".to_string()) - } else { - "".to_string() - }; - let svc_use = if (svc_imports_str.clone().as_str() != "".to_string().as_str()) { - v1_rt::concat(svc_imports_str.clone(), "\n".to_string()) - } else { - "".to_string() - }; + let resource_use = + if (crate::v2_std_text::host_string_text_to_rust_host(resource_imports_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat(resource_imports_str.clone(), "\n".to_string()) + } else { + "".to_string() + }; + let svc_use = + if (crate::v2_std_text::host_string_text_to_rust_host(svc_imports_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat(svc_imports_str.clone(), "\n".to_string()) + } else { + "".to_string() + }; if (((workflow_funcs.clone().len() as i64) == 0) && (has_pipeline.clone() == false)) { return Rc::new(TextFile { path: v1_rt::concat( @@ -21308,8 +21656,8 @@ pub fn emit_main_rs( pub fn emit_main_mod_uses( workflow_funcs: Rc>>, has_pipeline: bool, - crate_name: String, -) -> String { + crate_name: Rc>, +) -> Rc> { { let mod_names = Rc::new({ let mut __result = Vec::new(); @@ -21350,11 +21698,13 @@ pub fn emit_main_mod_uses( pub fn emit_cli_struct( workflow_funcs: Rc>>, - binary_name: String, - about: String, -) -> String { + binary_name: Rc>, + about: Rc>, +) -> Rc> { { - let about_attr = if (about.clone().as_str() != "".to_string().as_str()) { + let about_attr = if (crate::v2_std_text::host_string_text_to_rust_host(about.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { v1_rt::concat( v1_rt::concat(", about = \"".to_string(), about.clone()), "\"".to_string(), @@ -21405,7 +21755,7 @@ pub fn emit_cli_struct( pub fn emit_subcommand_enum( workflow_funcs: Rc>>, has_pipeline: bool, -) -> String { +) -> Rc> { { let depth = 0; let variants = Rc::new({ @@ -21484,7 +21834,7 @@ pub fn emit_subcommand_enum( } } -pub fn emit_subcommand_variant(wf: Rc, depth: i64) -> String { +pub fn emit_subcommand_variant(wf: Rc, depth: i64) -> Rc> { { let variant_name = to_pascal(wf.name.clone()); let doc_line = v1_rt::concat( @@ -21538,7 +21888,7 @@ pub fn emit_subcommand_field( param: Rc, source_indices: Rc>>, resolved_defaults: Rc>, -) -> String { +) -> Rc> { { let field_name = emit_ident( param_node_name_at(param.clone(), source_indices.clone()), @@ -21582,7 +21932,7 @@ pub fn emit_subcommand_field( pub fn emit_cli_param_type_node( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); let has_structure = (n.connective.clone() != Connective::NoConnective); @@ -21601,11 +21951,26 @@ pub fn emit_cli_param_type_node( if ((n.children.clone().len() as i64) == 0) { { let nname = authored_name_at(source_indices, n.clone()); - let mapped = coerce_primitive_type(RenderTarget::Rust, nname.clone()); - if (mapped.clone().as_str() != nname.clone().as_str()) { - mapped.clone() - } else { + if (crate::v2_std_text::host_string_text_to_rust_host(nname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "String".to_string(), + )) + { "String".to_string() + } else { + { + let mapped = + coerce_primitive_type(RenderTarget::Rust, nname.clone()); + if (crate::v2_std_text::host_string_text_to_rust_host( + mapped.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + nname.clone(), + )) { + mapped.clone() + } else { + "String".to_string() + } + } } } } else { @@ -21620,8 +21985,8 @@ pub fn emit_main_fn( workflow_funcs: Rc>>, has_services: bool, has_pipeline: bool, - crate_name: String, -) -> String { + crate_name: Rc>, +) -> Rc> { { let depth = 0; let async_attr = if has_services.clone() { @@ -21676,20 +22041,23 @@ pub fn emit_main_fn( ";".to_string(), ) }; - let body_lines = if (dry_run_line.clone().as_str() == "".to_string().as_str()) { - v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), result_handling) - } else { - v1_rt::concat( + let body_lines = + if (crate::v2_std_text::host_string_text_to_rust_host(dry_run_line.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { + v1_rt::concat(v1_rt::concat(parse_line, "\n".to_string()), result_handling) + } else { v1_rt::concat( v1_rt::concat( - v1_rt::concat(parse_line, "\n".to_string()), - dry_run_line.clone(), + v1_rt::concat( + v1_rt::concat(parse_line, "\n".to_string()), + dry_run_line.clone(), + ), + "\n".to_string(), ), - "\n".to_string(), - ), - result_handling, - ) - }; + result_handling, + ) + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -21703,26 +22071,18 @@ pub fn emit_main_fn( } } -pub fn emit_compile_match_arm(crate_name: String) -> String { +pub fn emit_compile_match_arm(crate_name: Rc>) -> Rc> { { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("Commands::Compile { source_roots, source_dir, output_dir, target } => {\n".to_string(), " let render_targets = parse_render_targets(&target);\n".to_string()), "\n".to_string()), " let sources = if !source_roots.is_empty() {\n".to_string()), " // FF-9: Import-driven resolution from source roots\n".to_string()), " let index = build_module_index(&source_roots);\n".to_string()), " eprintln!(\"indexed {} modules from {} source roots\", index.len(), source_roots.len());\n".to_string()), "\n".to_string()), " // Entry modules: all .dag files in the FIRST source root.\n".to_string()), " // Additional roots are dependency pools resolved via imports.\n".to_string()), " // This is intentional: --source-root src/v1 --source-root dsl\n".to_string()), " // means 'compile src/v1, using dsl as a dependency pool.'\n".to_string()), " let first_root = std::path::Path::new(&source_roots[0]);\n".to_string()), " let mut entry_files = Vec::new();\n".to_string()), " if first_root.is_dir() {\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(first_root, &mut dag_paths);\n".to_string()), " for path in dag_paths {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " entry_files.push((path.to_string_lossy().to_string(), content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut seen: HashMap> = HashMap::new();\n".to_string()), " let mut entry_for_queue = Vec::new();\n".to_string()), " for (path, content) in &entry_files {\n".to_string()), " if let Some(mod_path) = extract_module_path(content) {\n".to_string()), " let source = Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(mod_path, source);\n".to_string()), " }\n".to_string()), " entry_for_queue.push((path.clone(), content.clone()));\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut resolved = resolve_transitively_with_seen(entry_for_queue, &index, seen);\n".to_string()), " for (path, content) in entry_files {\n".to_string()), " let already_there = resolved.iter().any(|s| s.path == path);\n".to_string()), " if !already_there {\n".to_string()), " resolved.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile { path, content }));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " eprintln!(\"resolved {} sources (transitive import closure)\", resolved.len());\n".to_string()), " resolved\n".to_string()), "\n".to_string()), " } else if let Some(dir) = source_dir {\n".to_string()), " // Legacy: flat directory scan (backward compatibility)\n".to_string()), " let mut dag_paths = Vec::new();\n".to_string()), " collect_dag_files(std::path::Path::new(&dir), &mut dag_paths);\n".to_string()), " let mut sources = Vec::new();\n".to_string()), " for path in &dag_paths {\n".to_string()), " let content = std::fs::read_to_string(path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " let filename = path.file_name().unwrap().to_string_lossy().to_string();\n".to_string()), " sources.push(Rc::new(".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: filename,\n".to_string()), " content,\n".to_string()), " }));\n".to_string()), " }\n".to_string()), " eprintln!(\"compiling {} .dag files from {} (target: {})\", sources.len(), dir, target);\n".to_string()), " sources\n".to_string()), "\n".to_string()), " } else {\n".to_string()), " eprintln!(\"error: provide --source-root or --source-dir\");\n".to_string()), " std::process::exit(1);\n".to_string()), " };\n".to_string()), "\n".to_string()), " if render_targets.len() == 1 {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::compile_sources(Rc::new(sources), render_targets[0].1.clone());\n".to_string()), " write_output_files(&output_dir, &result);\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " if hard_errors(&result) {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"error: no files emitted\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " } else {\n".to_string()), " let resolved = ".to_string()), pipeline_mod.clone()), "::compile_to_resolved(Rc::new(sources));\n".to_string()), " let mut any_hard_errors = false;\n".to_string()), " let mut any_empty = false;\n".to_string()), " let mut total_files = 0usize;\n".to_string()), " let mut total_diagnostics = 0usize;\n".to_string()), " for (name, render_target) in render_targets {\n".to_string()), " let result = ".to_string()), pipeline_mod.clone()), "::emit_resolved_for_target(resolved.clone(), render_target);\n".to_string()), " let target_output_dir = format!(\"{}/{}\", output_dir, name);\n".to_string()), " write_output_files(&target_output_dir, &result);\n".to_string()), " eprintln!(\"compiled[{}]: {} files emitted, {} diagnostics\", name, result.files.len(), result.diagnostics.len());\n".to_string()), " render_diagnostics(&result);\n".to_string()), " any_hard_errors |= hard_errors(&result);\n".to_string()), " any_empty |= result.files.is_empty();\n".to_string()), " total_files += result.files.len();\n".to_string()), " total_diagnostics += result.diagnostics.len();\n".to_string()), " }\n".to_string()), " eprintln!(\"compiled: {} files emitted, {} diagnostics\", total_files, total_diagnostics);\n".to_string()), " if any_hard_errors {\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " if any_empty {\n".to_string()), " eprintln!(\"error: no files emitted for at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " },".to_string()) } } -pub fn emit_run_match_arm(crate_name: String) -> String { - v1_rt::concat( - v1_rt::concat( - "\n Commands::Run { source_roots, function, entry, claim_run } => {\n" - .to_string(), - " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n" - .to_string(), - ), - " },".to_string(), - ) +pub fn emit_run_match_arm(crate_name: Rc>) -> Rc> { + v1_rt::concat(v1_rt::concat("\n Commands::Run { source_roots, function, entry, claim_run } => {\n".to_string(), " cli_run::handle_run_with_options(source_roots, function, entry, cli.dry_run, claim_run);\n".to_string()), " },".to_string()) } -pub fn emit_main_pipeline_fns(crate_name: String) -> String { +pub fn emit_main_pipeline_fns(crate_name: Rc>) -> Rc> { { let pipeline_mod = module_to_filename("v1.compiler.compile".to_string()); let artifact_mod = module_to_filename("v1.compiler.artifact".to_string()); @@ -21743,41 +22103,44 @@ pub fn emit_main_pipeline_fns(crate_name: String) -> String { } pub fn emit_compile_target_helpers( - crate_name: String, - pipeline_mod: String, - artifact_mod: String, -) -> String { + crate_name: Rc>, + pipeline_mod: Rc>, + artifact_mod: Rc>, +) -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("fn render_target_from_name(target: &str) -> Option<".to_string(), crate_name.clone()), "::".to_string()), artifact_mod.clone()), "::RenderTarget> {\n".to_string()), " match target {\n".to_string()), " \"rust\" => Some(".to_string()), crate_name.clone()), "::".to_string()), artifact_mod.clone()), "::RenderTarget::Rust),\n".to_string()), " \"python\" => Some(".to_string()), crate_name.clone()), "::".to_string()), artifact_mod.clone()), "::RenderTarget::Python),\n".to_string()), " \"go\" => Some(".to_string()), crate_name.clone()), "::".to_string()), artifact_mod.clone()), "::RenderTarget::Go),\n".to_string()), " \"dag\" => Some(".to_string()), crate_name.clone()), "::".to_string()), artifact_mod.clone()), "::RenderTarget::Dag),\n".to_string()), " _ => None,\n".to_string()), " }\n".to_string()), "}\n".to_string()), "\n".to_string()), "fn parse_render_targets(target: &str) -> Vec<(String, ".to_string()), crate_name.clone()), "::".to_string()), artifact_mod.clone()), "::RenderTarget)> {\n".to_string()), " let mut targets = Vec::new();\n".to_string()), " for part in target.split('+') {\n".to_string()), " let trimmed = part.trim();\n".to_string()), " if trimmed.is_empty() {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " match render_target_from_name(trimmed) {\n".to_string()), " Some(render_target) => targets.push((trimmed.to_string(), render_target)),\n".to_string()), " None => {\n".to_string()), " eprintln!(\"unknown target: {}. supported: rust, python, go, dag, rust+dag\", target);\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), " if targets.is_empty() {\n".to_string()), " eprintln!(\"error: --target must name at least one target\");\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " targets\n".to_string()), "}\n".to_string()), "\n".to_string()), "fn write_output_files(output_dir: &str, result: &".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::PipelineResult) {\n".to_string()), " std::fs::create_dir_all(format!(\"{}/src\", output_dir))\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to create output dir: {}\", e));\n".to_string()), " for file in result.files.iter() {\n".to_string()), " let out_path = format!(\"{}/{}\", output_dir, file.path);\n".to_string()), " if let Some(parent) = std::path::Path::new(&out_path).parent() {\n".to_string()), " std::fs::create_dir_all(parent).ok();\n".to_string()), " }\n".to_string()), " std::fs::write(&out_path, &*file.content)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to write {}: {}\", file.path, e));\n".to_string()), " }\n".to_string()), "}\n".to_string()), "\n".to_string()), "fn hard_errors(result: &".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::PipelineResult) -> bool {\n".to_string()), " result.diagnostics.iter().any(|d| {\n".to_string()), " !matches!(*d.diagnostic.clone(), CompilerDiagnostic::ComplexityUnknown { .. })\n".to_string()), " })\n".to_string()), "}\n".to_string()), "\n".to_string()) } -pub fn emit_collect_dag_files_fn() -> String { +pub fn emit_collect_dag_files_fn() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("/// Recursively find all .dag files under a directory.\n".to_string(), "/// Fail-closed: panics on unreadable directory entries.\n".to_string()), "fn collect_dag_files(dir: &std::path::Path, files: &mut Vec) {\n".to_string()), " let mut entries: Vec<_> = std::fs::read_dir(dir)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read dir {:?}: {}\", dir, e))\n".to_string()), " .map(|e| e.unwrap_or_else(|e| panic!(\"failed to read dir entry in {:?}: {}\", dir, e)))\n".to_string()), " .collect();\n".to_string()), " entries.sort_by_key(|e| e.file_name());\n".to_string()), " for entry in entries {\n".to_string()), " let path = entry.path();\n".to_string()), " if path.is_dir() {\n".to_string()), " collect_dag_files(&path, files);\n".to_string()), " } else if path.extension().map(|e| e == \"dag\").unwrap_or(false) {\n".to_string()), " files.push(path);\n".to_string()), " }\n".to_string()), " }\n".to_string()), "}\n\n".to_string()) } -pub fn emit_extract_module_path_fn() -> String { +pub fn emit_extract_module_path_fn() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("/// Extract the `module x.y.z` declaration from a .dag file's first lines.\n".to_string(), "fn extract_module_path(content: &str) -> Option {\n".to_string()), " for line in content.lines() {\n".to_string()), " let trimmed = line.trim();\n".to_string()), " if trimmed.starts_with(\"module \") {\n".to_string()), " return Some(trimmed[\"module \".len()..].trim().to_string());\n".to_string()), " }\n".to_string()), " if !trimmed.is_empty() && !trimmed.starts_with(\"//\") {\n".to_string()), " break;\n".to_string()), " }\n".to_string()), " }\n".to_string()), " None\n".to_string()), "}\n\n".to_string()) } -pub fn emit_extract_import_paths_fn() -> String { +pub fn emit_extract_import_paths_fn() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("/// Extract import module paths from a .dag file's import declarations.\n".to_string(), "fn extract_import_paths(content: &str) -> Vec {\n".to_string()), " let mut imports = Vec::new();\n".to_string()), " for line in content.lines() {\n".to_string()), " let trimmed = line.trim();\n".to_string()), " if trimmed.starts_with(\"import \") {\n".to_string()), " let rest = trimmed[\"import \".len()..].trim();\n".to_string()), " let module_path = rest.split('{').next().unwrap_or(rest).trim();\n".to_string()), " if !module_path.is_empty() {\n".to_string()), " imports.push(module_path.to_string());\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), " imports\n".to_string()), "}\n\n".to_string()) } -pub fn emit_build_module_index_fn() -> String { +pub fn emit_build_module_index_fn() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("/// Build module index: scan all source roots, map module_path -> file_path.\n".to_string(), "/// Fail-closed: panics on missing roots, unreadable files, and duplicate module paths.\n".to_string()), "fn build_module_index(source_roots: &[String]) -> HashMap {\n".to_string()), " let mut index = HashMap::new();\n".to_string()), " for root in source_roots {\n".to_string()), " let root_path = std::path::Path::new(root);\n".to_string()), " if !root_path.exists() {\n".to_string()), " panic!(\"source root does not exist: {}\", root);\n".to_string()), " }\n".to_string()), " let mut dag_files = Vec::new();\n".to_string()), " collect_dag_files(root_path, &mut dag_files);\n".to_string()), " for path in dag_files {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " if let Some(module_path) = extract_module_path(&content) {\n".to_string()), " if let Some(existing) = index.get(&module_path) {\n".to_string()), " panic!(\"duplicate module path '{}': declared in both {:?} and {:?}\",\n".to_string()), " module_path, existing, path);\n".to_string()), " }\n".to_string()), " index.insert(module_path, path);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), " index\n".to_string()), "}\n\n".to_string()) } -pub fn emit_resolve_transitively_fn(crate_name: String, pipeline_mod: String) -> String { +pub fn emit_resolve_transitively_fn( + crate_name: Rc>, + pipeline_mod: Rc>, +) -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("/// Resolve imports transitively from entry modules.\n".to_string(), "/// Fail-closed: panics on unreadable imported files.\n".to_string()), "/// Returns sources sorted by path for deterministic fixed-point convergence.\n".to_string()), "fn resolve_transitively_with_seen(\n".to_string()), " entry_sources: Vec<(String, String)>,\n".to_string()), " index: &HashMap,\n".to_string()), " mut seen: HashMap>,\n".to_string()), ") -> Vec> {\n".to_string()), " let mut queue: Vec<(String, String)> = entry_sources;\n".to_string()), "\n".to_string()), " while let Some((_path, content)) = queue.pop() {\n".to_string()), " let imports = extract_import_paths(&content);\n".to_string()), " for module_path in imports {\n".to_string()), " if seen.contains_key(&module_path) {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " if let Some(file_path) = index.get(&module_path) {\n".to_string()), " let file_content = std::fs::read_to_string(file_path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read imported module '{}' at {:?}: {}\",\n".to_string()), " module_path, file_path, e));\n".to_string()), " let rel_path = file_path.to_string_lossy().to_string();\n".to_string()), " let source = Rc::new(".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: rel_path.clone(),\n".to_string()), " content: file_content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(module_path, source);\n".to_string()), " queue.push((rel_path, file_content));\n".to_string()), " }\n".to_string()), " // If not found in index, the compiler's resolve stage will report the error.\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut result: Vec<_> = seen.into_values().collect();\n".to_string()), " result.sort_by(|a, b| a.path.cmp(&b.path));\n".to_string()), " result\n".to_string()), "}\n\n".to_string()) } -pub fn emit_main_diagnostic_fns(crate_name: String) -> String { +pub fn emit_main_diagnostic_fns(crate_name: Rc>) -> Rc> { { let core_mod = module_to_filename("v1.std.core".to_string()); v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("\nfn render_diagnostics(result: &PipelineResult) {\n".to_string(), " if result.diagnostics.is_empty() {\n".to_string()), " return;\n".to_string()), " }\n".to_string()), "\n".to_string()), " let index_map: HashMap> = result\n".to_string()), " .newline_indices\n".to_string()), " .iter()\n".to_string()), " .map(|idx| (idx.file.clone(), idx.clone()))\n".to_string()), " .collect();\n".to_string()), "\n".to_string()), " for d in result.diagnostics.iter() {\n".to_string()), " render_one_diagnostic(d, &index_map, \"\");\n".to_string()), " }\n".to_string()), "\n".to_string()), " eprintln!(\"\\n{} error(s)\", result.diagnostics.len());\n".to_string()), "}\n".to_string()), "\n".to_string()), "fn render_one_diagnostic(\n".to_string()), " d: &".to_string()), crate_name), "::".to_string()), core_mod), "::ErrorNode,\n".to_string()), " index_map: &HashMap>,\n".to_string()), " indent: &str,\n".to_string()), ") {\n".to_string()), " let severity = \"error\";\n".to_string()), " let message = diagnostic_to_message(d.diagnostic.clone());\n".to_string()), " let span = diagnostic_to_span(d.diagnostic.clone());\n".to_string()), "\n".to_string()), " let location = if !span.file.is_empty() {\n".to_string()), " if let Some(idx) = index_map.get(&span.file) {\n".to_string()), " let lc = byte_to_line_col(idx.clone(), span.start);\n".to_string()), " format!(\"{}:{}:{}\", span.file, lc.line, lc.col)\n".to_string()), " } else {\n".to_string()), " span.file.clone()\n".to_string()), " }\n".to_string()), " } else if !d.module_name.is_empty() {\n".to_string()), " d.module_name.clone()\n".to_string()), " } else {\n".to_string()), " String::new()\n".to_string()), " };\n".to_string()), "\n".to_string()), " if location.is_empty() {\n".to_string()), " eprintln!(\"{}{}: {}\", indent, severity, message);\n".to_string()), " } else {\n".to_string()), " eprintln!(\"{}{}[{}]: {}\", indent, severity, location, message);\n".to_string()), " }\n".to_string()), "\n".to_string()), " if !span.file.is_empty() {\n".to_string()), " if let Some(idx) = index_map.get(&span.file) {\n".to_string()), " let lc = byte_to_line_col(idx.clone(), span.start);\n".to_string()), " let line_text = source_line_at(idx.clone(), lc.line);\n".to_string()), " let line_num = format!(\"{}\", lc.line);\n".to_string()), " let gutter_width = line_num.len();\n".to_string()), " eprintln!(\"{} {} |\", indent, \" \".repeat(gutter_width));\n".to_string()), " eprintln!(\"{} {} | {}\", indent, line_num, line_text);\n".to_string()), "\n".to_string()), " let span_len = std::cmp::max(1, (span.end - span.start) as usize);\n".to_string()), " let col_offset = (lc.col - 1) as usize;\n".to_string()), " eprintln!(\n".to_string()), " \"{} {} | {}{}\",\n".to_string()), " indent,\n".to_string()), " \" \".repeat(gutter_width),\n".to_string()), " \" \".repeat(col_offset),\n".to_string()), " \"^\".repeat(std::cmp::min(span_len, line_text.len().saturating_sub(col_offset)))\n".to_string()), " );\n".to_string()), " }\n".to_string()), " }\n".to_string()), "}\n".to_string()) } } -pub fn emit_main_match_arm(wf: Rc, has_services: bool) -> String { +pub fn emit_main_match_arm(wf: Rc, has_services: bool) -> Rc> { { let variant_name = to_pascal(wf.name.clone()); let mod_name = module_to_filename(wf.module_name.clone()); @@ -21860,7 +22223,7 @@ pub fn emit_main_match_arm(wf: Rc, has_services: bool) -> String { } } -pub fn emit_main_call_args(wf: Rc, has_services: bool) -> String { +pub fn emit_main_call_args(wf: Rc, has_services: bool) -> Rc> { { let param_args = Rc::new({ let mut __result = Vec::new(); @@ -21878,7 +22241,7 @@ pub fn emit_main_call_args(wf: Rc, has_services: bool) -> String { } } -pub fn emit_main_service_args(wf: Rc, has_services: bool) -> String { +pub fn emit_main_service_args(wf: Rc, has_services: bool) -> Rc> { { let service_args = emit_main_service_arg_list(wf, has_services); service_args.join(&", ".to_string()) diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 88f94cf7a6a..3753f5e0dea 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -162,9 +162,11 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn is_witness_type_name(name: String) -> bool { - ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) +pub fn is_witness_type_name(name: Rc>) -> bool { + ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("witness".to_string()))) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -199,7 +201,7 @@ pub struct InferScope { pub func_env: Rc, pub locals: Rc>>, pub match_bound_names: Rc>, - pub module_name: String, + pub module_name: Rc>, pub service_registry: Rc>>>>, pub item_registry: Rc>>, pub lambda_param_provenance: Rc>>, @@ -517,11 +519,11 @@ pub fn merge_scope_from_imports( } } -pub fn nominal_leaf_type(name: String) -> Rc { +pub fn nominal_leaf_type(name: Rc>) -> Rc { nominal_type_ref(name) } -pub fn nominal_type_binding(name: String) -> Rc { +pub fn nominal_type_binding(name: Rc>) -> Rc { Rc::new(TypeBinding { name: name.clone(), resolved: nominal_leaf_type(name.clone()), @@ -532,12 +534,12 @@ pub fn nominal_type_binding(name: String) -> Rc { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FieldRecursionResult { pub shape: RecursionShape, - pub element_type: String, + pub element_type: Rc>, } pub fn classify_field_recursion( field_node: Rc, - parent_name: String, + parent_name: Rc>, recursive_type_set: Rc>, source_indices: Rc>>, ) -> Option> { @@ -547,7 +549,9 @@ pub fn classify_field_recursion( _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); - if (field_type_name.clone().as_str() == parent_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(field_type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(parent_name.clone())) + { match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, @@ -575,17 +579,23 @@ pub fn classify_field_recursion( Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; - let is_recursive_element = ((value_type.clone().as_str() - == parent_name.clone().as_str()) - || v1_rt::set_contains(&recursive_type_set, value_type.clone())); + let is_recursive_element = + ((crate::v2_std_text::host_string_text_to_rust_host(value_type.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + parent_name.clone(), + )) + || v1_rt::set_contains(&recursive_type_set, value_type.clone())); if is_recursive_element { { - let elem = - if (value_type.clone().as_str() == parent_name.clone().as_str()) { - parent_name.clone() - } else { - value_type.clone() - }; + let elem = if (crate::v2_std_text::host_string_text_to_rust_host( + value_type.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + parent_name.clone(), + )) { + parent_name.clone() + } else { + value_type.clone() + }; match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, @@ -628,8 +638,8 @@ pub fn classify_field_recursion( pub fn collect_fields_inductive( fields: Rc>>, - parent_name: String, - variant_name: String, + parent_name: Rc>, + variant_name: Rc>, recursive_type_set: Rc>, acc: Rc>>>>, source_indices: Rc>>, @@ -666,7 +676,7 @@ pub fn collect_item_inductive_fields( let item_name = authored_name_at(source_indices.clone(), item.clone()); match item.connective.clone() { Connective::Disj => item.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |variant_acc: Rc>>>>, variant_node: Rc| { collect_fields_inductive( @@ -684,10 +694,10 @@ pub fn collect_item_inductive_fields( item_name.clone(), "".to_string(), recursive_type_set.clone(), - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), source_indices.clone(), ), - _ => v1_rt::rc_empty_map::>>>(), + _ => v1_rt::rc_empty_map::>, Rc>>>(), } } } @@ -698,7 +708,7 @@ pub fn build_item_inductive_fields( source_indices: Rc>>, ) -> Rc>>>> { items.iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |acc: Rc>>>>, item: Rc| { merge_inductive_fields( acc, @@ -713,7 +723,7 @@ pub fn build_item_inductive_fields( } pub fn nominal_ref_node( - name: String, + name: Rc>, span: Rc, ident_span: Option>, ) -> Rc { @@ -747,15 +757,18 @@ pub fn resolved_callable_type(func_params: Rc>>, ret: Rc) -> pub fn namespace_root_from_properties( properties: Rc>>, - name: String, + name: Rc>, source_indices: Rc>>, -) -> String { +) -> Rc> { match Rc::new({ let mut __result = Vec::new(); for p in properties.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "namespace_root".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + p.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "namespace_root".to_string(), + )) { __result.push(p); } } @@ -790,15 +803,18 @@ pub fn ok_infer(texpr: Rc) -> Rc { }) } -pub fn semantic_expr_error_node(message: String, span: Rc) -> Rc { +pub fn semantic_expr_error_node(message: Rc>, span: Rc) -> Rc { make_expr_error_node(ExprErrorKind::SemanticExprError, message, span) } -pub fn internal_expr_error_node(message: String, span: Rc) -> Rc { +pub fn internal_expr_error_node(message: Rc>, span: Rc) -> Rc { make_expr_error_node(ExprErrorKind::InternalExprError, message, span) } -pub fn lookup_variant_parent_enum(scope: Rc, name: String) -> Option { +pub fn lookup_variant_parent_enum( + scope: Rc, + name: Rc>, +) -> Rc> { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { Some(parent) => { @@ -826,7 +842,10 @@ pub fn lookup_variant_parent_enum(scope: Rc, name: String) -> Option } } -pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc { +pub fn infer_var_binding_kind( + scope: Rc, + name: Rc>, +) -> Rc { match lookup_variant_parent_enum(scope.clone(), name.clone()) { Some(parent_enum) => Rc::new(VarBindingKind::VariantValueBinding { parent_enum: parent_enum.clone(), @@ -845,9 +864,9 @@ pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc>, span: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::InternalError { @@ -859,10 +878,10 @@ pub fn inference_error( } pub fn type_mismatch_error( - expected: String, - got: String, + expected: Rc>, + got: Rc>, span: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::TypeMismatch { @@ -885,13 +904,16 @@ pub fn rejects_string_for_optional_coproduct_field( == Cardinality::CardOptional) && (expected_inner.connective.clone() == Connective::Disj)); let got_is_string = - (authored_name_at(source_indices, got).as_str() == "String".to_string().as_str()); + (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices, + got, + )) == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())); (expected_is_optional_coproduct && got_is_string) } } pub fn record_lit_expected_fields( - type_name: Option, + type_name: Rc>, scope: Rc, ) -> Rc>> { match type_name { @@ -903,13 +925,14 @@ pub fn record_lit_expected_fields( Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { - if (authored_name_at( - scope.type_env.clone().source_indices.clone(), - v.clone(), - ) - .as_str() - == tn.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( + scope.type_env.clone().source_indices.clone(), + v.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + tn.clone(), + )) { __result.push(v); } } @@ -932,19 +955,17 @@ pub fn record_lit_expected_fields( } pub fn record_lit_expanded_from_expected( - type_name: Option, + type_name: Rc>, expected: Option>, scope: Rc, ) -> Option> { match type_name { Some(tn) => match expected { Some(exp) => { - if (((authored_name_at( + if (((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( scope.type_env.clone().source_indices.clone(), exp.clone(), - ) - .as_str() - == tn.clone().as_str()) + )) == crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { @@ -952,12 +973,12 @@ pub fn record_lit_expanded_from_expected( } else { match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { - if (authored_name_at( - scope.type_env.clone().source_indices.clone(), - expanded.clone(), - ) - .as_str() - == tn.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( + scope.type_env.clone().source_indices.clone(), + expanded.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) { Some(expanded.clone()) } else { @@ -966,12 +987,12 @@ pub fn record_lit_expanded_from_expected( } _ => { let rt = resolved_type(exp.clone()); - if (authored_name_at( - scope.type_env.clone().source_indices.clone(), - rt.clone(), - ) - .as_str() - == tn.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( + scope.type_env.clone().source_indices.clone(), + rt.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) { Some(rt.clone()) } else { @@ -988,7 +1009,7 @@ pub fn record_lit_expanded_from_expected( } pub fn record_lit_fields_from_expected( - type_name: Option, + type_name: Rc>, expected: Option>, scope: Rc, ) -> Option>>> { @@ -1007,16 +1028,17 @@ pub fn record_lit_fields_from_expected( } pub fn record_lit_instantiated_fields( - type_name: Option, + type_name: Rc>, expected: Option>, scope: Rc, ) -> Option>>> { match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) - .as_str() - != tn.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + scope.type_env.clone().source_indices.clone(), + exp.clone(), + )) != crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) { None } else { @@ -1031,7 +1053,7 @@ pub fn record_lit_instantiated_fields( None } else { { - let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { + let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pair: (i64, Rc)| { let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), @@ -1183,13 +1205,22 @@ pub fn type_node_is_callable(n: Rc) -> bool { ((n.params.clone().len() as i64) > 0) } -pub fn module_skips_direct_call_arg_check(module_name: String) -> bool { +pub fn module_skips_direct_call_arg_check(module_name: Rc>) -> bool { { let is_v4 = ((v1_rt::string_length(&module_name) >= 3) - && (v1_rt::substring(&module_name, 0, 3).as_str() == "v2.".to_string().as_str())); + && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( + &module_name, + 0, + 3, + )) == crate::v2_std_text::host_string_text_to_rust_host("v2.".to_string()))); let is_compiler_substrate = ((v1_rt::string_length(&module_name) >= 13) - && (v1_rt::substring(&module_name, 0, 13).as_str() - == "v1.compiler.".to_string().as_str())); + && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( + &module_name, + 0, + 13, + )) == crate::v2_std_text::host_string_text_to_rust_host( + "v1.compiler.".to_string(), + ))); (is_v4 || is_compiler_substrate) } } @@ -1204,13 +1235,17 @@ pub fn nominal_call_arg_brand_mismatch( let actual_name = authored_name_at(source_indices.clone(), actual.clone()); ((((((((formal.connective.clone() != Connective::Arrow) && (actual.connective.clone() != Connective::Arrow)) - && (formal_name.clone().as_str() != "".to_string().as_str())) - && (actual_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() != actual_name.clone().as_str())) - && (structural_carrier_template_name(formal.clone(), source_indices.clone()) - .as_str() - == structural_carrier_template_name(actual.clone(), source_indices.clone()) - .as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + && (crate::v2_std_text::host_string_text_to_rust_host(actual_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + && (crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(actual_name.clone()))) + && (crate::v2_std_text::host_string_text_to_rust_host( + structural_carrier_template_name(formal.clone(), source_indices.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + structural_carrier_template_name(actual.clone(), source_indices.clone()), + ))) && !is_declared_container_alias_spelling(formal_name.clone())) && !is_declared_container_alias_spelling(actual_name.clone())) } @@ -1220,13 +1255,18 @@ pub fn container_element_nominal_brand_mismatch( formal: Rc, actual: Rc, type_env: Rc, - module_name: String, + module_name: Rc>, source_indices: Rc>>, ) -> bool { if ((node_is_element_collection(formal.clone(), source_indices.clone()) && node_is_element_collection(actual.clone(), source_indices.clone())) - && (authored_name_at(source_indices.clone(), formal.clone()).as_str() - == authored_name_at(source_indices.clone(), actual.clone()).as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + formal.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + actual.clone(), + )))) { match formal.children.clone().first().cloned() { Some(formal_ch) => match actual.children.clone().first().cloned() { @@ -1256,7 +1296,7 @@ pub fn direct_call_arg_type_mismatch( formal: Rc, actual: Rc, type_env: Rc, - module_name: String, + module_name: Rc>, source_indices: Rc>>, ) -> bool { if (type_node_is_callable(formal.clone()) || type_node_is_callable(actual.clone())) { @@ -1278,7 +1318,7 @@ pub fn direct_call_arg_mismatch_diags( typed_args: Rc>>, call_subst: Rc>>, type_env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc>> { { let source_indices = type_env.source_indices.clone(); @@ -1352,13 +1392,15 @@ pub struct Tier2bBt { } pub fn infer_tier2b_builtin_with_kernel_diags( - func_name: String, + func_name: Rc>, typed_args: Rc>>, scope: Rc, span: Rc, ) -> Rc { - if ((func_name.clone().as_str() == "lookup".to_string().as_str()) - || (func_name.clone().as_str() == "map_get".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("lookup".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("map_get".to_string()))) { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { @@ -1374,7 +1416,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => { match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(value_type) => { - if (func_name.clone().as_str() == "lookup".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "lookup".to_string(), + )) { witness_of_element(value_type.clone()) } else { with_optional_cardinality(value_type.clone()) @@ -1390,7 +1436,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( kernel_diags: Rc::new(vec![]), }) } else { - if (func_name.clone().as_str() == "map_keys".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("map_keys".to_string())) + { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1427,7 +1475,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (func_name.clone().as_str() == "map_values".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("map_values".to_string())) + { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1465,15 +1515,31 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (((func_name.clone().as_str() == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_union".to_string().as_str())) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + if (((crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "set_insert".to_string(), + )) + || (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "set_union".to_string(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "set_contains".to_string(), + ))) { { - let operand_elem = if ((func_name.clone().as_str() - == "set_insert".to_string().as_str()) - || (func_name.clone().as_str() == "set_contains".to_string().as_str())) - { + let operand_elem = if ((crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "set_insert".to_string(), + )) + || (crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "set_contains".to_string(), + ))) { match typed_args.clone().get(1 as usize).cloned() { Some(insert_arg) => match arg_value(insert_arg.clone()) .inferred @@ -1516,18 +1582,22 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } None => false, }; - let union_other_bad = - if (func_name.clone().as_str() == "set_union".to_string().as_str()) { - match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => set_union_other_operand_is_resolved_non_set( - other_arg.clone(), - scope.clone(), - ), - None => false, - } - } else { - false - }; + let union_other_bad = if (crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "set_union".to_string(), + )) { + match typed_args.clone().get(1 as usize).cloned() { + Some(other_arg) => set_union_other_operand_is_resolved_non_set( + other_arg.clone(), + scope.clone(), + ), + None => false, + } + } else { + false + }; let recv_elem = match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1590,9 +1660,11 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { Rc::new(vec![]) }; - let result_bt = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let result_bt = if (crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "set_contains".to_string(), + )) { if (recv_is_set.clone() && !elem_mismatch.clone()) { bool_type() } else { @@ -1635,9 +1707,12 @@ pub fn infer_tier2b_builtin_with_kernel_diags( None => resolve_builtin_call_type(func_name.clone()), } }; - let build_diags = if (func_name.clone().as_str() - == "set_contains".to_string().as_str()) - { + let build_diags = if (crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "set_contains".to_string(), + )) { Rc::new(vec![]) } else { match operand_elem.clone() { @@ -1685,11 +1760,13 @@ pub struct MethodPipeFallback { pub fn method_pipe_map_keys_values_fallback( recv_rt: Rc, - method_name: String, + method_name: Rc>, scope: Rc, span: Rc, ) -> Rc { - if (method_name.clone().as_str() == "map_keys".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("map_keys".to_string())) + { match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); @@ -1704,7 +1781,9 @@ pub fn method_pipe_map_keys_values_fallback( }), } } else { - if (method_name.clone().as_str() == "map_values".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("map_values".to_string())) + { match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); @@ -1728,10 +1807,10 @@ pub fn method_pipe_map_keys_values_fallback( } pub fn categorized_error( - message: String, + message: Rc>, span: Rc, - module_name: String, - category: String, + module_name: Rc>, + category: Rc>, ) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::InternalError { @@ -1744,15 +1823,17 @@ pub fn categorized_error( pub fn validate_cast( source_inferred: Option>, - target_name: String, + target_name: Rc>, span: Rc, source_indices: Rc>>, - module_name: String, + module_name: Rc>, ) -> Option> { match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { let source_name = authored_name_at(source_indices, src_node.clone()); - if (source_name.clone().as_str() == target_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(source_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(target_name.clone())) + { None } else { if !is_dag_cast_domain_type(source_name.clone()) { @@ -1790,7 +1871,7 @@ pub fn validate_cast( } } -pub fn type_variable_node(id: String) -> Rc { +pub fn type_variable_node(id: Rc>) -> Rc { Rc::new(Node { name: "".to_string(), span: make_span(0, 0), @@ -1822,7 +1903,7 @@ pub fn is_type_variable(inferred: Rc) -> bool { pub fn inferred_or_error( result: Option>, - fallback_message: String, + fallback_message: Rc>, fallback_span: Rc, ) -> Rc { match result { @@ -1880,23 +1961,48 @@ pub fn annotate_pattern_parent_enums( let optional_cardinality_subject = ((resolved_scrut_node.return_cardinality.clone() == Cardinality::CardOptional) - && (scrutinee_name.clone().as_str() - != "Optional".to_string().as_str())); - let optional_coproduct_subject = ((scrutinee_name.clone().as_str() - == "Optional".to_string().as_str()) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))); + && (crate::v2_std_text::host_string_text_to_rust_host( + scrutinee_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "Optional".to_string(), + ))); + let optional_coproduct_subject = + ((crate::v2_std_text::host_string_text_to_rust_host( + scrutinee_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Optional".to_string(), + )) && ((crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + )) || (crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "Absent".to_string(), + )))); let witness_container_subject = (is_witness_type_name(scrutinee_name.clone()) - && ((variant_name.clone().as_str() - == "Holds".to_string().as_str()) - || (variant_name.clone().as_str() - == "Violates".to_string().as_str()))); + && ((crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Holds".to_string(), + )) || (crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "Violates".to_string(), + )))); if ((optional_cardinality_subject || optional_coproduct_subject) - && ((variant_name.clone().as_str() == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))) + && ((crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + )) || (crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Absent".to_string(), + )))) { Some("Optional".to_string()) } else { @@ -2003,14 +2109,15 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R module_name: scope.module_name.clone(), service_registry: scope.service_registry.clone(), item_registry: scope.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::>(), + lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>( + ), }) } } pub fn extend_scope( scope: Rc, - name: String, + name: Rc>, resolved: Rc, provenance: Rc, ) -> Rc { @@ -2036,7 +2143,7 @@ pub fn extend_scope( pub fn extend_scope_match_bound( scope: Rc, - name: String, + name: Rc>, resolved: Rc, provenance: Rc, ) -> Rc { @@ -2068,7 +2175,7 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) { let new_locals = params.iter().cloned().fold( scope.locals.clone(), - |acc: Rc>>, p: String| { + |acc: Rc>>, p: Rc>| { v1_rt::rc_map_insert( acc, p.clone(), @@ -2128,8 +2235,8 @@ pub fn derive_field_provenance( scope: Rc, scrutinee_provenance: Rc, scrutinee_subject: Rc, - variant_name: String, - field_name: String, + variant_name: Rc>, + field_name: Rc>, ) -> Rc { match (*scrutinee_provenance.clone()).clone() { SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), @@ -2141,7 +2248,9 @@ pub fn derive_field_provenance( ), _ => "".to_string(), }; - if (scrut_type_name.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(scrut_type_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { Rc::new(SubValueRelation::SubValueUnknown) } else { { @@ -2150,9 +2259,15 @@ pub fn derive_field_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) - && (f.field_name.clone().as_str() == field_name.clone().as_str())) - { + if ((crate::v2_std_text::host_string_text_to_rust_host( + f.variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + )) && (crate::v2_std_text::host_string_text_to_rust_host( + f.field_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + field_name.clone(), + ))) { __result.push(f); } } @@ -2275,17 +2390,18 @@ pub fn extend_scope_with_pattern_node( }) } -pub fn method_name_is(opt: Option, expected: String) -> bool { +pub fn method_name_is(opt: Rc>, expected: Rc>) -> bool { if (opt.clone() == None) { false } else { - (opt.clone().unwrap().as_str() == expected.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(opt.clone().unwrap()) + == crate::v2_std_text::host_string_text_to_rust_host(expected)) } } pub fn arg_has_name( arg: Rc, - name: String, + name: Rc>, source_indices: Rc>>, ) -> bool { { @@ -2293,13 +2409,14 @@ pub fn arg_has_name( if (n.clone() == None) { false } else { - (n.clone().unwrap().as_str() == name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(n.clone().unwrap()) + == crate::v2_std_text::host_string_text_to_rust_host(name)) } } } pub fn extract_fold_init_info( - method_name: Option, + method_name: Rc>, method_args: Rc>>, min_args: i64, scope: Rc, @@ -2364,12 +2481,10 @@ pub fn derive_element_provenance( match (*coll_prov).clone() { SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { - if (authored_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( scope.type_env.clone().source_indices.clone(), elem_type.clone(), - ) - .as_str() - == "".to_string().as_str()) + )) == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { Rc::new(SubValueRelation::SubValueUnknown) } else { @@ -2409,7 +2524,7 @@ pub fn derive_element_provenance( } pub fn infer_method_args_with_fold( - method_name: Option, + method_name: Rc>, method_args: Rc>>, fold_info: Option>, fold_acc_type: Rc, @@ -2494,11 +2609,16 @@ pub fn infer_method_args_with_fold( }); let lam_value = arg_value(a.clone()); let prov_map = match (*elem_provenance.clone()).clone() { - SubValueRelation::SubValueUnknown => { - v1_rt::rc_empty_map::>() - } + SubValueRelation::SubValueUnknown => v1_rt::rc_empty_map::< + Rc>, + Rc, + >( + ), _ => v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), "elem".to_string(), elem_provenance.clone(), ), @@ -2535,11 +2655,16 @@ pub fn infer_method_args_with_fold( { let nf_lam_value = arg_value(a.clone()); let nf_prov_map = match (*elem_provenance.clone()).clone() { - SubValueRelation::SubValueUnknown => { - v1_rt::rc_empty_map::>() - } + SubValueRelation::SubValueUnknown => v1_rt::rc_empty_map::< + Rc>, + Rc, + >( + ), _ => v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), "elem".to_string(), elem_provenance.clone(), ), @@ -2589,14 +2714,17 @@ pub fn is_record_lit_expr(e: Rc) -> bool { pub fn seed_override_map() -> Rc>> { Rc::new(vec!["".to_string()]).iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, k: String| { + v1_rt::rc_empty_map::>, Rc>(), + |acc: Rc>>, k: Rc>| { v1_rt::rc_map_insert(acc, k.clone(), unit_type()) }, ) } -pub fn fold_override_map(key: String, value: Rc) -> Rc>> { +pub fn fold_override_map( + key: Rc>, + value: Rc, +) -> Rc>> { v1_rt::rc_map_insert(seed_override_map(), key, value) } @@ -2943,7 +3071,7 @@ pub fn infer_expr( && (sig.clone() == None)) { Rc::new(ArgGenericFoldState { - subst: v1_rt::rc_empty_map::>(), + subst: v1_rt::rc_empty_map::>, Rc>(), results: match call_args.clone().first().cloned() { Some(first_arg) => { let first_result = @@ -3038,7 +3166,7 @@ pub fn infer_expr( .fold( Rc::new(ArgGenericFoldState { results: Rc::new(vec![]), - subst: v1_rt::rc_empty_map::>(), + subst: v1_rt::rc_empty_map::>, Rc>(), }), |st: Rc, pair: (i64, Rc)| { let a = pair.1.clone(); @@ -3425,7 +3553,11 @@ pub fn infer_expr( }) } } else { - if (func_name.clone().as_str() == "empty_map".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "empty_map".to_string(), + )) { { let bare_m = bare_map_node(); match expected.clone() { @@ -3489,8 +3621,11 @@ match bare_m { } } } else { - if (func_name.clone().as_str() == "empty_set".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + func_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "empty_set".to_string(), + )) { { let bare_s = bare_set_node(); match expected.clone() { @@ -3563,13 +3698,11 @@ match bare_s { span.clone(), ); let bt = tier2b.bt.clone(); - let call_semantics = if (func_name.clone().as_str() - == "lookup".to_string().as_str()) - { - Some(CallSemantics::LookupCallSemantics) - } else { - Some(CallSemantics::PlainCallSemantics) - }; + let call_semantics = if (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("lookup".to_string())) { + Some(CallSemantics::LookupCallSemantics) + } else { + Some(CallSemantics::PlainCallSemantics) + }; Rc::new(InferResult { typed: make_named_expr_node( func_name.clone(), @@ -4297,12 +4430,12 @@ match bare_s { ExprData::ExprVar { binding_kind: _, .. } => { - (authored_name_at( + (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( scope.type_env.clone().source_indices.clone(), bd.clone(), - ) - .as_str() - == let_name.clone().as_str()) + )) == crate::v2_std_text::host_string_text_to_rust_host( + let_name.clone(), + )) } _ => false, }, @@ -4678,7 +4811,10 @@ match bare_s { module_name: lam_scope.module_name.clone(), service_registry: lam_scope.service_registry.clone(), item_registry: lam_scope.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::>(), + lambda_param_provenance: v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); let body_typed = body_result.typed.clone(); @@ -5086,7 +5222,7 @@ match bare_s { } pub fn infer_variant_constructor_call( - func_name: String, + func_name: Rc>, call_args: Rc>>, span: Rc, name_span: Rc, @@ -5247,7 +5383,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { pub fn peel_alias_once_for_field_access( mut n: Rc, mut env: Rc, - mut module_name: String, + mut module_name: Rc>, ) -> Rc { loop { let once = resolve_node(n, env.clone(), module_name.clone()) @@ -5306,7 +5442,11 @@ pub fn record_field_type_is_unresolved_param( let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { - if (pn.clone().as_str() == fname.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(pn.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + )) + { __found = true; break; } @@ -5354,8 +5494,8 @@ pub fn record_has_unresolved_param_field(record: Rc, env: Rc) -> pub fn expand_alias_chain_for_field_access( mut n: Rc, mut env: Rc, - mut module_name: String, - mut origin_name: String, + mut module_name: Rc>, + mut origin_name: Rc>, mut seen: Rc>, mut lossy: bool, ) -> Rc { @@ -5380,7 +5520,9 @@ pub fn expand_alias_chain_for_field_access( } else { let next_name = structural.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional || (next_name.clone().as_str() == "".to_string().as_str())) + let stop = ((is_optional + || (crate::v2_std_text::host_string_text_to_rust_host(next_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) || emit_map_has(seen.clone(), next_name.clone())); if stop { break structural.clone(); @@ -5412,7 +5554,7 @@ pub fn expand_alias_chain_for_field_access( pub fn expand_type_for_field_access( n: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() @@ -5424,7 +5566,7 @@ pub fn expand_type_for_field_access( env.clone(), module_name, origin_name, - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), false, ) } @@ -5432,7 +5574,7 @@ pub fn expand_type_for_field_access( } pub fn record_lit_alias_struct_fields( - type_name: String, + type_name: Rc>, scope: Rc, ) -> Option>>> { match lookup_type_by_name(scope.type_env.clone(), type_name) { @@ -5466,7 +5608,7 @@ pub fn record_lit_alias_struct_fields( } pub fn infer_record_lit( - type_name: Option, + type_name: Rc>, field_inits: Rc>>, span: Rc, name_span: Rc, @@ -5523,13 +5665,14 @@ pub fn infer_record_lit( let field_expected = match Rc::new({ let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { - if (authored_name_at( - scope.type_env.clone().source_indices.clone(), - sf.clone(), - ) - .as_str() - == fi_name.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( + scope.type_env.clone().source_indices.clone(), + sf.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + fi_name.clone(), + )) { __result.push(sf); } } @@ -5701,22 +5844,25 @@ pub fn infer_record_lit( None => error_type(), }; let expected_optional_parent = Some("Optional".to_string()); - let is_present_ctor = ((type_name.clone().unwrap().as_str() - == "Present".to_string().as_str()) - && (local_variant_parent.clone().as_deref() - == expected_optional_parent.as_deref())); + let is_present_ctor = ((crate::v2_std_text::host_string_text_to_rust_host( + type_name.clone().unwrap(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + )) && (local_variant_parent.clone().as_deref() + == expected_optional_parent.as_deref())); let resolved_node = if is_present_ctor { { let val_field = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - if (field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "value".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + field_init_node_name_at( + fir.typed_field.clone(), + scope.type_env.clone().source_indices.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "value".to_string(), + )) { __result.push(fir); } } @@ -5774,11 +5920,16 @@ pub fn infer_record_lit( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum SizeExpr { - ParamSize { param: String }, - DividedSize { param: String, divisor: i64 }, + ParamSize { + param: Rc>, + }, + DividedSize { + param: Rc>, + divisor: i64, + }, } impl SizeExpr { - pub fn param(&self) -> String { + pub fn param(&self) -> Rc> { match self { SizeExpr::ParamSize { param: __val, .. } => __val.clone(), SizeExpr::DividedSize { param: __val, .. } => __val.clone(), @@ -5788,7 +5939,7 @@ impl SizeExpr { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DescentContext { - pub fn_name: String, + pub fn_name: Rc>, pub param_names: Rc>, pub param_order: Rc>, pub type_env: Rc, @@ -5807,7 +5958,9 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - if (mname.as_str() == "count".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(mname) + == crate::v2_std_text::host_string_text_to_rust_host("count".to_string())) + { { let receiver = method_receiver(val.clone()); match (*receiver.expr_data.clone()).clone() { @@ -5884,7 +6037,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option, lit_expr: Rc, - param_name: String, + param_name: Rc>, ctx: Rc, ) -> Option> { match (*alias_expr.expr_data.clone()).clone() { @@ -5904,7 +6057,9 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (p.clone().as_str() == param_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(p.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) + { match (*lit_expr.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { @@ -5948,7 +6103,7 @@ pub fn proportional_skip_alias_plus_literal( pub fn classify_collection_shrink( arg_expr: Rc, - param_name: String, + param_name: Rc>, ctx: Rc, ) -> Rc { match (*arg_expr.expr_data.clone()).clone() { @@ -5960,8 +6115,10 @@ pub fn classify_collection_shrink( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "take".to_string().as_str()) - || (mname.clone().as_str() == "skip".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("take".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string()))) { { let receiver = method_receiver(arg_expr.clone()); @@ -5973,24 +6130,19 @@ pub fn classify_collection_shrink( receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (rname.as_str() == param_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(rname) + == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) + { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { Some(arg_node) => { let arg_val = arg_value(arg_node.clone()); match (*arg_val.expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: k, .. } = - value.as_ref() - else { - unreachable!() - }; - if ((k.clone() > 0) - && (mname.clone().as_str() - == "skip".to_string().as_str())) - { - match positive_descent_amount_from_positive_int(k.clone()) { + ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { unreachable!() }; if ((k.clone() > 0) && (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string()))) { + match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), @@ -6008,33 +6160,14 @@ Rc::new(SubValueRelation::StrictSubValue { }, None => Rc::new(SubValueRelation::SubValueUnknown), } - } else { - Rc::new(SubValueRelation::SubValueUnknown) - } - } - ExprData::ExprVar { - binding_kind: _, .. - } => { - let aname = expr_var_name_at( - arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - match v1_rt::map_get( - &ctx.size_aliases.clone(), - aname, - ) - .as_deref() - .cloned() - { - Some(SizeExpr::DividedSize { - param: p, - divisor: d, - .. - }) => { - if (p.clone().as_str() - == param_name.clone().as_str()) - { - match proportional_divisor_from_int_at_least_two(d.clone()) { + } else { + Rc::new(SubValueRelation::SubValueUnknown) + } }, + ExprData::ExprVar { binding_kind: _, .. } => { + let aname = expr_var_name_at(arg_val.clone(), ctx.type_env.clone().source_indices.clone()); +match v1_rt::map_get(&ctx.size_aliases.clone(), aname).as_deref().cloned() { + Some(SizeExpr::DividedSize { param: p, divisor: d, .. }) => if (crate::v2_std_text::host_string_text_to_rust_host(p.clone()) == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) { + match proportional_divisor_from_int_at_least_two(d.clone()) { Some(div_w) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), @@ -6052,49 +6185,33 @@ Rc::new(SubValueRelation::StrictSubValue { }, None => Rc::new(SubValueRelation::SubValueUnknown), } - } else { - Rc::new(SubValueRelation::SubValueUnknown) - } - } - _ => Rc::new( - SubValueRelation::SubValueUnknown, - ), - } - } - ExprData::ExprBinOp { op, .. } => { - match op.clone() { - BinOp::Add => { - if (mname.clone().as_str() - == "skip".to_string().as_str()) - { - { - let left = - binop_left(arg_val.clone()); - let right = binop_right( - arg_val.clone(), - ); - match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { + } else { + Rc::new(SubValueRelation::SubValueUnknown) + }, + _ => Rc::new(SubValueRelation::SubValueUnknown), +} +}, + ExprData::ExprBinOp { op, .. } => match op.clone() { + BinOp::Add => if (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string())) { + { + let left = binop_left(arg_val.clone()); +let right = binop_right(arg_val.clone()); +match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { Some(rel) => rel.clone(), None => match proportional_skip_alias_plus_literal(right.clone(), left.clone(), param_name.clone(), ctx.clone()) { Some(rel) => rel.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), }, } - } - } else { - Rc::new(SubValueRelation::SubValueUnknown) - } - } - BinOp::Sub => Rc::new( - SubValueRelation::SubValueUnknown, - ), - _ => Rc::new( - SubValueRelation::SubValueUnknown, - ), - } - } - _ => Rc::new(SubValueRelation::SubValueUnknown), - } +} + } else { + Rc::new(SubValueRelation::SubValueUnknown) + }, + BinOp::Sub => Rc::new(SubValueRelation::SubValueUnknown), + _ => Rc::new(SubValueRelation::SubValueUnknown), +}, + _ => Rc::new(SubValueRelation::SubValueUnknown), +} } None => Rc::new(SubValueRelation::SubValueUnknown), } @@ -6135,7 +6252,7 @@ pub fn method_callback_element_position(semantics: Option>) pub fn maybe_insert_composed_field_relation( acc: Rc>>, - fname: String, + fname: Rc>, composed: Option>, ) -> Rc>> { match composed { @@ -6150,7 +6267,7 @@ pub fn maybe_insert_composed_field_relation( pub fn maybe_insert_output_field_relation( acc: Rc>>, idx: i64, - fname: String, + fname: Rc>, sig: Rc, val: Rc, ctx: Rc, @@ -6166,9 +6283,9 @@ pub fn maybe_insert_output_field_relation( pub fn maybe_insert_match_field_relation( fp_acc: Rc>>, - pname: String, - field_label: String, - vname: String, + pname: Rc>, + field_label: Rc>, + vname: Rc>, scrut_rel: Option>, param_types: Rc>, type_env: Rc, @@ -6186,16 +6303,28 @@ pub fn maybe_insert_match_field_relation( SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), _ => "".to_string(), }; - if (lookup_type.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(lookup_type.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { { let ind_fields = inductive_fields_for(type_env, lookup_type.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((f.field_name.clone().as_str() == field_label.clone().as_str()) - && ((f.variant_name.clone().as_str() == vname.clone().as_str()) - || (f.variant_name.clone().as_str() - == "".to_string().as_str()))) + if ((crate::v2_std_text::host_string_text_to_rust_host( + f.field_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + field_label.clone(), + )) && ((crate::v2_std_text::host_string_text_to_rust_host( + f.variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + vname.clone(), + )) || (crate::v2_std_text::host_string_text_to_rust_host( + f.variant_name.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )))) { __result.push(f); } @@ -6223,7 +6352,7 @@ pub fn maybe_insert_match_field_relation( pub fn build_per_field_for_let( val: Rc, - binding_name: String, + binding_name: Rc>, ctx: Rc, ) -> Rc>>>> { match (*val.expr_data.clone()).clone() { @@ -6248,7 +6377,7 @@ pub fn build_per_field_for_let( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); @@ -6308,7 +6437,7 @@ pub fn build_per_field_for_let( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); @@ -6387,7 +6516,9 @@ pub fn resolve_collection_field( } } }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(base_type.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { break Rc::new({ let mut __result = Vec::new(); for f in Rc::new({ @@ -6399,8 +6530,11 @@ pub fn resolve_collection_field( .iter() .cloned() { - if (f.field_name.clone().as_str() == fname.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + f.field_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + )) { __result.push(f); } } @@ -6471,12 +6605,28 @@ pub fn resolve_collection_field( } => { let inner_mname = expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); - let is_collection_preserving = (((((inner_mname.clone().as_str() - == "enumerate".to_string().as_str()) - || (inner_mname.clone().as_str() == "skip".to_string().as_str())) - || (inner_mname.clone().as_str() == "take".to_string().as_str())) - || (inner_mname.clone().as_str() == "filter".to_string().as_str())) - || (inner_mname.clone().as_str() == "reverse".to_string().as_str())); + let is_collection_preserving = + (((((crate::v2_std_text::host_string_text_to_rust_host( + inner_mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "enumerate".to_string(), + )) || (crate::v2_std_text::host_string_text_to_rust_host( + inner_mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "skip".to_string(), + ))) || (crate::v2_std_text::host_string_text_to_rust_host( + inner_mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "take".to_string(), + ))) || (crate::v2_std_text::host_string_text_to_rust_host( + inner_mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "filter".to_string(), + ))) || (crate::v2_std_text::host_string_text_to_rust_host( + inner_mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "reverse".to_string(), + ))); if is_collection_preserving { { let __tco_0 = method_receiver(expr); @@ -6530,7 +6680,11 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (type_name.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + type_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { { let fields = inductive_fields_for( ctx.type_env.clone(), type_name.clone(), ); - let matching = Rc::new({ - let mut __result = Vec::new(); - for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() - == field.clone().as_str()) - { - __result.push(f); - } - } - __result - }) - .first() - .cloned(); + let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field.clone())) { __result.push(f); } } __result }).first().cloned(); match matching { Some(ind_field) => { Some(Rc::new(SubValueRelation::StrictSubValue { @@ -6693,42 +6839,24 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (inner_type.clone().as_str() - != "".to_string().as_str()) - { - { - let fields = inductive_fields_for( - ctx.type_env.clone(), - inner_type.clone(), - ); - let cf = - Rc::new({ - let mut __result = Vec::new(); - for f in fields.iter().cloned() { - if match f.shape.clone() { + if (crate::v2_std_text::host_string_text_to_rust_host(inner_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + { + let fields = inductive_fields_for(ctx.type_env.clone(), inner_type.clone()); +let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { if match f.shape.clone() { RecursionShape::ListRecursion => true, _ => false, -} { __result.push(f); } - } - __result - }) - .first() - .cloned(); - match cf { - Some(ind_field) => Some(Rc::new( - SubValueRelation::StrictSubValue { - field: ind_field.clone(), - factor: Rc::new( - ShrinkFactor::UnitShrink, - ), - }, - )), - None => None, - } - } - } else { - None - } +} { __result.push(f); } } __result }).first().cloned(); +match cf { + Some(ind_field) => Some(Rc::new(SubValueRelation::StrictSubValue { + field: ind_field.clone(), + factor: Rc::new(ShrinkFactor::UnitShrink), +})), + None => None, +} +} + } else { + None + } } _ => None, } @@ -6757,7 +6885,10 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }; - if ((elem.clone().as_str() != "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(elem.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { @@ -6799,26 +6930,114 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option type_based.clone(), - None => match (*val.expr_data.clone()).clone() { - ExprData::ExprBinOp { op: op, .. } => { - let left = binop_left(val.clone()); - let right = binop_right(val.clone()); - match op.clone() { - BinOp::Sub => match (*left.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => { - let lname = expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) - != None) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - lname.clone(), - ) != None)) - { + None => { + match (*val.expr_data.clone()).clone() { + ExprData::ExprBinOp { op: op, .. } => { + let left = binop_left(val.clone()); + let right = binop_right(val.clone()); + match op.clone() { + BinOp::Sub => { + match (*left.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => { + let lname = expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + if ((v1_rt::map_get( + &ctx.param_names.clone(), + lname.clone(), + ) != None) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + lname.clone(), + ) != None)) + { + match (*right.expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { + value: k, .. + } = value.as_ref() + else { + unreachable!() + }; + match positive_descent_amount_from_positive_int(k.clone()) { + Some(steps) => Some(Rc::new(SubValueRelation::ArithmeticDescent { + param: lname.clone(), + factor: Rc::new(ShrinkFactor::ConstantShrink { + steps: steps.clone(), +}), +})), + None => None, +} + } + _ => None, + } + } else { + None + } + } + _ => None, + } + } + BinOp::Div => { + let left_name = match (*left.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => { + let lname = expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + if ((v1_rt::map_get( + &ctx.param_names.clone(), + lname.clone(), + ) != None) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + lname.clone(), + ) != None)) + { + lname.clone() + } else { + "".to_string() + } + } + ExprData::ExprBinOp { op: BinOp::Sub, .. } => { + let inner_left = binop_left(left.clone()); + match (*inner_left.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => { + let lname = expr_var_name_at( + inner_left.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + if ((v1_rt::map_get( + &ctx.param_names.clone(), + lname.clone(), + ) != None) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + lname.clone(), + ) != None)) + { + lname.clone() + } else { + "".to_string() + } + } + _ => "".to_string(), + } + } + _ => "".to_string(), + }; + if (crate::v2_std_text::host_string_text_to_rust_host( + left_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = @@ -6826,15 +7045,15 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option Some(Rc::new( + Some(div_w) => Some(Rc::new( SubValueRelation::ArithmeticDescent { - param: lname.clone(), + param: left_name.clone(), factor: Rc::new( - ShrinkFactor::ConstantShrink { - steps: steps.clone(), + ShrinkFactor::ProportionalShrink { + divisor: div_w.clone(), }, ), }, @@ -6848,173 +7067,74 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option None, _ => None, - }, - BinOp::Div => { - let left_name = match (*left.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => { - let lname = expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - if ((v1_rt::map_get( - &ctx.param_names.clone(), - lname.clone(), - ) != None) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - lname.clone(), - ) != None)) - { - lname.clone() - } else { - "".to_string() - } - } - ExprData::ExprBinOp { op: BinOp::Sub, .. } => { - let inner_left = binop_left(left.clone()); - match (*inner_left.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => { - let lname = expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - if ((v1_rt::map_get( - &ctx.param_names.clone(), - lname.clone(), - ) != None) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - lname.clone(), - ) != None)) - { - lname.clone() - } else { - "".to_string() - } - } - _ => "".to_string(), - } - } - _ => "".to_string(), - }; - if (left_name.clone().as_str() != "".to_string().as_str()) { - match (*right.expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: k, .. } = - value.as_ref() - else { - unreachable!() - }; - match proportional_divisor_from_int_at_least_two( - k.clone(), - ) { - Some(div_w) => Some(Rc::new( - SubValueRelation::ArithmeticDescent { - param: left_name.clone(), - factor: Rc::new( - ShrinkFactor::ProportionalShrink { - divisor: div_w.clone(), - }, - ), - }, - )), - None => None, - } - } - _ => None, - } - } else { - None - } } - BinOp::Add => None, - _ => None, } - } - ExprData::ExprMethodCall { - method_semantics: _, - .. - } => { - let mname = expr_method_name_at( - val.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - let is_collection_preserving = (((((mname.clone().as_str() - == "skip".to_string().as_str()) - || (mname.clone().as_str() == "filter".to_string().as_str())) - || (mname.clone().as_str() == "take".to_string().as_str())) - || (mname.clone().as_str() == "enumerate".to_string().as_str())) - || (mname.clone().as_str() == "reverse".to_string().as_str())); - if is_collection_preserving { - { - let receiver = method_receiver(val.clone()); - let coll_field = - resolve_collection_field(receiver.clone(), ctx.clone()); - match coll_field { - Some(ind_field) => { - Some(Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), - factor: Rc::new(ShrinkFactor::UnitShrink), - })) - } - None => { - if (mname.clone().as_str() == "skip".to_string().as_str()) { - { - let skip_args = method_arg_nodes(val.clone()); - let skip_amount = match skip_args.first().cloned() { - Some(a) => match (*arg_value(a.clone()) - .expr_data - .clone()) - .clone() - { - ExprData::ExprLiteral { - ref value, .. - } => { - let LiteralValue::LitInt { - value: k, - .. - } = value.as_ref() - else { - unreachable!() - }; - if (k.clone() > 0) { - k.clone() - } else { - 0 - } - } - _ => 0, - }, - None => 0, - }; - if (skip_amount.clone() > 0) { - match (*receiver.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, - .. - } => { - let rname = expr_var_name_at( - receiver.clone(), - ctx.type_env - .clone() - .source_indices - .clone(), - ); - if ((v1_rt::map_get( - &ctx.param_names.clone(), - rname.clone(), - ) != None) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - rname.clone(), - ) != None)) - { - match positive_descent_amount_from_positive_int(skip_amount.clone()) { + ExprData::ExprMethodCall { + method_semantics: _, + .. + } => { + let mname = expr_method_name_at( + val.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + let is_collection_preserving = + (((((crate::v2_std_text::host_string_text_to_rust_host( + mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "skip".to_string(), + )) || (crate::v2_std_text::host_string_text_to_rust_host( + mname.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "filter".to_string(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host( + mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "take".to_string(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host( + mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "enumerate".to_string(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host( + mname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "reverse".to_string(), + ))); + if is_collection_preserving { + { + let receiver = method_receiver(val.clone()); + let coll_field = + resolve_collection_field(receiver.clone(), ctx.clone()); + match coll_field { + Some(ind_field) => Some(Rc::new(SubValueRelation::StrictSubValue { + field: ind_field.clone(), + factor: Rc::new(ShrinkFactor::UnitShrink), +})), + None => if (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string())) { + { + let skip_args = method_arg_nodes(val.clone()); +let skip_amount = match skip_args.first().cloned() { + Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { unreachable!() }; if (k.clone() > 0) { + k.clone() + } else { + 0 + } }, + _ => 0, +}, + None => 0, +}; +if (skip_amount.clone() > 0) { + match (*receiver.expr_data.clone()).clone() { + ExprData::ExprVar { binding_kind: _, .. } => { + let rname = expr_var_name_at(receiver.clone(), ctx.type_env.clone().source_indices.clone()); +if ((v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) != None) || (v1_rt::map_get(&ctx.sub_value_vars.clone(), rname.clone()) != None)) { + match positive_descent_amount_from_positive_int(skip_amount.clone()) { Some(steps) => { let synth_field = Rc::new(InductiveField { type_name: rname.clone(), @@ -7032,28 +7152,28 @@ Some(Rc::new(SubValueRelation::StrictSubValue { }, None => None, } - } else { - None - } - } - _ => None, - } - } else { - None - } - } - } else { - None - } + } else { + None } +}, + _ => None, +} + } else { + None + } +} + } else { + None + }, +} } + } else { + None } - } else { - None } + _ => None, } - _ => None, - }, + } } } } @@ -7067,7 +7187,7 @@ pub fn classify_call_via_provenance( { let call_args = call.children.clone(); let arg_by_name = call_args.iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), ctx.type_env.clone().source_indices.clone(), @@ -7080,8 +7200,10 @@ pub fn classify_call_via_provenance( ); Rc::new(v1_rt::map_keys(¶m_map)).iter().cloned().fold( None, - |result: _, callee_pname: String| match v1_rt::map_get(¶m_map, callee_pname.clone()) - { + |result: _, callee_pname: Rc>| match v1_rt::map_get( + ¶m_map, + callee_pname.clone(), + ) { Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { Some(arg_expr) => { let arg_rel = classify_call_arg_provenance(arg_expr.clone(), ctx.clone()); @@ -7150,7 +7272,7 @@ pub fn merge_argument_relations(rels: Rc>>) -> Rc, - param_name: String, + param_name: Rc>, ctx: Rc, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -7162,7 +7284,9 @@ pub fn classify_argument( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (vname.clone().as_str() == param_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) + { Rc::new(SubValueRelation::PreservedValue) } else { match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { @@ -7208,7 +7332,11 @@ pub fn classify_argument( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + f.field_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + field.clone(), + )) { __result.push(f); } } @@ -7349,19 +7477,20 @@ pub fn classify_argument( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) != None)) + ((crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) != None)) } _ => false, }; @@ -7395,19 +7524,20 @@ pub fn classify_argument( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) != None)) + ((crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) != None)) } ExprData::ExprBinOp { op: BinOp::Sub, .. } => { let inner_left = binop_left(left.clone()); @@ -7415,19 +7545,20 @@ pub fn classify_argument( ExprData::ExprVar { binding_kind: _, .. } => { - ((expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), - ) - .as_str() - == param_name.clone().as_str()) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) != None)) + ((crate::v2_std_text::host_string_text_to_rust_host( + expr_var_name_at( + inner_left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) == crate::v2_std_text::host_string_text_to_rust_host( + param_name.clone(), + )) || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + expr_var_name_at( + inner_left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) != None)) } _ => false, } @@ -7513,7 +7644,7 @@ pub fn classify_argument( pub fn read_arg_provenance( arg_expr: Rc, - param_name: String, + param_name: Rc>, ctx: Rc, ) -> Rc { match (*arg_expr.expr_data.clone()).clone() { @@ -7547,39 +7678,30 @@ pub fn read_arg_provenance( let bname = expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { - Some(binding) => match (*binding.provenance.clone()).clone() { - SubValueRelation::SubValueUnknown => { - classify_argument(arg_expr.clone(), param_name, ctx.clone()) - } - _ => { - let fields = inductive_fields_for( - ctx.type_env.clone(), - authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), - ), - ); - let matching = Rc::new({ - let mut __result = Vec::new(); - for f in fields.iter().cloned() { - if (f.field_name.clone().as_str() == field.clone().as_str()) - { - __result.push(f); - } + Some(binding) => { + match (*binding.provenance.clone()).clone() { + SubValueRelation::SubValueUnknown => { + classify_argument(arg_expr.clone(), param_name, ctx.clone()) + } + _ => { + let fields = inductive_fields_for( + ctx.type_env.clone(), + authored_name_at( + ctx.type_env.clone().source_indices.clone(), + binding.resolved.clone(), + ), + ); + let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field.clone())) { __result.push(f); } } __result }).first().cloned(); + match matching { + Some(ind_field) => compose_sub_value( + binding.provenance.clone(), + ind_field.clone(), + ), + None => Rc::new(SubValueRelation::SubValueUnknown), } - __result - }) - .first() - .cloned(); - match matching { - Some(ind_field) => compose_sub_value( - binding.provenance.clone(), - ind_field.clone(), - ), - None => Rc::new(SubValueRelation::SubValueUnknown), } } - }, + } None => classify_argument(arg_expr.clone(), param_name, ctx.clone()), } } @@ -7622,7 +7744,7 @@ pub fn build_call_evidence( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let arg_node = pair.1.clone(); @@ -7702,8 +7824,14 @@ pub fn build_call_evidence( } } -pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { - if (found.clone().as_str() != "".to_string().as_str()) { +pub fn descent_source_type( + found: Rc>, + arg_node: Rc, + ctx: Rc, +) -> Rc> { + if (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { @@ -7739,7 +7867,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let evidence = build_call_evidence(body.clone(), ctx.clone()); let source_type = body.children.clone().iter().cloned().fold( "".to_string(), - |found: String, arg_node: Rc| { + |found: Rc>, arg_node: Rc| { descent_source_type(found, arg_node.clone(), ctx.clone()) }, ); @@ -7747,147 +7875,67 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let mut __result = Vec::new(); for child in body.children.clone().iter().cloned() { __result.push({ - let arg_val = arg_value(child.clone()); - match (*arg_val.expr_data.clone()).clone() { - ExprData::ExprLambda => { - if (source_type.clone().as_str() != "".to_string().as_str()) { - { - let lparams = lambda_param_names_at( - arg_val.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - let p1 = match lparams.clone().first().cloned() { - Some(n) => n.clone(), - None => "".to_string(), - }; - let p2 = match lparams.clone().get(1 as usize).cloned() - { - Some(n) => n.clone(), - None => "".to_string(), - }; - let lambda_ctx = Rc::new(DescentContext { - fn_name: ctx.fn_name.clone(), - param_names: if (p2.clone().as_str() - != "".to_string().as_str()) - { - v1_rt::rc_map_insert( - v1_rt::rc_map_insert( - ctx.param_names.clone(), - p1.clone(), - source_type.clone(), - ), - p2.clone(), - source_type.clone(), - ) - } else { - if (p1.clone().as_str() - != "".to_string().as_str()) - { - v1_rt::rc_map_insert( - ctx.param_names.clone(), - p1.clone(), - source_type.clone(), - ) - } else { - ctx.param_names.clone() - } - }, - param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), - sub_value_vars: if (p1.clone().as_str() - != "".to_string().as_str()) - { - { - let source_fields = inductive_fields_for( - ctx.type_env.clone(), - source_type.clone(), - ); - let cf = Rc::new({ - let mut __result = Vec::new(); - for f in source_fields - .clone() - .iter() - .cloned() - { - if match f.shape.clone() { + let arg_val = arg_value(child.clone()); +match (*arg_val.expr_data.clone()).clone() { + ExprData::ExprLambda => if (crate::v2_std_text::host_string_text_to_rust_host(source_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + { + let lparams = lambda_param_names_at(arg_val.clone(), ctx.type_env.clone().source_indices.clone()); +let p1 = match lparams.clone().first().cloned() { + Some(n) => n.clone(), + None => "".to_string(), +}; +let p2 = match lparams.clone().get(1 as usize).cloned() { + Some(n) => n.clone(), + None => "".to_string(), +}; +let lambda_ctx = Rc::new(DescentContext { + fn_name: ctx.fn_name.clone(), + param_names: if (crate::v2_std_text::host_string_text_to_rust_host(p2.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + v1_rt::rc_map_insert(v1_rt::rc_map_insert(ctx.param_names.clone(), p1.clone(), source_type.clone()), p2.clone(), source_type.clone()) + } else { + if (crate::v2_std_text::host_string_text_to_rust_host(p1.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + v1_rt::rc_map_insert(ctx.param_names.clone(), p1.clone(), source_type.clone()) + } else { + ctx.param_names.clone() + } + }, + param_order: ctx.param_order.clone(), + type_env: ctx.type_env.clone(), + sub_value_vars: if (crate::v2_std_text::host_string_text_to_rust_host(p1.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + { + let source_fields = inductive_fields_for(ctx.type_env.clone(), source_type.clone()); +let cf = Rc::new({ let mut __result = Vec::new(); for f in source_fields.clone().iter().cloned() { if match f.shape.clone() { RecursionShape::ListRecursion => true, _ => false, -} { __result.push(f); } - } - __result - }) - .first() - .cloned(); - let rel = match cf.clone() { +} { __result.push(f); } } __result }).first().cloned(); +let rel = match cf.clone() { Some(f) => Rc::new(SubValueRelation::IteratedSubValue { field: f.clone(), }), None => Rc::new(SubValueRelation::PreservedValue), }; - if (p2.clone().as_str() - != "".to_string().as_str()) - { - v1_rt::rc_map_insert( - v1_rt::rc_map_insert( - ctx.sub_value_vars.clone(), - p1.clone(), - rel.clone(), - ), - p2.clone(), - rel.clone(), - ) - } else { - v1_rt::rc_map_insert( - ctx.sub_value_vars.clone(), - p1.clone(), - rel.clone(), - ) - } - } - } else { - ctx.sub_value_vars.clone() - }, - size_aliases: ctx.size_aliases.clone(), - scope_locals: ctx.scope_locals.clone(), - func_sigs: ctx.func_sigs.clone(), - per_field_vars: ctx.per_field_vars.clone(), - }); - make_arg_node( - arg_name_at( - child.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - annotate_descent( - arg_val.clone(), - lambda_ctx.clone(), - ), - child.span.clone(), - child.span.clone(), - ) - } - } else { - make_arg_node( - arg_name_at( - child.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - annotate_descent(arg_val.clone(), ctx.clone()), - child.span.clone(), - child.span.clone(), - ) - } +if (crate::v2_std_text::host_string_text_to_rust_host(p2.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + v1_rt::rc_map_insert(v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), p1.clone(), rel.clone()), p2.clone(), rel.clone()) + } else { + v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), p1.clone(), rel.clone()) } - _ => make_arg_node( - arg_name_at( - child.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - annotate_descent(arg_val.clone(), ctx.clone()), - child.span.clone(), - child.span.clone(), - ), - } - }); +} + } else { + ctx.sub_value_vars.clone() + }, + size_aliases: ctx.size_aliases.clone(), + scope_locals: ctx.scope_locals.clone(), + func_sigs: ctx.func_sigs.clone(), + per_field_vars: ctx.per_field_vars.clone(), +}); +make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()), annotate_descent(arg_val.clone(), lambda_ctx.clone()), child.span.clone(), child.span.clone()) +} + } else { + make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), child.span.clone()) + }, + _ => make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), child.span.clone()), +} +}); } __result }); @@ -7965,25 +8013,17 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { Some(t) => t.clone(), None => "".to_string(), }; - if (base_type.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + base_type.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), base_type.clone(), ); - Rc::new({ - let mut __result = Vec::new(); - for f in ind_fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { - __result.push(f); - } - } - __result - }) - .first() - .cloned() + Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(fname.clone())) { __result.push(f); } } __result }).first().cloned() } } else { None @@ -8000,8 +8040,14 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { scrut.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((mname.clone().as_str() == "first".to_string().as_str()) - || (mname.clone().as_str() == "last".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "first".to_string(), + )) + || (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "last".to_string(), + ))) { { let receiver = method_receiver(scrut.clone()); @@ -8013,12 +8059,13 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { } _ => None, }; - let scrut_has_inductive = (((scrut_type.clone().as_str() - != "".to_string().as_str()) - && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() - as i64) - > 0)) - || (scrut_inducing_field.clone() != None)); + let scrut_has_inductive = + (((crate::v2_std_text::host_string_text_to_rust_host(scrut_type.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() + as i64) + > 0)) + || (scrut_inducing_field.clone() != None)); let scrut_variant_sig = match (*scrut.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( @@ -8055,7 +8102,7 @@ let arm_ctx = match variant_arm_ctx.clone() { None => if scrut_has_inductive.clone() { match (*arm_pattern(arm_node.clone())).clone() { MatchPattern::VariantPattern { name: vname, field_bindings: bindings, .. } => match scrut_inducing_field.clone() { - Some(ind_field) => if (vname.clone().as_str() == "Present".to_string().as_str()) { + Some(ind_field) => if (crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) { bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), @@ -8079,9 +8126,9 @@ let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), }; -let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == inner_vname.clone().as_str()) && (f.field_name.clone().as_str() == inner_field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((crate::v2_std_text::host_string_text_to_rust_host(f.variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(inner_vname.clone())) && (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(inner_field_name.clone()))) { __result.push(f); } } __result }).first().cloned(); match inner_matching.clone() { - Some(inner_ind_field) => if (inner_bind_name.clone().as_str() != "".to_string().as_str()) { + Some(inner_ind_field) => if (crate::v2_std_text::host_string_text_to_rust_host(inner_bind_name.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { Rc::new(DescentContext { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), @@ -8116,9 +8163,9 @@ let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), }; -let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == vname.clone().as_str()) && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); +let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((crate::v2_std_text::host_string_text_to_rust_host(f.variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(vname.clone())) && (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()))) { __result.push(f); } } __result }).first().cloned(); match matching.clone() { - Some(ind_field) => if (bind_name.clone().as_str() != "".to_string().as_str()) { + Some(ind_field) => if (crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), @@ -8141,7 +8188,7 @@ match matching.clone() { }) }, }, - MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone().as_str() != "".to_string().as_str()) { + MatchPattern::Bind { name: bname, .. } => if (crate::v2_std_text::host_string_text_to_rust_host(scrut_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), @@ -8234,7 +8281,11 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (sub_type.clone().as_str() != "".to_string().as_str()) { + param_names: if (crate::v2_std_text::host_string_text_to_rust_host( + sub_type.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), @@ -8314,109 +8365,72 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }) } ExprData::ExprBlock => { - let threaded = body.children.clone().iter().cloned().fold( - Rc::new(BlockAnnotateAcc { - ctx: ctx.clone(), - children: Rc::new(vec![]), - }), - |acc: Rc, child: Rc| { - let annotated = annotate_descent(child.clone(), acc.ctx.clone()); - let next_ctx = match (*child.expr_data.clone()).clone() { - ExprData::ExprLet => { - let val = let_value(child.clone()); - let bname = let_binding_name_at( - child.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); - let sa = classify_size_expr(val.clone(), acc.ctx.clone()); - let new_sa = match sa.clone() { - Some(se) => v1_rt::rc_map_insert( - acc.ctx.clone().size_aliases.clone(), - bname.clone(), - se.clone(), - ), - None => acc.ctx.clone().size_aliases.clone(), - }; - match val_rel.clone() { - Some(rel) => { - let sub_type = match (*rel.clone()).clone() { - SubValueRelation::StrictSubValue { - field: f, .. - } => f.element_type.clone(), - SubValueRelation::IteratedSubValue { - field: f, .. - } => f.element_type.clone(), - _ => "".to_string(), - }; - Rc::new(DescentContext { - fn_name: acc.ctx.clone().fn_name.clone(), - param_names: if (sub_type.clone().as_str() - != "".to_string().as_str()) - { - v1_rt::rc_map_insert( - acc.ctx.clone().param_names.clone(), - bname.clone(), - sub_type.clone(), - ) - } else { - acc.ctx.clone().param_names.clone() - }, - param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), - sub_value_vars: v1_rt::rc_map_insert( - acc.ctx.clone().sub_value_vars.clone(), - bname.clone(), - rel.clone(), - ), - size_aliases: new_sa.clone(), - scope_locals: v1_rt::rc_map_insert( - acc.ctx.clone().scope_locals.clone(), - bname.clone(), - Rc::new(TypeBinding { - name: bname.clone(), - resolved: resolved_type(val.clone()), - provenance: rel.clone(), - }), - ), - func_sigs: acc.ctx.clone().func_sigs.clone(), - per_field_vars: acc.ctx.clone().per_field_vars.clone(), - }) - } - None => Rc::new(DescentContext { - fn_name: acc.ctx.clone().fn_name.clone(), - param_names: acc.ctx.clone().param_names.clone(), - param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), - sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), - size_aliases: new_sa.clone(), - scope_locals: v1_rt::rc_map_insert( - acc.ctx.clone().scope_locals.clone(), - bname.clone(), - Rc::new(TypeBinding { - name: bname.clone(), - resolved: resolved_type(val.clone()), - provenance: Rc::new( - SubValueRelation::SubValueUnknown, - ), - }), - ), - func_sigs: acc.ctx.clone().func_sigs.clone(), - per_field_vars: acc.ctx.clone().per_field_vars.clone(), - }), - } - } - _ => acc.ctx.clone(), - }; - Rc::new(BlockAnnotateAcc { - ctx: next_ctx.clone(), - children: v1_rt::concat( - acc.children.clone(), - Rc::new(vec![annotated.clone()]), - ), - }) - }, - ); + let threaded = body.children.clone().iter().cloned().fold(Rc::new(BlockAnnotateAcc { + ctx: ctx.clone(), + children: Rc::new(vec![]), +}), |acc: Rc, child: Rc| { + let annotated = annotate_descent(child.clone(), acc.ctx.clone()); +let next_ctx = match (*child.expr_data.clone()).clone() { + ExprData::ExprLet => { + let val = let_value(child.clone()); +let bname = let_binding_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()); +let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); +let sa = classify_size_expr(val.clone(), acc.ctx.clone()); +let new_sa = match sa.clone() { + Some(se) => v1_rt::rc_map_insert(acc.ctx.clone().size_aliases.clone(), bname.clone(), se.clone()), + None => acc.ctx.clone().size_aliases.clone(), +}; +match val_rel.clone() { + Some(rel) => { + let sub_type = match (*rel.clone()).clone() { + SubValueRelation::StrictSubValue { field: f, .. } => f.element_type.clone(), + SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), + _ => "".to_string(), +}; +Rc::new(DescentContext { + fn_name: acc.ctx.clone().fn_name.clone(), + param_names: if (crate::v2_std_text::host_string_text_to_rust_host(sub_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + v1_rt::rc_map_insert(acc.ctx.clone().param_names.clone(), bname.clone(), sub_type.clone()) + } else { + acc.ctx.clone().param_names.clone() + }, + param_order: acc.ctx.clone().param_order.clone(), + type_env: acc.ctx.clone().type_env.clone(), + sub_value_vars: v1_rt::rc_map_insert(acc.ctx.clone().sub_value_vars.clone(), bname.clone(), rel.clone()), + size_aliases: new_sa.clone(), + scope_locals: v1_rt::rc_map_insert(acc.ctx.clone().scope_locals.clone(), bname.clone(), Rc::new(TypeBinding { + name: bname.clone(), + resolved: resolved_type(val.clone()), + provenance: rel.clone(), +})), + func_sigs: acc.ctx.clone().func_sigs.clone(), + per_field_vars: acc.ctx.clone().per_field_vars.clone(), +}) +}, + None => Rc::new(DescentContext { + fn_name: acc.ctx.clone().fn_name.clone(), + param_names: acc.ctx.clone().param_names.clone(), + param_order: acc.ctx.clone().param_order.clone(), + type_env: acc.ctx.clone().type_env.clone(), + sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), + size_aliases: new_sa.clone(), + scope_locals: v1_rt::rc_map_insert(acc.ctx.clone().scope_locals.clone(), bname.clone(), Rc::new(TypeBinding { + name: bname.clone(), + resolved: resolved_type(val.clone()), + provenance: Rc::new(SubValueRelation::SubValueUnknown), +})), + func_sigs: acc.ctx.clone().func_sigs.clone(), + per_field_vars: acc.ctx.clone().per_field_vars.clone(), +}), +} +}, + _ => acc.ctx.clone(), +}; +Rc::new(BlockAnnotateAcc { + ctx: next_ctx.clone(), + children: v1_rt::concat(acc.children.clone(), Rc::new(vec![annotated.clone()])), +}) +}); Rc::new(Node { name: body.name.clone(), span: body.span.clone(), @@ -8457,7 +8471,11 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota raw_receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (inner_mname.as_str() == "enumerate".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(inner_mname) + == crate::v2_std_text::host_string_text_to_rust_host( + "enumerate".to_string(), + )) + { method_receiver(raw_receiver.clone()) } else { raw_receiver.clone() @@ -8496,33 +8514,19 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota } => f.element_type.clone(), SubValueRelation::IteratedSubValue { field: f, - .. - } => f.element_type.clone(), - _ => "".to_string(), - }, - None => "".to_string(), - }, - }; - if (base_type.clone().as_str() != "".to_string().as_str()) { - Rc::new({ - let mut __result = Vec::new(); - for f in inductive_fields_for( - ctx.type_env.clone(), - base_type.clone(), - ) - .iter() - .cloned() - { - if (f.field_name.clone().as_str() - == fname.clone().as_str()) - { - __result.push(f); - } - } - __result - }) - .first() - .cloned() + .. + } => f.element_type.clone(), + _ => "".to_string(), + }, + None => "".to_string(), + }, + }; + if (crate::v2_std_text::host_string_text_to_rust_host( + base_type.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { + Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for(ctx.type_env.clone(), base_type.clone()).iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(fname.clone())) { __result.push(f); } } __result }).first().cloned() } else { None } @@ -8601,7 +8605,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), elem_name.clone(), Rc::new(SubValueRelation::IteratedSubValue { field: ind_field.clone(), @@ -8627,7 +8634,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { - v1_rt::rc_empty_map::>() + v1_rt::rc_empty_map::< + Rc>, + Rc, + >() } else { ctx.sub_value_vars.clone() }, @@ -8728,7 +8738,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), fe_var.clone(), Rc::new(SubValueRelation::IteratedSubValue { field: ind_field.clone(), @@ -8744,7 +8754,10 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), - sub_value_vars: v1_rt::rc_empty_map::>(), + sub_value_vars: v1_rt::rc_empty_map::< + Rc>, + Rc, + >(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), func_sigs: ctx.func_sigs.clone(), @@ -8784,7 +8797,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota pub fn resolved_type_name( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, rt.clone()) @@ -8815,12 +8828,14 @@ pub fn infer_output_provenance( __result }); let param_types = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(ptype.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -8834,7 +8849,7 @@ pub fn infer_output_provenance( param_types.clone(), type_env.clone(), func_sigs.clone(), - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), ); if ((Rc::new(v1_rt::map_keys(&scalar)).len() as i64) > 0) { Rc::new(vec![scalar.clone()]) @@ -8846,7 +8861,10 @@ pub fn infer_output_provenance( param_types.clone(), type_env.clone(), func_sigs.clone(), - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::< + Rc>, + Rc>>, + >(), ); if (((per_field.clone().len() as i64) > 0) && { let mut __found = false; @@ -8887,7 +8905,11 @@ pub fn classify_body_provenance( if { let mut __found = false; for pn in param_names.clone().iter().cloned() { - if (pn.clone().as_str() == vname.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(pn.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + vname.clone(), + )) + { __found = true; break; } @@ -8895,12 +8917,12 @@ pub fn classify_body_provenance( __found } { v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), vname.clone(), Rc::new(SubValueRelation::PreservedValue), ) } else { - v1_rt::rc_empty_map::>() + v1_rt::rc_empty_map::>, Rc>() } } } @@ -8916,65 +8938,32 @@ pub fn classify_body_provenance( func_sigs.clone(), let_prov.clone(), ); - Rc::new(v1_rt::map_keys(&base_prov)).iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, pname: String| { - match v1_rt::map_get(&base_prov, pname.clone()) { - Some(base_rel) => { - let type_for_lookup = match (*base_rel.clone()).clone() { - SubValueRelation::PreservedValue => { - match v1_rt::map_get(¶m_types, pname.clone()) { - Some(t) => t.clone(), - None => "".to_string(), - } - } - SubValueRelation::StrictSubValue { field: f, .. } => { - f.element_type.clone() - } - SubValueRelation::IteratedSubValue { field: f, .. } => { - f.element_type.clone() - } - _ => "".to_string(), - }; - if (type_for_lookup.clone().as_str() != "".to_string().as_str()) { - { - let fields = inductive_fields_for( - type_env.clone(), - type_for_lookup.clone(), - ); - let matching = Rc::new({ - let mut __result = Vec::new(); - for f in fields.clone().iter().cloned() { - if (f.field_name.clone().as_str() - == field.clone().as_str()) - { - __result.push(f); - } - } - __result - }) - .first() - .cloned(); - match matching.clone() { - Some(ind_field) => v1_rt::rc_map_insert( - acc.clone(), - pname.clone(), - compose_sub_value( - base_rel.clone(), - ind_field.clone(), - ), - ), - None => acc.clone(), - } - } - } else { - acc.clone() - } - } - None => acc.clone(), - } - }, - ) + Rc::new(v1_rt::map_keys(&base_prov)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pname: Rc>| match v1_rt::map_get(&base_prov, pname.clone()) { + Some(base_rel) => { + let type_for_lookup = match (*base_rel.clone()).clone() { + SubValueRelation::PreservedValue => match v1_rt::map_get(¶m_types, pname.clone()) { + Some(t) => t.clone(), + None => "".to_string(), +}, + SubValueRelation::StrictSubValue { field: f, .. } => f.element_type.clone(), + SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), + _ => "".to_string(), +}; +if (crate::v2_std_text::host_string_text_to_rust_host(type_for_lookup.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + { + let fields = inductive_fields_for(type_env.clone(), type_for_lookup.clone()); +let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field.clone())) { __result.push(f); } } __result }).first().cloned(); +match matching.clone() { + Some(ind_field) => v1_rt::rc_map_insert(acc.clone(), pname.clone(), compose_sub_value(base_rel.clone(), ind_field.clone())), + None => acc.clone(), +} +} + } else { + acc.clone() + } +}, + None => acc.clone(), +}) } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(expr.clone(), type_env.source_indices.clone()); @@ -9048,35 +9037,22 @@ pub fn classify_body_provenance( func_sigs.clone(), let_prov.clone(), ); - Rc::new(v1_rt::map_keys(&recv_prov)).iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, - pname: String| { - match v1_rt::map_get(&recv_prov, pname.clone()) { - Some(recv_rel) => { - let synth_field = Rc::new(InductiveField { - type_name: pname.clone(), - variant_name: "".to_string(), - field_name: mname.clone(), - shape: RecursionShape::ListRecursion, - element_type: pname.clone(), - }); - v1_rt::rc_map_insert( - acc.clone(), - pname.clone(), - compose_sub_value( - recv_rel.clone(), - synth_field.clone(), - ), - ) - } - None => acc.clone(), - } - }, - ) + Rc::new(v1_rt::map_keys(&recv_prov)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pname: Rc>| match v1_rt::map_get(&recv_prov, pname.clone()) { + Some(recv_rel) => { + let synth_field = Rc::new(InductiveField { + type_name: pname.clone(), + variant_name: "".to_string(), + field_name: mname.clone(), + shape: RecursionShape::ListRecursion, + element_type: pname.clone(), +}); +v1_rt::rc_map_insert(acc.clone(), pname.clone(), compose_sub_value(recv_rel.clone(), synth_field.clone())) +}, + None => acc.clone(), +}) } } else { - v1_rt::rc_empty_map::>() + v1_rt::rc_empty_map::>, Rc>() } } } @@ -9103,9 +9079,9 @@ let bind_name = match (*field_binding_pattern(binding.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; -if ((bind_name.clone().as_str() != "".to_string().as_str()) && (field_label.clone().as_str() != "".to_string().as_str())) { +if ((crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) && (crate::v2_std_text::host_string_text_to_rust_host(field_label.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) { { - let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: String| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); + let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: Rc>| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); v1_rt::rc_map_insert(acc.clone(), bind_name.clone(), field_prov.clone()) } } else { @@ -9168,7 +9144,7 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types func_sigs.clone(), updated, ), - None => v1_rt::rc_empty_map::>(), + None => v1_rt::rc_empty_map::>, Rc>(), } } ExprData::ExprBlock => { @@ -9247,9 +9223,9 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types func_sigs.clone(), let_prov.clone(), ), - None => v1_rt::rc_empty_map::>(), + None => v1_rt::rc_empty_map::>, Rc>(), }, - _ => v1_rt::rc_empty_map::>(), + _ => v1_rt::rc_empty_map::>, Rc>(), } }) } @@ -9265,7 +9241,7 @@ pub fn call_args_by_name( source_indices: Rc>>, ) -> Rc>> { call.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), source_indices.clone(), @@ -9291,19 +9267,21 @@ pub fn method_call_args_by_name( Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); - if (first_pname.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(first_pname.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), first_pname.clone(), recv, ) } else { - v1_rt::rc_empty_map::>() + v1_rt::rc_empty_map::>, Rc>() } } - None => v1_rt::rc_empty_map::>(), + None => v1_rt::rc_empty_map::>, Rc>(), }, - None => v1_rt::rc_empty_map::>(), + None => v1_rt::rc_empty_map::>, Rc>(), }; mc_args.iter().cloned().fold( base, @@ -9321,7 +9299,7 @@ pub fn method_call_args_by_name( } pub fn compose_callee_provenance( - callee: String, + callee: Rc>, arg_by_name: Rc>>, param_names: Rc>, param_types: Rc>, @@ -9330,72 +9308,33 @@ pub fn compose_callee_provenance( let_prov: Rc>>>>, ) -> Rc>> { match v1_rt::map_get(&func_sigs, callee) { - Some(sig) => match sig.output_provenance.clone().first().cloned() { - Some(callee_prov) => Rc::new(v1_rt::map_keys(&callee_prov)).iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, callee_pname: String| { - match v1_rt::map_get(&callee_prov, callee_pname.clone()) { - Some(callee_rel) => { - match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { - Some(arg) => { - let arg_prov = classify_body_provenance( - arg.clone(), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_sigs.clone(), - let_prov.clone(), - ); - Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold( - acc.clone(), - |inner: Rc>>, - pname: String| { - match v1_rt::map_get(&arg_prov, pname.clone()) { - Some(arg_rel) => { - let composed = compose_sub_value_relations( - arg_rel.clone(), - callee_rel.clone(), - ); - match (*composed.clone()).clone() { - SubValueRelation::SubValueUnknown => { - inner.clone() - } - _ => match v1_rt::map_get( - &inner, - pname.clone(), - ) { - Some(existing) => v1_rt::rc_map_insert( - inner.clone(), - pname.clone(), - meet_sub_value( - existing.clone(), - composed.clone(), - ), - ), - None => v1_rt::rc_map_insert( - inner.clone(), - pname.clone(), - composed.clone(), - ), - }, - } - } - None => inner.clone(), - } - }, - ) - } - None => acc.clone(), - } - } - None => acc.clone(), - } - }, - ), - None => v1_rt::rc_empty_map::>(), - }, - None => v1_rt::rc_empty_map::>(), - } + Some(sig) => match sig.output_provenance.clone().first().cloned() { + Some(callee_prov) => Rc::new(v1_rt::map_keys(&callee_prov)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, callee_pname: Rc>| match v1_rt::map_get(&callee_prov, callee_pname.clone()) { + Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { + Some(arg) => { + let arg_prov = classify_body_provenance(arg.clone(), param_names.clone(), param_types.clone(), type_env.clone(), func_sigs.clone(), let_prov.clone()); +Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold(acc.clone(), |inner: Rc>>, pname: Rc>| match v1_rt::map_get(&arg_prov, pname.clone()) { + Some(arg_rel) => { + let composed = compose_sub_value_relations(arg_rel.clone(), callee_rel.clone()); +match (*composed.clone()).clone() { + SubValueRelation::SubValueUnknown => inner.clone(), + _ => match v1_rt::map_get(&inner, pname.clone()) { + Some(existing) => v1_rt::rc_map_insert(inner.clone(), pname.clone(), meet_sub_value(existing.clone(), composed.clone())), + None => v1_rt::rc_map_insert(inner.clone(), pname.clone(), composed.clone()), +}, +} +}, + None => inner.clone(), +}) +}, + None => acc.clone(), +}, + None => acc.clone(), +}), + None => v1_rt::rc_empty_map::>, Rc>(), +}, + None => v1_rt::rc_empty_map::>, Rc>(), +} } pub fn classify_body_per_field( @@ -9626,7 +9565,7 @@ pub fn meet_per_field_results( } pub fn empty_prov_map() -> Rc>> { - v1_rt::rc_empty_map::>() + v1_rt::rc_empty_map::>, Rc>() } pub fn meet_body_provenance_maps( @@ -9660,19 +9599,18 @@ pub fn intersect_prov_maps( ) -> Rc>> { Rc::new(v1_rt::map_keys(&a)).iter().cloned().fold( empty_prov_map(), - |result: Rc>>, key: String| match v1_rt::map_get( - &b, - key.clone(), - ) { - Some(b_rel) => match v1_rt::map_get(&a, key.clone()) { - Some(a_rel) => v1_rt::rc_map_insert( - result.clone(), - key.clone(), - meet_sub_value(a_rel.clone(), b_rel.clone()), - ), + |result: Rc>>, key: Rc>| { + match v1_rt::map_get(&b, key.clone()) { + Some(b_rel) => match v1_rt::map_get(&a, key.clone()) { + Some(a_rel) => v1_rt::rc_map_insert( + result.clone(), + key.clone(), + meet_sub_value(a_rel.clone(), b_rel.clone()), + ), + None => result.clone(), + }, None => result.clone(), - }, - None => result.clone(), + } }, ) } @@ -9703,8 +9641,13 @@ pub fn arm_ctx_from_variant_provenance( MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; - if ((bind_name.clone().as_str() == "".to_string().as_str()) - || (field_label.clone().as_str() == "".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host( + field_label.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + ))) { c.clone() } else { @@ -9718,7 +9661,7 @@ pub fn arm_ctx_from_variant_provenance( c.type_env.clone(), c.func_sigs.clone(), v1_rt::rc_empty_map::< - String, + Rc>, Rc>>, >(), ); @@ -9780,47 +9723,47 @@ pub fn compose_callee_param_map( let_prov: Rc>>>>, ) -> Rc>> { Rc::new(v1_rt::map_keys(&callee_prov)).iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, callee_pname: String| match v1_rt::map_get( - &callee_prov, - callee_pname.clone(), - ) { - Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { - Some(arg) => { - let arg_prov = classify_body_provenance( - arg.clone(), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_sigs.clone(), - let_prov.clone(), - ); - Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold( - acc.clone(), - |inner: Rc>>, pname: String| { - match v1_rt::map_get(&arg_prov, pname.clone()) { - Some(arg_rel) => { - let composed = compose_sub_value_relations( - arg_rel.clone(), - callee_rel.clone(), - ); - match (*composed.clone()).clone() { - SubValueRelation::SubValueUnknown => inner.clone(), - _ => v1_rt::rc_map_insert( - inner.clone(), - pname.clone(), - composed.clone(), - ), + v1_rt::rc_empty_map::>, Rc>(), + |acc: Rc>>, callee_pname: Rc>| { + match v1_rt::map_get(&callee_prov, callee_pname.clone()) { + Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { + Some(arg) => { + let arg_prov = classify_body_provenance( + arg.clone(), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_sigs.clone(), + let_prov.clone(), + ); + Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold( + acc.clone(), + |inner: Rc>>, + pname: Rc>| { + match v1_rt::map_get(&arg_prov, pname.clone()) { + Some(arg_rel) => { + let composed = compose_sub_value_relations( + arg_rel.clone(), + callee_rel.clone(), + ); + match (*composed.clone()).clone() { + SubValueRelation::SubValueUnknown => inner.clone(), + _ => v1_rt::rc_map_insert( + inner.clone(), + pname.clone(), + composed.clone(), + ), + } } + None => inner.clone(), } - None => inner.clone(), - } - }, - ) - } + }, + ) + } + None => acc.clone(), + }, None => acc.clone(), - }, - None => acc.clone(), + } }, ) } @@ -9856,14 +9799,21 @@ pub fn compute_variant_provenance( __result }); let param_types = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((pname.clone().as_str() != "".to_string().as_str()) - && (ptype.clone().as_str() != "".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) + && (crate::v2_std_text::host_string_text_to_rust_host( + ptype.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + ))) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -9878,20 +9828,23 @@ pub fn compute_variant_provenance( param_types, type_env.clone(), func_sigs, - v1_rt::rc_empty_map::>>>(), v1_rt::rc_empty_map::< - String, + Rc>, + Rc>>, + >(), + v1_rt::rc_empty_map::< + Rc>, Rc>>>>, >(), ) } _ => v1_rt::rc_empty_map::< - String, + Rc>, Rc>>>>, >(), }, None => v1_rt::rc_empty_map::< - String, + Rc>, Rc>>>>, >(), } @@ -9900,7 +9853,7 @@ pub fn compute_variant_provenance( pub fn collect_variant_constructors( body: Rc, - parent_enum: String, + parent_enum: Rc>, param_names: Rc>, param_types: Rc>, type_env: Rc, @@ -9914,12 +9867,14 @@ pub fn collect_variant_constructors( parent_enum: pe, .. } => match pe.clone() { Some(enum_name) => { - if (enum_name.clone().as_str() == parent_enum.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(enum_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(parent_enum.clone())) + { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( v1_rt::rc_empty_map::< - String, + Rc>, Rc>>, >(), |m: Rc< @@ -9938,7 +9893,11 @@ pub fn collect_variant_constructors( func_sigs.clone(), let_prov.clone(), ); - if (fname.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { v1_rt::rc_map_insert( m.clone(), fname.clone(), @@ -9972,24 +9931,23 @@ pub fn collect_variant_constructors( let callee = expr_call_func_at(body.clone(), type_env.source_indices.clone()); match v1_rt::map_get(&func_sigs, callee) { Some(sig) => { - if ((authored_name_at( + if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - ) - .as_str() - == parent_enum.clone().as_str()) - && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() - as i64) - > 0)) + )) == crate::v2_std_text::host_string_text_to_rust_host( + parent_enum.clone(), + )) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() + as i64) + > 0)) { { let call_args = call_args_by_name( body.clone(), type_env.source_indices.clone(), ); - Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).iter().cloned().fold(acc.clone(), |variant_acc: Rc>>>>>>, variant_name: String| match v1_rt::map_get(&sig.variant_provenance.clone(), variant_name.clone()) { + Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).iter().cloned().fold(acc.clone(), |variant_acc: Rc>>>>>>, variant_name: Rc>| match v1_rt::map_get(&sig.variant_provenance.clone(), variant_name.clone()) { Some(field_map) => { - let composed_field_map = Rc::new(v1_rt::map_keys(&field_map)).iter().cloned().fold(v1_rt::rc_empty_map::>>>(), |fm_acc: Rc>>>>, field_name: String| match v1_rt::map_get(&field_map, field_name.clone()) { + let composed_field_map = Rc::new(v1_rt::map_keys(&field_map)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>>>(), |fm_acc: Rc>>>>, field_name: Rc>| match v1_rt::map_get(&field_map, field_name.clone()) { Some(param_map) => { let composed = compose_callee_param_map(param_map.clone(), call_args.clone(), param_names.clone(), param_types.clone(), type_env.clone(), func_sigs.clone(), let_prov.clone()); if ((Rc::new(v1_rt::map_keys(&composed)).len() as i64) > 0) { @@ -10161,9 +10119,9 @@ pub fn merge_field_prov_maps( ) -> Rc>>>> { { let from_a = Rc::new(v1_rt::map_keys(&a)).iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |result: Rc>>>>, - fname: String| match v1_rt::map_get(&a, fname.clone()) { + fname: Rc>| match v1_rt::map_get(&a, fname.clone()) { Some(a_prov) => match v1_rt::map_get(&b, fname.clone()) { Some(b_prov) => v1_rt::rc_map_insert( result.clone(), @@ -10178,7 +10136,7 @@ pub fn merge_field_prov_maps( Rc::new(v1_rt::map_keys(&b)).iter().cloned().fold( from_a, |result: Rc>>>>, - fname: String| { + fname: Rc>| { if (v1_rt::map_get(&result, fname.clone()) != None) { result.clone() } else { @@ -10201,24 +10159,23 @@ pub fn union_prov_maps( { let from_a = Rc::new(v1_rt::map_keys(&a)).iter().cloned().fold( empty_prov_map(), - |result: Rc>>, key: String| match v1_rt::map_get( - &a, - key.clone(), - ) { - Some(a_rel) => match v1_rt::map_get(&b, key.clone()) { - Some(b_rel) => v1_rt::rc_map_insert( - result.clone(), - key.clone(), - join_sub_value(a_rel.clone(), b_rel.clone()), - ), - None => v1_rt::rc_map_insert(result.clone(), key.clone(), a_rel.clone()), - }, - None => result.clone(), + |result: Rc>>, key: Rc>| { + match v1_rt::map_get(&a, key.clone()) { + Some(a_rel) => match v1_rt::map_get(&b, key.clone()) { + Some(b_rel) => v1_rt::rc_map_insert( + result.clone(), + key.clone(), + join_sub_value(a_rel.clone(), b_rel.clone()), + ), + None => v1_rt::rc_map_insert(result.clone(), key.clone(), a_rel.clone()), + }, + None => result.clone(), + } }, ); Rc::new(v1_rt::map_keys(&b)).iter().cloned().fold( from_a, - |result: Rc>>, key: String| { + |result: Rc>>, key: Rc>| { if (v1_rt::map_get(&result, key.clone()) != None) { result.clone() } else { @@ -10261,8 +10218,16 @@ pub fn populate_output_provenance( first_param.clone(), type_env.source_indices.clone(), ); - if ((ptype.clone().as_str() != "".to_string().as_str()) - && (pname.clone().as_str() != "".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host( + ptype.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) && (crate::v2_std_text::host_string_text_to_rust_host( + pname.clone(), + ) + != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + ))) { { let fields = inductive_fields_for( @@ -10295,7 +10260,7 @@ pub fn populate_output_provenance( let provenance = Rc::new(vec![v1_rt::rc_map_insert( v1_rt::rc_empty_map::< - String, + Rc>, Rc, >( ), @@ -10359,7 +10324,7 @@ pub fn populate_output_provenance( acc.clone(), ), _ => v1_rt::rc_empty_map::< - String, + Rc>, Rc< HashMap< String, @@ -10432,7 +10397,7 @@ pub fn populate_output_provenance( pub fn annotate_descent_evidence( body: Rc, - fn_name: String, + fn_name: Rc>, params: Rc>>, type_env: Rc, scope_locals: Rc>>, @@ -10440,7 +10405,7 @@ pub fn annotate_descent_evidence( ) -> Rc { { let param_name_map = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); @@ -10462,12 +10427,14 @@ pub fn annotate_descent_evidence( param_names: param_name_map, param_order: param_order_list, type_env: type_env.clone(), - sub_value_vars: v1_rt::rc_empty_map::>(), - size_aliases: v1_rt::rc_empty_map::>(), + sub_value_vars: v1_rt::rc_empty_map::>, Rc>(), + size_aliases: v1_rt::rc_empty_map::>, Rc>(), scope_locals: scope_locals, func_sigs: func_sigs, - per_field_vars: v1_rt::rc_empty_map::>>>( - ), + per_field_vars: v1_rt::rc_empty_map::< + Rc>, + Rc>>, + >(), }); annotate_descent(body, ctx) } @@ -10551,13 +10518,12 @@ pub fn infer_auth_source_properties( let mut __result = Vec::new(); for p in props.iter().cloned() { __result.push( - if (field_init_node_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == "svc_auth_source".to_string().as_str()) - { + )) == crate::v2_std_text::host_string_text_to_rust_host( + "svc_auth_source".to_string(), + )) { { let val = field_init_node_value(p.clone()); let val_result = infer_expr(val.clone(), scope.clone(), None); @@ -10979,12 +10945,17 @@ pub fn infer_items( }) } -pub fn is_type_variable_name(name: String) -> bool { - (((((name.clone().as_str() == "T".to_string().as_str()) - || (name.clone().as_str() == "K".to_string().as_str())) - || (name.clone().as_str() == "V".to_string().as_str())) - || (name.clone().as_str() == "MappedElement".to_string().as_str())) - || (name.clone().as_str() == "FoldAccumulator".to_string().as_str())) +pub fn is_type_variable_name(name: Rc>) -> bool { + (((((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("T".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("K".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("V".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("MappedElement".to_string()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("FoldAccumulator".to_string()))) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -10996,10 +10967,12 @@ pub struct ArgGenericFoldState { pub fn type_node_label( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let authored = authored_name_at(source_indices, n.clone()); - if (authored.clone().as_str() != "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(authored.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { authored.clone() } else { match n.inferred.clone().as_deref().cloned() { @@ -11024,9 +10997,13 @@ pub fn param_is_generic_decl( }; (((((pt.children.clone().len() as i64) == 0) && (pt.connective.clone() == Connective::NoConnective)) - && (pname.clone().as_str() != "".to_string().as_str())) - && ((pname.clone().as_str() == tname.as_str()) - || (type_expr_is_var && (pname.clone().as_str() == pt.name.clone().as_str())))) + && (crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + && ((crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(tname)) + || (type_expr_is_var + && (crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(pt.name.clone()))))) } } @@ -11049,7 +11026,9 @@ pub fn unify_generics( && { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == bind_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(g.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone())) + { __found = true; break; } @@ -11108,9 +11087,12 @@ pub fn should_unify_record_lit_generics( { let formal_name = type_node_label(formal.clone(), source_indices.clone()); let record_name = type_node_label(arg_expr.clone(), source_indices.clone()); - (((formal_name.clone().as_str() != "".to_string().as_str()) - && (record_name.clone().as_str() != "".to_string().as_str())) - && (formal_name.clone().as_str() == record_name.clone().as_str())) + (((crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(record_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + && (crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(record_name.clone()))) } } } @@ -11132,12 +11114,10 @@ pub fn unify_record_lit_field_walk( match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (field_init_node_name_at( + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( fi.clone(), scope.type_env.clone().source_indices.clone(), - ) - .as_str() - == field_name.clone().as_str()) + )) == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone())) { __result.push(fi); } @@ -11192,7 +11172,9 @@ pub fn unify_record_lit_generics( let is_generic_slot = { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (g.clone().as_str() == formal_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(g.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone())) + { __found = true; break; } @@ -11214,9 +11196,15 @@ pub fn unify_record_lit_generics( record.clone(), scope.type_env.clone().source_indices.clone(), ); - if ((record_type_name.clone().as_str() != "".to_string().as_str()) - && (formal_name.clone().as_str() == record_type_name.clone().as_str())) - { + if ((crate::v2_std_text::host_string_text_to_rust_host( + record_type_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) && (crate::v2_std_text::host_string_text_to_rust_host( + formal_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + record_type_name.clone(), + ))) { unify_record_lit_field_walk( record_lit_expected_fields( Some(record_type_name.clone()), @@ -11406,7 +11394,7 @@ pub fn collect_parent_bindings_filtered( ) } -pub fn kernel_span(name: String) -> Rc { +pub fn kernel_span(name: Rc>) -> Rc { Rc::new(SourceSpan { file: v1_rt::concat( v1_rt::concat(">>, name: String| { + |acc: Rc>>, name: Rc>| { v1_rt::rc_map_insert( acc, v1_rt::concat( @@ -11457,7 +11445,7 @@ pub fn build_type_env( .cloned() .fold( source_indices.clone(), - |acc: Rc>>, name: String| { + |acc: Rc>>, name: Rc>| { v1_rt::rc_map_insert( acc, v1_rt::concat( @@ -11477,9 +11465,12 @@ pub fn build_type_env( let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() - .fold(intern_table.clone(), |t: Rc, name: String| { - intern(t, name.clone()).table.clone() - }); + .fold( + intern_table.clone(), + |t: Rc, name: Rc>| { + intern(t, name.clone()).table.clone() + }, + ); let intern_table = Rc::new(vec![ "Optional".to_string(), "Present".to_string(), @@ -11489,21 +11480,25 @@ pub fn build_type_env( ]) .iter() .cloned() - .fold(intern_table.clone(), |t: Rc, name: String| { - intern(t, name.clone()).table.clone() - }); + .fold( + intern_table.clone(), + |t: Rc, name: Rc>| intern(t, name.clone()).table.clone(), + ); let intern_table = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) .iter() .cloned() - .fold(intern_table.clone(), |t: Rc, name: String| { - intern(t, name.clone()).table.clone() - }); + .fold( + intern_table.clone(), + |t: Rc, name: Rc>| { + intern(t, name.clone()).table.clone() + }, + ); let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { + |acc: Rc>>, name: Rc>| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -11672,7 +11667,7 @@ pub fn build_type_env( .cloned() .fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -11691,7 +11686,9 @@ pub fn build_type_env( let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) + { __found = true; break; } @@ -11699,17 +11696,18 @@ pub fn build_type_env( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = if ((module_name_str.clone().as_str() - != "std.types".to_string().as_str()) - && (imports_std_types == false)) - { - match v1_rt::map_get(&parent_index, "std.types".to_string()) { - Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), - None => Rc::new(vec![]), - } - } else { - Rc::new(vec![]) - }; + let std_types_parent_env = + if ((crate::v2_std_text::host_string_text_to_rust_host(module_name_str.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) + && (imports_std_types == false)) + { + match v1_rt::map_get(&parent_index, "std.types".to_string()) { + Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), + None => Rc::new(vec![]), + } + } else { + Rc::new(vec![]) + }; let imported_parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -11733,7 +11731,11 @@ pub fn build_type_env( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "std.types".to_string(), + )) + { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -11787,7 +11789,7 @@ pub fn build_type_env( }, ); let import_inductive_fields = parent_envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |acc: Rc>>>>, env: Rc| { merge_inductive_fields(acc, env.inductive_fields.clone()) }, @@ -12054,7 +12056,8 @@ pub fn build_type_env( bindings: all_local_bindings, recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), + inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( + ), source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); @@ -12063,7 +12066,7 @@ pub fn build_type_env( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>>(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>>>, b: Rc| { v1_rt::rc_map_insert( acc, @@ -12076,7 +12079,7 @@ pub fn build_type_env( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, b: Rc| { v1_rt::rc_map_insert(acc, b.name.clone(), b.clone()) }, @@ -12093,16 +12096,13 @@ pub fn build_type_env( cycle_set_str.clone(), Rc::new(v1_rt::map_keys(&compiler_recursive_types())), ); - let cross_type_set_str = cross_type_all_names - .clone() - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { - v1_rt::rc_set_insert(acc, name.clone()) - }); + let cross_type_set_str = cross_type_all_names.clone().iter().cloned().fold( + v1_rt::rc_empty_set::<_>(), + |acc: _, name: Rc>| v1_rt::rc_set_insert(acc, name.clone()), + ); let cross_type_set = cross_type_all_names.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -12158,22 +12158,23 @@ pub fn build_type_env_unresolved( let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() - .fold(intern_table.clone(), |t: Rc, name: String| { - intern(t, name.clone()).table.clone() - }); - let intern_table = Rc::new(vec!["Optional".to_string()]) - .iter() - .cloned() - .fold(intern_table.clone(), |t: Rc, name: String| { - intern(t, name.clone()).table.clone() - }); + .fold( + intern_table.clone(), + |t: Rc, name: Rc>| { + intern(t, name.clone()).table.clone() + }, + ); + let intern_table = Rc::new(vec!["Optional".to_string()]).iter().cloned().fold( + intern_table.clone(), + |t: Rc, name: Rc>| intern(t, name.clone()).table.clone(), + ); let zero_span = make_span(0, 0); let kernel_bindings = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: String| { + |acc: Rc>>, name: Rc>| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -12301,14 +12302,17 @@ pub fn build_type_env_unresolved( bindings: kernel_bindings.clone(), recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), + inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( + ), source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) + { __found = true; break; } @@ -12316,17 +12320,18 @@ pub fn build_type_env_unresolved( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = if ((module_name_str.as_str() - != "std.types".to_string().as_str()) - && (imports_std_types == false)) - { - match v1_rt::map_get(&parent_index, "std.types".to_string()) { - Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), - None => Rc::new(vec![]), - } - } else { - Rc::new(vec![]) - }; + let std_types_parent_env = + if ((crate::v2_std_text::host_string_text_to_rust_host(module_name_str) + != crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) + && (imports_std_types == false)) + { + match v1_rt::map_get(&parent_index, "std.types".to_string()) { + Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), + None => Rc::new(vec![]), + } + } else { + Rc::new(vec![]) + }; let imported_parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12350,7 +12355,11 @@ pub fn build_type_env_unresolved( imp.module_path.clone(), ) { Some(typed_parent) => { - if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "std.types".to_string(), + )) + { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -12404,7 +12413,7 @@ pub fn build_type_env_unresolved( }, ); let import_inductive_fields = parent_envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |acc: Rc>>>>, env: Rc| { merge_inductive_fields(acc, env.inductive_fields.clone()) }, @@ -12545,7 +12554,8 @@ pub fn build_type_env_unresolved( bindings: local_bindings, recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>>>(), + inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( + ), source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); @@ -12554,7 +12564,7 @@ pub fn build_type_env_unresolved( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>>(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>>>, b: Rc| { v1_rt::rc_map_insert( acc, @@ -12567,7 +12577,7 @@ pub fn build_type_env_unresolved( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, b: Rc| { v1_rt::rc_map_insert(acc, b.name.clone(), b.clone()) }, @@ -12584,16 +12594,13 @@ pub fn build_type_env_unresolved( cycle_set_str.clone(), Rc::new(v1_rt::map_keys(&compiler_recursive_types())), ); - let cross_type_set_str = cross_type_all_names - .clone() - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { - v1_rt::rc_set_insert(acc, name.clone()) - }); + let cross_type_set_str = cross_type_all_names.clone().iter().cloned().fold( + v1_rt::rc_empty_set::<_>(), + |acc: _, name: Rc>| v1_rt::rc_set_insert(acc, name.clone()), + ); let cross_type_set = cross_type_all_names.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -12626,7 +12633,7 @@ pub fn build_type_env_unresolved( pub fn build_item_info( item: Rc, source_indices: Rc>>, - module_name: String, + module_name: Rc>, ) -> Rc { { let kind = item_kind(item.clone()); @@ -12704,7 +12711,11 @@ pub fn build_item_info( } } -pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { +pub fn analyze_item( + item: Rc, + env: Rc, + module_name: Rc>, +) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); let ritem = resolved.item.clone(); @@ -12726,7 +12737,7 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc is_async: ((ritem.uses.clone().len() as i64) > 0), output_provenance: Rc::new(vec![]), variant_provenance: v1_rt::rc_empty_map::< - String, + Rc>, Rc>>>>, >(), })) @@ -12858,32 +12869,32 @@ pub fn build_module_context( parent_index: Rc>>, resolved_imports: Rc>>, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { { let local = fold_module_contributions( contributions, Rc::new(vec![]), - v1_rt::rc_empty_map::>(), - v1_rt::rc_empty_map::>>>(), - v1_rt::rc_empty_map::>(), - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>, Rc>(), Rc::new(vec![]), env.source_indices.clone(), ); let imported_enum_names = resolved_imports.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, imp: Rc| { imp.specific_names.clone().iter().cloned().fold( acc, - |inner: Rc>, n: String| { + |inner: Rc>, n: Rc>| { v1_rt::rc_map_insert(inner, n.clone(), true) }, ) }, ); let variant_fold = Rc::new(v1_rt::map_values(&env.bindings.clone())).iter().cloned().fold(Rc::new(VariantFoldState { - locals: v1_rt::rc_empty_map::>(), + locals: v1_rt::rc_empty_map::>, Rc>(), collision_errors: Rc::new(vec![]), }), |acc: Rc, binding: Rc| { let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); @@ -12943,7 +12954,7 @@ if (curr_is_imported.clone() && prev_is_imported.clone()) { resolved_imports.clone(), parent_index, env.clone(), - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), local.svc_registry.clone(), local.svc_locals.clone(), ); @@ -13025,9 +13036,10 @@ pub fn typecheck_module( items: Rc::new(vec![]), type_env: env.clone(), func_env: Rc::new(ResolvedFuncEnv { - signatures: v1_rt::rc_empty_map::>(), + signatures: v1_rt::rc_empty_map::>, Rc>( + ), }), - item_registry: v1_rt::rc_empty_map::>(), + item_registry: v1_rt::rc_empty_map::>, Rc>(), }), diagnostics: v1_rt::concat(env_diags.clone(), seed_diags.clone()), }); @@ -13077,11 +13089,12 @@ pub fn typecheck_module( type_env: env.clone(), func_env: ctx.func_env.clone(), locals: data_locals.clone(), - match_bound_names: v1_rt::rc_empty_map::(), + match_bound_names: v1_rt::rc_empty_map::>, bool>(), module_name: resolved_module_name.clone(), service_registry: ctx.svc_registry.clone(), item_registry: ctx.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::>(), + lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>( + ), }); let typed_item_results = infer_items(ctx.resolved_items.clone(), infer_scope); let typed_items = Rc::new({ @@ -13192,7 +13205,7 @@ pub struct BindingsAccum { pub fn resolve_env_bindings( env: Rc, - module_name: String, + module_name: Rc>, local_names: Rc>, deps_map: Rc>>>, ) -> Rc { @@ -13236,7 +13249,7 @@ pub fn resolve_env_bindings( pub fn topo_resolve_types( mut remaining: Rc>, mut env: Rc, - mut module_name: String, + mut module_name: Rc>, mut diagnostics: Rc>>, mut local_names: Rc>, mut deps_map: Rc>>>, @@ -13249,13 +13262,10 @@ pub fn topo_resolve_types( diagnostics: diagnostics.clone(), }); } - let remaining_set = remaining - .clone() - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { - v1_rt::rc_set_insert(acc, name.clone()) - }); + let remaining_set = remaining.clone().iter().cloned().fold( + v1_rt::rc_empty_set::<_>(), + |acc: _, name: Rc>| v1_rt::rc_set_insert(acc, name.clone()), + ); let ready = Rc::new({ let mut __result = Vec::new(); for name in remaining.clone().iter().cloned() { @@ -13264,8 +13274,16 @@ pub fn topo_resolve_types( let mut __all = true; for dep in deps.clone().iter().cloned() { if !((((is_kernel_type(dep.clone()) - || (dep.clone().as_str() == "None".to_string().as_str())) - || (dep.clone().as_str() == "".to_string().as_str())) + || (crate::v2_std_text::host_string_text_to_rust_host( + dep.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "None".to_string(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host( + dep.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + ))) || is_recursive_type_by_name(env.clone(), dep.clone())) || (v1_rt::set_contains(&remaining_set, dep.clone()) == false)) { @@ -13289,7 +13307,7 @@ pub fn topo_resolve_types( bindings: env.bindings.clone(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, name: String| { + |acc: Rc, name: Rc>| { let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { @@ -13343,7 +13361,7 @@ pub fn topo_resolve_types( bindings: env.bindings.clone(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, name: String| { + |acc: Rc, name: Rc>| { let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { @@ -13376,8 +13394,8 @@ pub fn topo_resolve_types( }, ); let ready_set = ready.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -13479,7 +13497,10 @@ pub fn variant_has_positional_payload_shape( (((variant.children.clone().len() as i64) == 1) && match variant.children.clone().first().cloned() { Some(f) => { - (field_node_name_at(f.clone(), source_indices).as_str() == "0".to_string().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(field_node_name_at( + f.clone(), + source_indices, + )) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) } None => false, }) @@ -13610,7 +13631,7 @@ pub fn build_positional_payload_variants( pub fn build_emit_graph_info(modules: Rc>>) -> Rc { { let init = Rc::new(EmitInfoBuildState { - type_summaries: v1_rt::rc_empty_map::>(), + type_summaries: v1_rt::rc_empty_map::>, Rc>(), }); let built = modules.clone().iter().cloned().fold( init.clone(), @@ -13653,13 +13674,15 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), - ownership_index: v1_rt::rc_empty_map::>>( - ), + ownership_index: v1_rt::rc_empty_map::< + Rc>, + Rc>, + >(), movable: v1_rt::rc_empty_set::(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), read_only_params_index: v1_rt::rc_empty_map::< - String, + Rc>, Rc>, >(), read_only_params: v1_rt::rc_empty_set::(), @@ -13675,8 +13698,8 @@ pub fn typecheck( typecheck_modules( graph.modules.clone(), Rc::new(vec![]), - v1_rt::rc_empty_map::>(), - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>, Rc>(), Rc::new(vec![]), source_indices, intern_table, diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index c3d02096a6e..3ae945462e6 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -35,7 +35,11 @@ pub struct KeyedCollectionParts { pub value_type: Rc, } -pub fn access_error(message: String, span: Rc, module_name: String) -> Rc { +pub fn access_error( + message: Rc>, + span: Rc, + module_name: Rc>, +) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::InternalError { message: message, @@ -49,7 +53,7 @@ pub fn access_result( inferred: Rc, diagnostics: Rc>>, span: Rc, - fallback_message: String, + fallback_message: Rc>, ) -> Rc { if ((diagnostics.clone().len() as i64) == 0) { Rc::new(AccessCheckResultNode { @@ -99,7 +103,7 @@ pub fn check_index_access_node( base_type: Rc, index_type: Rc, span: Rc, - module_name: String, + module_name: Rc>, source_indices: Rc>>, ) -> Rc { { @@ -205,7 +209,7 @@ pub fn check_slice_access_node( start_type: Rc, end_type: Rc, span: Rc, - module_name: String, + module_name: Rc>, source_indices: Rc>>, ) -> Rc { { diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index e06cb29b877..0038bb82a79 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -18,26 +18,28 @@ pub fn compute_in_graph_deps( ) -> Rc>>> { { let result = all_names.iter().cloned().fold( - v1_rt::rc_empty_map::>>(), - |acc: Rc>>>, name: String| match v1_rt::map_get( - &deps_map, - name.clone(), - ) { - Some(deps) => { - let local = Rc::new({ - let mut __result = Vec::new(); - for d in deps.clone().iter().cloned() { - if ((d.clone().as_str() != name.clone().as_str()) - && v1_rt::set_contains(&name_set, d.clone())) - { - __result.push(d); + v1_rt::rc_empty_map::>, Rc>>(), + |acc: Rc>>>, name: Rc>| { + match v1_rt::map_get(&deps_map, name.clone()) { + Some(deps) => { + let local = Rc::new({ + let mut __result = Vec::new(); + for d in deps.clone().iter().cloned() { + if ((crate::v2_std_text::host_string_text_to_rust_host(d.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + name.clone(), + )) + && v1_rt::set_contains(&name_set, d.clone())) + { + __result.push(d); + } } - } - __result - }); - v1_rt::rc_map_insert(acc.clone(), name.clone(), local.clone()) + __result + }); + v1_rt::rc_map_insert(acc.clone(), name.clone(), local.clone()) + } + None => v1_rt::rc_map_insert(acc.clone(), name.clone(), Rc::new(vec![])), } - None => v1_rt::rc_map_insert(acc.clone(), name.clone(), Rc::new(vec![])), }, ); result @@ -49,14 +51,14 @@ pub fn build_reverse_adj( local_deps: Rc>>>, ) -> Rc>>> { all_names.iter().cloned().fold( - v1_rt::rc_empty_map::>>(), - |acc: Rc>>>, name: String| match v1_rt::map_get( + v1_rt::rc_empty_map::>, Rc>>(), + |acc: Rc>>>, name: Rc>| match v1_rt::map_get( &local_deps, name.clone(), ) { Some(deps) => deps.clone().iter().cloned().fold( acc.clone(), - |inner_acc: Rc>>>, dep: String| { + |inner_acc: Rc>>>, dep: Rc>| { let existing = match v1_rt::map_get(&inner_acc, dep.clone()) { Some(v) => v.clone(), None => Rc::new(vec![]), @@ -78,8 +80,8 @@ pub fn build_in_degree( local_deps: Rc>>>, ) -> Rc> { all_names.iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, i64>(), + |acc: Rc>, name: Rc>| { let deg = match v1_rt::map_get(&local_deps, name.clone()) { Some(deps) => (deps.clone().len() as i64), None => 0, @@ -159,7 +161,7 @@ pub fn kahn_cycle_drain( in_degree: in_degree.clone(), removed_count: removed_count.clone(), }), - |state: Rc, node: String| { + |state: Rc, node: Rc>| { let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); { let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { @@ -168,7 +170,7 @@ pub fn kahn_cycle_drain( }; let new_deg = dependents.clone().iter().cloned().fold( state.in_degree, - |deg_acc: Rc>, dep: String| { + |deg_acc: Rc>, dep: Rc>| { let old = match v1_rt::map_get(°_acc, dep.clone()) { Some(d) => d.clone(), None => 0, @@ -183,32 +185,29 @@ pub fn kahn_cycle_drain( } }, ); - let next_queue = - queue - .clone() - .iter() - .cloned() - .fold(Rc::new(vec![]), |acc: _, node: String| { - let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { - Some(v) => v.clone(), - None => Rc::new(vec![]), - }; - dependents - .clone() - .iter() - .cloned() - .fold(acc, |inner_acc: _, dep: String| { - let deg = match v1_rt::map_get(&result.in_degree.clone(), dep.clone()) { - Some(d) => d.clone(), - None => 0, - }; - if (deg.clone() == 0) { - v1_rt::rc_list_push(inner_acc.clone(), dep.clone()) - } else { - inner_acc.clone() - } - }) - }); + let next_queue = queue.clone().iter().cloned().fold( + Rc::new(vec![]), + |acc: _, node: Rc>| { + let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { + Some(v) => v.clone(), + None => Rc::new(vec![]), + }; + dependents.clone().iter().cloned().fold( + acc, + |inner_acc: _, dep: Rc>| { + let deg = match v1_rt::map_get(&result.in_degree.clone(), dep.clone()) { + Some(d) => d.clone(), + None => 0, + }; + if (deg.clone() == 0) { + v1_rt::rc_list_push(inner_acc.clone(), dep.clone()) + } else { + inner_acc.clone() + } + }, + ) + }, + ); { let __tco_0 = next_queue; let __tco_1 = result.in_degree.clone(); @@ -235,13 +234,10 @@ pub fn detect_type_cycles_kahn( } __result }); - let name_set = all_names - .clone() - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, n: String| { - v1_rt::rc_set_insert(acc, n.clone()) - }); + let name_set = all_names.clone().iter().cloned().fold( + v1_rt::rc_empty_set::<_>(), + |acc: _, n: Rc>| v1_rt::rc_set_insert(acc, n.clone()), + ); let local_deps = compute_in_graph_deps(all_names.clone(), deps_map.clone(), name_set); let self_refs = Rc::new({ let mut __result = Vec::new(); @@ -250,7 +246,9 @@ pub fn detect_type_cycles_kahn( Some(deps) => { let mut __found = false; for d in deps.clone().iter().cloned() { - if (d.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(d.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -265,16 +263,14 @@ pub fn detect_type_cycles_kahn( __result }); let cycle_members = kahn_remove_loop(all_names.clone(), local_deps); - let sr_set = self_refs - .iter() - .cloned() - .fold(v1_rt::rc_empty_set::<_>(), |acc: _, n: String| { - v1_rt::rc_set_insert(acc, n.clone()) - }); + let sr_set = self_refs.iter().cloned().fold( + v1_rt::rc_empty_set::<_>(), + |acc: _, n: Rc>| v1_rt::rc_set_insert(acc, n.clone()), + ); let cm_set = cycle_members .iter() .cloned() - .fold(sr_set, |acc: _, n: String| { + .fold(sr_set, |acc: _, n: Rc>| { v1_rt::rc_set_insert(acc, n.clone()) }); let result = Rc::new({ diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index 98745ada53b..c270c9de145 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -53,7 +53,7 @@ impl TypeRepr { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeSummary { - pub name: String, + pub name: Rc>, pub repr: Rc, pub field_summaries: Rc>>, pub field_type_map: Rc>, @@ -84,25 +84,30 @@ pub struct EmitInfoBuildState { pub fn empty_emit_graph_info() -> Rc { Rc::new(EmitGraphInfo { - type_summaries: v1_rt::rc_empty_map::>(), + type_summaries: v1_rt::rc_empty_map::>, Rc>(), recursive_type_set: v1_rt::rc_empty_set::(), fielded_variants: v1_rt::rc_empty_set::(), positional_payload_variants: v1_rt::rc_empty_set::(), shared_types: v1_rt::rc_empty_set::(), - ownership_index: v1_rt::rc_empty_map::>>(), + ownership_index: v1_rt::rc_empty_map::< + Rc>, + Rc>, + >(), movable: v1_rt::rc_empty_set::(), - variant_to_enum: v1_rt::rc_empty_map::(), + variant_to_enum: v1_rt::rc_empty_map::>, Rc>>(), owned_bindings: v1_rt::rc_empty_set::(), - read_only_params_index: v1_rt::rc_empty_map::>>( - ), + read_only_params_index: v1_rt::rc_empty_map::< + Rc>, + Rc>, + >(), read_only_params: v1_rt::rc_empty_set::(), }) } pub fn variant_has_fields( emit_info: Rc, - enum_name: String, - variant_name: String, + enum_name: Rc>, + variant_name: Rc>, ) -> bool { { let key = v1_rt::concat(v1_rt::concat(enum_name, "::".to_string()), variant_name); @@ -110,13 +115,16 @@ pub fn variant_has_fields( } } -pub fn variant_summary_key(enum_name: String, variant_name: String) -> String { +pub fn variant_summary_key( + enum_name: Rc>, + variant_name: Rc>, +) -> Rc> { v1_rt::concat(v1_rt::concat(enum_name, "::".to_string()), variant_name) } pub fn lookup_emit_type_summary( emit_info: Rc, - type_name: String, + type_name: Rc>, ) -> Option> { v1_rt::map_get(&emit_info.type_summaries.clone(), type_name) } @@ -128,7 +136,7 @@ pub fn derive_variant_to_enum( .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, summary: Rc| match (*summary .repr .clone()) @@ -140,18 +148,19 @@ pub fn derive_variant_to_enum( .cloned() .fold( acc.clone(), - |inner: Rc>, vn: String| match v1_rt::map_get( - &inner, - vn.clone(), - ) { - Some(_) => { - v1_rt::rc_map_insert(inner.clone(), vn.clone(), "".to_string()) + |inner: Rc>, vn: Rc>| { + match v1_rt::map_get(&inner, vn.clone()) { + Some(_) => v1_rt::rc_map_insert( + inner.clone(), + vn.clone(), + "".to_string(), + ), + None => v1_rt::rc_map_insert( + inner.clone(), + vn.clone(), + summary.name.clone(), + ), } - None => v1_rt::rc_map_insert( - inner.clone(), - vn.clone(), - summary.name.clone(), - ), }, ) } @@ -162,7 +171,7 @@ pub fn derive_variant_to_enum( pub fn is_known_variant( type_summaries: Rc>>, - name: String, + name: Rc>, ) -> bool { { let mut __found = false; @@ -183,8 +192,8 @@ pub fn is_known_variant( pub fn variant_belongs_to_enum( type_summaries: Rc>>, - variant_name: String, - enum_name: String, + variant_name: Rc>, + enum_name: Rc>, ) -> bool { match v1_rt::map_get(&type_summaries, enum_name) { Some(summary) => match (*summary.repr.clone()).clone() { @@ -199,7 +208,7 @@ pub fn variant_belongs_to_enum( pub fn is_enum_in_summaries( type_summaries: Rc>>, - type_name: String, + type_name: Rc>, ) -> bool { match v1_rt::map_get(&type_summaries, type_name) { Some(summary) => match (*summary.repr.clone()).clone() { @@ -212,9 +221,9 @@ pub fn is_enum_in_summaries( pub fn find_variant_parent( type_summaries: Rc>>, - variant_name: String, + variant_name: Rc>, scope_enums: Rc>, -) -> Option { +) -> Rc> { Rc::new({ let mut __result = Vec::new(); for en in scope_enums.iter().cloned() { @@ -264,7 +273,7 @@ pub fn build_struct_field_summaries( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let child = pair.1.clone(); @@ -301,7 +310,7 @@ pub fn build_struct_field_summaries( pub fn find_first_enum_field_node( variants: Rc>>, - field_name: String, + field_name: Rc>, source_indices: Rc>>, ) -> Option> { match variants.first().cloned() { @@ -315,7 +324,7 @@ pub fn find_first_enum_field_node( pub fn enum_field_present_in_all_variants( variants: Rc>>, - field_name: String, + field_name: Rc>, source_indices: Rc>>, ) -> bool { { @@ -332,7 +341,7 @@ pub fn enum_field_present_in_all_variants( pub fn enum_field_type_consistent( variants: Rc>>, - field_name: String, + field_name: Rc>, expected: Rc, source_indices: Rc>>, ) -> bool { @@ -406,8 +415,8 @@ pub fn build_enum_field_summaries( __result }); consistent.iter().cloned().fold( - v1_rt::rc_empty_map::>(), - |acc: Rc>>, field_name: String| { + v1_rt::rc_empty_map::>, Rc>(), + |acc: Rc>>, field_name: Rc>| { match find_first_enum_field_node( variants.clone(), field_name.clone(), @@ -435,7 +444,7 @@ pub fn build_field_type_map( source_indices: Rc>>, ) -> Rc> { children.iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>, child: Rc| match child .inferred .clone() @@ -453,9 +462,13 @@ pub fn build_field_type_map( false }; let key = authored_name_at(source_indices.clone(), child.clone()); - if (((resolved_name.clone().as_str() != "".to_string().as_str()) + if (((crate::v2_std_text::host_string_text_to_rust_host(resolved_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) && !ft_is_type_var.clone()) - && (resolved_name.clone().as_str() != "Dynamic".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(resolved_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "Dynamic".to_string(), + ))) { v1_rt::rc_map_insert(acc.clone(), key.clone(), resolved_name.clone()) } else { @@ -507,7 +520,7 @@ pub fn build_type_summary( repr: Rc::new(TypeRepr::StructRepr), field_summaries: build_struct_field_summaries(item.clone(), source_indices.clone()), field_type_map: build_field_type_map(item.children.clone(), source_indices.clone()), - variant_name_set: v1_rt::rc_empty_map::(), + variant_name_set: v1_rt::rc_empty_map::>, bool>(), generic_param_names: gpn, has_fn_fields: has_fn, })) @@ -532,9 +545,10 @@ pub fn build_type_summary( item.children.clone(), source_indices.clone(), ), - field_type_map: v1_rt::rc_empty_map::(), + field_type_map: v1_rt::rc_empty_map::>, Rc>>( + ), variant_name_set: item.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, child: Rc| { v1_rt::rc_map_insert( acc, @@ -598,7 +612,11 @@ pub fn add_emit_item_summary( variant.children.clone(), source_indices.clone(), ), - variant_name_set: v1_rt::rc_empty_map::(), + variant_name_set: v1_rt::rc_empty_map::< + Rc>, + bool, + >( + ), generic_param_names: Rc::new(vec![]), has_fn_fields: v_has_fn.clone(), }), diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 34a7f135c98..95139a95c3d 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -30,7 +30,7 @@ pub struct TypeEnv { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { - pub name: String, + pub name: Rc>, pub resolved: Rc, pub provenance: Rc, } @@ -42,7 +42,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } } -pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { +pub fn is_recursive_type_by_name(env: Rc, name: Rc>) -> bool { match intern_find(env.intern_table.clone(), name) { Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, @@ -56,14 +56,14 @@ pub fn lookup_type(env: Rc, ident: i64) -> Option> { } } -pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { +pub fn lookup_type_by_name(env: Rc, name: Rc>) -> Option> { match intern_find(env.intern_table.clone(), name) { Some(id) => lookup_type(env.clone(), id.clone()), None => None, } } -pub fn authored_name(env: Rc, node: Rc) -> String { +pub fn authored_name(env: Rc, node: Rc) -> Rc> { authored_name_at(env.source_indices.clone(), node) } @@ -81,7 +81,10 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { } } -pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { +pub fn inductive_fields_for( + env: Rc, + type_name: Rc>, +) -> Rc>> { match v1_rt::map_get(&env.inductive_fields.clone(), type_name) { Some(fields) => fields.clone(), None => Rc::new(vec![]), @@ -90,15 +93,17 @@ pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc, - type_name: String, - variant_name: String, - field_name: String, + type_name: Rc>, + variant_name: Rc>, + field_name: Rc>, ) -> bool { { let mut __found = false; for f in inductive_fields_for(env, type_name).iter().cloned() { - if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) - && (f.field_name.clone().as_str() == field_name.clone().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(f.variant_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone())) + && (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()))) { __found = true; break; @@ -110,9 +115,9 @@ pub fn is_inductive_field( pub fn put_inductive_field( fields: Rc>>>>, - type_name: String, - variant_name: String, - field_name: String, + type_name: Rc>, + variant_name: Rc>, + field_name: Rc>, shape: RecursionShape, ) -> Rc>>>> { { @@ -139,11 +144,11 @@ pub fn put_inductive_field( pub fn put_inductive_field_cross( fields: Rc>>>>, - type_name: String, - variant_name: String, - field_name: String, + type_name: Rc>, + variant_name: Rc>, + field_name: Rc>, shape: RecursionShape, - element_type: String, + element_type: Rc>, ) -> Rc>>>> { { let existing = match v1_rt::map_get(&fields, type_name.clone()) { @@ -173,7 +178,7 @@ pub fn merge_inductive_fields( ) -> Rc>>>> { Rc::new(v1_rt::map_keys(&right)).iter().cloned().fold( left.clone(), - |acc: Rc>>>>, type_name: String| { + |acc: Rc>>>>, type_name: Rc>| { match v1_rt::map_get(&right, type_name.clone()) { Some(incoming) => { let existing = match v1_rt::map_get(&acc, type_name.clone()) { @@ -196,7 +201,7 @@ pub fn inductive_fields_list_to_map( fields: Rc>>, ) -> Rc>>>> { fields.iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |acc: Rc>>>>, field: Rc| { let existing = match v1_rt::map_get(&acc, field.type_name.clone()) { Some(fs) => fs.clone(), @@ -233,13 +238,13 @@ pub fn merge_envs(envs: Rc>>) -> Rc { }, ); let merged_inductive_fields = envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>, Rc>>>(), |acc: Rc>>>>, env: Rc| { merge_inductive_fields(acc, env.inductive_fields.clone()) }, ); let merged_source_indices = envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, env: Rc| { v1_rt::rc_map_merge(acc, env.source_indices.clone()) }, diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index f8f68621146..dc7bb6b8a40 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -43,8 +43,8 @@ pub enum ItemKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemInfo { - pub name: String, - pub module_name: String, + pub name: Rc>, + pub module_name: Rc>, pub kind: ItemKind, pub service_names: Rc>, pub resource_names: Rc>, diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 72331fe9761..11d49c60997 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -56,9 +56,11 @@ pub fn is_type_variable(inferred: Rc) -> bool { } } -pub fn is_witness_type_name(name: String) -> bool { - ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) +pub fn is_witness_type_name(name: Rc>) -> bool { + ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("witness".to_string()))) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -70,7 +72,7 @@ pub struct KnownMethodResolution { pub fn lookup_in_scope( locals: Rc>>, - name: String, + name: Rc>, ) -> Option> { match v1_rt::map_get(&locals, name) { Some(binding) => Some(binding.resolved.clone()), @@ -78,13 +80,16 @@ pub fn lookup_in_scope( } } -pub fn lookup_func_sig(func_env: Rc, name: String) -> Option> { +pub fn lookup_func_sig( + func_env: Rc, + name: Rc>, +) -> Option> { v1_rt::map_get(&func_env.signatures.clone(), name) } pub fn lookup_field_type_node( n: Rc, - field_name: String, + field_name: Rc>, source_indices: Rc>>, ) -> Option> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -92,7 +97,9 @@ pub fn lookup_field_type_node( if is_optional { { let inner = with_required_cardinality(n.clone()); - if (field_name.clone().as_str() == "value".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("value".to_string())) + { Some(inner) } else { match lookup_field_type_node(inner, field_name.clone(), source_indices.clone()) @@ -116,8 +123,11 @@ pub fn lookup_field_type_node( ) { Some(field_child) => { if (node_is_keyed_collection(n.clone(), source_indices.clone()) - && (field_name.clone().as_str() - == "lookup".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host( + field_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "lookup".to_string(), + ))) { { let value_child = @@ -167,7 +177,7 @@ pub fn lookup_field_type_node( pub fn lookup_coproduct_common_field_node( variants: Rc>>, - field_name: String, + field_name: Rc>, source_indices: Rc>>, ) -> Option> { { @@ -201,7 +211,7 @@ pub fn lookup_coproduct_common_field_node( } pub fn resolve_scrutinee_type_node(env: Rc, n: Rc) -> Rc { - resolve_scrutinee_type_node_seen(env, n, v1_rt::rc_empty_map::()) + resolve_scrutinee_type_node_seen(env, n, v1_rt::rc_empty_map::>, bool>()) } pub fn resolve_scrutinee_type_node_seen( @@ -237,16 +247,24 @@ pub fn resolve_scrutinee_type_node_seen( let canonical = authored_name(env.clone(), normed.clone()); if (normed.inferred.clone() != None) { { - let next_seen = - if (canonical.clone().as_str() == "".to_string().as_str()) { - seen.clone() - } else { - v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) - }; + let next_seen = if (crate::v2_std_text::host_string_text_to_rust_host( + canonical.clone(), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { + seen.clone() + } else { + v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) + }; match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - if ((((authored_name(env.clone(), target.clone()).as_str() - == canonical.clone().as_str()) + if ((((crate::v2_std_text::host_string_text_to_rust_host( + authored_name(env.clone(), target.clone()), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + canonical.clone(), + )) && (target.inferred.clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) @@ -264,23 +282,31 @@ pub fn resolve_scrutinee_type_node_seen( } } } else { - if ((canonical.clone().as_str() != "".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(canonical.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) && emit_map_has(seen.clone(), canonical.clone())) { nominal_type_ref(canonical.clone()) } else { { let next_seen = - if (canonical.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + canonical.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "".to_string(), + )) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; match lookup_type_for(env.clone(), normed.clone()) { Some(resolved) => { - if ((((authored_name(env.clone(), resolved.clone()) - .as_str() - == canonical.clone().as_str()) + if ((((crate::v2_std_text::host_string_text_to_rust_host( + authored_name(env.clone(), resolved.clone()), + ) + == crate::v2_std_text::host_string_text_to_rust_host( + canonical.clone(), + )) && (resolved.inferred.clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) @@ -375,13 +401,16 @@ pub fn set_element_type_in_env(type_node: Rc, env: Rc) -> Option< pub fn field_summary_for_type( base_type: Rc, env: Rc, - field: String, + field: Rc>, ) -> Option> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let resolved = resolve_scrutinee_type_node(env.clone(), base_type); let normed = normalize_access_type_node(resolved.clone()); let normed_opt = (normed.return_cardinality.clone() == Cardinality::CardOptional); - if ((field.clone().as_str() == "value".to_string().as_str()) && normed_opt.clone()) { + if ((crate::v2_std_text::host_string_text_to_rust_host(field.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("value".to_string())) + && normed_opt.clone()) + { Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::OptionalUnwrap, value_shape: FieldValueShape::PlainValue, @@ -469,7 +498,11 @@ pub fn map_lookup_result_type( field: Rc, source_indices: Rc>>, ) -> Option> { - if (authored_name_at(source_indices.clone(), product).as_str() == "Map".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + product, + )) == crate::v2_std_text::host_string_text_to_rust_host("Map".to_string())) + { match product_field_result_type(field) { Some(raw) => { if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { @@ -491,15 +524,17 @@ pub fn map_lookup_result_type( pub fn lookup_field_in_product( product: Rc, - method_name: String, + method_name: Rc>, source_indices: Rc>>, ) -> Option> { { let matching = Rc::new({ let mut __result = Vec::new(); for c in product.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()).as_str() - == method_name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + c.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(method_name.clone())) { __result.push(c); } @@ -507,30 +542,33 @@ pub fn lookup_field_in_product( __result }); match matching.first().cloned() { - Some(field) => match if (method_name.clone().as_str() == "lookup".to_string().as_str()) - { - map_lookup_result_type(product.clone(), field.clone(), source_indices.clone()) - } else { - None - } { - Some(lookup_rt) => Some(Rc::new(MethodFieldResult { - field_node: field.clone(), - result_type: lookup_rt.clone(), - size_effect: None, - cost_shape: None, - algebra_template: None, - })), - None => match product_field_result_type(field.clone()) { - Some(rt) => Some(Rc::new(MethodFieldResult { + Some(field) => { + match if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("lookup".to_string())) + { + map_lookup_result_type(product.clone(), field.clone(), source_indices.clone()) + } else { + None + } { + Some(lookup_rt) => Some(Rc::new(MethodFieldResult { field_node: field.clone(), - result_type: rt.clone(), + result_type: lookup_rt.clone(), size_effect: None, cost_shape: None, algebra_template: None, })), - None => None, - }, - }, + None => match product_field_result_type(field.clone()) { + Some(rt) => Some(Rc::new(MethodFieldResult { + field_node: field.clone(), + result_type: rt.clone(), + size_effect: None, + cost_shape: None, + algebra_template: None, + })), + None => None, + }, + } + } None => None, } } @@ -538,7 +576,7 @@ pub fn lookup_field_in_product( pub fn lookup_structural_method( receiver_type: Rc, - method_name: String, + method_name: Rc>, source_indices: Rc>>, ) -> Rc { { @@ -580,19 +618,7 @@ pub fn lookup_structural_method( let template_match = match profile { Some(p) => { let templates = algebra_templates_for_profile(p.clone()); - Rc::new({ - let mut __result = Vec::new(); - for t in templates.iter().cloned() { - if (t.name.clone().as_str() - == method_name.clone().as_str()) - { - __result.push(t); - } - } - __result - }) - .first() - .cloned() + Rc::new({ let mut __result = Vec::new(); for t in templates.iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(t.name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(method_name.clone())) { __result.push(t); } } __result }).first().cloned() } None => None, }; @@ -631,7 +657,7 @@ pub fn lookup_structural_method( pub fn resolve_known_method_node( receiver: Rc, receiver_type: Rc, - method_name: String, + method_name: Rc>, fold_accumulator_type: Option>, service_registry: Rc>>>>, source_indices: Rc>>, diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 2cbb1838368..792287f3ecd 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -20,7 +20,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn type_variable_node(id: String) -> Rc { +pub fn type_variable_node(id: Rc>) -> Rc { Rc::new(Node { name: "".to_string(), span: make_span(0, 0), @@ -52,7 +52,7 @@ pub fn map_of_type_variables() -> Rc { .clone() } -pub fn list_of_type_variable(id: String) -> Rc { +pub fn list_of_type_variable(id: Rc>) -> Rc { make_container_type("List".to_string(), type_variable_node(id)) .ty .clone() @@ -68,8 +68,12 @@ pub fn witness_of_element(element: Rc) -> Rc { .clone() } -pub fn seed_node_map(key: String, value: Rc) -> Rc>> { - v1_rt::rc_map_insert(v1_rt::rc_empty_map::>(), key, value) +pub fn seed_node_map(key: Rc>, value: Rc) -> Rc>> { + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, Rc>(), + key, + value, + ) } pub fn builtin_kernel_seed_diagnostics() -> Rc>> { @@ -192,11 +196,6 @@ pub fn builtin_function_registry() -> Rc>> { "extdeps_dead_param_count_for_operation".to_string(), int_type(), ); - let m = v1_rt::rc_map_insert( - m.clone(), - "shell_materialize_argv_for_operation".to_string(), - list_of_element(string_type()), - ); let m = v1_rt::rc_map_insert( m.clone(), "extdeps_dead_param_count_for_path".to_string(), @@ -252,36 +251,6 @@ pub fn builtin_function_registry() -> Rc>> { "transport_script_literal_violation_count_for_path".to_string(), int_type(), ); - let m = v1_rt::rc_map_insert( - m.clone(), - "layer_import_facts".to_string(), - list_of_type_variable("layer_import_fact_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "import_resolution_facts".to_string(), - list_of_type_variable("import_resolution_fact_elem".to_string()), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_coexistence_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_diverged_fork_count".to_string(), - int_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_is_coexistence".to_string(), - bool_type(), - ); - let m = v1_rt::rc_map_insert( - m.clone(), - "fact_cardinality_cross_tree_is_diverged_fork".to_string(), - bool_type(), - ); let m = v1_rt::rc_map_insert( m.clone(), "languages_consumer_census_data_decl_count".to_string(), @@ -316,11 +285,11 @@ pub fn builtin_function_registry() -> Rc>> { } } -pub fn infer_builtin_call_type(name: String) -> Option> { +pub fn infer_builtin_call_type(name: Rc>) -> Option> { v1_rt::map_get(&builtin_function_registry(), name) } -pub fn resolve_builtin_call_type(name: String) -> Rc { +pub fn resolve_builtin_call_type(name: Rc>) -> Rc { match infer_builtin_call_type(name) { Some(v) => v.clone(), None => unit_type(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 84910fc453a..91d060a8b25 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -34,9 +34,11 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn is_witness_type_name(name: String) -> bool { - ((name.clone().as_str() == "Witness".to_string().as_str()) - || (name.clone().as_str() == "witness".to_string().as_str())) +pub fn is_witness_type_name(name: Rc>) -> bool { + ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("witness".to_string()))) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -311,8 +313,8 @@ pub fn pattern_binding_type(subject: Rc) -> Rc { pub fn variant_not_found_result( scrut: Rc, - variant_name: String, - module_name: String, + variant_name: Rc>, + module_name: Rc>, source_indices: Rc>>, ) -> Rc { node_lookup_failed(Rc::new(vec![make_error_node( @@ -327,8 +329,8 @@ pub fn variant_not_found_result( pub fn lookup_variant_in_type( scrut: Rc, - variant_name: String, - module_name: String, + variant_name: Rc>, + module_name: Rc>, source_indices: Rc>>, field_binding_count: i64, ) -> Rc { @@ -356,34 +358,53 @@ pub fn lookup_variant_in_type( } else { { let optional_cardinality_subject = (scrut_opt.clone() - && (authored_name_at(source_indices.clone(), scrut_node.clone()).as_str() - != "Optional".to_string().as_str())); + && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + scrut_node.clone(), + )) != crate::v2_std_text::host_string_text_to_rust_host( + "Optional".to_string(), + ))); let witness_subject = (is_witness_type_name(authored_name_at( source_indices.clone(), scrut_node.clone(), )) && ((scrut_node.children.clone().len() as i64) == 1)); if (optional_cardinality_subject.clone() - && (variant_name.clone().as_str() == "Present".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Present".to_string(), + ))) { node_lookup_resolved(synthesize_optional_present_variant( scrut_node.clone(), )) } else { if (optional_cardinality_subject.clone() - && (variant_name.clone().as_str() == "Absent".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Absent".to_string(), + ))) { node_lookup_resolved(none_type()) } else { if (witness_subject.clone() - && (variant_name.clone().as_str() == "Holds".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Holds".to_string(), + ))) { node_lookup_resolved(synthesize_witness_holds_variant( scrut_node.clone(), )) } else { if (witness_subject.clone() - && (variant_name.clone().as_str() - == "Violates".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "Violates".to_string(), + ))) { node_lookup_resolved(synthesize_witness_violates_variant( scrut_node.clone(), @@ -394,50 +415,25 @@ pub fn lookup_variant_in_type( source_indices.clone(), scrut_node.clone(), ); - let optional_coproduct_subject = - ((scrut_name.clone().as_str() - == "Optional".to_string().as_str()) - && ((variant_name.clone().as_str() - == "Present".to_string().as_str()) - || (variant_name.clone().as_str() - == "Absent".to_string().as_str()))); + let optional_coproduct_subject = ((crate::v2_std_text::host_string_text_to_rust_host(scrut_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Optional".to_string())) && ((crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) || (crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Absent".to_string())))); let direct_match = find_child_named( scrut_node.clone(), variant_name.clone(), source_indices.clone(), ); - let record_destructure = (((field_binding_count > 0) - && (scrut_node.connective.clone() - == Connective::Conj)) - && (scrut_name.clone().as_str() - == variant_name.clone().as_str())); + let record_destructure = (((field_binding_count > 0) && (scrut_node.connective.clone() == Connective::Conj)) && (crate::v2_std_text::host_string_text_to_rust_host(scrut_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()))); let fallback = if record_destructure { node_lookup_resolved(scrut_node.clone()) } else { - if (optional_coproduct_subject.clone() - && (variant_name.clone().as_str() - == "Present".to_string().as_str())) - { - node_lookup_resolved( - synthesize_optional_present_variant( - scrut_node.clone(), - ), - ) + if (optional_coproduct_subject.clone() && (crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string()))) { + node_lookup_resolved(synthesize_optional_present_variant(scrut_node.clone())) + } else { + if (optional_coproduct_subject.clone() && (crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Absent".to_string()))) { + node_lookup_resolved(none_type()) } else { - if (optional_coproduct_subject.clone() - && (variant_name.clone().as_str() - == "Absent".to_string().as_str())) - { - node_lookup_resolved(none_type()) - } else { - variant_not_found_result( - scrut_node.clone(), - variant_name.clone(), - module_name, - source_indices.clone(), - ) - } + variant_not_found_result(scrut_node.clone(), variant_name.clone(), module_name, source_indices.clone()) } + } }; match direct_match { Some(v) => node_lookup_resolved(v.clone()), @@ -456,8 +452,8 @@ pub fn lookup_variant_in_type( pub fn lookup_field_in_variant( variant: Rc, - field_name: String, - module_name: String, + field_name: Rc>, + module_name: Rc>, source_indices: Rc>>, ) -> Rc { match (*variant).clone() { @@ -500,7 +496,7 @@ pub fn check_match_exhaustiveness( arms: Rc>>, env: Rc, span: Rc, - module_name: String, + module_name: Rc>, ) -> Rc>> { { let scrut_is_optional = @@ -566,7 +562,7 @@ pub fn check_match_exhaustiveness( } else { { let covered_set = arms.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, arm: Rc| match (*arm_pattern( arm.clone(), )) diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 7cd8064ee66..a7aaeba8f74 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -62,7 +62,7 @@ pub fn is_unit_variant_node(variant: Rc) -> bool { pub fn unit_variant_in_coproduct( env: Rc, ty: Rc, - variant_name: String, + variant_name: Rc>, ) -> Option> { match ty.connective.clone() { Connective::Disj => { @@ -74,9 +74,12 @@ pub fn unit_variant_in_coproduct( if (acc.clone() != None) { acc.clone() } else { - if ((authored_name_at(env.source_indices.clone(), v.clone()).as_str() - == variant_name.clone().as_str()) - && is_unit_variant_node(v.clone())) + if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + env.source_indices.clone(), + v.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + variant_name.clone(), + )) && is_unit_variant_node(v.clone())) { Some(v.clone()) } else { @@ -102,7 +105,7 @@ pub fn structural_type_for_variant_lookup(env: Rc, ty: Rc) -> Rc< pub fn lookup_unit_variant_phantom_type( env: Rc, - variant_name: String, + variant_name: Rc>, ) -> Option> { { let matches = collect_unit_variant_phantom_matches(env, variant_name); @@ -119,7 +122,7 @@ pub fn lookup_unit_variant_phantom_type( pub fn collect_unit_variant_phantom_matches( env: Rc, - variant_name: String, + variant_name: Rc>, ) -> Rc>> { Rc::new(v1_rt::map_keys(&env.bindings.clone())) .iter() @@ -185,12 +188,16 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc, structural: Rc, - brand_name: String, + brand_name: Rc>, source_indices: Rc>>, ) -> Rc { - if (((brand_name.clone().as_str() != "".to_string().as_str()) - && (brand_name.clone().as_str() - != authored_name_at(source_indices, structural.clone()).as_str())) + if (((crate::v2_std_text::host_string_text_to_rust_host(brand_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(brand_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices, + structural.clone(), + )))) && !is_declared_container_alias_spelling(brand_name.clone())) { with_authored_identity(identity, structural.clone()) @@ -199,7 +206,11 @@ pub fn preserve_nominal_brand_on_resolve( } } -pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: String) -> Rc { +pub fn peel_nominal_alias_identity( + n: Rc, + env: Rc, + module_name: Rc>, +) -> Rc { { let source_indices = env.source_indices.clone(); let brand = authored_name_at(source_indices.clone(), n.clone()); @@ -232,9 +243,13 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S .resolved .clone() }; - if (((brand.clone().as_str() != "".to_string().as_str()) - && (brand.clone().as_str() - != authored_name_at(source_indices.clone(), structural.clone()).as_str())) + if (((crate::v2_std_text::host_string_text_to_rust_host(brand.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + && (crate::v2_std_text::host_string_text_to_rust_host(brand.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + structural.clone(), + )))) && !is_declared_container_alias_spelling(brand.clone())) { with_authored_identity(n.clone(), structural.clone()) @@ -333,7 +348,11 @@ pub struct ResourceUseResult { pub diagnostics: Rc>>, } -pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc { +pub fn resolve_node( + n: Rc, + env: Rc, + module_name: Rc>, +) -> Rc { resolve_node_bounded(n, env, module_name, 0) } @@ -346,8 +365,10 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { decl.clone() } else { if ((((n.children.clone().len() as i64) > 0) - && (n.name.clone().as_str() != "".to_string().as_str())) - && (n.name.clone().as_str() != brand.as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + && (crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host(brand))) { match lookup_type_by_name(env.clone(), n.name.clone()) { Some(structural) => structural.clone(), @@ -395,7 +416,7 @@ pub fn is_user_generic_use_site(n: Rc, env: Rc) -> bool { pub fn substitute_type_slots( n: Rc, slot_bindings: Rc>>, - decl_name: String, + decl_name: Rc>, source_indices: Rc>>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -417,9 +438,11 @@ pub fn substitute_type_slots( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.push( - if (authored_name_at(source_indices.clone(), child.clone()).as_str() - == decl_name.clone().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), child.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + decl_name.clone(), + )) { { let substituted_args = Rc::new({ let mut __result = Vec::new(); @@ -536,7 +559,7 @@ pub fn classify_alias(target: Rc) -> AliasKind { pub fn resolve_alias_target( target: Rc, env: Rc, - module_name: String, + module_name: Rc>, depth: i64, ) -> Rc { match classify_alias(target.clone()) { @@ -567,7 +590,7 @@ pub fn is_parametric_type_alias_decl(item: Rc) -> bool { pub fn resolve_nominal_alias_rhs( n: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if ((n.connective.clone() == Connective::NoConnective) @@ -633,7 +656,7 @@ pub fn resolve_nominal_alias_rhs( pub fn resolve_node_bounded( n: Rc, env: Rc, - module_name: String, + module_name: Rc>, depth: i64, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -823,60 +846,26 @@ pub fn resolve_node_bounded( let mut __result = Vec::new(); for variant_child in n.children.clone().iter().cloned() { __result.push({ - let field_results = Rc::new({ - let mut __result = Vec::new(); - for field_child in - variant_child.children.clone().iter().cloned() - { - __result.push( - if (field_child.inferred.clone() == None) { - Rc::new(NodeResolveResult { - resolved: field_child.clone(), - diagnostics: Rc::new(vec![]), - }) - } else { - { - let field_rt = resolved_type( - field_child.clone(), - ); - let is_self_ref = ((authored_name( - env.clone(), - field_rt.clone(), - ) - .as_str() - == authored_name( - env.clone(), - n.clone(), - ) - .as_str()) - && ((field_rt - .children - .clone() - .len() - as i64) - > 0)); - let rt_result = if is_self_ref - .clone() - { - Rc::new(NodeResolveResult { - resolved: field_rt.clone(), - diagnostics: Rc::new( - vec![], - ), - }) - } else { - resolve_node_bounded( - field_rt.clone(), - env.clone(), - module_name.clone(), - (depth.clone() + 1), - ) - }; - let rt_resolved = - rt_result.resolved.clone(); - let rt_diags = - rt_result.diagnostics.clone(); - Rc::new(NodeResolveResult { + let field_results = Rc::new({ let mut __result = Vec::new(); for field_child in variant_child.children.clone().iter().cloned() { __result.push(if (field_child.inferred.clone() == None) { + Rc::new(NodeResolveResult { + resolved: field_child.clone(), + diagnostics: Rc::new(vec![]), +}) + } else { + { + let field_rt = resolved_type(field_child.clone()); +let is_self_ref = ((crate::v2_std_text::host_string_text_to_rust_host(authored_name(env.clone(), field_rt.clone())) == crate::v2_std_text::host_string_text_to_rust_host(authored_name(env.clone(), n.clone()))) && ((field_rt.children.clone().len() as i64) > 0)); +let rt_result = if is_self_ref.clone() { + Rc::new(NodeResolveResult { + resolved: field_rt.clone(), + diagnostics: Rc::new(vec![]), +}) + } else { + resolve_node_bounded(field_rt.clone(), env.clone(), module_name.clone(), (depth.clone() + 1)) + }; +let rt_resolved = rt_result.resolved.clone(); +let rt_diags = rt_result.diagnostics.clone(); +Rc::new(NodeResolveResult { resolved: Rc::new(Node { name: field_child.name.clone(), span: field_child.span.clone(), @@ -901,56 +890,34 @@ pub fn resolve_node_bounded( }), diagnostics: rt_diags.clone(), }) - } - }, - ); - } - __result - }); - let resolved_fields = Rc::new({ - let mut __result = Vec::new(); - for fr in field_results.clone().iter().cloned() { - __result.push(fr.resolved.clone()); - } - __result - }); - let field_diags = Rc::new({ - let mut __result = Vec::new(); - for fr in field_results.clone().iter().cloned() { - __result.extend( - (*fr.diagnostics.clone()).iter().cloned(), - ); - } - __result - }); - Rc::new(NodeResolveResult { - resolved: Rc::new(Node { - name: variant_child.name.clone(), - span: variant_child.span.clone(), - ident_span: variant_child.ident_span.clone(), - children: resolved_fields.clone(), - connective: variant_child.connective.clone(), - params: variant_child.params.clone(), - inferred: variant_child.inferred.clone(), - return_cardinality: variant_child - .return_cardinality - .clone(), - uses: variant_child.uses.clone(), - body: variant_child.body.clone(), - transport: variant_child.transport.clone(), - properties: variant_child.properties.clone(), - type_annotation: variant_child - .type_annotation - .clone(), - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - diagnostics: field_diags.clone(), - }) - }); +} + }); } __result }); +let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { __result.push(fr.resolved.clone()); } __result }); +let field_diags = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { __result.extend((*fr.diagnostics.clone()).iter().cloned()); } __result }); +Rc::new(NodeResolveResult { + resolved: Rc::new(Node { + name: variant_child.name.clone(), + span: variant_child.span.clone(), + ident_span: variant_child.ident_span.clone(), + children: resolved_fields.clone(), + connective: variant_child.connective.clone(), + params: variant_child.params.clone(), + inferred: variant_child.inferred.clone(), + return_cardinality: variant_child.return_cardinality.clone(), + uses: variant_child.uses.clone(), + body: variant_child.body.clone(), + transport: variant_child.transport.clone(), + properties: variant_child.properties.clone(), + type_annotation: variant_child.type_annotation.clone(), + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, +}), + diagnostics: field_diags.clone(), +}) +}); } __result }); @@ -1056,7 +1023,7 @@ pub fn resolve_node_bounded( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let slot_name = @@ -1540,7 +1507,7 @@ pub fn resolve_node_bounded( pub fn missing_generic_args_diagnostics( n: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc>> { if ((((n.children.clone().len() as i64) == 0) && ((n.params.clone().len() as i64) == 0)) && is_user_generic_use_site(n.clone(), env.clone())) @@ -1569,7 +1536,7 @@ pub fn missing_generic_args_diagnostics( pub fn resolve_optional_node( n: Option>, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { if (n.clone() == None) { Rc::new(NodeResolveResult { @@ -1626,7 +1593,11 @@ pub fn resolve_optional_node( } } -pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> Rc { +pub fn resolve_field( + field: Rc, + env: Rc, + module_name: Rc>, +) -> Rc { { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); @@ -1669,7 +1640,11 @@ pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> } } -pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> Rc { +pub fn resolve_param( + param: Rc, + env: Rc, + module_name: Rc>, +) -> Rc { { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); @@ -1741,7 +1716,7 @@ pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> pub fn resolve_resource_use( ru: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); @@ -1762,7 +1737,7 @@ pub fn resolve_resource_use( pub fn resolve_named_arg( arg: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); @@ -1783,7 +1758,7 @@ pub fn resolve_named_arg( pub fn resolve_field_init( field_init: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { { let value_result = resolve_expr_types( @@ -1808,7 +1783,7 @@ pub fn resolve_field_init( pub fn resolve_match_arm( arm: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { { let arm_g = arm_guard(arm.clone()); @@ -1846,7 +1821,7 @@ pub fn resolve_match_arm( pub fn resolve_string_part( part: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { match (*part).clone() { StringPart::Text { value: value, .. } => Rc::new(StringPartResolveResult { @@ -1872,7 +1847,7 @@ pub fn resolve_string_part( pub fn resolve_transport_binding( transport: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { if is_local_transport(transport.clone(), env.source_indices.clone()) { Rc::new(TransportResolveResult { @@ -1971,7 +1946,7 @@ pub fn resolve_transport_binding( pub fn resolve_expr_types( texpr: Rc, env: Rc, - module_name: String, + module_name: Rc>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { @@ -2808,10 +2783,13 @@ pub fn fn_type_param_names( for p in Rc::new({ let mut __result = Vec::new(); for p in item.params.clone().iter().cloned() { - if (param_node_name_at(p.clone(), source_indices.clone()).as_str() - == authored_name_at(source_indices.clone(), param_node_type_expr(p.clone())) - .as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host(param_node_name_at( + p.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + param_node_type_expr(p.clone()), + ))) { __result.push(p); } } @@ -2857,7 +2835,9 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { .iter() .cloned() { - if (other.clone().as_str() == s.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(other.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(s.clone())) + { __found = true; break; } @@ -2873,7 +2853,11 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { } } -pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) -> Rc { +pub fn resolve_item_types( + item: Rc, + env: Rc, + module_name: Rc>, +) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tp_names = if ((item.connective.clone() != Connective::NoConnective) && (item.transport.clone() == None)) @@ -2898,7 +2882,7 @@ pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) }; let env = tp_names.clone().iter().cloned().fold( env.clone(), - |e: Rc, tp_name: String| { + |e: Rc, tp_name: Rc>| { Rc::new(TypeEnv { bindings: v1_rt::rc_map_insert( e.bindings.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index f4617b9f287..afe715f1d41 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -34,7 +34,7 @@ pub struct UniqueAccum { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OpEntry { - pub name: String, + pub name: Rc>, pub outputs: Rc>>, pub params: Rc>>, } @@ -73,7 +73,7 @@ pub fn is_typed_service_call_receiver( pub fn extract_typed_service_name( receiver: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { match (*receiver.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: _, .. } => { let f = field_access_field_at(receiver.clone(), source_indices.clone()); @@ -100,7 +100,7 @@ pub fn collect_typed_service_calls( let result = collect_typed_service_calls_into( texpr, Rc::new(UniqueAccum { - seen: v1_rt::rc_empty_map::(), + seen: v1_rt::rc_empty_map::>, bool>(), result: Rc::new(vec![]), }), source_indices, @@ -196,7 +196,7 @@ pub fn collect_called_func_names( let result = collect_called_func_names_into( texpr, Rc::new(UniqueAccum { - seen: v1_rt::rc_empty_map::(), + seen: v1_rt::rc_empty_map::>, bool>(), result: Rc::new(vec![]), }), source_indices, @@ -223,7 +223,7 @@ let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.c Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), }).iter().cloned()); } __result }); -let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: String| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (s.clone().as_str() == svc.clone().as_str()) { __found = true; break; } } __found } { +let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: Rc>| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(s.clone()) == crate::v2_std_text::host_string_text_to_rust_host(svc.clone())) { __found = true; break; } } __found } { svc_list.clone() } else { v1_rt::rc_list_push(svc_list.clone(), svc.clone()) @@ -289,7 +289,7 @@ pub fn expand_transitive_services( pub fn check_service_field_access_node( base_type: Rc, - field: String, + field: Rc>, service_registry: Rc>>>>, source_indices: Rc>>, ) -> Option> { @@ -316,7 +316,7 @@ pub fn check_service_field_access_node( pub fn check_service_method_call_node( receiver_type: Rc, - method: String, + method: Rc>, service_registry: Rc>>>>, source_indices: Rc>>, ) -> Option> { @@ -331,7 +331,9 @@ pub fn check_service_method_call_node( let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.clone().iter().cloned() { - if (op.name.clone().as_str() == method.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(op.name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(method.clone())) + { __result.push(op); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index eb42df493d0..9d990427a25 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -21,7 +21,7 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ResolvedFuncSig { - pub name: String, + pub name: Rc>, pub params: Rc>>, pub inferred: Rc, pub is_async: bool, @@ -49,8 +49,8 @@ pub struct SigsAccum { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CallEdge { - pub caller: String, - pub callee: String, + pub caller: Rc>, + pub callee: Rc>, } pub fn collect_func_call_edges( @@ -81,7 +81,7 @@ pub fn collect_func_call_edges( } pub fn collect_calls_in_expr( - caller: String, + caller: Rc>, texpr: Rc, local_func_set: Rc>, source_indices: Rc>>, @@ -123,8 +123,8 @@ pub fn collect_calls_in_expr( } pub fn func_reaches_self( - root: String, - current: String, + root: Rc>, + current: Rc>, call_edges: Rc>>, visited: Rc>, ) -> bool { @@ -139,7 +139,11 @@ pub fn func_reaches_self( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (e.caller.clone().as_str() == current.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(e.caller.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + current.clone(), + )) + { __result.push(e); } } @@ -155,7 +159,9 @@ pub fn func_reaches_self( { let mut __found = false; for c in callees.iter().cloned() { - if if (c.clone().as_str() == root.clone().as_str()) { + if if (crate::v2_std_text::host_string_text_to_rust_host(c.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(root.clone())) + { true } else { func_reaches_self( @@ -178,8 +184,8 @@ pub fn func_reaches_self( pub fn build_name_set(names: Rc>) -> Rc> { names.iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ) @@ -193,7 +199,7 @@ pub fn collect_parent_resolved_sigs( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, dsig: Rc| { if emit_map_has(local_func_set.clone(), dsig.name.clone()) { acc.clone() @@ -252,7 +258,7 @@ pub fn topo_resolve_loop( mut declared_sigs: Rc>>, mut call_edges: Rc>>, mut local_func_set: Rc>, - mut module_name: String, + mut module_name: Rc>, mut diagnostics: Rc>>, mut fuel: i64, ) -> Rc { @@ -296,7 +302,11 @@ pub fn topo_resolve_loop( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (e.caller.clone().as_str() == fn_name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + e.caller.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + fn_name.clone(), + )) { __result.push(e); } } @@ -341,7 +351,7 @@ pub fn topo_resolve_loop( signatures: resolved.clone(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, fn_name: String| match v1_rt::map_get( + |acc: Rc, fn_name: Rc>| match v1_rt::map_get( &declared_sigs, fn_name.clone(), ) { @@ -409,7 +419,7 @@ pub fn topo_resolve_loop( signatures: resolved.clone(), diagnostics: diagnostics.clone(), }), - |acc: Rc, fn_name: String| match v1_rt::map_get( + |acc: Rc, fn_name: Rc>| match v1_rt::map_get( &declared_sigs, fn_name.clone(), ) { @@ -444,8 +454,8 @@ pub fn topo_resolve_loop( }, ); let ready_set = ready.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, fn_name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, fn_name: Rc>| { v1_rt::rc_map_insert(acc, fn_name.clone(), true) }, ); @@ -475,7 +485,7 @@ pub fn topo_resolve_loop( pub fn resolve_func_sigs( declared_sigs: Rc>>, items: Rc>>, - module_name: String, + module_name: Rc>, source_indices: Rc>>, ) -> Rc { { diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index 8f708772956..e297a53f711 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -59,7 +59,7 @@ pub fn is_type_variable(inferred: Rc) -> bool { } } -pub fn type_variable_node(id: String) -> Rc { +pub fn type_variable_node(id: Rc>) -> Rc { Rc::new(Node { name: "".to_string(), span: make_span(0, 0), @@ -132,14 +132,16 @@ pub fn node_is_set_collection( source_indices: Rc>>, ) -> bool { (node_is_element_collection(n.clone(), source_indices.clone()) - && (authored_name_at(source_indices.clone(), n.clone()).as_str() - == "Set".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + n.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("Set".to_string()))) } pub fn canonical_template_name( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { { let nm = authored_name_at(source_indices, n); match container_template_algebra(nm.clone()) { @@ -149,7 +151,7 @@ pub fn canonical_template_name( } } -pub fn is_declared_container_alias_spelling(name: String) -> bool { +pub fn is_declared_container_alias_spelling(name: Rc>) -> bool { match container_template_algebra(name) { Some(_) => true, None => false, @@ -159,8 +161,10 @@ pub fn is_declared_container_alias_spelling(name: String) -> bool { pub fn structural_carrier_template_name( n: Rc, source_indices: Rc>>, -) -> String { - if (n.name.clone().as_str() != "".to_string().as_str()) { +) -> Rc> { + if (crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { canonical_template_name( Rc::new(Node { name: n.name.clone(), @@ -368,7 +372,7 @@ pub fn bare_set_node() -> Option> { } } -pub fn kernel_container_profile_miss_diagnostic(kind_name: String) -> Rc { +pub fn kernel_container_profile_miss_diagnostic(kind_name: Rc>) -> Rc { { let msg = v1_rt::concat("missing kernel container profile: ".to_string(), kind_name); make_error_node( @@ -381,7 +385,7 @@ pub fn kernel_container_profile_miss_diagnostic(kind_name: String) -> Rc Rc { +pub fn missing_kernel_container_profile_type(kind_name: Rc>) -> Rc { { let msg = v1_rt::concat("missing kernel container profile: ".to_string(), kind_name); Rc::new(Node { @@ -419,7 +423,10 @@ pub struct KernelTypeBuild { pub diagnostics: Rc>>, } -pub fn make_container_type(kind_name: String, element: Rc) -> Rc { +pub fn make_container_type( + kind_name: Rc>, + element: Rc, +) -> Rc { match container_param_name(kind_name.clone(), 0) { Some(param_name) => Rc::new(KernelTypeBuild { ty: Rc::new(Node { @@ -642,7 +649,7 @@ pub fn make_tuple_type(first: Rc, second: Rc) -> Rc { }) } -pub fn algebra_value_field(name: String, type_node: Rc) -> Rc { +pub fn algebra_value_field(name: Rc>, type_node: Rc) -> Rc { Rc::new(Node { name: name.clone(), span: kernel_span(name.clone()), @@ -666,7 +673,7 @@ pub fn algebra_value_field(name: String, type_node: Rc) -> Rc { } pub fn algebra_method_field( - name: String, + name: Rc>, param_types: Rc>>, return_type: Rc, ) -> Rc { @@ -709,7 +716,7 @@ pub fn algebra_method_field( } pub fn enrich_base_with_fields( - name: String, + name: Rc>, base: Rc, fields: Rc>>, ) -> Rc { @@ -735,18 +742,18 @@ pub fn enrich_base_with_fields( }) } -pub fn placeholder_type_node(name: String) -> Rc { +pub fn placeholder_type_node(name: Rc>) -> Rc { nominal_type_ref(name) } -pub fn nominal_type_ref(name: String) -> Rc { +pub fn nominal_type_ref(name: Rc>) -> Rc { leaf_node_with_span(name.clone(), kernel_span(name.clone())) } pub fn algebra_child_or_placeholder( base: Rc, child_index: i64, - placeholder: String, + placeholder: Rc>, ) -> Rc { match Rc::new({ let mut __result = Vec::new(); @@ -963,7 +970,7 @@ pub fn instantiate_algebra_field( } pub fn enrich_kernel_type( - name: String, + name: Rc>, base: Rc, source_indices: Rc>>, ) -> Rc { @@ -1096,8 +1103,10 @@ pub fn unify_template( } ContainerSource::Named { name: n, .. } => n.clone(), }; - if (authored_name_at(source_indices.clone(), concrete.clone()).as_str() - != expected_name.as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + concrete.clone(), + )) != crate::v2_std_text::host_string_text_to_rust_host(expected_name)) { subst.clone() } else { @@ -1648,7 +1657,7 @@ pub fn normalize_access_type_node(mut n: Rc) -> Rc { pub fn node_type_shape( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let __is_leaf = (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -1661,8 +1670,11 @@ pub fn node_type_shape( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (authored_name_at(source_indices.clone(), rt.clone()).as_str() - != "None".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), rt.clone()), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "None".to_string(), + ))) && (is_kernel_type(authored_name_at( source_indices.clone(), rt.clone(), @@ -1808,11 +1820,11 @@ pub fn node_type_compatible( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { - if (canonical_template_name(left.clone(), source_indices.clone()) - .as_str() - != canonical_template_name(right.clone(), source_indices.clone()) - .as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + canonical_template_name(left.clone(), source_indices.clone()), + ) != crate::v2_std_text::host_string_text_to_rust_host( + canonical_template_name(right.clone(), source_indices.clone()), + )) { break false; } else { match left.children.clone().first().cloned() { @@ -1847,20 +1859,16 @@ pub fn node_type_compatible( } } } else { - if (((((canonical_template_name( - left.clone(), - source_indices.clone(), + if (((((crate::v2_std_text::host_string_text_to_rust_host( + canonical_template_name(left.clone(), source_indices.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + canonical_template_name(right.clone(), source_indices.clone()), + )) && (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), left.clone()), ) - .as_str() - == canonical_template_name( - right.clone(), - source_indices.clone(), - ) - .as_str()) - && (authored_name_at(source_indices.clone(), left.clone()) - .as_str() - != authored_name_at(source_indices.clone(), right.clone()) - .as_str())) + != crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), right.clone()), + ))) && ((left.children.clone().len() as i64) == 1)) && ((right.children.clone().len() as i64) == 1)) && (is_declared_container_alias_spelling(authored_name_at( @@ -1921,16 +1929,15 @@ pub fn node_type_compatible( if (left_opt.clone() || right_opt.clone()) { break false; } else { - break (authored_name_at( - source_indices.clone(), - left.clone(), + break (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), left.clone()), ) - .as_str() - == authored_name_at( - source_indices.clone(), - right.clone(), - ) - .as_str()); + == crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at( + source_indices.clone(), + right.clone(), + ), + )); } } } @@ -1974,8 +1981,11 @@ pub fn prefer_specific_type( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); let right_is_optional = (right.return_cardinality.clone() == Cardinality::CardOptional); let same_kind = if (left_is_container.clone() && right_is_container) { - (left_norm_name.as_str() - == authored_name_at(source_indices.clone(), right.clone()).as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(left_norm_name) + == crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + right.clone(), + ))) } else { if (left_is_optional.clone() && right_is_optional) { true @@ -2076,10 +2086,13 @@ pub fn node_type_equals_core( let left_name = authored_name_at(source_indices.clone(), left.clone()); let right_name = authored_name_at(source_indices.clone(), right.clone()); if (left_leaf.clone() && right_leaf.clone()) { - (left_name.as_str() == right_name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(left_name) + == crate::v2_std_text::host_string_text_to_rust_host(right_name)) } else { if (left_struct.clone() && right_struct.clone()) { - if (left_name.as_str() != right_name.as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(left_name) + != crate::v2_std_text::host_string_text_to_rust_host(right_name)) + { false } else { if ((left.connective.clone() == Connective::Conj) @@ -2130,10 +2143,12 @@ pub fn node_type_equals_core( } } else { if (left_leaf.clone() && right_struct.clone()) { - (left_name.as_str() == right_name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(left_name) + == crate::v2_std_text::host_string_text_to_rust_host(right_name)) } else { if (left_struct.clone() && right_leaf.clone()) { - (left_name.as_str() == right_name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(left_name) + == crate::v2_std_text::host_string_text_to_rust_host(right_name)) } else { { let left_is_container = @@ -2141,7 +2156,11 @@ pub fn node_type_equals_core( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { - if (left_name.as_str() != right_name.as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(left_name) + != crate::v2_std_text::host_string_text_to_rust_host( + right_name, + )) + { false } else { match left.children.clone().first().cloned() { @@ -2338,8 +2357,12 @@ pub fn node_type_deps( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (authored_name_at(source_indices.clone(), rt.clone()).as_str() - != "None".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + rt.clone(), + )) != crate::v2_std_text::host_string_text_to_rust_host( + "None".to_string(), + ))) && (is_kernel_type(authored_name_at(source_indices.clone(), rt.clone())) == false)) } @@ -2411,7 +2434,10 @@ pub fn node_type_deps( } } else { if ((is_kernel_type(n_name.clone()) - || (n_name.clone().as_str() == "None".to_string().as_str())) + || (crate::v2_std_text::host_string_text_to_rust_host(n_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "None".to_string(), + ))) || (n.ident_span.clone() == None)) { Rc::new(vec![]) @@ -2472,7 +2498,8 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { if is_optional { with_required_cardinality(n.clone()) } else { - if ((n.name.clone().as_str() == "Optional".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("Optional".to_string())) && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { @@ -2486,7 +2513,7 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { } } -pub fn algebra_field_kind_name(kind: AlgebraFieldKind) -> String { +pub fn algebra_field_kind_name(kind: AlgebraFieldKind) -> Rc> { match kind { AlgebraFieldKind::AlgAdd => "add".to_string(), AlgebraFieldKind::AlgMul => "mul".to_string(), @@ -2683,8 +2710,12 @@ pub fn for_each_element_type_node( if ((((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) == 0)) && ((normed.properties.clone().len() as i64) == 0)) - && (authored_name_at(source_indices, normed.clone()).as_str() - == "String".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices, + normed.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "String".to_string(), + ))) { string_type() } else { @@ -2695,7 +2726,7 @@ pub fn for_each_element_type_node( } } -pub fn emit_map_has(m: Rc>, key: String) -> bool { +pub fn emit_map_has(m: Rc>, key: Rc>) -> bool { match v1_rt::map_get(&m, key) { Some(_) => true, None => false, diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index 8305799b23f..06379572485 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -85,8 +85,8 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ReservedWordStrategy { - PrefixEscape { prefix: String }, - SuffixEscape { suffix: String }, + PrefixEscape { prefix: Rc> }, + SuffixEscape { suffix: Rc> }, NoEscape, } @@ -98,22 +98,22 @@ pub struct ReservedWords { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ProjectScaffold { - pub manifest_file: Option, - pub module_init_file: Option, - pub source_file_extension: String, - pub source_dir: Option, + pub manifest_file: Rc>, + pub module_init_file: Rc>, + pub source_file_extension: Rc>, + pub source_dir: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SerializationSpec { - pub struct_derives: Option, - pub struct_derives_copy: Option, - pub enum_derives: Option, - pub enum_derives_copy: Option, - pub tag_attribute: Option, - pub rename_attribute_template: Option, - pub derive_attribute: Option, - pub default_value: Option, + pub struct_derives: Rc>, + pub struct_derives_copy: Rc>, + pub enum_derives: Rc>, + pub enum_derives_copy: Rc>, + pub tag_attribute: Rc>, + pub rename_attribute_template: Rc>, + pub derive_attribute: Rc>, + pub default_value: Rc>, } #[derive( @@ -127,88 +127,88 @@ pub enum TestNameStyle { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TestConventions { - pub file_prefix: String, - pub file_suffix: String, - pub file_dir: Option, - pub function_prefix: String, + pub file_prefix: Rc>, + pub file_suffix: Rc>, + pub file_dir: Rc>, + pub function_prefix: Rc>, pub name_style: TestNameStyle, - pub async_decorator: Option, + pub async_decorator: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ImportTrigger { - TypeUsageTrigger { type_name: String }, - TraitImplTrigger { trait_name: String }, - DeriveMacroTrigger { macro_name: String }, - ContainerUsageTrigger { container: String }, + TypeUsageTrigger { type_name: Rc> }, + TraitImplTrigger { trait_name: Rc> }, + DeriveMacroTrigger { macro_name: Rc> }, + ContainerUsageTrigger { container: Rc> }, AsyncUsageTrigger, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ImportRule { pub trigger: Rc, - pub import_path: String, + pub import_path: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SharingStrategy { pub needs_sharing: bool, - pub wrap_template: String, - pub clone_value: String, - pub deref_clone: String, - pub field_clone: String, - pub iter_owned: String, - pub clone_suffix: String, - pub borrow_param_template: String, - pub borrow_arg_template: String, + pub wrap_template: Rc>, + pub clone_value: Rc>, + pub deref_clone: Rc>, + pub field_clone: Rc>, + pub iter_owned: Rc>, + pub clone_suffix: Rc>, + pub borrow_param_template: Rc>, + pub borrow_arg_template: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct IndexingSemantics { - pub list_index: String, - pub map_index: String, - pub string_index: String, - pub list_slice: Option, - pub string_slice: Option, + pub list_index: Rc>, + pub map_index: Rc>, + pub string_index: Rc>, + pub list_slice: Rc>, + pub string_slice: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct AnnotationRequirements { - pub let_binding_inferred: String, - pub let_binding_annotated: String, - pub lambda_param_typed: String, - pub lambda_param_untyped: String, + pub let_binding_inferred: Rc>, + pub let_binding_annotated: Rc>, + pub lambda_param_typed: Rc>, + pub lambda_param_untyped: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ServiceFieldTemplates { - pub rest_decl: String, - pub auth_decl: String, - pub shell_decl: String, - pub file_decl: String, - pub rest_ctor: String, - pub auth_ctor: String, - pub shell_ctor: String, - pub file_ctor: String, + pub rest_decl: Rc>, + pub auth_decl: Rc>, + pub shell_decl: Rc>, + pub file_decl: Rc>, + pub rest_ctor: Rc>, + pub auth_ctor: Rc>, + pub shell_ctor: Rc>, + pub file_ctor: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct BlockSyntax { - pub block_open: String, - pub block_close: String, - pub else_clause: String, - pub match_keyword: String, - pub case_keyword: String, - pub arm_separator: String, - pub stmt_terminator: String, + pub block_open: Rc>, + pub block_close: Rc>, + pub else_clause: Rc>, + pub match_keyword: Rc>, + pub case_keyword: Rc>, + pub arm_separator: Rc>, + pub stmt_terminator: Rc>, pub significant_whitespace: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ForEachSyntax { - pub prefix: String, - pub separator: String, + pub prefix: Rc>, + pub separator: Rc>, } #[derive( @@ -234,20 +234,20 @@ pub enum MatchValueForm { pub struct ExpressionSemantics { pub if_value_form: IfValueForm, pub match_value_form: MatchValueForm, - pub wildcard_case: Option, + pub wildcard_case: Rc>, pub variant_pattern: Option>, - pub guard_prefix: Option, - pub empty_return_value: String, - pub return_suffix: String, + pub guard_prefix: Rc>, + pub empty_return_value: Rc>, + pub return_suffix: Rc>, pub suppress_unit_return: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct VariantPatternSyntax { - pub open: String, - pub close: String, - pub binding_sep: String, - pub empty_suffix: String, + pub open: Rc>, + pub close: Rc>, + pub binding_sep: Rc>, + pub empty_suffix: Rc>, } #[derive( @@ -264,35 +264,35 @@ pub enum NamingCase { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum VisibilitySpec { - KeywordVisibility { prefix: String }, + KeywordVisibility { prefix: Rc> }, CaseVisibility { export_case: NamingCase }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TcoSyntax { - pub loop_keyword: String, - pub break_return: String, - pub continue_str: String, - pub temp_var_prefix: String, - pub temp_decl_prefix: String, - pub temp_assign_op: String, + pub loop_keyword: Rc>, + pub break_return: Rc>, + pub continue_str: Rc>, + pub temp_var_prefix: Rc>, + pub temp_decl_prefix: Rc>, + pub temp_assign_op: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ServiceMethodStrategy { - SelfInParams { self_param: String }, - ExternalReceiver { var_name: String }, + SelfInParams { self_param: Rc> }, + ExternalReceiver { var_name: Rc> }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ServiceReturnStrategy { ArrowReturn, - ErrorTupleReturn { error_type: String }, + ErrorTupleReturn { error_type: Rc> }, } impl ServiceReturnStrategy { - pub fn error_type(&self) -> String { + pub fn error_type(&self) -> Rc> { match self { ServiceReturnStrategy::ArrowReturn => panic!("no error_type on unit variant"), ServiceReturnStrategy::ErrorTupleReturn { @@ -302,14 +302,17 @@ impl ServiceReturnStrategy { } } -pub fn service_self_param(spec: Rc) -> String { +pub fn service_self_param(spec: Rc) -> Rc> { match (*spec.service_method.clone()).clone() { ServiceMethodStrategy::SelfInParams { self_param: sp, .. } => sp.clone(), ServiceMethodStrategy::ExternalReceiver { var_name: _, .. } => "".to_string(), } } -pub fn service_receiver_str(spec: Rc, service_name: String) -> String { +pub fn service_receiver_str( + spec: Rc, + service_name: Rc>, +) -> Rc> { match (*spec.service_method.clone()).clone() { ServiceMethodStrategy::SelfInParams { self_param: _, .. } => "".to_string(), ServiceMethodStrategy::ExternalReceiver { var_name: v, .. } => v1_rt::concat( @@ -336,7 +339,10 @@ pub fn service_methods_inside_class(spec: Rc) -> bool { } } -pub fn service_return_str(spec: Rc, ret_type: String) -> String { +pub fn service_return_str( + spec: Rc, + ret_type: Rc>, +) -> Rc> { match (*spec.service_return.clone()).clone() { ServiceReturnStrategy::ArrowReturn => { v1_rt::concat(spec.items.clone().return_arrow.clone(), ret_type) @@ -353,20 +359,23 @@ pub fn service_return_str(spec: Rc, ret_type: String) -> String { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemKeywords { - pub func_keyword: String, - pub async_prefix: String, - pub struct_keyword: String, - pub enum_keyword: String, - pub type_alias_keyword: String, - pub param_separator: String, - pub return_arrow: String, - pub param_type_sep: String, - pub module_keyword: String, - pub import_keyword: String, - pub import_from_keyword: String, + pub func_keyword: Rc>, + pub async_prefix: Rc>, + pub struct_keyword: Rc>, + pub enum_keyword: Rc>, + pub type_alias_keyword: Rc>, + pub param_separator: Rc>, + pub return_arrow: Rc>, + pub param_type_sep: Rc>, + pub module_keyword: Rc>, + pub import_keyword: Rc>, + pub import_from_keyword: Rc>, } -pub fn item_keyword_for_kind(forms: Rc>>, kind: ItemFormKind) -> String { +pub fn item_keyword_for_kind( + forms: Rc>>, + kind: ItemFormKind, +) -> Rc> { { let matching = Rc::new({ let mut __result = Vec::new(); @@ -386,7 +395,7 @@ pub fn item_keyword_for_kind(forms: Rc>>, kind: ItemFormKind) - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct LanguageSpec { - pub target_name: String, + pub target_name: Rc>, pub reserved_words: Rc, pub scaffold: Rc, pub serialization: Rc, @@ -401,21 +410,21 @@ pub struct LanguageSpec { pub tco: Rc, pub items: Rc, pub expression_semantics: Rc, - pub lambda_template: String, - pub error_expr_template: String, - pub list_literal_empty: String, - pub list_literal_template: String, - pub null_coalesce_template: String, - pub error_type_template: String, - pub type_arg_open: String, - pub type_arg_close: String, - pub void_type: String, + pub lambda_template: Rc>, + pub error_expr_template: Rc>, + pub list_literal_empty: Rc>, + pub list_literal_template: Rc>, + pub null_coalesce_template: Rc>, + pub error_type_template: Rc>, + pub type_arg_open: Rc>, + pub type_arg_close: Rc>, + pub void_type: Rc>, pub tuple_syntax: Rc, pub string_interp: Rc, - pub callable_type_template: Option, + pub callable_type_template: Rc>, pub naming_case: NamingCase, - pub async_call_prefix: String, - pub bridge_method_prefix: String, + pub async_call_prefix: Rc>, + pub bridge_method_prefix: Rc>, pub bridge_method_case: NamingCase, pub bridge_method_overrides: Rc>, pub record_lit: Rc, @@ -425,35 +434,35 @@ pub struct LanguageSpec { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TupleSyntax { - pub empty: String, - pub pair_template: String, - pub multi_template: String, - pub separator: String, - pub first_accessor: String, - pub second_accessor: String, + pub empty: Rc>, + pub pair_template: Rc>, + pub multi_template: Rc>, + pub separator: Rc>, + pub first_accessor: Rc>, + pub second_accessor: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RecordLitSyntax { - pub named_open: String, - pub named_close: String, - pub named_empty: String, - pub named_field_sep: String, - pub named_field_join: String, - pub anon_empty: String, - pub anon_prefix: String, - pub anon_suffix: String, - pub anon_field_indent: String, + pub named_open: Rc>, + pub named_close: Rc>, + pub named_empty: Rc>, + pub named_field_sep: Rc>, + pub named_field_join: Rc>, + pub anon_empty: Rc>, + pub anon_prefix: Rc>, + pub anon_suffix: Rc>, + pub anon_field_indent: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum InterpStyle { - FormatArgs { placeholder: String }, + FormatArgs { placeholder: Rc> }, InlineExpr, } impl InterpStyle { - pub fn placeholder(&self) -> String { + pub fn placeholder(&self) -> Rc> { match self { InterpStyle::FormatArgs { placeholder: __val, .. @@ -465,15 +474,15 @@ impl InterpStyle { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EscapePair { - pub from: String, - pub to: String, + pub from: Rc>, + pub to: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StringInterpSyntax { pub style: Rc, - pub format_template: String, - pub plain_template: String, + pub format_template: Rc>, + pub plain_template: Rc>, pub escape_pairs: Rc>>, } @@ -639,7 +648,7 @@ pub fn rust_spec() -> Rc { async_call_prefix: "".to_string(), bridge_method_prefix: "".to_string(), bridge_method_case: NamingCase::SnakeCase, - bridge_method_overrides: v1_rt::rc_empty_map::(), + bridge_method_overrides: v1_rt::rc_empty_map::>, Rc>>(), record_lit: Rc::new(RecordLitSyntax { named_open: " {".to_string(), named_close: "}".to_string(), @@ -819,7 +828,7 @@ pub fn python_spec() -> Rc { bridge_method_prefix: "".to_string(), bridge_method_case: NamingCase::SnakeCase, bridge_method_overrides: v1_rt::rc_map_insert( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, Rc>>(), "with".to_string(), "with_update".to_string(), ), @@ -989,7 +998,7 @@ pub fn go_spec() -> Rc { async_call_prefix: "".to_string(), bridge_method_prefix: "v2rt.".to_string(), bridge_method_case: NamingCase::PascalCase, - bridge_method_overrides: v1_rt::rc_empty_map::(), + bridge_method_overrides: v1_rt::rc_empty_map::>, Rc>>(), record_lit: Rc::new(RecordLitSyntax { named_open: "{".to_string(), named_close: "}".to_string(), @@ -1165,7 +1174,7 @@ pub fn dag_spec() -> Rc { async_call_prefix: "".to_string(), bridge_method_prefix: "".to_string(), bridge_method_case: NamingCase::SnakeCase, - bridge_method_overrides: v1_rt::rc_empty_map::(), + bridge_method_overrides: v1_rt::rc_empty_map::>, Rc>>(), record_lit: Rc::new(RecordLitSyntax { named_open: " {".to_string(), named_close: "}".to_string(), @@ -1193,7 +1202,7 @@ pub fn language_spec_for_target(target: RenderTarget) -> Rc { } } -pub fn target_keyword(target: RenderTarget, key: String) -> String { +pub fn target_keyword(target: RenderTarget, key: Rc>) -> Rc> { match target { RenderTarget::Rust => match v1_rt::lookup(&rust_keywords(), key.clone()) { v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), @@ -1224,7 +1233,7 @@ pub fn binop_symbol( target: RenderTarget, op: BinOp, algebra_field: Option, -) -> Option { +) -> Rc> { { let ops = target_operators(target); let op_matching = Rc::new({ @@ -1277,12 +1286,14 @@ pub fn binop_symbol( } } -pub fn is_string_like(target: RenderTarget, name: String) -> bool { +pub fn is_string_like(target: RenderTarget, name: Rc>) -> bool { match target { RenderTarget::Rust => { let mut __found = false; for t in rust_string_types().iter().cloned() { - if (t.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(t.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -1292,7 +1303,9 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Go => { let mut __found = false; for t in go_string_types().iter().cloned() { - if (t.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(t.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -1302,7 +1315,9 @@ pub fn is_string_like(target: RenderTarget, name: String) -> bool { RenderTarget::Python => { let mut __found = false; for t in python_string_types().iter().cloned() { - if (t.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(t.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -1339,7 +1354,7 @@ pub fn expression_semantics_for_target(target: RenderTarget) -> Rc String { +pub fn wrap_shared_type(target: RenderTarget, inner: Rc>) -> Rc> { { let tmpl = sharing_for_target(target).wrap_template.clone(); v1_rt::replace(tmpl, "{0}".to_string(), inner) @@ -1354,6 +1369,4 @@ pub struct IfStatement; pub struct MatchExpression; pub struct MatchStatementArmReturn; pub struct PascalCase; -pub struct SnakeCase; pub struct CamelCase; -pub struct AsAuthored; diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 0da15e2a8e5..928b81029d0 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -28,7 +28,7 @@ pub struct NormalizeResult { pub fn check_bare_containers( n: Rc, - module_name: String, + module_name: Rc>, source_indices: Rc>>, ) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index adacc83a08e..b98626e24fa 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -43,13 +43,13 @@ pub enum EdgeKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EdgeClassification { pub kind: EdgeKind, - pub site: String, + pub site: Rc>, pub span_start: i64, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct BindingUsage { - pub name: String, + pub name: Rc>, pub binding_kind: Option>, pub consumers: Rc>>, } @@ -90,21 +90,21 @@ pub fn binding_fan_out(usage: Rc) -> i64 { #[serde(tag = "_variant")] pub enum OwnershipDecision { SoleOwner { - binding: String, - site: String, + binding: Rc>, + site: Rc>, }, SharedError { - binding: String, + binding: Rc>, consumer_count: i64, sites: Rc>, }, Unclassified { - binding: String, - reason: String, + binding: Rc>, + reason: Rc>, }, } impl OwnershipDecision { - pub fn binding(&self) -> String { + pub fn binding(&self) -> Rc> { match self { OwnershipDecision::SoleOwner { binding: __val, .. } => __val.clone(), OwnershipDecision::SharedError { binding: __val, .. } => __val.clone(), @@ -115,9 +115,9 @@ impl OwnershipDecision { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FoldAccUnwrapProof { - pub site_key: String, - pub acc_param_name: String, - pub acc_type_name: String, + pub site_key: Rc>, + pub acc_param_name: Rc>, + pub acc_type_name: Rc>, pub body_constructs_acc: bool, pub whole_acc_single_use: bool, pub safe_field_moves: bool, @@ -133,7 +133,7 @@ pub struct FoldAccUseSummary { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipProof { - pub func_name: String, + pub func_name: Rc>, pub bindings: Rc>>, pub decisions: Rc>>, pub fold_acc_unwrap: Rc>>, @@ -147,16 +147,16 @@ pub struct UsageAccum { pub fn empty_usage_accum() -> Rc { Rc::new(UsageAccum { - bindings: v1_rt::rc_empty_map::>(), + bindings: v1_rt::rc_empty_map::>, Rc>(), fold_call_nodes: Rc::new(vec![]), }) } pub fn record_use( accum: Rc, - name: String, + name: Rc>, kind: EdgeKind, - site: String, + site: Rc>, binding_kind: Option>, span_start: i64, ) -> Rc { @@ -201,7 +201,7 @@ pub fn max_usage_by_fan_out(a: Rc, b: Rc) -> Rc>>, - key: String, + key: Rc>, new_val: Rc, ) -> Rc>> { match v1_rt::map_get(&base, key.clone()) { @@ -314,14 +314,18 @@ pub fn walk_expr( } ExprData::ExprCall { .. } => { let fname = expr_call_func_at(texpr.clone(), si.clone()); - if (fname.as_str() == "fold".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname) + == crate::v2_std_text::host_string_text_to_rust_host("fold".to_string())) + { { let init_arg = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - == "init".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(si.clone(), a.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "init".to_string(), + )) { __result.push(a); } } @@ -354,9 +358,11 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - != "init".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(si.clone(), a.clone()), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "init".to_string(), + )) { __result.push(a); } } @@ -382,15 +388,19 @@ pub fn walk_expr( let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let mname = expr_method_name_at(texpr.clone(), si.clone()); - if (mname.as_str() == "fold".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(mname) + == crate::v2_std_text::host_string_text_to_rust_host("fold".to_string())) + { { let recv_accum = walk_expr(accum, recv, false, si.clone()); let init_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - == "init".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(si.clone(), a.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "init".to_string(), + )) { __result.push(a); } } @@ -423,9 +433,11 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (authored_name_at(si.clone(), a.clone()).as_str() - != "init".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(si.clone(), a.clone()), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "init".to_string(), + )) { __result.push(a); } } @@ -922,7 +934,7 @@ pub fn merge_fold_acc_use_summaries( pub fn summarize_fold_acc_uses( node: Rc, - acc_name: String, + acc_name: Rc>, si: Rc>>, inside_nested: bool, ) -> Rc { @@ -931,8 +943,10 @@ pub fn summarize_fold_acc_uses( ExprData::ExprVar { binding_kind: _, .. } => { - if (expr_var_name_at(node.clone(), si.clone()).as_str() - == acc_name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + node.clone(), + si.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(acc_name.clone())) { if inside_nested.clone() { Rc::new(FoldAccUseSummary { @@ -957,8 +971,10 @@ pub fn summarize_fold_acc_uses( ExprData::ExprVar { binding_kind: _, .. } => { - (expr_var_name_at(base.clone(), si.clone()).as_str() - == acc_name.clone().as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( + base.clone(), + si.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(acc_name.clone())) } _ => false, }; @@ -1063,7 +1079,7 @@ pub fn summarize_fold_acc_uses( pub fn fold_lambda_acc_use_summary( lambda_node: Rc, - acc_name: String, + acc_name: Rc>, si: Rc>>, ) -> Rc { match (*lambda_node.expr_data.clone()).clone() { @@ -1076,7 +1092,7 @@ pub fn fold_lambda_acc_use_summary( pub fn fold_body_constructs_acc_struct( lambda_node: Rc, - acc_type_name: String, + acc_type_name: Rc>, si: Rc>>, ) -> bool { match (*lambda_node.expr_data.clone()).clone() { @@ -1085,7 +1101,10 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (authored_name_at(si, terminal.clone()).as_str() == acc_type_name.as_str()) + (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + si, + terminal.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(acc_type_name)) } _ => false, } @@ -1096,14 +1115,14 @@ pub fn fold_body_constructs_acc_struct( pub fn fold_body_safe_field_moves( lambda_node: Rc, - acc_name: String, + acc_name: Rc>, si: Rc>>, ) -> bool { { let summary = fold_lambda_acc_use_summary(lambda_node, acc_name, si); let deduped = summary.field_moves.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |seen: Rc>, field: String| { + v1_rt::rc_empty_map::>, bool>(), + |seen: Rc>, field: Rc>| { v1_rt::rc_map_insert(seen, field.clone(), true) }, ); @@ -1115,7 +1134,7 @@ pub fn fold_body_safe_field_moves( pub fn fold_body_consumes_acc_once( lambda_node: Rc, - acc_name: String, + acc_name: Rc>, si: Rc>>, ) -> bool { { @@ -1179,10 +1198,13 @@ pub fn analyze_single_fold( si.clone(), ); let eligible = ((cond_required - && (acc_type_name.clone().as_str() != "".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(acc_type_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { - site_key: (method_call.span.clone().start.clone()).to_string(), + site_key: crate::v2_std_text::host_string_text_from_rust_host( + (method_call.span.clone().start.clone()).to_string(), + ), acc_param_name: acc_param_name.clone(), acc_type_name: acc_type_name.clone(), body_constructs_acc: cond_struct.clone(), @@ -1194,7 +1216,7 @@ pub fn analyze_single_fold( } pub fn analyze_ownership( - func_name: String, + func_name: Rc>, params: Rc>>, body: Rc, si: Rc>>, diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index de03eb7556a..5580b6113ad 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -140,7 +140,7 @@ pub struct TokenResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct NameResult { - pub name: String, + pub name: Rc>, pub span: Rc, pub tokens: Rc>>, pub err: Option>, @@ -284,7 +284,7 @@ pub struct ResUseResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemPrefixResult { - pub name: String, + pub name: Rc>, pub name_span: Rc, pub type_params: Rc>>, pub params: Rc>>, @@ -322,7 +322,7 @@ pub struct BindingPower { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ExpectedToken { - ExpectKeyword { text: String }, + ExpectKeyword { text: Rc> }, ExpectLBrace, ExpectRBrace, ExpectLParen, @@ -341,7 +341,7 @@ pub enum ExpectedToken { ExpectPipe, } impl ExpectedToken { - pub fn text(&self) -> String { + pub fn text(&self) -> Rc> { match self { ExpectedToken::ExpectKeyword { text: __val, .. } => __val.clone(), ExpectedToken::ExpectLBrace => panic!("no text on unit variant"), @@ -484,7 +484,7 @@ pub struct BindingsResult { pub err: Option>, } -pub fn parse_recovery_expr(span: Rc, message: String) -> Rc { +pub fn parse_recovery_expr(span: Rc, message: Rc>) -> Rc { make_expr_error_node(ExprErrorKind::ParseRecoveryError, message, span) } @@ -510,7 +510,7 @@ pub struct GuardResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FromKeyResult { - pub from_key: Option, + pub from_key: Rc>, pub tokens: Rc>>, pub ctx: Rc, pub err: Option>, @@ -527,7 +527,7 @@ pub struct PostfixResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ParserParam { - pub name: String, + pub name: Rc>, pub span: Rc, } @@ -560,7 +560,7 @@ pub struct RangeArgsResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct NamedIntResult { - pub arg_name: String, + pub arg_name: Rc>, pub arg_value: i64, pub tokens: Rc>>, pub ctx: Rc, @@ -657,7 +657,7 @@ pub struct UnitResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StringLitResult { - pub value: String, + pub value: Rc>, pub tokens: Rc>>, pub err: Option>, } @@ -683,7 +683,7 @@ pub enum ParserHelperIdentity { #[serde(tag = "_variant")] pub enum ParserCallIdentity { ParserCallHelper { helper: ParserHelperIdentity }, - ParserCallFunction { name: String }, + ParserCallFunction { name: Rc> }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -709,7 +709,7 @@ impl ParserResultWitness { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DescResult { - pub desc: Option, + pub desc: Rc>, pub tokens: Rc>>, } @@ -737,7 +737,7 @@ pub fn advance(tokens: Rc>>) -> Rc { } } -pub fn parse_error(msg: String, span: Rc) -> Rc { +pub fn parse_error(msg: Rc>, span: Rc) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::ParseError { message: msg, @@ -1144,14 +1144,18 @@ pub fn is_pipe_arrow_shape(shape: TokenShape) -> bool { } } -pub fn tok_is_keyword(tok: Option>, kw: String) -> bool { +pub fn tok_is_keyword(tok: Option>, kw: Rc>) -> bool { match tok { - Some(t) => (is_keyword_shape(t.shape.clone()) && (t.text.clone().as_str() == kw.as_str())), + Some(t) => { + (is_keyword_shape(t.shape.clone()) + && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(kw))) + } None => false, } } -pub fn tok_keyword_text(tok: Option>) -> String { +pub fn tok_keyword_text(tok: Option>) -> Rc> { match tok { Some(t) => { if is_keyword_shape(t.shape.clone()) { @@ -1171,16 +1175,20 @@ pub fn tok_is_ident(tok: Option>) -> bool { } } -pub fn tok_is_ident_text(tok: Option>, text: String) -> bool { +pub fn tok_is_ident_text(tok: Option>, text: Rc>) -> bool { match tok { - Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == text.as_str())), + Some(t) => { + (is_ident_shape(t.shape.clone()) + && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(text))) + } None => false, } } pub fn drop_leading_type_modifier( tokens: Rc>>, - modifier: String, + modifier: Rc>, ) -> Rc>> { if tok_is_ident_text(tokens.clone().first().cloned(), modifier) { skip_newlines(Rc::new( @@ -1198,8 +1206,9 @@ pub fn drop_leading_type_modifier( pub fn drop_leading_test_marker(tokens: Rc>>) -> Rc>> { if (tok_is_ident_text(tokens.clone().first().cloned(), "test".to_string()) - && (tok_keyword_text(tokens.clone().get(1 as usize).cloned()).as_str() - != "".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(tok_keyword_text( + tokens.clone().get(1 as usize).cloned(), + )) != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) { Rc::new( tokens @@ -1372,7 +1381,7 @@ pub fn tok_span(tok: Option>) -> Rc { } } -pub fn tok_keyword_to_name(tok: Option>) -> Option { +pub fn tok_keyword_to_name(tok: Option>) -> Rc> { match tok { Some(t) => { if is_name_keyword(t.clone()) { @@ -1392,7 +1401,7 @@ pub fn tok_is_keyword_name(tok: Option>) -> bool { } } -pub fn shape_display_name(shape: TokenShape) -> String { +pub fn shape_display_name(shape: TokenShape) -> Rc> { match shape { TokenShape::ShKeyword => "keyword".to_string(), TokenShape::ShLBrace => "LBrace".to_string(), @@ -1440,7 +1449,7 @@ pub fn shape_display_name(shape: TokenShape) -> String { } } -pub fn token_display_name(token: Rc) -> String { +pub fn token_display_name(token: Rc) -> Rc> { if is_keyword_shape(token.shape.clone()) { v1_rt::concat( "keyword '".to_string(), @@ -1451,7 +1460,7 @@ pub fn token_display_name(token: Rc) -> String { } } -pub fn expected_token_name(expected: Rc) -> String { +pub fn expected_token_name(expected: Rc) -> Rc> { match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => v1_rt::concat( "keyword '".to_string(), @@ -1480,7 +1489,8 @@ pub fn token_matches_expected(token: Rc, expected: Rc) -> match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => { (is_keyword_shape(token.shape.clone()) - && (token.text.clone().as_str() == kw.clone().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(token.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(kw.clone()))) } ExpectedToken::ExpectLBrace => is_lbrace_shape(token.shape.clone()), ExpectedToken::ExpectRBrace => is_rbrace_shape(token.shape.clone()), @@ -1536,7 +1546,10 @@ pub fn expect(tokens: Rc>>, expected: Rc) -> Rc>>, expected: Rc) -> Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => match expr.children.clone().first().cloned() { Some(base) => match (*base.expr_data.clone()).clone() { @@ -1785,8 +1798,14 @@ pub fn parser_helper_state_arg_expr( let arg_node = pair.1.clone(); let matches_state = match arg_name_at(arg_node.clone(), source_indices.clone()) { Some(name) => { - ((name.clone().as_str() == "state".to_string().as_str()) - || (name.clone().as_str() == "tokens".to_string().as_str())) + ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "state".to_string(), + )) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "tokens".to_string(), + ))) } None => (idx.clone() == 0), }; @@ -1803,12 +1822,14 @@ pub fn parser_helper_state_arg_expr( pub fn parser_progress_flag_var( expr: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), source_indices.clone()); - if ((field.clone().as_str() == "consumed".to_string().as_str()) - || (field.clone().as_str() == "changed".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(field.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("consumed".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(field.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("changed".to_string()))) { parser_result_base_var(expr.clone(), source_indices.clone()) } else { @@ -1819,14 +1840,22 @@ pub fn parser_progress_flag_var( } } -pub fn parser_helper_identity(callee: String) -> Option { - if (callee.clone().as_str() == "skip_newlines".to_string().as_str()) { +pub fn parser_helper_identity(callee: Rc>) -> Option { + if (crate::v2_std_text::host_string_text_to_rust_host(callee.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("skip_newlines".to_string())) + { Some(ParserHelperIdentity::ParserHelperSkipNewlines) } else { - if (callee.clone().as_str() == "skip_continuation_newlines".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(callee.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "skip_continuation_newlines".to_string(), + )) + { Some(ParserHelperIdentity::ParserHelperSkipContinuationNewlines) } else { - if (callee.clone().as_str() == "with".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(callee.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("with".to_string())) + { Some(ParserHelperIdentity::ParserHelperWith) } else { None @@ -1887,11 +1916,13 @@ pub fn parser_result_witness( } } -pub fn leaf_type_node(name: String, span: Rc) -> Rc { +pub fn leaf_type_node(name: Rc>, span: Rc) -> Rc { Rc::new(Node { name: name.clone(), span: span.clone(), - ident_span: if (name.clone().as_str() == "".to_string().as_str()) { + ident_span: if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { None } else { Some(span.clone()) @@ -2047,7 +2078,7 @@ pub fn parse_dotted_ident(tokens: Rc>>) -> Rc { pub fn parse_dotted_ident_rest( mut tokens: Rc>>, - mut acc: String, + mut acc: Rc>, mut span: Rc, ) -> Rc { loop { @@ -2438,7 +2469,7 @@ pub fn parse_import_names(tokens: Rc>>, ctx: Rc) -> parse_import_names_acc(tokens, ctx, Rc::new(vec![])) } -pub fn parsed_name_leaf(name: String, span: Rc) -> Rc { +pub fn parsed_name_leaf(name: Rc>, span: Rc) -> Rc { leaf_node_with_span(name, span) } @@ -2482,12 +2513,17 @@ pub fn parse_import_names_acc( } } -pub fn find_item_form(forms: Rc>>, keyword: String) -> Option> { +pub fn find_item_form( + forms: Rc>>, + keyword: Rc>, +) -> Option> { { let matches = Rc::new({ let mut __result = Vec::new(); for f in forms.iter().cloned() { - if (f.keyword.clone().as_str() == keyword.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(f.keyword.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(keyword.clone())) + { __result.push(f); } } @@ -2916,7 +2952,7 @@ pub fn outputs_to_inferred( } pub fn make_operation_node( - name: String, + name: Rc>, ident_span: Option>, inputs: Rc>>, outputs: Rc>>, @@ -2969,7 +3005,7 @@ pub fn make_operation_node( } pub fn make_capability_node( - name: String, + name: Rc>, ident_span: Option>, inputs: Rc>>, outputs: Rc>>, @@ -3357,7 +3393,7 @@ pub fn parse_type_body_from_prefix( pub fn parse_type_body_after_eq( tokens: Rc>>, ctx: Rc, - name: String, + name: Rc>, name_span: Rc, start_span: Rc, type_params: Rc>>, @@ -4175,24 +4211,34 @@ pub fn parse_named_int_args( err: r2.err.clone(), }); } - let min_val = if (r.arg_name.clone().as_str() == "min".to_string().as_str()) { - Some(r.arg_value.clone()) - } else { - if (r2.arg_name.clone().as_str() == "min".to_string().as_str()) { - Some(r2.arg_value.clone()) + let min_val = + if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("min".to_string())) + { + Some(r.arg_value.clone()) } else { - None - } - }; - let max_val = if (r.arg_name.clone().as_str() == "max".to_string().as_str()) { - Some(r.arg_value.clone()) - } else { - if (r2.arg_name.clone().as_str() == "max".to_string().as_str()) { - Some(r2.arg_value.clone()) + if (crate::v2_std_text::host_string_text_to_rust_host(r2.arg_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("min".to_string())) + { + Some(r2.arg_value.clone()) + } else { + None + } + }; + let max_val = + if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("max".to_string())) + { + Some(r.arg_value.clone()) } else { - None - } - }; + if (crate::v2_std_text::host_string_text_to_rust_host(r2.arg_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("max".to_string())) + { + Some(r2.arg_value.clone()) + } else { + None + } + }; Rc::new(RangeArgsResult { min_val: min_val, max_val: max_val, @@ -4202,16 +4248,22 @@ pub fn parse_named_int_args( }) } EatResult::EatUnchanged { tokens: __eu, .. } => { - let min_val = if (r.arg_name.clone().as_str() == "min".to_string().as_str()) { - Some(r.arg_value.clone()) - } else { - None - }; - let max_val = if (r.arg_name.clone().as_str() == "max".to_string().as_str()) { - Some(r.arg_value.clone()) - } else { - None - }; + let min_val = + if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("min".to_string())) + { + Some(r.arg_value.clone()) + } else { + None + }; + let max_val = + if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("max".to_string())) + { + Some(r.arg_value.clone()) + } else { + None + }; Rc::new(RangeArgsResult { min_val: min_val, max_val: max_val, @@ -4314,7 +4366,7 @@ pub fn parse_positional_variant_type_fields( pub fn parse_variant_fields( tokens: Rc>>, ctx: Rc, - vname: String, + vname: Rc>, vname_span: Rc, ) -> Rc { { @@ -4564,7 +4616,10 @@ pub fn parse_type_expr(tokens: Rc>>, ctx: Rc) -> Rc< }) } Some(TokenShape::ShKeyword) => { - if (tok.clone().unwrap().text.clone().as_str() == "fn".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + tok.clone().unwrap().text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host("fn".to_string())) + { parse_callable_type_expr( Rc::new( tokens @@ -4763,7 +4818,7 @@ pub fn parse_callable_param_types( pub fn finish_type_expr_from_name( tokens: Rc>>, ctx: Rc, - type_name: String, + type_name: Rc>, start_span: Rc, ) -> Rc { { @@ -5173,7 +5228,10 @@ pub fn parse_optional_from_key( }; match sh { Some(TokenShape::ShIdent) => { - if (tok.clone().unwrap().text.clone().as_str() == "from".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + tok.clone().unwrap().text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host("from".to_string())) + { { let tok2 = tokens.clone().get(1 as usize).cloned(); let sh2 = match tok2.clone() { @@ -5512,7 +5570,9 @@ pub fn parse_func_def(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> R let is_uses = match tok { Some(t) => { (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "uses".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("uses".to_string()))) } None => false, }; @@ -6355,7 +6421,9 @@ pub fn parse_service_entries( match sh { Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (id.clone().as_str() == "config".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("config".to_string())) + { let r = expect( Rc::new( tokens @@ -6413,7 +6481,11 @@ pub fn parse_service_entries( continue; } } else { - if (id.clone().as_str() == "transport".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "transport".to_string(), + )) + { let r = parse_transport_binding( Rc::new( tokens @@ -6462,7 +6534,11 @@ pub fn parse_service_entries( } Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text.as_str() == "operation".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text) + == crate::v2_std_text::host_string_text_to_rust_host( + "operation".to_string(), + )) + { let r = parse_operation_def(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ServiceBodyResult { @@ -6674,7 +6750,9 @@ pub fn parse_transport_binding( }; match sh { Some(TokenShape::ShIdent) => { - if (tok_text.clone().as_str() == "rest".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(tok_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("rest".to_string())) + { { let r = expect( Rc::new( @@ -6725,7 +6803,9 @@ pub fn parse_transport_binding( }) } } else { - if (tok_text.clone().as_str() == "shell".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(tok_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("shell".to_string())) + { { let r = expect( Rc::new( @@ -6778,7 +6858,11 @@ pub fn parse_transport_binding( }) } } else { - if (tok_text.clone().as_str() == "file".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(tok_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "file".to_string(), + )) + { { let r = expect( Rc::new( @@ -6950,52 +7034,73 @@ pub fn parse_rest_fields( EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; ctx = r3.ctx.clone(); - if (fname.clone().as_str() == transport_url_key().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_url_key())) + { { let __tco_0 = Some(r3.expr.clone()); base_url = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_method_key().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_method_key())) + { { let __tco_0 = Some(r3.expr.clone()); method = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_path_template_key().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + transport_path_template_key(), + )) + { { let __tco_0 = Some(r3.expr.clone()); path_template = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_query_key().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + transport_query_key(), + )) + { { let __tco_0 = Some(r3.expr.clone()); query = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_body_key().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + transport_body_key(), + )) + { { let __tco_0 = Some(r3.expr.clone()); request_body = __tco_0; continue; } } else { - if (fname.clone().as_str() - == transport_response_format_key().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + transport_response_format_key(), + )) { { let __tco_0 = Some(r3.expr.clone()); response_format = __tco_0; continue; } } else { - if (fname.clone().as_str() == transport_headers_key().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + fname.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + transport_headers_key(), + )) { let h = match (*r3.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), _ => return Rc::new(TransportResult { @@ -7074,7 +7179,9 @@ pub fn parse_shell_fields( err: r2.err.clone(), }); } - if (fname.clone().as_str() == "argv".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("argv".to_string())) + { let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectLBracket)); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7119,7 +7226,9 @@ pub fn parse_shell_fields( continue; } } else { - if (fname.clone().as_str() == transport_stdin_key().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_stdin_key())) + { let r3 = parse_expr(r2.tokens.clone(), ctx.clone()); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7239,8 +7348,10 @@ pub fn parse_file_fields( EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; - if ((fname.clone().as_str() == "path".to_string().as_str()) - || (fname.clone().as_str() == transport_path_key().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("path".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_path_key()))) { { let __tco_0 = r3.ctx.clone(); @@ -7325,7 +7436,7 @@ pub fn parse_operation_def(tokens: Rc>>, ctx: Rc) -> pub fn parse_operation_v2_inline( tokens: Rc>>, ctx: Rc, - name: String, + name: Rc>, name_span: Rc, start_span: Rc, ) -> Rc { @@ -7445,7 +7556,7 @@ pub fn parse_operation_v2_inline( pub fn parse_operation_v1_body( tokens: Rc>>, ctx: Rc, - name: String, + name: Rc>, name_span: Rc, start_span: Rc, ) -> Rc { @@ -7563,7 +7674,9 @@ pub fn parse_op_body_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (kw_text.clone().as_str() == "input".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("input".to_string())) + { let r = expect( Rc::new( tokens @@ -7632,7 +7745,11 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "output".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "output".to_string(), + )) + { let r = expect( Rc::new( tokens @@ -7701,7 +7818,11 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "idempotent".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "idempotent".to_string(), + )) + { let prop = modifier_to_prop("idempotent".to_string(), span); { let __tco_0 = Rc::new( @@ -7713,7 +7834,11 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "readonly".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + kw_text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "readonly".to_string(), + )) { let prop = modifier_to_prop("readonly".to_string(), span); { let __tco_0 = Rc::new( @@ -7729,8 +7854,11 @@ pub fn parse_op_body_entries( continue; } } else { - if (kw_text.clone().as_str() == "hermetic".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + kw_text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "hermetic".to_string(), + )) { let prop = modifier_to_prop("hermetic".to_string(), span); { let __tco_0 = Rc::new( @@ -7755,7 +7883,11 @@ pub fn parse_op_body_entries( } Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (id.clone().as_str() == "transport".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "transport".to_string(), + )) + { let r = parse_transport_binding( Rc::new( tokens @@ -7791,7 +7923,11 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone().as_str() == "exit".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "exit".to_string(), + )) + { let r = expect( Rc::new( tokens @@ -7861,7 +7997,11 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone().as_str() == "response".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "response".to_string(), + )) + { let r = parse_optional_response_block(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(OpBodyResult { @@ -7887,7 +8027,11 @@ pub fn parse_op_body_entries( continue; } } else { - if (id.clone().as_str() == "mock_response".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "mock_response".to_string(), + )) + { let r = parse_optional_mock_response_block( tokens.clone(), ctx.clone(), @@ -7984,9 +8128,11 @@ pub fn parse_op_body_entries( tokens: tokens.clone(), ctx: ctx.clone(), err: Some(parse_error( - format!( - "unexpected '{}' in operation body", - id.clone() + crate::v2_std_text::host_string_text_from_rust_host( + format!( + "unexpected '{}' in operation body", + id.clone() + ), ), span, )), @@ -8019,7 +8165,7 @@ pub fn parse_op_body_entries( } } -pub fn modifier_to_prop(name: String, span: Rc) -> Rc { +pub fn modifier_to_prop(name: Rc>, span: Rc) -> Rc { make_field_init_node( name, make_expr_node( @@ -8061,7 +8207,7 @@ pub fn modifiers_to_props( pub fn status_expr_to_str( expr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitInt { value: n, .. } => int_to_string(n.clone()), @@ -8075,7 +8221,7 @@ pub fn status_expr_to_str( } } -pub fn int_to_string(value: i64) -> String { +pub fn int_to_string(value: i64) -> Rc> { if (value.clone() == 0) { "0".to_string() } else { @@ -8158,7 +8304,7 @@ pub fn last_child_or_self(n: Rc) -> Rc { pub fn node_to_name_str( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); let effective_n = if is_optional.clone() { @@ -8341,7 +8487,9 @@ pub fn parse_operation_modifiers_acc( ) -> Rc { loop { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (kw.clone().as_str() == "idempotent".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("idempotent".to_string())) + { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); let __tco_1 = v1_rt::rc_list_push(acc, OperationModifier::Idempotent); @@ -8350,7 +8498,9 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (kw.clone().as_str() == "readonly".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("readonly".to_string())) + { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8360,7 +8510,9 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (kw.clone().as_str() == "hermetic".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("hermetic".to_string())) + { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8419,13 +8571,19 @@ pub fn parse_status_pattern(tokens: Rc>>, ctx: Rc) - match next_tok { Some(t) => { if (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "xx".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "xx".to_string(), + ))) { Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprLiteral { value: Rc::new(LiteralValue::LitStr { - value: format!("{}xx", n), + value: + crate::v2_std_text::host_string_text_from_rust_host( + format!("{}xx", n), + ), }), }), Rc::new(vec![]), @@ -8546,7 +8704,10 @@ pub fn parse_optional_response_block( let is_response = match tok { Some(t) => { (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "response".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "response".to_string(), + ))) } None => false, }; @@ -8703,7 +8864,10 @@ pub fn parse_optional_mock_response_block( let is_mock = match tok { Some(t) => { (is_ident_shape(t.shape.clone()) - && (t.text.clone().as_str() == "mock_response".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "mock_response".to_string(), + ))) } None => false, }; @@ -9043,7 +9207,11 @@ pub fn parse_resource_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok_keyword_text(tok.clone()); - if (kw_text.clone().as_str() == "capability".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "capability".to_string(), + )) + { let r = parse_capability(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ResPropResult { @@ -9064,7 +9232,11 @@ pub fn parse_resource_entries( continue; } } else { - if (kw_text.clone().as_str() == "acquire".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "acquire".to_string(), + )) + { let r = expect( Rc::new( tokens @@ -9103,7 +9275,11 @@ pub fn parse_resource_entries( continue; } } else { - if (kw_text.clone().as_str() == "release".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "release".to_string(), + )) + { let r = expect( Rc::new( tokens @@ -9481,7 +9657,9 @@ pub fn parse_io_blocks_acc( }); } else { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (kw.clone().as_str() == "input".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("input".to_string())) + { let r = expect( Rc::new( tokens @@ -9535,7 +9713,9 @@ pub fn parse_io_blocks_acc( continue; } } else { - if (kw.clone().as_str() == "output".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("output".to_string())) + { let r = expect( Rc::new( tokens @@ -10073,10 +10253,14 @@ pub fn parse_stmt(tokens: Rc>>, ctx: Rc) -> Rc { let kw_text = tok_keyword_text(tok.clone()); - if (kw_text.clone().as_str() == "let".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("let".to_string())) + { parse_let(tokens.clone(), ctx) } else { - if (kw_text.clone().as_str() == "return".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("return".to_string())) + { parse_return(tokens.clone(), ctx) } else { if peek_is_eq_after_ident(tokens.clone()) { @@ -10229,10 +10413,12 @@ pub fn parse_constrained_assignment( } } -pub fn peek_text_is(tokens: Rc>>, expected: String) -> bool { +pub fn peek_text_is(tokens: Rc>>, expected: Rc>) -> bool { match tokens.first().cloned() { Some(t) => { - (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == expected.as_str())) + (is_ident_shape(t.shape.clone()) + && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(expected))) } None => false, } @@ -10631,12 +10817,17 @@ pub fn parse_expr_loop( } } -pub fn find_operator_bp(ops: Rc>>, symbol: String) -> Option { +pub fn find_operator_bp( + ops: Rc>>, + symbol: Rc>, +) -> Option { { let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (op.symbol.clone().as_str() == symbol.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(op.symbol.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(symbol.clone())) + { __result.push(op); } } @@ -10663,12 +10854,17 @@ pub fn infix_bp(tokens: Rc>>) -> Option { } } -pub fn find_operator_binop(ops: Rc>>, symbol: String) -> Option { +pub fn find_operator_binop( + ops: Rc>>, + symbol: Rc>, +) -> Option { { let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (op.symbol.clone().as_str() == symbol.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(op.symbol.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(symbol.clone())) + { __result.push(op); } } @@ -10959,18 +11155,18 @@ pub fn parse_caret_expr(tokens: Rc>>, ctx: Rc) -> Rc Rc::new(ExprResult { expr: parse_recovery_expr( span.clone(), - format!( + crate::v2_std_text::host_string_text_from_rust_host(format!( "expected identifier or `(` after `^`, found {}", found.clone() - ), + )), ), tokens: after_caret.clone(), ctx: ctx.clone(), err: Some(parse_error( - format!( + crate::v2_std_text::host_string_text_from_rust_host(format!( "expected identifier or `(` after `^`, found {}", found.clone() - ), + )), span.clone(), )), }) @@ -11012,41 +11208,57 @@ pub fn parse_primary(tokens: Rc>>, ctx: Rc) -> Rc { - if (kw_text.clone().as_str() == "match".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "match".to_string(), + )) + { parse_match(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() == "if".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "if".to_string(), + )) + { parse_if(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() == "for".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + kw_text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "for".to_string(), + )) { parse_for(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() == "let".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + kw_text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "let".to_string(), + )) { parse_let(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() - == "return".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + kw_text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "return".to_string(), + )) { parse_return(tokens.clone(), ctx.clone()) } else { - if (kw_text.clone().as_str() - == "fn".to_string().as_str()) - { - parse_fn_lambda(tokens.clone(), ctx.clone()) - } else { - { - let kw_name = tok_keyword_to_name(tok.clone()); - match kw_name { + if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) == crate::v2_std_text::host_string_text_to_rust_host("fn".to_string())) { + parse_fn_lambda(tokens.clone(), ctx.clone()) + } else { + { + let kw_name = tok_keyword_to_name(tok.clone()); +match kw_name { Some(n) => parse_ident_expr(tokens.clone(), ctx.clone(), n.clone()), None => Rc::new(ExprResult { - expr: parse_recovery_expr(span.clone(), format!("expected expression, found keyword '{}'", kw_text.clone())), + expr: parse_recovery_expr(span.clone(), crate::v2_std_text::host_string_text_from_rust_host(format!("expected expression, found keyword '{}'", kw_text.clone()))), tokens: tokens.clone(), ctx: ctx.clone(), - err: Some(parse_error(format!("expected expression, found keyword '{}'", kw_text.clone()), span.clone())), + err: Some(parse_error(crate::v2_std_text::host_string_text_from_rust_host(format!("expected expression, found keyword '{}'", kw_text.clone())), span.clone())), }), } - } - } +} + } } } } @@ -11163,12 +11375,18 @@ pub fn parse_primary(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc, - name: String, + name: Rc>, ) -> Rc { { let span = token_span(tokens.clone().first().cloned()); @@ -11329,7 +11547,7 @@ pub fn parse_ident_expr( } } -pub fn is_uppercase_start(name: String) -> bool { +pub fn is_uppercase_start(name: Rc>) -> bool { { let ch = v1_rt::char_at(&name, 0); ((ch.clone() >= "A".to_string()) && (ch.clone() <= "Z".to_string())) @@ -11388,7 +11606,10 @@ pub fn try_postfix( } } Some(TokenShape::ShIdent) => { - if (tok.clone().unwrap().text.clone().as_str() == "as".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + tok.clone().unwrap().text.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host("as".to_string())) + { if (13 < min_bp) { Rc::new(PostfixResult { expr: lhs.clone(), @@ -11562,8 +11783,10 @@ pub fn is_constraint_bracket(tokens: Rc>>) -> bool { match tokens.get(1 as usize).cloned() { Some(t) => { if is_ident_shape(t.shape.clone()) { - ((t.text.clone().as_str() == "after".to_string().as_str()) - || (t.text.clone().as_str() == "when".to_string().as_str())) + ((crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("after".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("when".to_string()))) } else { false } @@ -11626,8 +11849,12 @@ pub fn parse_constraint_list( let is_constraint_kw = match tok.clone() { Some(t) => { (is_ident_shape(t.shape.clone()) - && ((t.text.clone().as_str() == "after".to_string().as_str()) - || (t.text.clone().as_str() == "when".to_string().as_str()))) + && ((crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("after".to_string())) + || (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "when".to_string(), + )))) } None => false, }; @@ -12590,7 +12817,9 @@ pub fn looks_like_arm_start(tokens: Rc>>) -> bool { match sh { Some(TokenShape::ShIdent) => { let n = tok.clone().unwrap().text.clone(); - if (n.clone().as_str() == "_".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("_".to_string())) + { peek_is_fat_arrow_at(tokens.clone(), 1) } else { if is_uppercase_start(n.clone()) { @@ -12761,7 +12990,9 @@ pub fn parse_pattern(tokens: Rc>>, ctx: Rc) -> Rc { let n = tok.clone().unwrap().text.clone(); - if (n.clone().as_str() == "_".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("_".to_string())) + { Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), tokens: Rc::new( @@ -12901,7 +13132,7 @@ pub fn parse_pattern(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc, - name: String, + name: Rc>, ) -> Rc { { let span = token_span(tokens.clone().first().cloned()); @@ -13395,7 +13626,7 @@ pub fn parse_for(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc, - name: String, + name: Rc>, span: Rc, ) -> Rc { { @@ -14304,8 +14535,15 @@ pub fn parse_brace_expr(tokens: Rc>>, ctx: Rc) -> Rc match sh { Some(TokenShape::ShKeyword) => { let brace_kw = tok_keyword_text(tok.clone()); - if ((brace_kw.clone().as_str() == "let".to_string().as_str()) - || (brace_kw.clone().as_str() == "return".to_string().as_str())) + if ((crate::v2_std_text::host_string_text_to_rust_host(brace_kw.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "let".to_string(), + )) + || (crate::v2_std_text::host_string_text_to_rust_host( + brace_kw.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "return".to_string(), + ))) { { let r = parse_stmts(tokens.clone(), ctx); diff --git a/src/v1/stage0/src/v1_compiler_resolve.rs b/src/v1/stage0/src/v1_compiler_resolve.rs index 1b987853c7b..25905d6c08b 100644 --- a/src/v1/stage0/src/v1_compiler_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_resolve.rs @@ -35,7 +35,7 @@ pub struct ResolvedModule { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ResolvedImport { - pub module_path: String, + pub module_path: Rc>, pub is_all: bool, pub specific_names: Rc>, pub target_module: Option>, @@ -43,8 +43,8 @@ pub struct ResolvedImport { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DepEdge { - pub from_module: String, - pub to_module: String, + pub from_module: Rc>, + pub to_module: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -53,7 +53,7 @@ pub struct ResolveAccum { pub diagnostics: Rc>>, } -pub fn map_has(m: Rc>, key: String) -> bool { +pub fn map_has(m: Rc>, key: Rc>) -> bool { match v1_rt::map_get(&m, key) { Some(_) => true, None => false, @@ -67,7 +67,7 @@ pub fn resolve_modules( { let dup_diags = check_duplicate_modules(modules.clone(), source_indices.clone()); let module_index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, @@ -77,12 +77,12 @@ pub fn resolve_modules( }, ); let export_sets = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>>(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>>>, m: Rc| { let exported = get_exported_names(m.clone(), source_indices.clone()); let exported_set = exported.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |inner_acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |inner_acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(inner_acc, name.clone(), true) }, ); @@ -95,7 +95,10 @@ pub fn resolve_modules( ); let resolve_accum = modules.clone().iter().cloned().fold( Rc::new(ResolveAccum { - imports_by_name: v1_rt::rc_empty_map::>>>(), + imports_by_name: v1_rt::rc_empty_map::< + Rc>, + Rc>>, + >(), diagnostics: Rc::new(vec![]), }), |acc: Rc, m: Rc| { @@ -137,7 +140,7 @@ pub fn resolve_modules( .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, i64>(), |acc: Rc>, pair: (i64, String)| { v1_rt::rc_map_insert(acc, pair.1.clone(), pair.0.clone()) }, @@ -185,7 +188,10 @@ pub fn resolve_modules( } } -pub fn find_module(module_index: Rc>>, path: String) -> Option> { +pub fn find_module( + module_index: Rc>>, + path: Rc>, +) -> Option> { v1_rt::map_get(&module_index, path) } @@ -258,7 +264,7 @@ pub struct ImportResolveResult { pub fn resolve_import( import: Rc, module_index: Rc>>, - importing_module: String, + importing_module: Rc>, export_sets: Rc>>>, source_indices: Rc>>, ) -> Rc { @@ -291,7 +297,7 @@ pub fn resolve_import( Some(target_mod) => { let exported_set = match v1_rt::map_get(&export_sets, import_path.clone()) { Some(set) => set.clone(), - None => v1_rt::rc_empty_map::(), + None => v1_rt::rc_empty_map::>, bool>(), }; let name_diags = if import_is_all(import.clone()) { Rc::new(vec![]) @@ -392,7 +398,7 @@ pub fn get_exported_names( pub fn get_item_name( item: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, item) } @@ -429,7 +435,7 @@ pub fn check_duplicate_modules( { let result = modules.iter().cloned().fold( Rc::new(DuplicateCheckState { - seen_names: v1_rt::rc_empty_map::(), + seen_names: v1_rt::rc_empty_map::>, bool>(), diagnostics: Rc::new(vec![]), }), |state: Rc, m: Rc| { @@ -473,8 +479,8 @@ pub struct TopoResult { pub fn adjacency_add_edge( adjacency: Rc>>>, - from_module: String, - to_module: String, + from_module: Rc>, + to_module: Rc>, ) -> Rc>>> { { let existing = match v1_rt::map_get(&adjacency, from_module.clone()) { @@ -489,8 +495,10 @@ pub fn adjacency_add_edge( } } -pub fn topo_sort_key(name: String) -> String { - if (name.clone().as_str() == "std.types".to_string().as_str()) { +pub fn topo_sort_key(name: Rc>) -> Rc> { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) + { "".to_string() } else { name.clone() @@ -512,7 +520,9 @@ pub fn topological_sort( let has_std_types = { let mut __found = false; for name in module_names.clone().iter().cloned() { - if (name.clone().as_str() == "std.types".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) + { __found = true; break; } @@ -549,22 +559,30 @@ pub fn topological_sort( let imports_std_types = { let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { - if (authored_name_at(source_indices.clone(), imp.clone()) - .as_str() - == "std.types".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host( + authored_name_at(source_indices.clone(), imp.clone()), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "std.types".to_string(), + )) { __found = true; break; } } __found }; - if ((((m_name.clone().as_str() != "std.types".to_string().as_str()) - && (m_name.clone().as_str() - != "std.algebra".to_string().as_str())) - && (m_name.clone().as_str() - != "std.error_primitives".to_string().as_str())) - && (imports_std_types.clone() == false)) + if ((((crate::v2_std_text::host_string_text_to_rust_host( + m_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "std.types".to_string(), + )) && (crate::v2_std_text::host_string_text_to_rust_host( + m_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "std.algebra".to_string(), + ))) && (crate::v2_std_text::host_string_text_to_rust_host( + m_name.clone(), + ) != crate::v2_std_text::host_string_text_to_rust_host( + "std.error_primitives".to_string(), + ))) && (imports_std_types.clone() == false)) { Rc::new(vec![Rc::new(DepEdge { from_module: "std.types".to_string(), @@ -587,21 +605,24 @@ pub fn topological_sort( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>>(), + v1_rt::rc_empty_map::>, Rc>>(), |acc: Rc>>>, edge: Rc| { adjacency_add_edge(acc, edge.from_module.clone(), edge.to_module.clone()) }, ); let in_degree_map = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), + v1_rt::rc_empty_map::>, i64>(), |acc: Rc>, m: Rc| { let m_name = authored_name_at(source_indices.clone(), m.clone()); let imports_std_types = { let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { - if (authored_name_at(source_indices.clone(), imp.clone()).as_str() - == "std.types".to_string().as_str()) - { + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + imp.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host( + "std.types".to_string(), + )) { __found = true; break; } @@ -609,9 +630,18 @@ pub fn topological_sort( __found }; let implicit_std_types_in_degree = if ((((has_std_types.clone() - && (m_name.clone().as_str() != "std.types".to_string().as_str())) - && (m_name.clone().as_str() != "std.algebra".to_string().as_str())) - && (m_name.clone().as_str() != "std.error_primitives".to_string().as_str())) + && (crate::v2_std_text::host_string_text_to_rust_host(m_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "std.types".to_string(), + ))) + && (crate::v2_std_text::host_string_text_to_rust_host(m_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "std.algebra".to_string(), + ))) + && (crate::v2_std_text::host_string_text_to_rust_host(m_name.clone()) + != crate::v2_std_text::host_string_text_to_rust_host( + "std.error_primitives".to_string(), + ))) && (imports_std_types.clone() == false)) { 1 @@ -642,9 +672,9 @@ pub fn topological_sort( .iter() .cloned() .collect(); - __sorted.sort_by(|a: &String, b: &String| { - let __ka = (|name: String| topo_sort_key(name.clone()))(a.clone()); - let __kb = (|name: String| topo_sort_key(name.clone()))(b.clone()); + __sorted.sort_by(|a: &Rc>, b: &Rc>| { + let __ka = (|name: Rc>| topo_sort_key(name.clone()))(a.clone()); + let __kb = (|name: Rc>| topo_sort_key(name.clone()))(b.clone()); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted @@ -665,8 +695,8 @@ pub fn topological_sort( } else { { let sorted_set = result.sorted.clone().iter().cloned().fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -720,7 +750,7 @@ pub fn kahn_drain( sorted: sorted.clone(), in_degree_map: in_degree_map.clone(), }), - |state: Rc, node: String| { + |state: Rc, node: Rc>| { let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); { let new_sorted = v1_rt::rc_list_push(state.sorted, node.clone()); @@ -730,7 +760,7 @@ pub fn kahn_drain( }; let new_degrees = neighbors.clone().iter().cloned().fold( state.in_degree_map, - |deg_map: Rc>, neighbor: String| { + |deg_map: Rc>, neighbor: Rc>| { let current = match v1_rt::map_get(°_map, neighbor.clone()) { Some(d) => d.clone(), None => 0, @@ -780,8 +810,8 @@ pub fn kahn_drain( .iter() .cloned() .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, name: String| { + v1_rt::rc_empty_map::>, bool>(), + |acc: Rc>, name: Rc>| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -790,9 +820,9 @@ pub fn kahn_drain( .iter() .cloned() .collect(); - __sorted.sort_by(|a: &String, b: &String| { - let __ka = (|name: String| name.clone())(a.clone()); - let __kb = (|name: String| name.clone())(b.clone()); + __sorted.sort_by(|a: &Rc>, b: &Rc>| { + let __ka = (|name: Rc>| name.clone())(a.clone()); + let __kb = (|name: Rc>| name.clone())(b.clone()); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted diff --git a/src/v1/stage0/src/v1_compiler_runtime_go.rs b/src/v1/stage0/src/v1_compiler_runtime_go.rs index f51dc3d24db..7510b3b1428 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_go.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_go.rs @@ -10,7 +10,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn go_rt_header() -> String { +pub fn go_rt_header() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -36,7 +36,7 @@ pub fn go_rt_header() -> String { ) } -pub fn go_rt_concat() -> String { +pub fn go_rt_concat() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -67,15 +67,15 @@ pub fn go_rt_concat() -> String { ) } -pub fn go_rt_slice_ops() -> String { +pub fn go_rt_slice_ops() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("func Map(xs interface{}, fn interface{}) interface{} {\n".to_string(), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tout := make([]interface{}, len(items))\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor i, x := range items {\n".to_string()), "\t\t\tout[i] = call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Interface()\n".to_string()), "\t\t}\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Filter(xs interface{}, fn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tout := make([]interface{}, 0, len(items))\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tif call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Bool() {\n".to_string()), "\t\t\t\tout = append(out, x)\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Any(xs interface{}, fn interface{}) bool {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tif call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Bool() {\n".to_string()), "\t\t\t\treturn true\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn false\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn false\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func All(xs interface{}, fn interface{}) bool {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tif !call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Bool() {\n".to_string()), "\t\t\t\treturn false\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn true\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn true\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func FlatMap(xs interface{}, fn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tout := make([]interface{}, 0)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tchunk := call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Interface()\n".to_string()), "\t\t\tif nested, ok := chunk.([]interface{}); ok {\n".to_string()), "\t\t\t\tout = append(out, nested...)\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Fold(xs interface{}, init interface{}, fn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tacc := init\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tacc = call.Call([]reflect.Value{reflect.ValueOf(acc), reflect.ValueOf(x)})[0].Interface()\n".to_string()), "\t\t}\n".to_string()), "\t\treturn acc\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn init\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func SortBy(xs interface{}, keyFn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(keyFn)\n".to_string()), "\t\tout := append([]interface{}(nil), items...)\n".to_string()), "\t\tsort.SliceStable(out, func(i, j int) bool {\n".to_string()), "\t\t\tki := call.Call([]reflect.Value{reflect.ValueOf(out[i])})[0].Interface()\n".to_string()), "\t\t\tkj := call.Call([]reflect.Value{reflect.ValueOf(out[j])})[0].Interface()\n".to_string()), "\t\t\treturn fmt.Sprint(ki) < fmt.Sprint(kj)\n".to_string()), "\t\t})\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Lookup(m interface{}, key interface{}) interface{} {\n".to_string()), "\tswitch table := m.(type) {\n".to_string()), "\tcase map[string]interface{}:\n".to_string()), "\t\treturn table[fmt.Sprint(key)]\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn nil\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()) } -pub fn go_rt_algebra() -> String { +pub fn go_rt_algebra() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("func Init(algebra interface{}, node interface{}) interface{} {\n".to_string(), "\tv := reflect.ValueOf(algebra)\n".to_string()), "\tinitFn := v.FieldByName(\"Init\")\n".to_string()), "\tif !initFn.IsValid() {\n".to_string()), "\t\treturn nil\n".to_string()), "\t}\n".to_string()), "\treturn initFn.Call([]reflect.Value{reflect.ValueOf(node)})[0].Interface()\n".to_string()), "}\n\n".to_string()), "func Step(algebra interface{}, acc interface{}, edge interface{}, sub interface{}) interface{} {\n".to_string()), "\tv := reflect.ValueOf(algebra)\n".to_string()), "\tstepFn := v.FieldByName(\"Step\")\n".to_string()), "\tif !stepFn.IsValid() {\n".to_string()), "\t\treturn acc\n".to_string()), "\t}\n".to_string()), "\treturn stepFn.Call([]reflect.Value{reflect.ValueOf(acc), reflect.ValueOf(edge), reflect.ValueOf(sub)})[0].Interface()\n".to_string()), "}\n\n".to_string()) } -pub fn go_runtime_source() -> String { +pub fn go_runtime_source() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat(go_rt_header(), go_rt_concat()), diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index 3df8222f6a3..757278006e8 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -10,7 +10,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn rt_header() -> String { +pub fn rt_header() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -29,27 +29,27 @@ pub fn rt_header() -> String { ) } -pub fn rt_text_lookup_work_counter() -> String { +pub fn rt_text_lookup_work_counter() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string(), "use std::cell::Cell;\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "thread_local! {\n".to_string()), " static TEXT_LOOKUP_CHARS_WALKED: Cell = Cell::new(0);\n".to_string()), "}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "pub fn reset_text_lookup_chars_walked() {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(0));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "pub fn reset_text_lookup_chars_walked() {}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "pub fn take_text_lookup_chars_walked() -> u64 {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| {\n".to_string()), " let walked = c.get();\n".to_string()), " c.set(0);\n".to_string()), " walked\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "pub fn take_text_lookup_chars_walked() -> u64 { 0 }\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "fn record_substring_chars_walked(s: &str, start: usize, take_len: usize) {\n".to_string()), " let walked = if s.is_ascii() {\n".to_string()), " take_len as u64\n".to_string()), " } else {\n".to_string()), " (start + take_len) as u64\n".to_string()), " };\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(c.get() + walked));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "fn record_substring_chars_walked(_s: &str, _start: usize, _take_len: usize) {}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "fn record_source_chars_slice_walked(units: u64) {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(c.get() + units));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "fn record_source_chars_slice_walked(_units: u64) {}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "pub fn record_source_chars_index_lookup() {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(c.get() + 1));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "pub fn record_source_chars_index_lookup() {}\n\n".to_string()) } -pub fn rt_concat_trait() -> String { +pub fn rt_concat_trait() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub trait V2Concat {\n".to_string(), " fn v1_concat(self, other: Self) -> Self;\n".to_string()), "}\n\n".to_string()), "impl V2Concat for String {\n".to_string()), " fn v1_concat(mut self, other: String) -> String { self.push_str(&other); self }\n".to_string()), "}\n\n".to_string()), "impl V2Concat for Vec {\n".to_string()), " fn v1_concat(mut self, other: Vec) -> Vec { self.extend(other); self }\n".to_string()), "}\n\n".to_string()), "pub fn concat(a: T, b: T) -> T { a.v1_concat(b) }\n\n".to_string()) } -pub fn rt_string_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) +pub fn rt_string_ops() -> Rc> { + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8.\n".to_string()), "pub fn utf8_decode_bytes(bytes: &[u8]) -> Result {\n".to_string()), " String::from_utf8(bytes.to_vec()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))\n".to_string()), "}\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) } -pub fn rt_collection_ops() -> String { +pub fn rt_collection_ops() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Clone, Debug, PartialEq)]\n".to_string(), "pub enum Witness {\n".to_string()), " Holds { value: V },\n".to_string()), " Violates { diagnostic: String },\n".to_string()), "}\n\n".to_string()), "pub fn lookup(table: &HashMap, key: String) -> Witness {\n".to_string()), " match table.get(&key).cloned() {\n".to_string()), " Some(value) => Witness::Holds { value },\n".to_string()), " None => Witness::Violates {\n".to_string()), " diagnostic: format!(\"lookup miss for key {}\", key),\n".to_string()), " },\n".to_string()), " }\n".to_string()), "}\n\n".to_string()), "pub fn index_by String>(list: Vec, key_fn: F) -> HashMap {\n".to_string()), " let mut map = HashMap::new();\n".to_string()), " for item in list { let key = key_fn(&item); map.insert(key, item); }\n".to_string()), " map\n".to_string()), "}\n\n".to_string()), "pub fn empty_map() -> HashMap { HashMap::new() }\n\n".to_string()), "pub fn map_insert(mut map: HashMap, key: K, value: V) -> HashMap {\n".to_string()), " map.insert(key, value); map\n".to_string()), "}\n\n".to_string()), "pub fn map_merge(mut base: HashMap, overlay: HashMap) -> HashMap {\n".to_string()), " base.extend(overlay); base\n".to_string()), "}\n\n".to_string()), "pub fn map_get(m: &HashMap, key: K) -> Option {\n".to_string()), " m.get(&key).cloned()\n".to_string()), "}\n\n".to_string()), "pub fn map_keys(m: &HashMap) -> Vec { m.keys().cloned().collect() }\n\n".to_string()), "pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() }\n\n".to_string()), "// Sound identity hint (see 04_infer.dag substitute_generics): returns true =>\n".to_string()), "// the two are structurally equal. The compiled realization answers with pointer\n".to_string()), "// identity (conservative: may say false when equal); never true-when-unequal, so\n".to_string()), "// callers that return the original on true preserve output structure. Owned Rc\n".to_string()), "// args (cheap refcount bump) keep the inner element pointers, so ptr_eq on the\n".to_string()), "// clones equals ptr_eq on the originals -- lets the .dag pass args by value and\n".to_string()), "// emit through the normal clone path (no all-args-by-ref emit rule needed).\n".to_string()), "pub fn rc_ptr_eq(a: Rc, b: Rc) -> bool { Rc::ptr_eq(&a, &b) }\n\n".to_string()), "pub fn rc_vec_ptr_eq(a: Rc>>, b: Rc>>) -> bool {\n".to_string()), " a.len() == b.len() && a.iter().zip(b.iter()).all(|(x, y)| Rc::ptr_eq(x, y))\n".to_string()), "}\n\n".to_string()), "pub fn map_values(m: &HashMap) -> Vec { m.values().cloned().collect() }\n\n".to_string()), "pub fn list_concat(mut a: Vec, b: Vec) -> Vec { a.extend(b); a }\n\n".to_string()), "pub fn list_push(mut list: Vec, item: T) -> Vec { list.push(item); list }\n\n".to_string()), "pub fn append(list: Rc>, item: T) -> Vec {\n".to_string()), " let mut v = (*list).clone();\n".to_string()), " v.push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn chars_to_string(chars: &Rc>, start: i64, end: i64) -> String {\n".to_string()), " let len = chars.len();\n".to_string()), " let start = (start.max(0) as usize).min(len);\n".to_string()), " let end = (end.max(0) as usize).min(len).max(start);\n".to_string()), " let units = (end.saturating_sub(start)) as u64;\n".to_string()), " record_source_chars_slice_walked(units);\n".to_string()), " chars[start..end]\n".to_string()), " .iter()\n".to_string()), " .filter_map(|&cp| char::from_u32(cp as u32))\n".to_string()), " .collect()\n".to_string()), "}\n\n".to_string()), "pub fn parse_int(s: String) -> Option { s.parse::().ok() }\n\n".to_string()), "pub fn map_contains_key(m: &HashMap, key: K) -> bool {\n".to_string()), " m.contains_key(&key)\n".to_string()), "}\n\n".to_string()), "pub fn map_has(m: &HashMap, key: K) -> bool {\n".to_string()), " m.contains_key(&key)\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_set() -> Rc> {\n".to_string()), " Rc::new(BTreeSet::new())\n".to_string()), "}\n\n".to_string()), "pub fn rc_set_insert(mut s: Rc>, x: T) -> Rc> {\n".to_string()), " Rc::make_mut(&mut s).insert(x);\n".to_string()), " s\n".to_string()), "}\n\n".to_string()), "pub fn rc_set_union(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut out = a;\n".to_string()), " for x in b.iter().cloned() {\n".to_string()), " Rc::make_mut(&mut out).insert(x);\n".to_string()), " }\n".to_string()), " out\n".to_string()), "}\n\n".to_string()), "pub fn set_contains>>(s: S, x: T) -> bool {\n".to_string()), " s.as_ref().contains(&x)\n".to_string()), "}\n\n".to_string()), "pub fn reverse(list: Rc>) -> Rc> {\n".to_string()), " let mut v = (*list).clone(); v.reverse(); Rc::new(v)\n".to_string()), "}\n\n".to_string()), "pub fn replace(s: String, from: String, to: String) -> String {\n".to_string()), " s.replace(&from, &to)\n".to_string()), "}\n\n".to_string()) } -pub fn rt_scanner_ops() -> String { +pub fn rt_scanner_ops() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn scan_while(s: &str, start: i64, pred: impl Fn(String) -> bool) -> i64 {\n".to_string(), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let mut pos = start.min(bytes.len());\n".to_string()), " while pos < bytes.len() && pred(String::from(bytes[pos] as char)) { pos += 1; }\n".to_string()), " return pos as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if pred(ch.to_string()) { pos += 1; } else { break; }\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()), "pub fn skip_horizontal_ws(s: &str, start: i64) -> i64 {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let mut pos = start.min(bytes.len());\n".to_string()), " while pos < bytes.len() && (bytes[pos] == b' ' || bytes[pos] == b'\\t') { pos += 1; }\n".to_string()), " return pos as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if ch == ' ' || ch == '\\t' { pos += 1; } else { break; }\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()), "pub fn scan_to_eol(s: &str, start: i64) -> i64 {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let start = start.min(bytes.len());\n".to_string()), " for i in start..bytes.len() { if bytes[i] == b'\\n' { return i as i64; } }\n".to_string()), " return bytes.len() as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if ch == '\\n' { return pos as i64; }\n".to_string()), " pos += 1;\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()), "pub fn scan_string_end(s: &str, start: i64) -> i64 {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let mut pos = start.min(bytes.len());\n".to_string()), " while pos < bytes.len() {\n".to_string()), " if bytes[pos] == b'\\\\' { pos += 2; }\n".to_string()), " else if bytes[pos] == b'\\\"' { return (pos + 1) as i64; }\n".to_string()), " else { pos += 1; }\n".to_string()), " }\n".to_string()), " return bytes.len() as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " let mut escaped = false;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if escaped {\n".to_string()), " escaped = false;\n".to_string()), " pos += 1;\n".to_string()), " } else if ch == '\\\\' {\n".to_string()), " escaped = true;\n".to_string()), " pos += 1;\n".to_string()), " } else if ch == '\\\"' {\n".to_string()), " return (pos + 1) as i64;\n".to_string()), " } else {\n".to_string()), " pos += 1;\n".to_string()), " }\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()) } -pub fn rt_unicode_ops() -> String { +pub fn rt_unicode_ops() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -69,11 +69,11 @@ pub fn rt_unicode_ops() -> String { ) } -pub fn rt_rc_container_ops() -> String { +pub fn rt_rc_container_ops() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } -pub fn rt_filesystem() -> String { +pub fn rt_filesystem() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -103,11 +103,11 @@ pub fn rt_filesystem() -> String { ) } -pub fn rt_hash_ops() -> String { +pub fn rt_hash_ops() -> Rc> { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("const FNV1A64_OFFSET: u64 = 0xcbf29ce484222325;\n".to_string(), "const FNV1A64_PRIME: u64 = 0x100000001b3;\n\n".to_string()), "fn fnv1a64(bytes: &[u8]) -> u64 {\n".to_string()), " let mut hash = FNV1A64_OFFSET;\n".to_string()), " for b in bytes {\n".to_string()), " hash ^= *b as u64;\n".to_string()), " hash = hash.wrapping_mul(FNV1A64_PRIME);\n".to_string()), " }\n".to_string()), " hash\n".to_string()), "}\n\n".to_string()), "pub type Hash = String;\n\n".to_string()), "const HASH_DIGEST_LEN: usize = 16;\n\n".to_string()), "pub fn is_hash_digest(s: &str) -> bool {\n".to_string()), " s.len() == HASH_DIGEST_LEN && s.bytes().all(|b| b.is_ascii_hexdigit())\n".to_string()), "}\n\n".to_string()), "fn expect_hash_digest(s: &str, arg: &str) {\n".to_string()), " if !is_hash_digest(s) {\n".to_string()), " panic!(\"{} must be a 16-char hex Hash digest\", arg);\n".to_string()), " }\n".to_string()), "}\n\n".to_string()), "pub fn atom_identity_hash(s: String) -> Hash {\n".to_string()), " format!(\"{:016x}\", fnv1a64(s.as_bytes()))\n".to_string()), "}\n\n".to_string()), "pub fn hash_combine(a: Hash, b: Hash) -> Hash {\n".to_string()), " expect_hash_digest(&a, \"a\");\n".to_string()), " expect_hash_digest(&b, \"b\");\n".to_string()), " let mut bytes = a.into_bytes();\n".to_string()), " bytes.push(0);\n".to_string()), " bytes.extend_from_slice(b.as_bytes());\n".to_string()), " format!(\"{:016x}\", fnv1a64(&bytes))\n".to_string()), "}\n\n".to_string()) } -pub fn rust_runtime_source() -> String { +pub fn rust_runtime_source() -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index 47f5de648ab..a9c5526f97e 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -4,6 +4,7 @@ use self::Stage0CrateKind::*; use crate::extdeps_cargo::CargoDepSource::{LocalPathDep, RegistryDep}; pub use crate::extdeps_cargo::{CargoDepSource, CargoDependency, CargoFeature}; +pub use crate::extdeps_cargo_version::render_cargo_package_header_prefix; pub use crate::v1_compiler_emit_rust::{emit_cargo_dep, emit_non_empty_wrappers}; use crate::v1_rt; use crate::v1_rt::Witness; @@ -26,10 +27,10 @@ pub enum Stage0CrateKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Stage0CrateSpec { - pub package_name: String, - pub crate_dir: String, + pub package_name: Rc>, + pub crate_dir: Rc>, pub kind: Stage0CrateKind, - pub header_doc: String, + pub header_doc: Rc>, pub modules: Rc>, pub dependencies: Rc>>, pub features: Rc>>, @@ -41,7 +42,7 @@ pub struct Stage0CratePlan { pub crates: Rc>>, } -pub fn stage0_crate_allow_block() -> String { +pub fn stage0_crate_allow_block() -> Rc> { Rc::new(vec![ "#![allow(".to_string(), " unused_imports,".to_string(), @@ -58,7 +59,7 @@ pub fn stage0_crate_allow_block() -> String { .join(&"\n".to_string()) } -pub fn stage0_core_header_doc() -> String { +pub fn stage0_core_header_doc() -> Rc> { Rc::new(vec![ "//! Generated by regen_stage0 -- do not edit.".to_string(), "//!".to_string(), @@ -75,7 +76,7 @@ pub fn stage0_core_header_doc() -> String { .join(&"\n".to_string()) } -pub fn stage0_emit_core_header_doc() -> String { +pub fn stage0_emit_core_header_doc() -> Rc> { Rc::new(vec![ "//! Generated by regen_stage0 -- do not edit.".to_string(), "//!".to_string(), @@ -89,7 +90,7 @@ pub fn stage0_emit_core_header_doc() -> String { .join(&"\n".to_string()) } -pub fn render_stage0_crate_dep(dep: Rc) -> String { +pub fn render_stage0_crate_dep(dep: Rc) -> Rc> { match (*dep.source.clone()).clone() { CargoDepSource::RegistryDep { version, features, .. @@ -104,7 +105,7 @@ pub fn render_stage0_crate_dep(dep: Rc) -> String { } } -pub fn render_stage0_crate_feature(feature: Rc) -> String { +pub fn render_stage0_crate_feature(feature: Rc) -> Rc> { if ((feature.dependencies.clone().len() as i64) == 0) { v1_rt::concat(feature.name.clone(), " = []\n".to_string()) } else { @@ -131,7 +132,9 @@ pub fn render_stage0_crate_feature(feature: Rc) -> String { } } -pub fn render_stage0_crate_features_section(features: Rc>>) -> String { +pub fn render_stage0_crate_features_section( + features: Rc>>, +) -> Rc> { if ((features.clone().len() as i64) == 0) { "".to_string() } else { @@ -165,11 +168,8 @@ pub fn emit_stage0_crate_manifest(spec: Rc) -> Rc { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "[package]\nname = \"".to_string(), - spec.package_name.clone(), - ), - "\"\nversion = \"0.1.0\"\nedition = \"2021\"".to_string(), + render_cargo_package_header_prefix(spec.package_name.clone()), + "\nedition = \"2021\"".to_string(), ), render_stage0_crate_features_section(spec.features.clone()), ), @@ -184,7 +184,7 @@ pub fn emit_stage0_crate_manifest(spec: Rc) -> Rc { } } -pub fn render_stage0_core_lib(spec: Rc) -> String { +pub fn render_stage0_core_lib(spec: Rc) -> Rc> { { let includes = Rc::new({ let mut __result = Vec::new(); @@ -227,7 +227,7 @@ pub fn render_stage0_core_lib(spec: Rc) -> String { } } -pub fn render_stage0_emit_core_lib(spec: Rc) -> String { +pub fn render_stage0_emit_core_lib(spec: Rc) -> Rc> { { let reexports = Rc::new({ let mut __result = Vec::new(); diff --git a/src/v1/stage0/src/v1_compiler_tokenize.rs b/src/v1/stage0/src/v1_compiler_tokenize.rs index 3ffce56192f..9bbb2f59fba 100644 --- a/src/v1/stage0/src/v1_compiler_tokenize.rs +++ b/src/v1/stage0/src/v1_compiler_tokenize.rs @@ -22,7 +22,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn is_keyword_text(text: String) -> bool { +pub fn is_keyword_text(text: Rc>) -> bool { match v1_rt::lookup(&dag_keyword_set(), text) { v1_rt::Witness::Holds { value: _, .. } => true, v1_rt::Witness::Violates { diagnostic: _, .. } => false, @@ -33,18 +33,18 @@ pub fn single_punct() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("(".to_string(), TokenShape::ShLParen); - __m.insert(")".to_string(), TokenShape::ShRParen); - __m.insert("[".to_string(), TokenShape::ShLBracket); - __m.insert("]".to_string(), TokenShape::ShRBracket); - __m.insert(":".to_string(), TokenShape::ShColon); - __m.insert(",".to_string(), TokenShape::ShComma); - __m.insert(".".to_string(), TokenShape::ShDot); - __m.insert("+".to_string(), TokenShape::ShPlus); - __m.insert("*".to_string(), TokenShape::ShStar); - __m.insert("%".to_string(), TokenShape::ShPercent); - __m.insert("/".to_string(), TokenShape::ShSlash); - __m.insert("^".to_string(), TokenShape::ShCaret); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("("), TokenShape::ShLParen); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host(")"), TokenShape::ShRParen); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("["), TokenShape::ShLBracket); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("]"), TokenShape::ShRBracket); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host(":"), TokenShape::ShColon); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host(","), TokenShape::ShComma); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("."), TokenShape::ShDot); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("+"), TokenShape::ShPlus); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("*"), TokenShape::ShStar); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("%"), TokenShape::ShPercent); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("/"), TokenShape::ShSlash); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("^"), TokenShape::ShCaret); Rc::new(__m) }; } @@ -73,12 +73,12 @@ pub struct ScanResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SourceRef { - pub file: String, - pub text: String, + pub file: Rc>, + pub text: Rc>, pub source_chars: Rc>, } -pub fn make_token(text: String, span: Rc, shape: TokenShape) -> Rc { +pub fn make_token(text: Rc>, span: Rc, shape: TokenShape) -> Rc { Rc::new(Token { text: text, span: span, @@ -86,7 +86,7 @@ pub fn make_token(text: String, span: Rc, shape: TokenShape) -> Rc, pos: i64) -> String { +pub fn source_char(source: Rc, pos: i64) -> Rc> { v1_rt::from_code_point(source.source_chars.clone()[(pos) as usize].clone()) } @@ -101,7 +101,7 @@ pub fn source_len(source: Rc) -> i64 { (source.source_chars.clone().len() as i64) } -pub fn source_substring(source: Rc, start: i64, end: i64) -> String { +pub fn source_substring(source: Rc, start: i64, end: i64) -> Rc> { v1_rt::chars_to_string(&source.source_chars.clone(), start, end) } @@ -164,7 +164,7 @@ pub fn source_scan_to_eol(mut source: Rc, mut start: i64) -> i64 { } } -pub fn tokenize(source: String, file: String) -> Rc>> { +pub fn tokenize(source: Rc>, file: Rc>) -> Rc>> { { let c = Rc::new(source.clone().chars().map(|c| c as i64).collect::>()); let src = Rc::new(SourceRef { @@ -509,9 +509,9 @@ pub fn scan_token(source: Rc, pos: Rc, ch: i64) -> Rc, shape: TokenShape, - text: String, + text: Rc>, len: i64, - file: String, + file: Rc>, ) -> Rc { { let token = make_token( @@ -593,12 +593,21 @@ pub fn scan_number(source: Rc, pos: Rc) -> Rc { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum StringScanResult { - ClosedString { content: String, end_pos: i64 }, - InterpolationStart { content: String, end_pos: i64 }, - UnterminatedString { content: String, end_pos: i64 }, + ClosedString { + content: Rc>, + end_pos: i64, + }, + InterpolationStart { + content: Rc>, + end_pos: i64, + }, + UnterminatedString { + content: Rc>, + end_pos: i64, + }, } impl StringScanResult { - pub fn content(&self) -> String { + pub fn content(&self) -> Rc> { match self { StringScanResult::ClosedString { content: __val, .. } => __val.clone(), StringScanResult::InterpolationStart { content: __val, .. } => __val.clone(), @@ -735,13 +744,17 @@ pub fn scan_string_body( }); } else { let ch = source_char(source.clone(), pos.clone()); - if (ch.clone().as_str() == "\"".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("\"".to_string())) + { break Rc::new(StringScanResult::ClosedString { content: acc.join(&"".to_string()), end_pos: pos.clone(), }); } else { - if (ch.clone().as_str() == "\\".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("\\".to_string())) + { if ((pos.clone() + 1) < source_len(source.clone())) { let escaped = source_char(source.clone(), (pos.clone() + 1)); { @@ -762,7 +775,9 @@ pub fn scan_string_body( }); } } else { - if (ch.clone().as_str() == "{".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("{".to_string())) + { if should_start_interpolation(source.clone(), pos.clone()) { break Rc::new(StringScanResult::InterpolationStart { content: acc.join(&"".to_string()), @@ -804,36 +819,59 @@ pub fn should_start_interpolation(source: Rc, pos: i64) -> bool { } } -pub fn process_escapes(raw: String) -> String { +pub fn process_escapes(raw: Rc>) -> Rc> { process_escapes_loop(raw, 0, Rc::new(vec![])) } -pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc>) -> String { +pub fn process_escapes_loop( + mut source: Rc>, + mut pos: i64, + mut acc: Rc>, +) -> Rc> { loop { if (pos.clone() >= v1_rt::string_length(&source)) { break acc.join(&"".to_string()); } else { let ch = v1_rt::char_at(&source, pos.clone()); - if ((ch.clone().as_str() == "\\".to_string().as_str()) + if ((crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("\\".to_string())) && ((pos.clone() + 1) < v1_rt::string_length(&source))) { let next = v1_rt::char_at(&source, (pos.clone() + 1)); - let resolved = if (next.clone().as_str() == "\"".to_string().as_str()) { + let resolved = if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("\"".to_string())) + { "\"".to_string() } else { - if (next.clone().as_str() == "\\".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("\\".to_string())) + { "\\".to_string() } else { - if (next.clone().as_str() == "n".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("n".to_string())) + { "\n".to_string() } else { - if (next.clone().as_str() == "t".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "t".to_string(), + )) + { "\t".to_string() } else { - if (next.clone().as_str() == "{".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + "{".to_string(), + )) + { "{".to_string() } else { - if (next.clone().as_str() == "}".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host( + next.clone(), + ) == crate::v2_std_text::host_string_text_to_rust_host( + "}".to_string(), + )) { "}".to_string() } else { v1_rt::concat("\\".to_string(), next.clone()) diff --git a/src/v1/stage0/src/v1_compiler_trace.rs b/src/v1/stage0/src/v1_compiler_trace.rs index d1063b6e923..05c7fc54cec 100644 --- a/src/v1/stage0/src/v1_compiler_trace.rs +++ b/src/v1/stage0/src/v1_compiler_trace.rs @@ -23,23 +23,23 @@ pub struct SpanMapping { #[serde(tag = "_variant")] pub enum TraceEvent { TraceEnter { - node_id: String, + node_id: Rc>, span: Rc, inputs: Rc>, }, TraceExit { - node_id: String, + node_id: Rc>, span: Rc, - output: String, + output: Rc>, }, TraceError { - node_id: String, + node_id: Rc>, span: Rc, - message: String, + message: Rc>, }, } impl TraceEvent { - pub fn node_id(&self) -> String { + pub fn node_id(&self) -> Rc> { match self { TraceEvent::TraceEnter { node_id: __val, .. } => __val.clone(), TraceEvent::TraceExit { node_id: __val, .. } => __val.clone(), @@ -57,7 +57,7 @@ impl TraceEvent { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TraceFrame { - pub func_name: String, + pub func_name: Rc>, pub span: Rc, pub bindings: Rc>, } @@ -122,7 +122,7 @@ pub fn event_span(event: Rc) -> Rc { } } -pub fn event_node_id(event: Rc) -> String { +pub fn event_node_id(event: Rc) -> Rc> { match (*event).clone() { TraceEvent::TraceEnter { node_id: id, .. } => id.clone(), TraceEvent::TraceExit { node_id: id, .. } => id.clone(), @@ -133,7 +133,7 @@ pub fn event_node_id(event: Rc) -> String { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum TraceFilter { - FilterByFunc { func_name: String }, + FilterByFunc { func_name: Rc> }, FilterBySpan { start: i64, end: i64 }, FilterErrors, } @@ -152,7 +152,9 @@ pub fn replay_trace(trace: Rc, filter: Rc) -> Rc Rc::new({ let mut __result = Vec::new(); for e in trace.events.clone().iter().cloned() { - if (event_node_id(e.clone()).as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(event_node_id(e.clone())) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __result.push(e); } } @@ -184,20 +186,25 @@ pub fn replay_trace(trace: Rc, filter: Rc) -> Rc) -> String { +pub fn format_span(sp: Rc) -> Rc> { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("[".to_string(), (sp.start.clone()).to_string()), + v1_rt::concat( + "[".to_string(), + crate::v2_std_text::host_string_text_from_rust_host( + (sp.start.clone()).to_string(), + ), + ), "..".to_string(), ), - (sp.end.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host((sp.end.clone()).to_string()), ), ")".to_string(), ) } -pub fn format_trace_event(event: Rc) -> String { +pub fn format_trace_event(event: Rc) -> Rc> { match (*event).clone() { TraceEvent::TraceEnter { node_id: id, @@ -261,14 +268,14 @@ pub fn format_trace(trace: Rc) -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ReproCase { - pub func_name: String, + pub func_name: Rc>, pub inputs: Rc>, - pub expected_output: Option, + pub expected_output: Rc>, pub trace: Option>, } pub fn capture_repro( - func_name: String, + func_name: Rc>, inputs: Rc>, trace: Rc, ) -> Rc { @@ -282,7 +289,7 @@ pub fn capture_repro( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SourceMap { - pub generated_file: String, + pub generated_file: Rc>, pub mappings: Rc>>, } diff --git a/src/v1/stage0/src/v1_compiler_workspace_members.rs b/src/v1/stage0/src/v1_compiler_workspace_members.rs index 58d96300af0..8e5f763ce3c 100644 --- a/src/v1/stage0/src/v1_compiler_workspace_members.rs +++ b/src/v1/stage0/src/v1_compiler_workspace_members.rs @@ -12,22 +12,22 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn workspace_members_region_begin_marker() -> String { +pub fn workspace_members_region_begin_marker() -> Rc> { " # BEGIN generated stage0 crate members -- regen_stage0 writes this region (authority: v1.compiler.workspace_members)".to_string() } -pub fn workspace_members_region_end_marker() -> String { +pub fn workspace_members_region_end_marker() -> Rc> { " # END generated stage0 crate members".to_string() } -pub fn stage0_member_entry(spec: Rc) -> String { +pub fn stage0_member_entry(spec: Rc) -> Rc> { v1_rt::concat( v1_rt::concat(" \"".to_string(), spec.crate_dir.clone()), "\",".to_string(), ) } -pub fn stage0_workspace_member_region() -> String { +pub fn stage0_workspace_member_region() -> Rc> { Rc::new( stage0_crate_plan() .crates diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 7858d655b57..8462a365c03 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -152,11 +152,6 @@ pub fn to_string(value: i64) -> String { value.to_string() } -/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8. -pub fn utf8_decode_bytes(bytes: &[u8]) -> Result { - String::from_utf8(bytes.to_vec()).map_err(|e| format!("invalid UTF-8 in access payload: {e}")) -} - pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 { val.clamp(min_val, max_val) } diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index f8ef5220ab7..700dd460995 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -48,7 +48,7 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Token { - pub text: String, + pub text: Rc>, pub span: Rc, pub shape: TokenShape, } @@ -157,11 +157,11 @@ pub enum InferredNode { node: Rc, }, CompilerError { - message: String, + message: Rc>, span: Rc, }, TypeVariable { - id: String, + id: Rc>, }, } @@ -190,11 +190,11 @@ pub fn has_inferred(n: Rc) -> bool { pub enum VarBindingKind { LocalValueBinding, FunctionValueBinding, - VariantValueBinding { parent_enum: String }, + VariantValueBinding { parent_enum: Rc> }, MatchBoundBinding, } impl VarBindingKind { - pub fn parent_enum(&self) -> String { + pub fn parent_enum(&self) -> Rc> { match self { VarBindingKind::LocalValueBinding => panic!("no parent_enum on unit variant"), VarBindingKind::FunctionValueBinding => panic!("no parent_enum on unit variant"), @@ -227,7 +227,7 @@ pub enum MethodSemantics { algebra_template: Option>, }, ServiceMethodSemantics { - service_name: String, + service_name: Rc>, op_params: Rc>>, }, } @@ -251,7 +251,7 @@ pub enum ExprData { }, ExprError { kind: ExprErrorKind, - message: String, + message: Rc>, }, ExprVar { binding_kind: Option>, @@ -270,7 +270,7 @@ pub enum ExprData { ExprIf, ExprLet, ExprRecordLit { - parent_enum: Option, + parent_enum: Rc>, }, ExprListLit, ExprBinOp { @@ -294,14 +294,14 @@ pub enum ExprData { #[serde(tag = "_variant")] pub enum MatchPattern { Bind { - name: String, + name: Rc>, }, LitPattern { value: Rc, }, VariantPattern { - name: String, - parent_enum: Option, + name: Rc>, + parent_enum: Rc>, field_bindings: Rc>>, }, Wildcard, @@ -319,7 +319,7 @@ pub enum UnaryOpKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum StringPart { - Text { value: String }, + Text { value: Rc> }, Interpolation { expr: Rc }, } @@ -342,46 +342,46 @@ pub struct CompileResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TextFile { pub path: FilePath, - pub content: String, + pub content: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum CompilerDiagnostic { UnresolvedImport { - module_path: String, - importing_module: String, + module_path: Rc>, + importing_module: Rc>, span: Rc, }, MissingExport { - name: String, - module_path: String, - importing_module: String, + name: Rc>, + module_path: Rc>, + importing_module: Rc>, span: Rc, }, UnresolvedType { - name: String, + name: Rc>, span: Rc, }, TypeMismatch { - expected: String, - got: String, + expected: Rc>, + got: Rc>, span: Rc, }, ArityMismatch { - name: String, + name: Rc>, expected: i64, got: i64, span: Rc, }, VariantNotFound { - variant: String, - type_name: String, + variant: Rc>, + type_name: Rc>, span: Rc, }, FieldNotFound { - field: String, - type_name: String, + field: Rc>, + type_name: Rc>, span: Rc, }, NonExhaustiveMatch { @@ -393,37 +393,37 @@ pub enum CompilerDiagnostic { span: Rc, }, DuplicateModule { - name: String, + name: Rc>, span: Rc, }, MissingAnnotation { - fn_name: String, - what: String, + fn_name: Rc>, + what: Rc>, span: Rc, }, ParseError { - message: String, + message: Rc>, span: Rc, }, InternalError { - message: String, + message: Rc>, span: Rc, }, ComplexityUnknown { - func_name: String, - reason: String, + func_name: Rc>, + reason: Rc>, span: Rc, }, OwnershipViolation { - binding: String, - fn_name: String, + binding: Rc>, + fn_name: Rc>, consumers: i64, span: Rc, }, VariantCollision { - variant: String, - enum1: String, - enum2: String, + variant: Rc>, + enum1: Rc>, + enum2: Rc>, span: Rc, }, } @@ -453,7 +453,7 @@ impl CompilerDiagnostic { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ErrorNode { pub diagnostic: Rc, - pub module_name: String, + pub module_name: Rc>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -482,7 +482,7 @@ pub fn diagnostic_to_span(d: Rc) -> Rc { } } -pub fn diagnostic_to_message(d: Rc) -> String { +pub fn diagnostic_to_message(d: Rc) -> Rc> { match (*d).clone() { CompilerDiagnostic::UnresolvedImport { module_path: m, @@ -549,11 +549,11 @@ pub fn diagnostic_to_message(d: Rc) -> String { v1_rt::concat("type ".to_string(), n.clone()), " expects ".to_string(), ), - (e.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host((e.clone()).to_string()), ), " type arguments, got ".to_string(), ), - (g.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host((g.clone()).to_string()), ), CompilerDiagnostic::VariantNotFound { variant: v, @@ -639,7 +639,7 @@ pub fn diagnostic_to_message(d: Rc) -> String { ), "' has ".to_string(), ), - (c.clone()).to_string(), + crate::v2_std_text::host_string_text_from_rust_host((c.clone()).to_string()), ), " consumers".to_string(), ), @@ -678,7 +678,10 @@ pub fn is_interpreter_blocking_diagnostic(d: Rc) -> bool { } } -pub fn make_error_node(diagnostic: Rc, module_name: String) -> Rc { +pub fn make_error_node( + diagnostic: Rc, + module_name: Rc>, +) -> Rc { Rc::new(ErrorNode { diagnostic: diagnostic, module_name: module_name, @@ -687,7 +690,7 @@ pub fn make_error_node(diagnostic: Rc, module_name: String) #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DeclaredFuncSig { - pub name: String, + pub name: Rc>, pub params: Rc>>, pub inferred: Option>, pub is_async: bool, @@ -703,7 +706,7 @@ pub struct DeclaredFuncEnv { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Node { - pub name: String, + pub name: Rc>, pub ident: Option, pub span: Rc, pub ident_span: Option>, @@ -723,8 +726,13 @@ pub struct Node { pub expr_data: Rc, } -pub fn default_ident_span(name: String, span: Rc) -> Option> { - if (name.as_str() == "".to_string().as_str()) { +pub fn default_ident_span( + name: Rc>, + span: Rc, +) -> Option> { + if (crate::v2_std_text::host_string_text_to_rust_host(name) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { None } else { Some(span) @@ -767,7 +775,7 @@ pub fn make_expr_node( } pub fn make_named_expr_node( - name: String, + name: Rc>, expr_data: Rc, children: Rc>>, inferred: Option>, @@ -798,7 +806,7 @@ pub fn make_named_expr_node( pub fn make_expr_error_node( kind: ExprErrorKind, - message: String, + message: Rc>, span: Rc, ) -> Rc { Rc::new(Node { @@ -830,7 +838,7 @@ pub fn make_expr_error_node( } pub fn make_arg_node( - name: Option, + name: Rc>, value: Rc, span: Rc, name_span: Rc, @@ -898,7 +906,7 @@ pub fn make_arm_node( } pub fn make_resource_use_node( - name: String, + name: Rc>, resource: Rc, span: Rc, name_span: Rc, @@ -928,7 +936,7 @@ pub fn make_resource_use_node( pub fn resource_use_name_at( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, n) } @@ -944,7 +952,7 @@ pub fn resource_use_resource(n: Rc) -> Rc { } pub fn make_field_init_node( - name: String, + name: Rc>, value: Rc, span: Rc, name_span: Rc, @@ -972,7 +980,7 @@ pub fn make_field_init_node( } pub fn make_field_binding_node( - field_name: String, + field_name: Rc>, binding: Rc, span: Rc, name_span: Rc, @@ -1002,7 +1010,7 @@ pub fn make_field_binding_node( pub fn field_binding_name_at( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, n) } @@ -1013,7 +1021,7 @@ pub fn field_binding_pattern(n: Rc) -> Rc { } } -pub fn make_text_part_node(text: String, span: Rc) -> Rc { +pub fn make_text_part_node(text: Rc>, span: Rc) -> Rc { Rc::new(Node { name: "".to_string(), span: span, @@ -1062,7 +1070,7 @@ pub fn make_interp_part_node(expr: Rc, span: Rc) -> Rc { } pub fn make_param_node( - name: String, + name: Rc>, type_expr: Rc, default_value: Option>, span: Rc, @@ -1097,7 +1105,7 @@ pub fn make_param_node( } pub fn make_resolved_param_node( - name: String, + name: Rc>, type_expr: Rc, default_value: Option>, properties: Rc>>, @@ -1137,26 +1145,28 @@ pub fn make_resolved_param_node( pub fn param_node_name_at( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, n) } pub fn generic_param_name_at( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, n) } pub fn authored_name_at( source_indices: Rc>>, node: Rc, -) -> String { +) -> Rc> { match node.ident_span.clone() { Some(span) => match v1_rt::map_get(&source_indices, span.file.clone()) { Some(index) => { let text = source_text_at(index.clone(), span.clone()); - if (text.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(text.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { "".to_string() } else { text.clone() @@ -1164,8 +1174,13 @@ pub fn authored_name_at( } None => { if ((v1_rt::string_length(&span.file.clone()) > 8) - && (v1_rt::substring(&span.file.clone(), 0, 8).as_str() - == ", - name: String, + name: Rc>, source_indices: Rc>>, ) -> Option> { match Rc::new({ let mut __result = Vec::new(); for c in n.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()).as_str() - == name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + c.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { __result.push(c); } @@ -1207,14 +1224,16 @@ pub fn find_child_named( pub fn has_child_named( n: Rc, - name: String, + name: Rc>, source_indices: Rc>>, ) -> bool { { let mut __found = false; for c in n.children.clone().iter().cloned() { - if (authored_name_at(source_indices.clone(), c.clone()).as_str() - == name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + source_indices.clone(), + c.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { __found = true; break; @@ -1248,11 +1267,11 @@ pub fn param_node_span(n: Rc) -> Rc { } pub fn make_field_node( - name: String, + name: Rc>, type_expr: Rc, cardinality: Cardinality, default_value: Option>, - from_key: Option, + from_key: Rc>, span: Rc, name_span: Rc, ) -> Rc { @@ -1315,7 +1334,7 @@ pub fn make_field_node( pub fn field_node_name_at( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, n) } @@ -1345,7 +1364,7 @@ pub fn field_node_default_value(n: Rc) -> Option> { pub fn field_node_from_key( n: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { match find_property( n.properties.clone(), "from_key".to_string(), @@ -1361,7 +1380,7 @@ pub fn field_node_span(n: Rc) -> Rc { } pub fn make_variant_node( - name: String, + name: Rc>, fields: Rc>>, span: Rc, name_span: Rc, @@ -1391,7 +1410,7 @@ pub fn make_variant_node( pub fn variant_node_name_at( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, n) } @@ -1405,8 +1424,8 @@ pub fn variant_node_span(n: Rc) -> Rc { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ChildRole { - pub name: String, - pub accessor: String, + pub name: Rc>, + pub accessor: Rc>, pub position: i64, pub required: bool, } @@ -1431,7 +1450,7 @@ pub fn wrapper_child_roles() -> Rc>>>> { CACHED.with(|c: &Rc>>>>| c.clone()) } -pub fn is_child_accessor_in_model(name: String) -> bool { +pub fn is_child_accessor_in_model(name: Rc>) -> bool { ({ let mut __found = false; for roles in Rc::new(v1_rt::map_values(&expr_child_roles())) @@ -1441,7 +1460,9 @@ pub fn is_child_accessor_in_model(name: String) -> bool { if { let mut __found = false; for r in roles.clone().iter().cloned() { - if (r.accessor.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(r.accessor.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -1462,7 +1483,9 @@ pub fn is_child_accessor_in_model(name: String) -> bool { if { let mut __found = false; for r in roles.clone().iter().cloned() { - if (r.accessor.clone().as_str() == name.clone().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(r.accessor.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) + { __found = true; break; } @@ -1477,7 +1500,9 @@ pub fn is_child_accessor_in_model(name: String) -> bool { }) } -pub fn child_roles_for_variant(variant_name: String) -> Option>>> { +pub fn child_roles_for_variant( + variant_name: Rc>, +) -> Option>>> { v1_rt::map_get(&expr_child_roles(), variant_name) } @@ -1495,18 +1520,18 @@ pub fn node_field_roles() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert("children".to_string(), NodeFieldRole::ChildrenListField); - __m.insert("params".to_string(), NodeFieldRole::ChildrenListField); - __m.insert("body".to_string(), NodeFieldRole::SubValueField); - __m.insert("expr_data".to_string(), NodeFieldRole::SubValueField); - __m.insert("match_pattern".to_string(), NodeFieldRole::SubValueField); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("children"), NodeFieldRole::ChildrenListField); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("params"), NodeFieldRole::ChildrenListField); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("body"), NodeFieldRole::SubValueField); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("expr_data"), NodeFieldRole::SubValueField); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("match_pattern"), NodeFieldRole::SubValueField); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_children_list_field(field_name: String) -> bool { +pub fn is_children_list_field(field_name: Rc>) -> bool { match v1_rt::lookup(&node_field_roles(), field_name) { v1_rt::Witness::Holds { value: NodeFieldRole::ChildrenListField, @@ -1516,7 +1541,7 @@ pub fn is_children_list_field(field_name: String) -> bool { } } -pub fn is_sub_value_field(field_name: String) -> bool { +pub fn is_sub_value_field(field_name: Rc>) -> bool { match v1_rt::lookup(&node_field_roles(), field_name) { v1_rt::Witness::Holds { value: NodeFieldRole::SubValueField, @@ -1553,22 +1578,22 @@ pub fn function_size_effects() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert("with_required_cardinality".to_string(), Rc::new(FunctionSizeEffect::PropertyContraction { + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("with_required_cardinality"), Rc::new(FunctionSizeEffect::PropertyContraction { domain_size: 2, })); - __m.insert("resolved_type".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("param_node_type_expr".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("field_binding_pattern".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("wrapper_inner_arg".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("extractor_inner_arg".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); - __m.insert("child_type_node".to_string(), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("resolved_type"), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("param_node_type_expr"), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("field_binding_pattern"), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("wrapper_inner_arg"), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("extractor_inner_arg"), Rc::new(FunctionSizeEffect::TreeSizeReducing)); + __m.insert(crate::v2_std_text::host_string_text_from_rust_host("child_type_node"), Rc::new(FunctionSizeEffect::TreeSizeReducing)); Rc::new(__m) }; } CACHED.with(|c: &Rc>>| c.clone()) } -pub fn is_tree_size_preserving(func_name: String) -> bool { +pub fn is_tree_size_preserving(func_name: Rc>) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { FunctionSizeEffect::TreeSizePreserving => true, @@ -1579,7 +1604,7 @@ pub fn is_tree_size_preserving(func_name: String) -> bool { } } -pub fn is_tree_size_reducing(func_name: String) -> bool { +pub fn is_tree_size_reducing(func_name: Rc>) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { FunctionSizeEffect::TreeSizeReducing => true, @@ -1589,7 +1614,7 @@ pub fn is_tree_size_reducing(func_name: String) -> bool { } } -pub fn is_property_contraction(func_name: String) -> bool { +pub fn is_property_contraction(func_name: Rc>) -> bool { match v1_rt::lookup(&function_size_effects(), func_name) { v1_rt::Witness::Holds { value: effect, .. } => match (*effect.clone()).clone() { FunctionSizeEffect::PropertyContraction { domain_size: _, .. } => true, @@ -1599,7 +1624,7 @@ pub fn is_property_contraction(func_name: String) -> bool { } } -pub fn expr_child_at(texpr: Rc, index: i64, role: String) -> Rc { +pub fn expr_child_at(texpr: Rc, index: i64, role: Rc>) -> Rc { match texpr.children.clone().get(index as usize).cloned() { Some(v) => v.clone(), None => make_expr_error_node( @@ -1613,10 +1638,12 @@ pub fn expr_child_at(texpr: Rc, index: i64, role: String) -> Rc { pub fn arg_name_at( n: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { { let name = authored_name_at(source_indices, n); - if (name.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { None } else { Some(name.clone()) @@ -1664,7 +1691,7 @@ pub fn arm_body(n: Rc) -> Rc { pub fn field_init_node_name_at( n: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, n) } @@ -1722,7 +1749,7 @@ pub fn unaryop_operand(texpr: Rc) -> Rc { pub fn expr_var_name_at( texpr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, texpr) } @@ -1733,7 +1760,7 @@ pub fn field_access_base(texpr: Rc) -> Rc { pub fn field_access_field_at( texpr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, texpr) } @@ -1747,7 +1774,7 @@ pub fn expr_field_access_summary(texpr: Rc) -> Option> { pub fn expr_call_func_at( texpr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, texpr) } @@ -1780,7 +1807,7 @@ pub fn method_arg_nodes(texpr: Rc) -> Rc>> { pub fn expr_method_name_at( texpr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, texpr) } @@ -1833,7 +1860,7 @@ pub fn let_body(texpr: Rc) -> Option> { pub fn let_binding_name_at( texpr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, texpr) } @@ -1856,7 +1883,7 @@ pub fn foreach_body(texpr: Rc) -> Rc { pub fn foreach_variable_at( texpr: Rc, source_indices: Rc>>, -) -> String { +) -> Rc> { authored_name_at(source_indices, texpr) } @@ -1891,10 +1918,12 @@ pub fn block_stmts(texpr: Rc) -> Rc>> { pub fn record_lit_type_name_at( texpr: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { { let name = authored_name_at(source_indices, texpr); - if (name.clone().as_str() == "".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { None } else { Some(name.clone()) @@ -1902,112 +1931,112 @@ pub fn record_lit_type_name_at( } } -pub fn transport_url_key() -> String { +pub fn transport_url_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "base_url".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_path_key() -> String { +pub fn transport_path_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "base_path".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_auth_token_key() -> String { +pub fn transport_auth_token_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "auth_token".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_auth_header_key() -> String { +pub fn transport_auth_header_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "auth_header".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_auth_scheme_key() -> String { +pub fn transport_auth_scheme_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "auth_scheme".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_method_key() -> String { +pub fn transport_method_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "method".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_path_template_key() -> String { +pub fn transport_path_template_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "path".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_query_key() -> String { +pub fn transport_query_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "query".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_body_key() -> String { +pub fn transport_body_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "body".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_stdin_key() -> String { +pub fn transport_stdin_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "stdin".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_response_format_key() -> String { +pub fn transport_response_format_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "response_format".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } -pub fn transport_headers_key() -> String { +pub fn transport_headers_key() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "headers".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn make_transport_node( @@ -2204,14 +2233,16 @@ pub fn file_transport_node(base_path: Rc, span: Rc) -> Rc>>, - prop_name: String, + prop_name: Rc>, source_indices: Rc>>, ) -> Option> { match Rc::new({ let mut __result = Vec::new(); for p in props.iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == prop_name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + p.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(prop_name.clone())) { __result.push(p); } @@ -2228,9 +2259,9 @@ pub fn find_property( pub fn find_property_string( props: Rc>>, - prop_name: String, + prop_name: Rc>, source_indices: Rc>>, -) -> Option { +) -> Rc> { match find_property(props, prop_name, source_indices) { Some(n) => match (*n.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { @@ -2288,13 +2319,19 @@ pub fn field_init_operation_modifier( ) -> Option { { let fi_name = field_init_node_name_at(field_init, source_indices); - if (fi_name.clone().as_str() == "idempotent".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fi_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("idempotent".to_string())) + { Some(OperationModifier::Idempotent) } else { - if (fi_name.clone().as_str() == "readonly".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fi_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("readonly".to_string())) + { Some(OperationModifier::Readonly) } else { - if (fi_name.clone().as_str() == "hermetic".to_string().as_str()) { + if (crate::v2_std_text::host_string_text_to_rust_host(fi_name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("hermetic".to_string())) + { Some(OperationModifier::Hermetic) } else { None @@ -2304,7 +2341,7 @@ pub fn field_init_operation_modifier( } } -pub fn operation_modifier_name(modifier: OperationModifier) -> String { +pub fn operation_modifier_name(modifier: OperationModifier) -> Rc> { match modifier { OperationModifier::Idempotent => "idempotent".to_string(), OperationModifier::Readonly => "readonly".to_string(), @@ -2333,7 +2370,7 @@ pub fn transport_auth_token( pub fn transport_auth_header_name( t: Rc, source_indices: Rc>>, -) -> Option { +) -> Rc> { find_property_string( t.properties.clone(), transport_auth_header_key(), @@ -2405,19 +2442,37 @@ pub fn transport_response_format( ) } -pub fn is_config_reserved_key(name: String) -> bool { - ((((((((((((name.clone().as_str() == transport_url_key().as_str()) - || (name.clone().as_str() == transport_path_key().as_str())) - || (name.clone().as_str() == transport_auth_scheme_key().as_str())) - || (name.clone().as_str() == transport_auth_header_key().as_str())) - || (name.clone().as_str() == transport_auth_token_key().as_str())) - || (name.clone().as_str() == transport_method_key().as_str())) - || (name.clone().as_str() == transport_path_template_key().as_str())) - || (name.clone().as_str() == transport_query_key().as_str())) - || (name.clone().as_str() == transport_body_key().as_str())) - || (name.clone().as_str() == transport_stdin_key().as_str())) - || (name.clone().as_str() == transport_response_format_key().as_str())) - || (name.clone().as_str() == transport_headers_key().as_str())) +pub fn is_config_reserved_key(name: Rc>) -> bool { + ((((((((((((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_url_key())) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_path_key()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + transport_auth_scheme_key(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + transport_auth_header_key(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_auth_token_key()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_method_key()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host( + transport_path_template_key(), + ))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_query_key()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_body_key()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_stdin_key()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_response_format_key()))) + || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) + == crate::v2_std_text::host_string_text_to_rust_host(transport_headers_key()))) } pub fn transport_headers( @@ -2481,14 +2536,16 @@ pub fn map_children(node: Rc, transform: impl Fn(Rc) -> Rc + C pub fn expr_has_self_call( texpr: Rc, - fn_name: String, + fn_name: Rc>, source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() - == fn_name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(expr_call_func_at( + texpr.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(fn_name.clone())) { true } else { @@ -2524,15 +2581,17 @@ pub fn expr_has_self_call( pub fn expr_has_non_tail_self_call( texpr: Rc, - fn_name: String, + fn_name: Rc>, in_tail: bool, source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() - == fn_name.clone().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(expr_call_func_at( + texpr.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host(fn_name.clone())) { if (in_tail.clone() == false) { true @@ -2861,8 +2920,10 @@ pub fn has_service_config( { let mut __found = false; for p in n.properties.clone().iter().cloned() { - if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() - == "svc_endpoint".to_string().as_str()) + if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + p.clone(), + source_indices.clone(), + )) == crate::v2_std_text::host_string_text_to_rust_host("svc_endpoint".to_string())) { __found = true; break; @@ -2935,7 +2996,7 @@ pub fn service_config_auth_source( } pub fn module_node( - name: String, + name: Rc>, imports: Rc>>, items: Rc>>, span: Rc, @@ -2963,7 +3024,7 @@ pub fn module_node( } pub fn import_node( - module_path: String, + module_path: Rc>, is_all: bool, specific_names: Rc>>, span: Rc, @@ -3042,7 +3103,7 @@ pub fn module_items(n: Rc) -> Rc>> { n.children.clone() } -pub fn leaf_node_with_span(name: String, span: Rc) -> Rc { +pub fn leaf_node_with_span(name: Rc>, span: Rc) -> Rc { Rc::new(Node { name: name.clone(), span: span.clone(), @@ -3065,7 +3126,7 @@ pub fn leaf_node_with_span(name: String, span: Rc) -> Rc { }) } -pub fn kernel_span(name: String) -> Rc { +pub fn kernel_span(name: Rc>) -> Rc { Rc::new(SourceSpan { file: v1_rt::concat( v1_rt::concat(" Rc { CACHED.with(|c: &Rc| c.clone()) } -pub fn tuple_type_name() -> String { +pub fn tuple_type_name() -> Rc> { thread_local! { - static CACHED: String = { + static CACHED: Rc> = { "Tuple".to_string() }; } - CACHED.with(|c: &String| c.clone()) + CACHED.with(|c: &Rc>| c.clone()) } pub fn error_type() -> Rc { @@ -3323,7 +3384,7 @@ pub fn make_span(start: i64, end: i64) -> Rc { }) } -pub fn make_file_span(file: String, start: i64, end: i64) -> Rc { +pub fn make_file_span(file: Rc>, start: i64, end: i64) -> Rc { Rc::new(SourceSpan { file: file, start: start, @@ -3343,12 +3404,15 @@ pub struct LineCol { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct NewlineIndex { - pub file: String, + pub file: Rc>, pub offsets: Rc>, pub char_codes: Rc>, } -pub fn build_newline_index(file: String, source: String) -> Rc { +pub fn build_newline_index( + file: Rc>, + source: Rc>, +) -> Rc { { let char_codes = Rc::new(source.chars().map(|c| c as i64).collect::>()); let offsets = Rc::new( @@ -3416,7 +3480,7 @@ pub fn byte_to_line_col(index: Rc, offset: i64) -> LineCol { } } -pub fn source_line_at(index: Rc, line: i64) -> String { +pub fn source_line_at(index: Rc, line: i64) -> Rc> { { let src_len = (index.char_codes.clone().len() as i64); let line_start = if (line.clone() <= 1) { @@ -3445,7 +3509,7 @@ pub fn source_line_at(index: Rc, line: i64) -> String { } } -pub fn source_text_at(index: Rc, span: Rc) -> String { +pub fn source_text_at(index: Rc, span: Rc) -> Rc> { v1_rt::chars_to_string( &index.char_codes.clone(), span.start.clone(), @@ -3469,12 +3533,16 @@ pub struct InternResult { pub fn empty_intern_table() -> Rc { Rc::new(InternTable { strings: Rc::new(vec!["".to_string()]), - index: v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), "".to_string(), 0), + index: v1_rt::rc_map_insert( + v1_rt::rc_empty_map::>, i64>(), + "".to_string(), + 0, + ), next_id: 1, }) } -pub fn intern(table: Rc, s: String) -> Rc { +pub fn intern(table: Rc, s: Rc>) -> Rc { match v1_rt::map_get(&table.index.clone(), s.clone()) { Some(id) => Rc::new(InternResult { table: table.clone(), @@ -3494,21 +3562,21 @@ pub fn intern(table: Rc, s: String) -> Rc { } } -pub fn intern_str(table: Rc, id: i64) -> String { +pub fn intern_str(table: Rc, id: i64) -> Rc> { match table.strings.clone().get(id as usize).cloned() { Some(s) => s.clone(), None => "".to_string(), } } -pub fn intern_find(table: Rc, s: String) -> Option { +pub fn intern_find(table: Rc, s: Rc>) -> Option { match v1_rt::map_get(&table.index.clone(), s) { Some(id) => Some(id.clone()), None => None, } } -pub fn intern_find_or_empty(table: Rc, s: String) -> i64 { +pub fn intern_find_or_empty(table: Rc, s: Rc>) -> i64 { match v1_rt::map_get(&table.index.clone(), s) { Some(id) => id.clone(), None => 0, @@ -3519,17 +3587,18 @@ pub fn merge_intern_tables(tables: Rc>>) -> Rc tables.iter().cloned().fold( empty_intern_table(), |merged: Rc, t: Rc| { - t.strings - .clone() - .iter() - .cloned() - .fold(merged, |m: Rc, s: String| { - if (s.clone().as_str() == "".to_string().as_str()) { + t.strings.clone().iter().cloned().fold( + merged, + |m: Rc, s: Rc>| { + if (crate::v2_std_text::host_string_text_to_rust_host(s.clone()) + == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + { m.clone() } else { intern(m.clone(), s.clone()).table.clone() } - }) + }, + ) }, ) } From a16299271cb3f6dd8539f10815e69c8239da194a Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 14:55:25 +0000 Subject: [PATCH 13/15] WIP: Stage0 regen-lockstep REPAIR (Route A prerequisite): regen_stage0 --veri --- dsl/std/effects.dag | 3 ++- dsl/std/realization_schedule.dag | 14 ++++++++++- dsl/std/types.dag | 21 ---------------- src/v1/stage0/src/bin/regen_stage0.rs | 36 +++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/dsl/std/effects.dag b/dsl/std/effects.dag index a0af8fd4712..e89bf26efb8 100644 --- a/dsl/std/effects.dag +++ b/dsl/std/effects.dag @@ -38,7 +38,8 @@ module std.effects -import std.types { HttpMethod, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, String, List, string_list_eq } +import std.types { HttpMethod, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, String, List } +import std.realization_schedule { string_list_eq } import std.http_path { PathTemplate, PathTemplateParseResult, ParsedPathTemplate, MalformedPathTemplate, diff --git a/dsl/std/realization_schedule.dag b/dsl/std/realization_schedule.dag index 936982a0acf..da33cd8a4b8 100644 --- a/dsl/std/realization_schedule.dag +++ b/dsl/std/realization_schedule.dag @@ -7,7 +7,7 @@ module std.realization_schedule -import std.types { ContentHash, Bool, String, List, Int, string_list_eq } +import std.types { ContentHash, Bool, String, List, Int } import std.nat { Nat } import std.measure { Measure, Time, ByteSize, Watt, @@ -196,6 +196,18 @@ fn schedule_witness_entry_eq(a: ScheduleWitnessEntry, b: ScheduleWitnessEntry) - (a.entry == b.entry) && (a.function == b.function) } +fn string_list_eq(left: List, right: List) -> Bool { + if left.length() != right.length() { + false + } else if left.length() == 0 { + true + } else if left.first() != right.first() { + false + } else { + string_list_eq(left: left.skip(n: 1), right: right.skip(n: 1)) + } +} + fn schedule_witness_entry_list_eq(left: List, right: List) -> Bool { if left.length() != right.length() { false diff --git a/dsl/std/types.dag b/dsl/std/types.dag index 0fcbec1a9bf..fdf4a8e2685 100644 --- a/dsl/std/types.dag +++ b/dsl/std/types.dag @@ -177,27 +177,6 @@ fn canonical_container_names() -> List { ["BooleanAlgebra", "FreeMonoid", "List", "Map", "PartialFunction", "Set", "Witness"] } -// Element-wise structural equality of two string lists. Generic-free -// bootstrap helper -- the concrete String specialization (no element-Eq -// inhabitance / phantom generics), so the v1 seed renders it directly. -// Relocated here from std.realization_schedule (DESIGN.md §3: a plain -// List equality does not belong in a MEASURED/peripheral -// realization module); std.realization_schedule and std.effects now both -// consume it from std.types. Uses `.count()` (the templated list-length, -// renders to `.len() as i64`) -- NOT `.length()`, which the v1 emitter has -// no runtime bridge for. -fn string_list_eq(left: List, right: List) -> Bool { - if left.count() != right.count() { - false - } else if left.count() == 0 { - true - } else if left.first() != right.first() { - false - } else { - string_list_eq(left: left.skip(n: 1), right: right.skip(n: 1)) - } -} - // Bool: two-valued coproduct. Structurally: Disj + 2 unit variants. // Target: Bool = BooleanAlgebra over {True, False}. // Note: std.logic.Classical and std.bit.Bit carry the same structural diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index 668b89ffd3c..eb77852df2d 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -225,6 +225,9 @@ fn run() -> Result<(), String> { time_phase(&mut phases, "patch_bootstrap_dag_collect", || { patch_bootstrap_dag_collect(&fresh_dir.join("src")) })?; + time_phase(&mut phases, "patch_languages_consumer_census_mod", || { + patch_languages_consumer_census_mod(&fresh_dir.join("src")) + })?; time_phase(&mut phases, "assert_bootstrap_emit_core_support", || { assert_bootstrap_emit_core_support(&fresh_dir.join("src")) })?; @@ -751,6 +754,39 @@ fn patch_bootstrap_dag_collect(src_dir: &Path) -> Result<(), String> { Ok(()) } +/// Declare the hand-maintained `languages_consumer_census` module in the +/// generated `lib.rs`. +/// +/// `languages_consumer_census.rs` is a hand-maintained v1 seed module (the v2 +/// authority is the lens `src/v2/lens/languages_consumer_census.dag`); it is +/// copied into the fresh crate by `copy_hand_maintained_support` and consumed by +/// `v1_interpreter.rs`. Unlike its sibling lens/projection modules, it is +/// uniquely absent from the emitter's `all_module_files`, so +/// `emit_lib_rs_from_files` (src/v1/05_emit_rust.dag) does not write a +/// `pub mod languages_consumer_census;` for it and the fresh crate fails to +/// resolve `crate::languages_consumer_census::*`. Inject the declaration here, +/// mirroring `patch_bootstrap_dag_collect`. +/// +/// DISSOLUTION: remove this patch once 05_emit_rust.dag's `all_module_files` +/// (or its `hand_maintained_mods` emission path) includes +/// `languages_consumer_census`, so the emitter declares it directly (single +/// authority — the §3 parallel-ledger note on `HAND_MAINTAINED_STAGE0_FILES`). +fn patch_languages_consumer_census_mod(src_dir: &Path) -> Result<(), String> { + let lib_path = src_dir.join("lib.rs"); + let mut lib_text = + fs::read_to_string(&lib_path).map_err(|e| format!("read {}: {e}", lib_path.display()))?; + if !lib_text.contains("pub mod languages_consumer_census;") { + // Insert after import_resolution_project so `cargo fmt` module order + // matches the committed lib.rs (emitter emits mods in sorted order). + lib_text = lib_text.replace( + "pub mod import_resolution_project;\n", + "pub mod import_resolution_project;\npub mod languages_consumer_census;\n", + ); + } + fs::write(&lib_path, lib_text).map_err(|e| format!("write {}: {e}", lib_path.display()))?; + Ok(()) +} + fn assert_no_local_delegated_fns(text: &str) -> Result<(), String> { let mut duplicates = Vec::new(); for symbol in DELEGATED_DAG_COLLECT_SYMBOLS { From 59f40834158f8a090744de92aff921ea5c249f87 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 15:02:20 +0000 Subject: [PATCH 14/15] Stage0 B/C seed-wiring: languages_consumer_census lib.rs mod-decl + seed baseline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post-#5279 (fierce-ant's emitter merged solo, branch deleted): main's committed seed builds but is NOT a regen fixpoint (regen --verify fails, 66 files drift); a fresh regen = 188 errors, the algebra/measure carrier-completeness deficit that is the now-unowned A-lane emitter work. This commit lands the B/C seed-wiring my lane owns, isolating the residual to pure carrier-completeness: - regen_stage0.rs: add patch_languages_consumer_census_mod — inject the hand-maintained `pub mod languages_consumer_census;` into the generated lib.rs (mirrors patch_bootstrap_dag_collect). The module is uniquely absent from the emitter's all_module_files, so emit_lib_rs_from_files drops it and the fresh crate fails to resolve crate::languages_consumer_census::* (6x E0433 from v1_interpreter.rs). DISSOLUTION trigger documented (emitter all_module_files). - GENERATED/HAND_MAINTAINED registries already complete via #5279 (the 7 std entries + languages_consumer_census). - Committed seed reset to main-green baseline (buildable); abandoned prune (string_list_eq relocation) reverted — superseded by the carrier work + the v1_rt::length fix is A-lane (emitter/std_algebra, no shim). Gate (Stage0LockstepGate) authored + enrolled. #5325 stays DRAFT: regen --verify co-lands green only once the A-lane carrier-completeness (188->0) lands on main. Boundary respected: no src/v1/05_emit_rust.dag render-logic changes. Co-Authored-By: Claude Opus 4.8 --- src/v1/stage0/src/bin/regen_stage0.rs | 9 - src/v1/stage0/src/compiler_tests.rs | 6 +- src/v1/stage0/src/extdeps_cargo.rs | 154 +- .../stage0/src/extdeps_languages_dag_emit.rs | 182 +- .../src/extdeps_languages_dag_syntax.rs | 118 +- .../stage0/src/extdeps_languages_go_emit.rs | 192 +- .../stage0/src/extdeps_languages_go_types.rs | 54 +- .../src/extdeps_languages_python_emit.rs | 204 +- .../src/extdeps_languages_python_types.rs | 135 +- .../stage0/src/extdeps_languages_rust_emit.rs | 276 +- .../src/extdeps_languages_rust_syntax.rs | 78 +- .../src/extdeps_languages_rust_types.rs | 80 +- src/v1/stage0/src/lib.rs | 5 +- src/v1/stage0/src/main.rs | 6 + src/v1/stage0/src/std_algebra.rs | 42 +- src/v1/stage0/src/std_coercion.rs | 46 +- src/v1/stage0/src/std_computation.rs | 41 +- src/v1/stage0/src/std_effects.rs | 102 +- src/v1/stage0/src/std_emit_model.rs | 14 +- src/v1/stage0/src/std_error_primitives.rs | 3 - src/v1/stage0/src/std_graph.rs | 28 +- src/v1/stage0/src/std_http_path.rs | 87 +- src/v1/stage0/src/std_induction.rs | 64 +- src/v1/stage0/src/std_node.rs | 10 +- src/v1/stage0/src/std_syntax.rs | 48 +- src/v1/stage0/src/std_termination.rs | 28 +- src/v1/stage0/src/std_types.rs | 222 +- src/v1/stage0/src/v1_compiler_artifact.rs | 38 +- src/v1/stage0/src/v1_compiler_coercion.rs | 81 +- .../src/v1_compiler_compiler_tests_rust.rs | 52 +- src/v1/stage0/src/v1_compiler_complexity.rs | 1034 +++--- .../src/v1_compiler_effect_derivation.rs | 4 +- src/v1/stage0/src/v1_compiler_emit.rs | 761 ++--- .../src/v1_compiler_emit_core_support.rs | 83 +- src/v1/stage0/src/v1_compiler_emit_go.rs | 128 +- src/v1/stage0/src/v1_compiler_emit_python.rs | 119 +- src/v1/stage0/src/v1_compiler_infer.rs | 2781 ++++++++--------- src/v1/stage0/src/v1_compiler_infer_access.rs | 12 +- src/v1/stage0/src/v1_compiler_infer_cycle.rs | 128 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 100 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 47 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 11 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 154 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 51 +- .../stage0/src/v1_compiler_infer_patterns.rs | 100 +- .../stage0/src/v1_compiler_infer_resolve.rs | 311 +- .../stage0/src/v1_compiler_infer_service.rs | 18 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 46 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 159 +- src/v1/stage0/src/v1_compiler_languages.rs | 299 +- src/v1/stage0/src/v1_compiler_normalize.rs | 2 +- src/v1/stage0/src/v1_compiler_ownership.rs | 117 +- src/v1/stage0/src/v1_compiler_parse.rs | 596 ++-- src/v1/stage0/src/v1_compiler_resolve.rs | 130 +- src/v1/stage0/src/v1_compiler_runtime_go.rs | 10 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 24 +- .../stage0/src/v1_compiler_stage0_crates.rs | 35 +- src/v1/stage0/src/v1_compiler_tokenize.rs | 112 +- src/v1/stage0/src/v1_compiler_trace.rs | 43 +- .../src/v1_compiler_workspace_members.rs | 8 +- src/v1/stage0/src/v1_rt.rs | 5 + 61 files changed, 4332 insertions(+), 5501 deletions(-) diff --git a/src/v1/stage0/src/bin/regen_stage0.rs b/src/v1/stage0/src/bin/regen_stage0.rs index eb77852df2d..80b4867a9f0 100644 --- a/src/v1/stage0/src/bin/regen_stage0.rs +++ b/src/v1/stage0/src/bin/regen_stage0.rs @@ -109,15 +109,6 @@ const GENERATED_STAGE0_FILES: &[&str] = &[ "v1_std_core.rs", ]; -// MUST stay in lockstep with the emitter's `hand_maintained_mods` declaration in -// src/v1/05_emit_rust.dag (`emit_lib_rs_from_files`): every `pub mod X;` the emitter -// writes into the generated lib.rs for a hand-maintained module must be copied into -// the fresh-compile temp dir here, or `cargo fmt` of the emitted crate fails to -// resolve the module. These two lists are a §3 parallel-authority pair (the deeper -// fix is a single source); until then this is the synced copy of the emitter's set -// (13 modules) plus the two dag_collect bootstrap modules injected by -// patch_bootstrap_dag_collect. The lens-`*_project` / `*_census` / recorded_fixture -// modules are hand-maintained Rust seed, not regenerated, so they live here. const HAND_MAINTAINED_STAGE0_FILES: &[&str] = &[ "cli_run.rs", "coproduct_reflection.rs", diff --git a/src/v1/stage0/src/compiler_tests.rs b/src/v1/stage0/src/compiler_tests.rs index fe59340b25a..fc07fce7ded 100644 --- a/src/v1/stage0/src/compiler_tests.rs +++ b/src/v1/stage0/src/compiler_tests.rs @@ -50,7 +50,11 @@ mod compiler_tests { .unwrap() .to_string_lossy() .to_string(); - // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules. + // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules; + // exclude them so the self_* whole-tree module scans don't try to parse + // them as modules and panic. The only .dag under src/v1/**/tests/ is the + // fixture, so this skips exactly it (#5124 added the fixture; the cargo-test + // CI gate surfaced the panic). No real module lives under a tests/ dir. if rel.contains("/tests/") { continue; } diff --git a/src/v1/stage0/src/extdeps_cargo.rs b/src/v1/stage0/src/extdeps_cargo.rs index 76ca6dd3270..793c4c9abe1 100644 --- a/src/v1/stage0/src/extdeps_cargo.rs +++ b/src/v1/stage0/src/extdeps_cargo.rs @@ -3,12 +3,7 @@ use self::CargoDepSource::*; use self::CargoTarget::*; -use self::RustEdition::*; use self::TestHarness::*; -pub use crate::extdeps_cargo_version::{ - CargoPackageVersion, CargoToolVersionFloor, CargoVersionRequirement, -}; -pub use crate::std_types::FilePathParts; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -18,68 +13,29 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] -#[serde(tag = "_variant")] -pub enum RustEdition { - Edition2015, - Edition2018, - Edition2021, - Edition2024, -} - -pub fn rust_edition_str(edition: RustEdition) -> Rc> { - match edition { - RustEdition::Edition2015 => "2015".to_string(), - RustEdition::Edition2018 => "2018".to_string(), - RustEdition::Edition2021 => "2021".to_string(), - RustEdition::Edition2024 => "2024".to_string(), - } -} - -pub fn default_rust_edition() -> RustEdition { - thread_local! { - static CACHED: RustEdition = { - RustEdition::Edition2021 - }; - } - CACHED.with(|c: &RustEdition| c.clone()) -} - -pub fn min_cargo_version() -> SemVerConstraint { - thread_local! { - static CACHED: SemVerConstraint = { - serde_json::from_value(serde_json::json!(">= 1.56")) - .expect("valid data definition") - }; - } - CACHED.with(|c: &SemVerConstraint| c.clone()) -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoPackage { - pub name: Rc>, - pub version: Box, - pub edition: RustEdition, - pub path: Rc>, + pub name: String, + pub version: String, + pub edition: String, + pub path: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum CargoDepSource { RegistryDep { - version: Box, + version: String, features: Rc>, }, LocalPathDep { - path: Rc>, + path: String, }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoDependency { - pub name: Rc>, + pub name: String, pub source: Rc, } @@ -87,13 +43,13 @@ pub struct CargoDependency { #[serde(tag = "_variant")] pub enum CargoTarget { Lib, - Bin { name: Rc> }, - CargoTest { name: Rc> }, - Example { name: Rc> }, - Bench { name: Rc> }, + Bin { name: String }, + CargoTest { name: String }, + Example { name: String }, + Bench { name: String }, } impl CargoTarget { - pub fn name(&self) -> Rc> { + pub fn name(&self) -> String { match self { CargoTarget::Lib => panic!("no name on unit variant"), CargoTarget::Bin { name: __val, .. } => __val.clone(), @@ -104,67 +60,7 @@ impl CargoTarget { } } -pub fn cargo_target_source_path( - target: Rc, - package_name: Rc>, -) -> Rc { - match (*target).clone() { - CargoTarget::Lib => Rc::new(FilePathParts { - segments: Rc::new(vec!["src".to_string(), "lib.rs".to_string()]), - }), - CargoTarget::Bin { name: name, .. } => { - if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(package_name)) - { - Rc::new(FilePathParts { - segments: Rc::new(vec!["src".to_string(), "main.rs".to_string()]), - }) - } else { - Rc::new(FilePathParts { - segments: Rc::new(vec![ - "src".to_string(), - "bin".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }) - } - } - CargoTarget::CargoTest { name: name, .. } => Rc::new(FilePathParts { - segments: Rc::new(vec![ - "tests".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }), - CargoTarget::Example { name: name, .. } => Rc::new(FilePathParts { - segments: Rc::new(vec![ - "examples".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }), - CargoTarget::Bench { name: name, .. } => Rc::new(FilePathParts { - segments: Rc::new(vec![ - "benches".to_string(), - v1_rt::concat(name.clone(), ".rs".to_string()), - ]), - }), - } -} - -pub fn rust_module_candidate_paths(stem: Rc>) -> Rc>> { - Rc::new(vec![ - Rc::new(FilePathParts { - segments: Rc::new(vec![ - "src".to_string(), - v1_rt::concat(stem.clone(), ".rs".to_string()), - ]), - }), - Rc::new(FilePathParts { - segments: Rc::new(vec!["src".to_string(), stem.clone(), "mod.rs".to_string()]), - }), - ]) -} - -pub type CargoProfile = Rc>; +pub type CargoProfile = String; pub fn canonical_profiles() -> Rc> { thread_local! { @@ -177,7 +73,7 @@ pub fn canonical_profiles() -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CargoFeature { - pub name: Rc>, + pub name: String, pub dependencies: Rc>, } @@ -190,18 +86,20 @@ pub enum TestHarness { NoHarness, } -pub fn default_profile() -> Rc> { +pub fn default_edition() -> String { thread_local! { - static CACHED: Rc> = { - "dev".to_string() + static CACHED: String = { + "2021".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub struct Edition2015; -pub struct Edition2018; -pub struct Edition2021; -pub struct Edition2024; -pub struct Harness; -pub struct NoHarness; +pub fn default_profile() -> String { + thread_local! { + static CACHED: String = { + "dev".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} diff --git a/src/v1/stage0/src/extdeps_languages_dag_emit.rs b/src/v1/stage0/src/extdeps_languages_dag_emit.rs index 3fa03e74c98..53b714ba0d2 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_emit.rs @@ -14,13 +14,13 @@ pub fn dag_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "true".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "false".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "none".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "&&".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "||".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "!".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "/".to_string()); + __m.insert("true".to_string(), "true".to_string()); + __m.insert("false".to_string(), "false".to_string()); + __m.insert("null".to_string(), "none".to_string()); + __m.insert("and".to_string(), "&&".to_string()); + __m.insert("or".to_string(), "||".to_string()); + __m.insert("not".to_string(), "!".to_string()); + __m.insert("div".to_string(), "/".to_string()); Rc::new(__m) }; } @@ -31,15 +31,15 @@ pub fn dag_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "List<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "Set<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("non_empty_list"), "NonEmptyList<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("non_empty_set"), "NonEmptySet<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "{0}?".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "Map<{0}, {1}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "List<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "Map<{0}, {1}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "Bool".to_string()); + __m.insert("list".to_string(), "List<{0}>".to_string()); + __m.insert("set".to_string(), "Set<{0}>".to_string()); + __m.insert("non_empty_list".to_string(), "NonEmptyList<{0}>".to_string()); + __m.insert("non_empty_set".to_string(), "NonEmptySet<{0}>".to_string()); + __m.insert("optional".to_string(), "{0}?".to_string()); + __m.insert("map".to_string(), "Map<{0}, {1}>".to_string()); + __m.insert("free_monoid".to_string(), "List<{0}>".to_string()); + __m.insert("partial_function".to_string(), "Map<{0}, {1}>".to_string()); + __m.insert("boolean_algebra".to_string(), "Bool".to_string()); Rc::new(__m) }; } @@ -64,227 +64,227 @@ pub fn dag_string_types() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn dag_func_keyword() -> Rc> { +pub fn dag_func_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "fn".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_async_prefix() -> Rc> { +pub fn dag_async_prefix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_struct_keyword() -> Rc> { +pub fn dag_struct_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "type".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_enum_keyword() -> Rc> { +pub fn dag_enum_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "type".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_type_alias_keyword() -> Rc> { +pub fn dag_type_alias_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "type".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_param_separator() -> Rc> { +pub fn dag_param_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ", ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_return_arrow() -> Rc> { +pub fn dag_return_arrow() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { " -> ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_param_type_sep() -> Rc> { +pub fn dag_param_type_sep() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ": ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_module_keyword() -> Rc> { +pub fn dag_module_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "module".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_import_keyword() -> Rc> { +pub fn dag_import_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "import".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_import_from_keyword() -> Rc> { +pub fn dag_import_from_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_lambda_template() -> Rc> { +pub fn dag_lambda_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "({0}) => {1}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_error_expr_template() -> Rc> { +pub fn dag_error_expr_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "error({0})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_list_literal_empty() -> Rc> { +pub fn dag_list_literal_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_list_literal_template() -> Rc> { +pub fn dag_list_literal_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[{0}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_null_coalesce_template() -> Rc> { +pub fn dag_null_coalesce_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{0} ?? {1}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_error_type_template() -> Rc> { +pub fn dag_error_type_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "__EMIT_BUG_{0}__".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_type_arg_open() -> Rc> { +pub fn dag_type_arg_open() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "<".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_type_arg_close() -> Rc> { +pub fn dag_type_arg_close() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ">".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_void_type() -> Rc> { +pub fn dag_void_type() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "()".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_tuple_empty() -> Rc> { +pub fn dag_tuple_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "()".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_tuple_pair_template() -> Rc> { +pub fn dag_tuple_pair_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "({0}, {1})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_tuple_multi_template() -> Rc> { +pub fn dag_tuple_multi_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "({0})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_tuple_separator() -> Rc> { +pub fn dag_tuple_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ", ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dag_source_extension() -> Rc> { +pub fn dag_source_extension() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ".dag".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } diff --git a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs index 819ce9bf42d..aa38fb08090 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs @@ -108,14 +108,14 @@ pub fn dag_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), Rc::new(LiteralValue::LitBool { + __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), Rc::new(LiteralValue::LitBool { + __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { value: false, })); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("none"), Rc::new(LiteralValue::LitNull)); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), Rc::new(LiteralValue::LitNull)); + __m.insert("none".to_string(), Rc::new(LiteralValue::LitNull)); + __m.insert("null".to_string(), Rc::new(LiteralValue::LitNull)); Rc::new(__m) }; } @@ -126,41 +126,41 @@ pub fn dag_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("module"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("import"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("type"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("fn"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("func"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("resource"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("service"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("data"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("interface"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("pipeline"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("profile"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("pattern"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("let"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("return"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("match"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("if"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("then"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("else"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("for"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("in"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("where"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("with"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("none"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("acquire"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("release"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("capability"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("operation"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("input"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("output"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("idempotent"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("readonly"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("hermetic"), true); + __m.insert("module".to_string(), true); + __m.insert("import".to_string(), true); + __m.insert("type".to_string(), true); + __m.insert("fn".to_string(), true); + __m.insert("func".to_string(), true); + __m.insert("resource".to_string(), true); + __m.insert("service".to_string(), true); + __m.insert("data".to_string(), true); + __m.insert("interface".to_string(), true); + __m.insert("pipeline".to_string(), true); + __m.insert("profile".to_string(), true); + __m.insert("pattern".to_string(), true); + __m.insert("let".to_string(), true); + __m.insert("return".to_string(), true); + __m.insert("match".to_string(), true); + __m.insert("if".to_string(), true); + __m.insert("then".to_string(), true); + __m.insert("else".to_string(), true); + __m.insert("for".to_string(), true); + __m.insert("in".to_string(), true); + __m.insert("where".to_string(), true); + __m.insert("with".to_string(), true); + __m.insert("true".to_string(), true); + __m.insert("false".to_string(), true); + __m.insert("none".to_string(), true); + __m.insert("null".to_string(), true); + __m.insert("acquire".to_string(), true); + __m.insert("release".to_string(), true); + __m.insert("capability".to_string(), true); + __m.insert("operation".to_string(), true); + __m.insert("input".to_string(), true); + __m.insert("output".to_string(), true); + __m.insert("idempotent".to_string(), true); + __m.insert("readonly".to_string(), true); + __m.insert("hermetic".to_string(), true); Rc::new(__m) }; } @@ -171,12 +171,12 @@ pub fn dag_non_name_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("none"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("acquire"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("release"), true); + __m.insert("true".to_string(), true); + __m.insert("false".to_string(), true); + __m.insert("none".to_string(), true); + __m.insert("null".to_string(), true); + __m.insert("acquire".to_string(), true); + __m.insert("release".to_string(), true); Rc::new(__m) }; } @@ -292,20 +292,20 @@ pub fn v3_supported_dag_operators() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("||"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("&&"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("=="), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("!="), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("<"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host(">"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("<="), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host(">="), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("+"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("-"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("*"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("/"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("|>"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("."), true); + __m.insert("||".to_string(), true); + __m.insert("&&".to_string(), true); + __m.insert("==".to_string(), true); + __m.insert("!=".to_string(), true); + __m.insert("<".to_string(), true); + __m.insert(">".to_string(), true); + __m.insert("<=".to_string(), true); + __m.insert(">=".to_string(), true); + __m.insert("+".to_string(), true); + __m.insert("-".to_string(), true); + __m.insert("*".to_string(), true); + __m.insert("/".to_string(), true); + __m.insert("|>".to_string(), true); + __m.insert(".".to_string(), true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_go_emit.rs b/src/v1/stage0/src/extdeps_languages_go_emit.rs index cc05e9642c6..1ea6c48a70c 100644 --- a/src/v1/stage0/src/extdeps_languages_go_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_go_emit.rs @@ -15,13 +15,13 @@ pub fn go_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "true".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "false".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "nil".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "&&".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "||".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "!".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "/".to_string()); + __m.insert("true".to_string(), "true".to_string()); + __m.insert("false".to_string(), "false".to_string()); + __m.insert("null".to_string(), "nil".to_string()); + __m.insert("and".to_string(), "&&".to_string()); + __m.insert("or".to_string(), "||".to_string()); + __m.insert("not".to_string(), "!".to_string()); + __m.insert("div".to_string(), "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn go_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "[]{0}".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "map[{0}]struct{}".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "*{0}".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "map[{0}]{1}".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "[]{0}".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "map[{0}]{1}".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "bool".to_string()); + __m.insert("list".to_string(), "[]{0}".to_string()); + __m.insert("set".to_string(), "map[{0}]struct{}".to_string()); + __m.insert("optional".to_string(), "*{0}".to_string()); + __m.insert("map".to_string(), "map[{0}]{1}".to_string()); + __m.insert("free_monoid".to_string(), "[]{0}".to_string()); + __m.insert("partial_function".to_string(), "map[{0}]{1}".to_string()); + __m.insert("boolean_algebra".to_string(), "bool".to_string()); Rc::new(__m) }; } @@ -54,130 +54,130 @@ pub fn go_reserved() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn go_reserved_escape_suffix() -> Rc> { +pub fn go_reserved_escape_suffix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "_".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_func_keyword() -> Rc> { +pub fn go_func_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "func".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_async_prefix() -> Rc> { +pub fn go_async_prefix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_struct_keyword() -> Rc> { +pub fn go_struct_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "struct".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_enum_keyword() -> Rc> { +pub fn go_enum_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "type".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_type_alias_keyword() -> Rc> { +pub fn go_type_alias_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "type".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_param_separator() -> Rc> { +pub fn go_param_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ", ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_return_arrow() -> Rc> { +pub fn go_return_arrow() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { " ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_param_type_sep() -> Rc> { +pub fn go_param_type_sep() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { " ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_module_keyword() -> Rc> { +pub fn go_module_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "package".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_import_keyword() -> Rc> { +pub fn go_import_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "import".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_import_from_keyword() -> Rc> { +pub fn go_import_from_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_manifest_file() -> Rc> { +pub fn go_manifest_file() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "go.mod".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_source_extension() -> Rc> { +pub fn go_source_extension() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ".go".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn go_string_types() -> Rc> { @@ -201,126 +201,126 @@ pub fn go_simple_method_specs() -> Rc>> { pub fn go_method_templates_flat() -> Rc> { go_simple_method_specs().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), spec.template.clone()) }, ) } -pub fn go_lambda_template() -> Rc> { +pub fn go_lambda_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "func({0}) interface{} { {1} }".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_error_expr_template() -> Rc> { +pub fn go_error_expr_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "panic({0})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_list_literal_empty() -> Rc> { +pub fn go_list_literal_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[]interface{}{}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_list_literal_template() -> Rc> { +pub fn go_list_literal_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[]interface{}{{0}}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_null_coalesce_template() -> Rc> { +pub fn go_null_coalesce_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "func() interface{} { if {0} != nil { return {0} }; return {1} }()".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_error_type_template() -> Rc> { +pub fn go_error_type_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "__EMIT_BUG_{0}__".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_type_arg_open() -> Rc> { +pub fn go_type_arg_open() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "<".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_type_arg_close() -> Rc> { +pub fn go_type_arg_close() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ">".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_void_type() -> Rc> { +pub fn go_void_type() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_tuple_empty() -> Rc> { +pub fn go_tuple_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "struct{}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_tuple_pair_template() -> Rc> { +pub fn go_tuple_pair_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "struct{ First {0}; Second {1} }".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_tuple_multi_template() -> Rc> { +pub fn go_tuple_multi_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "struct{ {0} }".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_tuple_separator() -> Rc> { +pub fn go_tuple_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "; ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } diff --git a/src/v1/stage0/src/extdeps_languages_go_types.rs b/src/v1/stage0/src/extdeps_languages_go_types.rs index eca848ba4d0..7d529fc8148 100644 --- a/src/v1/stage0/src/extdeps_languages_go_types.rs +++ b/src/v1/stage0/src/extdeps_languages_go_types.rs @@ -41,80 +41,80 @@ pub fn go_callable() -> Rc { CACHED.with(|c: &Rc| c.clone()) } -pub fn pointer_template() -> Rc> { +pub fn pointer_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "*{0}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn go_optional_template() -> Rc> { +pub fn go_optional_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "*{0}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn address_of_template() -> Rc> { +pub fn address_of_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "&{value}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn nil_literal() -> Rc> { +pub fn nil_literal() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "nil".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn visibility_by_case() -> bool { true } -pub fn embedded_field_syntax() -> Rc> { +pub fn embedded_field_syntax() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{type}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn empty_interface() -> Rc> { +pub fn empty_interface() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "interface{}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn any_type() -> Rc> { +pub fn any_type() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "any".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn interface_def_template() -> Rc> { +pub fn interface_def_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "type {name} interface {\n{methods}\n}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn integer_types() -> Rc> { @@ -135,13 +135,13 @@ pub fn float_types() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn type_conversion_template() -> Rc> { +pub fn type_conversion_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{type}({expr})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn go_cast_syntax() -> Rc { diff --git a/src/v1/stage0/src/extdeps_languages_python_emit.rs b/src/v1/stage0/src/extdeps_languages_python_emit.rs index 04c578642ff..383495ab200 100644 --- a/src/v1/stage0/src/extdeps_languages_python_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_python_emit.rs @@ -15,13 +15,13 @@ pub fn python_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "True".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "False".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "None".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "and".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "or".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "not ".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "//".to_string()); + __m.insert("true".to_string(), "True".to_string()); + __m.insert("false".to_string(), "False".to_string()); + __m.insert("null".to_string(), "None".to_string()); + __m.insert("and".to_string(), "and".to_string()); + __m.insert("or".to_string(), "or".to_string()); + __m.insert("not".to_string(), "not ".to_string()); + __m.insert("div".to_string(), "//".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn python_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "list[{0}]".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "set[{0}]".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "Optional[{0}]".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "dict[{0}, {1}]".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "list[{0}]".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "dict[{0}, {1}]".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "bool".to_string()); + __m.insert("list".to_string(), "list[{0}]".to_string()); + __m.insert("set".to_string(), "set[{0}]".to_string()); + __m.insert("optional".to_string(), "Optional[{0}]".to_string()); + __m.insert("map".to_string(), "dict[{0}, {1}]".to_string()); + __m.insert("free_monoid".to_string(), "list[{0}]".to_string()); + __m.insert("partial_function".to_string(), "dict[{0}, {1}]".to_string()); + __m.insert("boolean_algebra".to_string(), "bool".to_string()); Rc::new(__m) }; } @@ -54,148 +54,148 @@ pub fn python_reserved() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn python_reserved_escape_suffix() -> Rc> { +pub fn python_reserved_escape_suffix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "_".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_derive_attribute() -> Rc> { +pub fn python_derive_attribute() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "@dataclass".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_default_value() -> Rc> { +pub fn python_default_value() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "None".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_func_keyword() -> Rc> { +pub fn python_func_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "def".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_async_prefix() -> Rc> { +pub fn python_async_prefix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "async ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_struct_keyword() -> Rc> { +pub fn python_struct_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "class".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_enum_keyword() -> Rc> { +pub fn python_enum_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "class".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_type_alias_keyword() -> Rc> { +pub fn python_type_alias_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_param_separator() -> Rc> { +pub fn python_param_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ", ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_return_arrow() -> Rc> { +pub fn python_return_arrow() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { " -> ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_param_type_sep() -> Rc> { +pub fn python_param_type_sep() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ": ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_module_keyword() -> Rc> { +pub fn python_module_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_import_keyword() -> Rc> { +pub fn python_import_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "import".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_import_from_keyword() -> Rc> { +pub fn python_import_from_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "from".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_source_extension() -> Rc> { +pub fn python_source_extension() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ".py".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_module_init() -> Rc> { +pub fn python_module_init() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "__init__.py".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn python_string_types() -> Rc> { @@ -219,126 +219,126 @@ pub fn python_simple_method_specs() -> Rc>> { pub fn python_method_templates_flat() -> Rc> { python_simple_method_specs().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), spec.template.clone()) }, ) } -pub fn python_lambda_template() -> Rc> { +pub fn python_lambda_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "lambda {0}: {1}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_error_expr_template() -> Rc> { +pub fn python_error_expr_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "raise RuntimeError({0})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_list_literal_empty() -> Rc> { +pub fn python_list_literal_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_list_literal_template() -> Rc> { +pub fn python_list_literal_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[{0}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_null_coalesce_template() -> Rc> { +pub fn python_null_coalesce_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "({0} if {0} is not None else {1})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_error_type_template() -> Rc> { +pub fn python_error_type_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "__EMIT_BUG_{0}__".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_type_arg_open() -> Rc> { +pub fn python_type_arg_open() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_type_arg_close() -> Rc> { +pub fn python_type_arg_close() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_void_type() -> Rc> { +pub fn python_void_type() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "None".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_tuple_empty() -> Rc> { +pub fn python_tuple_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Tuple".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_tuple_pair_template() -> Rc> { +pub fn python_tuple_pair_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Tuple[{0}, {1}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_tuple_multi_template() -> Rc> { +pub fn python_tuple_multi_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Tuple[{0}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_tuple_separator() -> Rc> { +pub fn python_tuple_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ", ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } diff --git a/src/v1/stage0/src/extdeps_languages_python_types.rs b/src/v1/stage0/src/extdeps_languages_python_types.rs index 64836ed0ca6..113a676ad25 100644 --- a/src/v1/stage0/src/extdeps_languages_python_types.rs +++ b/src/v1/stage0/src/extdeps_languages_python_types.rs @@ -51,202 +51,202 @@ pub enum PythonTypeKind { AnnotatedType, } -pub fn dataclass_decorator() -> Rc> { +pub fn dataclass_decorator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "@dataclass".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn dataclass_import() -> Rc> { +pub fn dataclass_import() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "from dataclasses import dataclass, field".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn field_default_template() -> Rc> { +pub fn field_default_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "field(default={value})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn field_default_factory_template() -> Rc> { +pub fn field_default_factory_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "field(default_factory={factory})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_enum_import() -> Rc> { +pub fn python_enum_import() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "from enum import Enum, auto".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn enum_class_template() -> Rc> { +pub fn enum_class_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "class {name}(Enum):\n{variants}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn enum_auto_value() -> Rc> { +pub fn enum_auto_value() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "auto()".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn union_syntax() -> Rc> { +pub fn union_syntax() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{a} | {b}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn optional_syntax() -> Rc> { +pub fn optional_syntax() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{type} | None".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn typing_optional() -> Rc> { +pub fn typing_optional() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Optional[{type}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_optional_template() -> Rc> { +pub fn python_optional_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Optional[{0}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn typing_union() -> Rc> { +pub fn typing_union() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Union[{types}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn python_typing_import() -> Rc> { +pub fn python_typing_import() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "from typing import Optional, Union".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn type_alias_template() -> Rc> { +pub fn type_alias_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{name} = {type}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn generic_param_template() -> Rc> { +pub fn generic_param_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "[{params}]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn typing_generic_import() -> Rc> { +pub fn typing_generic_import() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "from typing import Generic, TypeVar".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn none_literal() -> Rc> { +pub fn none_literal() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "None".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn none_check_template() -> Rc> { +pub fn none_check_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{expr} is None".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn none_not_check_template() -> Rc> { +pub fn none_not_check_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{expr} is not None".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn pass_statement() -> Rc> { +pub fn pass_statement() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "pass".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn type_checker() -> Rc> { +pub fn type_checker() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "mypy".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn type_checker_strict() -> Rc> { +pub fn type_checker_strict() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "mypy --strict".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn python_cast_syntax() -> Rc { @@ -258,6 +258,3 @@ pub fn python_cast_syntax() -> Rc { } CACHED.with(|c: &Rc| c.clone()) } - -pub struct DynamicType; -pub struct AnnotatedType; diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index b4cacad1608..1892d93af82 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -15,13 +15,13 @@ pub fn rust_keywords() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), "true".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), "false".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("null"), "None".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("and"), "&&".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("or"), "||".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("not"), "!".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("div"), "/".to_string()); + __m.insert("true".to_string(), "true".to_string()); + __m.insert("false".to_string(), "false".to_string()); + __m.insert("null".to_string(), "None".to_string()); + __m.insert("and".to_string(), "&&".to_string()); + __m.insert("or".to_string(), "||".to_string()); + __m.insert("not".to_string(), "!".to_string()); + __m.insert("div".to_string(), "/".to_string()); Rc::new(__m) }; } @@ -32,13 +32,13 @@ pub fn rust_container_templates() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "Vec<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "std::collections::BTreeSet<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("optional"), "Option<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "HashMap<{0}, {1}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "Vec<{0}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "HashMap<{0}, {1}>".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "bool".to_string()); + __m.insert("list".to_string(), "Vec<{0}>".to_string()); + __m.insert("set".to_string(), "std::collections::BTreeSet<{0}>".to_string()); + __m.insert("optional".to_string(), "Option<{0}>".to_string()); + __m.insert("map".to_string(), "HashMap<{0}, {1}>".to_string()); + __m.insert("free_monoid".to_string(), "Vec<{0}>".to_string()); + __m.insert("partial_function".to_string(), "HashMap<{0}, {1}>".to_string()); + __m.insert("boolean_algebra".to_string(), "bool".to_string()); Rc::new(__m) }; } @@ -57,7 +57,7 @@ pub fn rust_simple_method_specs() -> Rc>> { pub fn rust_method_templates() -> Rc> { rust_simple_method_specs().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), spec.template.clone()) }, @@ -77,7 +77,7 @@ pub fn rust_method_wraps_result() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, spec: Rc| { v1_rt::rc_map_insert(acc, spec.method_name.clone(), true) }, @@ -93,13 +93,13 @@ pub fn rust_reserved() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_reserved_escape_suffix() -> Rc> { +pub fn rust_reserved_escape_suffix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "_".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn rust_string_types() -> Rc> { @@ -111,325 +111,325 @@ pub fn rust_string_types() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn rust_struct_derives() -> Rc> { +pub fn rust_struct_derives() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_struct_derives_copy() -> Rc> { +pub fn rust_struct_derives_copy() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_enum_derives() -> Rc> { +pub fn rust_enum_derives() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_enum_derives_copy() -> Rc> { +pub fn rust_enum_derives_copy() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_serde_tag() -> Rc> { +pub fn rust_serde_tag() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[serde(tag = \"_variant\")]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_serde_rename_all_snake_case() -> Rc> { +pub fn rust_serde_rename_all_snake_case() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[serde(rename_all = \"snake_case\")]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_serde_rename_all_screaming_snake_case() -> Rc> { +pub fn rust_serde_rename_all_screaming_snake_case() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[serde(rename_all = \"SCREAMING_SNAKE_CASE\")]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_serde_rename_template() -> Rc> { +pub fn rust_serde_rename_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[serde(rename = \"{0}\")]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_func_keyword() -> Rc> { +pub fn rust_func_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "fn".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_async_prefix() -> Rc> { +pub fn rust_async_prefix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "async ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_struct_keyword() -> Rc> { +pub fn rust_struct_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "struct".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_enum_keyword() -> Rc> { +pub fn rust_enum_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "enum".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_type_alias_keyword() -> Rc> { +pub fn rust_type_alias_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "type".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_param_separator() -> Rc> { +pub fn rust_param_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ", ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_return_arrow() -> Rc> { +pub fn rust_return_arrow() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { " -> ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_param_type_sep() -> Rc> { +pub fn rust_param_type_sep() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ": ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_module_keyword() -> Rc> { +pub fn rust_module_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "mod".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_import_keyword() -> Rc> { +pub fn rust_import_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "use".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_import_from_keyword() -> Rc> { +pub fn rust_import_from_keyword() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_lambda_template() -> Rc> { +pub fn rust_lambda_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "|{0}| {1}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_error_expr_template() -> Rc> { +pub fn rust_error_expr_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "panic!({0})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_list_literal_empty() -> Rc> { +pub fn rust_list_literal_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Rc::new(vec![])".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_list_literal_template() -> Rc> { +pub fn rust_list_literal_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Rc::new(vec![{0}])".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_null_coalesce_template() -> Rc> { +pub fn rust_null_coalesce_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{0}.unwrap_or_else(|| {1})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_error_type_template() -> Rc> { +pub fn rust_error_type_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "compile_error!(\"{0}\")".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_type_arg_open() -> Rc> { +pub fn rust_type_arg_open() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "<".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_type_arg_close() -> Rc> { +pub fn rust_type_arg_close() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ">".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_void_type() -> Rc> { +pub fn rust_void_type() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "()".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_tuple_empty() -> Rc> { +pub fn rust_tuple_empty() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "()".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_tuple_pair_template() -> Rc> { +pub fn rust_tuple_pair_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "({0}, {1})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_tuple_multi_template() -> Rc> { +pub fn rust_tuple_multi_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "({0})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_tuple_separator() -> Rc> { +pub fn rust_tuple_separator() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ", ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_source_extension() -> Rc> { +pub fn rust_source_extension() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { ".rs".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_source_dir() -> Rc> { +pub fn rust_source_dir() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "src/".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_visibility() -> Rc> { +pub fn rust_visibility() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "pub ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RuntimeFunction { - pub name: Rc>, - pub bridge_name: Rc>, + pub name: String, + pub bridge_name: String, pub passes_by_ref: bool, pub wraps_result: bool, } @@ -446,7 +446,7 @@ pub fn rt_function_registry() -> Rc>> { pub fn rt_functions() -> Rc> { rt_function_registry().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), true) }, @@ -466,7 +466,7 @@ pub fn rt_ref_map_functions() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), true) }, @@ -486,7 +486,7 @@ pub fn rt_wraps_result() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), true) }, @@ -497,9 +497,7 @@ pub fn rt_bridge_function_names() -> Rc> { Rc::new({ let mut __result = Vec::new(); for f in rt_function_registry().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(f.name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host(f.bridge_name.clone())) - { + if (f.name.clone().as_str() != f.bridge_name.clone().as_str()) { __result.push(f); } } @@ -508,33 +506,33 @@ pub fn rt_bridge_function_names() -> Rc> { .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), entry.bridge_name.clone()) }, ) } -pub fn is_rt_function(name: Rc>) -> bool { +pub fn is_rt_function(name: String) -> bool { v1_rt::map_contains_key(&rt_functions(), name) } -pub fn rt_bridge_name(name: Rc>) -> Rc> { +pub fn rt_bridge_name(name: String) -> String { match v1_rt::map_get(&rt_bridge_function_names(), name.clone()) { Some(bridge) => bridge.clone(), None => name.clone(), } } -pub fn rt_passes_by_ref(name: Rc>) -> bool { +pub fn rt_passes_by_ref(name: String) -> bool { v1_rt::map_contains_key(&rt_ref_map_functions(), name) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct HigherOrderMethodSpec { - pub method_name: Rc>, - pub inline_template: Rc>, - pub fn_ref_template: Rc>, + pub method_name: String, + pub inline_template: String, + pub fn_ref_template: String, pub wraps_in_sharing: bool, } diff --git a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs index e8680b50a0d..a9ef8cc021c 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs @@ -113,10 +113,10 @@ pub fn rust_keyword_literals() -> Rc>> { thread_local! { static CACHED: Rc>> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), Rc::new(LiteralValue::LitBool { + __m.insert("true".to_string(), Rc::new(LiteralValue::LitBool { value: true, })); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), Rc::new(LiteralValue::LitBool { + __m.insert("false".to_string(), Rc::new(LiteralValue::LitBool { value: false, })); Rc::new(__m) @@ -129,43 +129,43 @@ pub fn rust_keyword_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("fn"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("struct"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("enum"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("type"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("trait"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("impl"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("const"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("static"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("mod"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("use"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("let"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("mut"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("return"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("match"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("if"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("else"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("for"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("in"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("while"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("loop"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("break"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("continue"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("pub"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("self"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("super"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("crate"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("as"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("where"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("ref"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("move"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("async"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("await"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("dyn"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("unsafe"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("extern"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("true"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("false"), true); + __m.insert("fn".to_string(), true); + __m.insert("struct".to_string(), true); + __m.insert("enum".to_string(), true); + __m.insert("type".to_string(), true); + __m.insert("trait".to_string(), true); + __m.insert("impl".to_string(), true); + __m.insert("const".to_string(), true); + __m.insert("static".to_string(), true); + __m.insert("mod".to_string(), true); + __m.insert("use".to_string(), true); + __m.insert("let".to_string(), true); + __m.insert("mut".to_string(), true); + __m.insert("return".to_string(), true); + __m.insert("match".to_string(), true); + __m.insert("if".to_string(), true); + __m.insert("else".to_string(), true); + __m.insert("for".to_string(), true); + __m.insert("in".to_string(), true); + __m.insert("while".to_string(), true); + __m.insert("loop".to_string(), true); + __m.insert("break".to_string(), true); + __m.insert("continue".to_string(), true); + __m.insert("pub".to_string(), true); + __m.insert("self".to_string(), true); + __m.insert("super".to_string(), true); + __m.insert("crate".to_string(), true); + __m.insert("as".to_string(), true); + __m.insert("where".to_string(), true); + __m.insert("ref".to_string(), true); + __m.insert("move".to_string(), true); + __m.insert("async".to_string(), true); + __m.insert("await".to_string(), true); + __m.insert("dyn".to_string(), true); + __m.insert("unsafe".to_string(), true); + __m.insert("extern".to_string(), true); + __m.insert("true".to_string(), true); + __m.insert("false".to_string(), true); Rc::new(__m) }; } diff --git a/src/v1/stage0/src/extdeps_languages_rust_types.rs b/src/v1/stage0/src/extdeps_languages_rust_types.rs index 632ea8c6462..eb83a073861 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_types.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_types.rs @@ -33,31 +33,31 @@ pub fn rust_algebra_inhabitants() -> Rc>> { CACHED.with(|c: &Rc>>| c.clone()) } -pub fn rust_optional_template() -> Rc> { +pub fn rust_optional_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Option<{0}>".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_none_expr() -> Rc> { +pub fn rust_none_expr() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "None".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rust_some_template() -> Rc> { +pub fn rust_some_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Some({0})".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn rust_callable() -> Rc { @@ -89,22 +89,22 @@ pub fn pass_non_copy_by_ref() -> bool { true } -pub fn ref_prefix() -> Rc> { +pub fn ref_prefix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "&".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn mut_ref_prefix() -> Rc> { +pub fn mut_ref_prefix() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "&mut ".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } #[derive( @@ -117,31 +117,31 @@ pub enum SmartPointerKind { ArcPtr, } -pub fn box_template() -> Rc> { +pub fn box_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Box<{0}>".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn rc_template() -> Rc> { +pub fn rc_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Rc<{0}>".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn arc_template() -> Rc> { +pub fn arc_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "Arc<{0}>".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn common_trait_bounds() -> Rc> { @@ -153,22 +153,22 @@ pub fn common_trait_bounds() -> Rc> { CACHED.with(|c: &Rc>| c.clone()) } -pub fn where_clause_template() -> Rc> { +pub fn where_clause_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "where\n {constraints}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn trait_bound_template() -> Rc> { +pub fn trait_bound_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "{type}: {bound}".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } pub fn integer_types() -> Rc> { @@ -199,28 +199,20 @@ pub fn rust_cast_syntax() -> Rc { CACHED.with(|c: &Rc| c.clone()) } -pub fn serde_enum_tag_attribute() -> Rc> { +pub fn serde_enum_tag_attribute() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[serde(tag = \"_variant\")]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } -pub fn serde_rename_template() -> Rc> { +pub fn serde_rename_template() -> String { thread_local! { - static CACHED: Rc> = { + static CACHED: String = { "#[serde(rename = \"{key}\")]".to_string() }; } - CACHED.with(|c: &Rc>| c.clone()) + CACHED.with(|c: &String| c.clone()) } - -pub struct Owned; -pub struct SharedRef; -pub struct MutRef; -pub struct RawPtr; -pub struct BoxPtr; -pub struct RcPtr; -pub struct ArcPtr; diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index 2adffafffe6..7383cb17be5 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -15,7 +15,6 @@ pub mod cli_run; pub mod coproduct_reflection; pub mod extdeps_cargo; -pub mod extdeps_cargo_version; pub mod extdeps_languages_dag_emit; pub mod extdeps_languages_dag_syntax; pub mod extdeps_languages_dag_types; @@ -29,10 +28,9 @@ pub mod extdeps_languages_rust_emit; pub mod extdeps_languages_rust_syntax; pub mod extdeps_languages_rust_types; pub mod extdeps_shape_transport_policy_project; -pub mod extdeps_version; -pub mod extdeps_version_semver; pub mod fact_cardinality_census; pub mod import_resolution_project; +pub mod languages_consumer_census; pub mod layering_imports_project; pub mod module_path_index; pub mod recorded_fixture; @@ -49,7 +47,6 @@ pub mod std_http_path; pub mod std_induction; pub mod std_iteration; pub mod std_node; -pub mod std_serialization; pub mod std_syntax; pub mod std_termination; pub mod std_types; diff --git a/src/v1/stage0/src/main.rs b/src/v1/stage0/src/main.rs index 52ee2e54b0b..5817bef1c05 100644 --- a/src/v1/stage0/src/main.rs +++ b/src/v1/stage0/src/main.rs @@ -44,6 +44,8 @@ enum Commands { #[arg(long, default_value = "rust")] target: String, }, + /// Run repo CI from CiSpec (delegates to dsl/tools/gunbc_ci.dag) + Ci, /// Execute a .dag program directly (interpreter) Run { /// Source root directories (searched recursively for .dag files) @@ -384,6 +386,10 @@ fn main() { } } + Commands::Ci {} => { + cli_run::handle_ci(); + } + Commands::Run { source_roots, function, diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index 431b9c53e82..e4beb0a704e 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -199,10 +199,10 @@ pub enum AlgebraProfile { #[serde(tag = "_variant")] pub enum ContainerSource { SameAsReceiver, - Named { name: Rc> }, + Named { name: String }, } impl ContainerSource { - pub fn name(&self) -> Rc> { + pub fn name(&self) -> String { match self { ContainerSource::SameAsReceiver => panic!("no name on unit variant"), ContainerSource::Named { name: __val, .. } => __val.clone(), @@ -218,7 +218,7 @@ pub enum AlgebraTypeTemplate { ReceiverKey, ReceiverValue, NamedTemplate { - name: Rc>, + name: String, }, ContainerOf { source: Rc, @@ -239,7 +239,7 @@ pub enum AlgebraTypeTemplate { return_type: Rc, }, AlgebraTypeVariable { - id: Rc>, + id: String, }, } @@ -266,7 +266,7 @@ pub enum CostShape { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct AlgebraFieldTemplate { - pub name: Rc>, + pub name: String, pub param_types: Rc>>, pub return_type: Rc, pub size_effect: Option, @@ -278,13 +278,13 @@ pub fn kernel_algebra_profile() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Int"), AlgebraProfile::OrderedRingProfile); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Float"), AlgebraProfile::ApproximateFieldProfile); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Bool"), AlgebraProfile::BooleanAlgebraProfile); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("String"), AlgebraProfile::FreeMonoidScalarProfile); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), AlgebraProfile::FreeMonoidCollectionProfile); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), AlgebraProfile::BooleanAlgebraCollectionProfile); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), AlgebraProfile::PartialFunctionProfile); + __m.insert("Int".to_string(), AlgebraProfile::OrderedRingProfile); + __m.insert("Float".to_string(), AlgebraProfile::ApproximateFieldProfile); + __m.insert("Bool".to_string(), AlgebraProfile::BooleanAlgebraProfile); + __m.insert("String".to_string(), AlgebraProfile::FreeMonoidScalarProfile); + __m.insert("List".to_string(), AlgebraProfile::FreeMonoidCollectionProfile); + __m.insert("Set".to_string(), AlgebraProfile::BooleanAlgebraCollectionProfile); + __m.insert("Map".to_string(), AlgebraProfile::PartialFunctionProfile); Rc::new(__m) }; } @@ -1416,21 +1416,3 @@ pub fn algebra_type_param_names(profile: AlgebraProfile) -> Rc> { AlgebraProfile::PartialFunctionProfile => Rc::new(vec!["K".to_string(), "V".to_string()]), } } - -pub struct Less; -pub struct Equal; -pub struct Greater; -pub struct OrderedRingProfile; -pub struct ApproximateFieldProfile; -pub struct BooleanAlgebraProfile; -pub struct BooleanAlgebraCollectionProfile; -pub struct FreeMonoidScalarProfile; -pub struct FreeMonoidCollectionProfile; -pub struct PartialFunctionProfile; -pub struct ShrinkEffect; -pub struct ProjectionEffect; -pub struct IdentityEffect; -pub struct ShapeConstant; -pub struct ShapeLinearScan; -pub struct ShapeIterateBody; -pub struct ShapeSortBody; diff --git a/src/v1/stage0/src/std_coercion.rs b/src/v1/stage0/src/std_coercion.rs index f8e946d7a45..861c5852c1a 100644 --- a/src/v1/stage0/src/std_coercion.rs +++ b/src/v1/stage0/src/std_coercion.rs @@ -12,40 +12,40 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeCheckpoint { - pub dag_name: Rc>, - pub target_type: Rc>, - pub default_expr: Rc>, + pub dag_name: String, + pub target_type: String, + pub default_expr: Option, pub is_copy: Option, - pub literal_suffix: Rc>, + pub literal_suffix: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct InhabitantDecl { - pub algebra: Rc>, - pub template: Rc>, + pub algebra: String, + pub template: String, pub arity: i64, - pub identity_expr: Rc>, - pub import_path: Rc>, + pub identity_expr: Option, + pub import_path: Option, pub is_copy: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CallableRepr { - pub template: Rc>, - pub param_separator: Rc>, - pub return_separator: Rc>, - pub import_path: Rc>, + pub template: String, + pub param_separator: String, + pub return_separator: String, + pub import_path: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CastRule { - pub from_type: Rc>, - pub to_type: Rc>, + pub from_type: String, + pub to_type: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CastSyntax { - pub template: Rc>, + pub template: String, pub cast_rules: Rc>>, } @@ -59,14 +59,12 @@ pub fn dag_cast_rules() -> Rc>> { CACHED.with(|c: &Rc>>| c.clone()) } -pub fn dag_can_cast(source_type: Rc>, target_type: Rc>) -> bool { +pub fn dag_can_cast(source_type: String, target_type: String) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((crate::v2_std_text::host_string_text_to_rust_host(r.from_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(source_type.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(r.to_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(target_type.clone()))) + if ((r.from_type.clone().as_str() == source_type.clone().as_str()) + && (r.to_type.clone().as_str() == target_type.clone().as_str())) { __found = true; break; @@ -76,14 +74,12 @@ pub fn dag_can_cast(source_type: Rc>, target_type: Rc>) -> bool { +pub fn is_dag_cast_domain_type(name: String) -> bool { { let mut __found = false; for r in dag_cast_rules().iter().cloned() { - if ((crate::v2_std_text::host_string_text_to_rust_host(r.from_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) - || (crate::v2_std_text::host_string_text_to_rust_host(r.to_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(name.clone()))) + if ((r.from_type.clone().as_str() == name.clone().as_str()) + || (r.to_type.clone().as_str() == name.clone().as_str())) { __found = true; break; diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index 7f9ca88ac83..2337843f5b2 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -33,17 +33,17 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum SizeBound { - CollectionSize { param: Rc> }, - ParserStreamSize { witness: Rc> }, - WorklistDrainSize { element: Rc> }, - TreeSize { param: Rc> }, - ArithmeticParam { param: Rc> }, + CollectionSize { param: String }, + ParserStreamSize { witness: String }, + WorklistDrainSize { element: String }, + TreeSize { param: String }, + ArithmeticParam { param: String }, ExplicitCountZero, ExplicitCountPositive { steps: Rc }, Forever, } -pub fn tree_size_bound(param: Rc>) -> Rc { +pub fn tree_size_bound(param: String) -> Rc { Rc::new(SizeBound::TreeSize { param: param }) } @@ -51,28 +51,28 @@ pub fn tree_size_bound(param: Rc>) -> Rc { #[serde(tag = "_variant")] pub enum CallPattern { ChildAccessorCall { - accessor: Rc>, + accessor: String, }, CollectionShrinkCall { amount: Rc, - collection: Rc>, + collection: String, }, ArithmeticSubtractCall { steps: Rc, - ring_param: Rc>, + ring_param: String, }, ArithmeticDivideCall { divisor: Rc, - ring_param: Rc>, + ring_param: String, }, ParserAdvanceCall { - witness: Rc>, + witness: String, }, WorklistDrainCall { - element: Rc>, + element: String, }, FoldBodyCall { - outer_collection: Rc>, + outer_collection: String, }, SameArgumentCall, } @@ -173,7 +173,7 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { } } -pub fn size_bound_param(bound: Rc) -> Rc> { +pub fn size_bound_param(bound: Rc) -> Option { match (*bound).clone() { SizeBound::TreeSize { param: p, .. } => Some(p.clone()), SizeBound::CollectionSize { param: p, .. } => Some(p.clone()), @@ -232,10 +232,8 @@ pub fn algebra_profile_to_dimension(profile: AlgebraProfile) -> Option>) -> Option { - if (crate::v2_std_text::host_string_text_to_rust_host(type_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("Node".to_string())) - { +pub fn type_iteration_dimension(type_name: String) -> Option { + if (type_name.clone().as_str() == "Node".to_string().as_str()) { Some(IterationDimension::TreeDescent) } else { match v1_rt::map_get(&kernel_algebra_profile(), type_name.clone()) { @@ -244,10 +242,3 @@ pub fn type_iteration_dimension(type_name: Rc>) -> Option> }, - InputField { field: Rc> }, + PathParam { param: String }, + InputField { field: String }, CompositeKey { fields: Rc> }, } @@ -67,7 +66,7 @@ pub enum IdempotencyEvidence { IdentityEffect, NonIdempotent { shape: Rc, - reason: Rc>, + reason: String, }, } impl IdempotencyEvidence { @@ -96,24 +95,18 @@ pub fn is_idempotent_effect(shape: Rc) -> bool { } } -pub fn key_source_eq(left: Rc, right: Rc) -> bool { - match (*left).clone() { - KeySource::PathParam { param: pa, .. } => match (*right).clone() { - KeySource::PathParam { param: pb, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(pa.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(pb.clone())) - } +pub fn key_source_eq(a: Rc, b: Rc) -> bool { + match (*a).clone() { + KeySource::PathParam { param: pa, .. } => match (*b).clone() { + KeySource::PathParam { param: pb, .. } => (pa.clone().as_str() == pb.clone().as_str()), _ => false, }, - KeySource::InputField { field: fa, .. } => match (*right).clone() { - KeySource::InputField { field: fb, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(fa.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(fb.clone())) - } + KeySource::InputField { field: fa, .. } => match (*b).clone() { + KeySource::InputField { field: fb, .. } => (fa.clone().as_str() == fb.clone().as_str()), _ => false, }, - KeySource::CompositeKey { fields: fa, .. } => match (*right).clone() { - KeySource::CompositeKey { fields: fb, .. } => string_list_eq(fa.clone(), fb.clone()), + KeySource::CompositeKey { fields: fa, .. } => match (*b).clone() { + KeySource::CompositeKey { fields: fb, .. } => (fa.clone() == fb.clone()), _ => false, }, } @@ -154,7 +147,7 @@ pub fn create_double_init_collapsible(a: Rc, b: Rc) -> #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OperationEffect { - pub operation_name: Rc>, + pub operation_name: String, pub shape: Rc, pub evidence: Rc, } @@ -202,7 +195,7 @@ pub fn compose_effects(effects: Rc>>) -> Rc>, + pub operation_name: String, pub method: HttpMethod, pub path_template: Rc, pub shape: Rc, @@ -215,11 +208,11 @@ pub enum DeriveOpEffectResult { effect: Rc, }, MalformedPathInput { - operation_name: Rc>, + operation_name: String, method: HttpMethod, - raw_path: Rc>, - segment: Rc>, - reason: Rc>, + raw_path: String, + segment: String, + reason: String, }, } @@ -259,7 +252,7 @@ pub fn derive_effect_shape(method: HttpMethod, path: Rc) -> Rc>, + operation_name: String, method: HttpMethod, path: Rc, ) -> Rc { @@ -280,11 +273,11 @@ pub fn derive_op_effect( #[serde(tag = "_variant")] pub enum ModifierAgreement { Agrees, - Disagrees { reason: Rc> }, - DerivationUnknown { reason: Rc> }, + Disagrees { reason: String }, + DerivationUnknown { reason: String }, } impl ModifierAgreement { - pub fn reason(&self) -> Rc> { + pub fn reason(&self) -> String { match self { ModifierAgreement::Agrees => panic!("no reason on unit variant"), ModifierAgreement::Disagrees { reason: __val, .. } => __val.clone(), @@ -295,7 +288,7 @@ impl ModifierAgreement { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ModifierCheck { - pub operation_name: Rc>, + pub operation_name: String, pub declared_idempotent: bool, pub declared_readonly: bool, pub derived_shape: Rc, @@ -314,14 +307,16 @@ pub fn check_modifier_vs_derivation( } else { if (declared_idempotent.clone() && !derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { ref cause, .. } => { - let CreateCause::PostAlways = cause.as_ref() else { - unreachable!() - }; - Rc::new(ModifierAgreement::DerivationUnknown { - reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared".to_string(), -}) - } + EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { + CreateCause::PostAlways => Rc::new(ModifierAgreement::DerivationUnknown { + reason: "POST with no path key derives CreateEffect; idempotency may be spec-declared" + .to_string(), + }), + CreateCause::CreateIfAbsent { .. } => Rc::new(ModifierAgreement::Disagrees { + reason: "derivation says non-idempotent but modifier declares idempotent" + .to_string(), + }), + }, _ => Rc::new(ModifierAgreement::Disagrees { reason: "derivation says non-idempotent but modifier declares idempotent" .to_string(), @@ -330,18 +325,15 @@ pub fn check_modifier_vs_derivation( } else { if (!declared_idempotent.clone() && derived_idempotent.clone()) { match (*op.shape.clone()).clone() { - EffectShape::CreateEffect { ref cause, .. } => { - let CreateCause::CreateIfAbsent { - key_source: key_source, - .. - } = cause.as_ref() - else { - unreachable!() - }; - Rc::new(ModifierAgreement::Disagrees { - reason: "create-if-absent has proven identity but modifier declares non-idempotent".to_string(), -}) - } + EffectShape::CreateEffect { cause, .. } => match (*cause).clone() { + CreateCause::CreateIfAbsent { .. } => { + Rc::new(ModifierAgreement::Disagrees { + reason: "create-if-absent has proven identity but modifier declares non-idempotent" + .to_string(), + }) + } + CreateCause::PostAlways => Rc::new(ModifierAgreement::Agrees), + }, _ => Rc::new(ModifierAgreement::Agrees), } } else { @@ -373,9 +365,9 @@ pub fn check_modifier_vs_derivation( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct IdempotencyTestObligation { - pub operation_name: Rc>, + pub operation_name: String, pub effect_shape: Rc, - pub claim: Rc>, + pub claim: String, pub witness_required: bool, } @@ -409,7 +401,7 @@ pub fn generate_idempotency_obligations( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct WorkflowEffectConcern { - pub workflow_name: Rc>, - pub create_op: Rc>, - pub reason: Rc>, + pub workflow_name: String, + pub create_op: String, + pub reason: String, } diff --git a/src/v1/stage0/src/std_emit_model.rs b/src/v1/stage0/src/std_emit_model.rs index 88117c9d09e..5bd6eebf3a1 100644 --- a/src/v1/stage0/src/std_emit_model.rs +++ b/src/v1/stage0/src/std_emit_model.rs @@ -2,7 +2,6 @@ // Source module: std.emit_model use self::PlaceholderConvention::*; -pub use crate::std_serialization::DeclarationRef; use crate::v1_rt; use crate::v1_rt::Witness; use crate::v1_rt::Witness::{Holds, Violates}; @@ -12,6 +11,8 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; +pub type DeclarationRef = String; + #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, )] @@ -23,19 +24,16 @@ pub enum PlaceholderConvention { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SimpleMethodSpec { - pub method_name: Rc>, - pub template: Rc>, + pub method_name: String, + pub template: String, pub wraps_result: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct MethodTemplateContract { pub dag_method: Box, - pub runtime_template: Rc>, - pub emit_template: Rc>, + pub runtime_template: String, + pub emit_template: String, pub wraps_result: bool, pub placeholder_convention: PlaceholderConvention, } - -pub struct IndexedArgs; -pub struct NamedArg; diff --git a/src/v1/stage0/src/std_error_primitives.rs b/src/v1/stage0/src/std_error_primitives.rs index b6cf7b7a27a..e0c45702a3b 100644 --- a/src/v1/stage0/src/std_error_primitives.rs +++ b/src/v1/stage0/src/std_error_primitives.rs @@ -29,6 +29,3 @@ pub enum DivError { DivideByZero, Overflow, } - -pub struct DivideByZero; -pub struct Overflow; diff --git a/src/v1/stage0/src/std_graph.rs b/src/v1/stage0/src/std_graph.rs index e57741988ed..0a335410820 100644 --- a/src/v1/stage0/src/std_graph.rs +++ b/src/v1/stage0/src/std_graph.rs @@ -14,8 +14,8 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct GraphEdge { - pub caller: Rc>, - pub callee: Rc>, + pub caller: String, + pub callee: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -49,8 +49,8 @@ pub struct SccCycleAcc { pub fn seed_adjacency_map(names: Rc>) -> Rc>>> { names.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), - |acc: Rc>>>, name: Rc>| { + v1_rt::rc_empty_map::>>(), + |acc: Rc>>>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), Rc::new(vec![])) }, ) @@ -66,9 +66,7 @@ pub fn build_call_graph_from_proof_edges( for e in Rc::new({ let mut __result = Vec::new(); for e in edges.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(e.caller.clone()) - != crate::v2_std_text::host_string_text_to_rust_host(e.callee.clone())) - { + if (e.caller.clone().as_str() != e.callee.clone().as_str()) { __result.push(e); } } @@ -142,7 +140,7 @@ pub fn reverse_adjacency( } pub fn dfs_finish_order( - node: Rc>, + node: String, adjacency: Rc>>>, acc: Rc, ) -> Rc { @@ -161,7 +159,7 @@ pub fn dfs_finish_order( visited: next_visited, order: acc.order.clone(), }), - |inner: Rc, neighbor: Rc>| { + |inner: Rc, neighbor: String| { dfs_finish_order(neighbor.clone(), adjacency.clone(), inner) }, ); @@ -175,7 +173,7 @@ pub fn dfs_finish_order( } pub fn dfs_collect_component( - node: Rc>, + node: String, adjacency: Rc>>>, acc: Rc, ) -> Rc { @@ -195,7 +193,7 @@ pub fn dfs_collect_component( visited: next_visited, members: next_members, }), - |inner: Rc, neighbor: Rc>| { + |inner: Rc, neighbor: String| { dfs_collect_component(neighbor.clone(), adjacency.clone(), inner) }, ) @@ -212,7 +210,7 @@ pub fn graph_has_multi_node_scc(names: Rc>, graph: Rc) -> visited: v1_rt::rc_empty_set::(), order: Rc::new(vec![]), }), - |acc: Rc, name: Rc>| { + |acc: Rc, name: String| { dfs_finish_order(name.clone(), adjacency.forward.clone(), acc) }, ); @@ -221,7 +219,7 @@ pub fn graph_has_multi_node_scc(names: Rc>, graph: Rc) -> visited: v1_rt::rc_empty_set::(), has_cycle: false, }), - |acc: Rc, name: Rc>| { + |acc: Rc, name: String| { if (acc.has_cycle.clone() || v1_rt::set_contains(&acc.visited.clone(), name.clone())) { @@ -294,9 +292,7 @@ pub fn is_valid_proof(proof: Rc, edges: Rc>> let has_self_cycle = { let mut __found = false; for e in non_descending.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(e.caller.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(e.callee.clone())) - { + if (e.caller.clone().as_str() == e.callee.clone().as_str()) { __found = true; break; } diff --git a/src/v1/stage0/src/std_http_path.rs b/src/v1/stage0/src/std_http_path.rs index dc23ae5282d..f5dd9a50bec 100644 --- a/src/v1/stage0/src/std_http_path.rs +++ b/src/v1/stage0/src/std_http_path.rs @@ -16,8 +16,8 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum UrlPathToken { - LiteralToken { text: Rc> }, - ParamToken { name: Rc> }, + LiteralToken { text: String }, + ParamToken { name: String }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -28,13 +28,8 @@ pub struct PathTemplate { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum PathSegmentTokensResult { - ParsedSegmentTokens { - tokens: Rc>>, - }, - MalformedPathSegment { - segment: Rc>, - reason: Rc>, - }, + ParsedSegmentTokens { tokens: Rc>> }, + MalformedPathSegment { segment: String, reason: String }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -44,13 +39,13 @@ pub enum PathTemplateParseResult { template: Rc, }, MalformedPathTemplate { - raw: Rc>, - segment: Rc>, - reason: Rc>, + raw: String, + segment: String, + reason: String, }, } -pub fn parse_path_template(raw: Rc>) -> Rc { +pub fn parse_path_template(raw: String) -> Rc { { let path_only = match Rc::new( raw.clone() @@ -75,9 +70,7 @@ pub fn parse_path_template(raw: Rc>) -> Rc>) -> Rc, seg: Rc>| match (*acc - .clone()) - .clone() + |acc: Rc, seg: String| match (*acc.clone()).clone() { PathTemplateParseResult::MalformedPathTemplate { .. } => acc.clone(), PathTemplateParseResult::ParsedPathTemplate { @@ -157,7 +148,7 @@ pub fn parse_path_template(raw: Rc>) -> Rc>) -> Rc { +pub fn parse_segment_tokens(seg: String) -> Rc { if !v1_rt::contains(seg.clone(), "{".to_string()) { if v1_rt::contains(seg.clone(), "}".to_string()) { Rc::new(PathSegmentTokensResult::MalformedPathSegment { @@ -236,38 +227,28 @@ pub fn parse_segment_tokens(seg: Rc>) -> Rc) -> bool { } } -pub fn last_path_param(template: Rc) -> Rc> { +pub fn last_path_param(template: Rc) -> Option { { let params = Rc::new({ let mut __result = Vec::new(); diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index e3956db985b..5fecbc40044 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -51,11 +51,11 @@ pub enum RecursionShape { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct InductiveField { - pub type_name: Rc>, - pub variant_name: Rc>, - pub field_name: Rc>, + pub type_name: String, + pub variant_name: String, + pub field_name: String, pub shape: RecursionShape, - pub element_type: Rc>, + pub element_type: String, } pub fn recursion_shape_eq(a: RecursionShape, b: RecursionShape) -> bool { @@ -84,20 +84,16 @@ pub fn recursion_shape_eq(a: RecursionShape, b: RecursionShape) -> bool { } pub fn inductive_field_eq(a: Rc, b: Rc) -> bool { - (((((crate::v2_std_text::host_string_text_to_rust_host(a.type_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(b.type_name.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(a.variant_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(b.variant_name.clone()))) - && (crate::v2_std_text::host_string_text_to_rust_host(a.field_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(b.field_name.clone()))) + (((((a.type_name.clone().as_str() == b.type_name.clone().as_str()) + && (a.variant_name.clone().as_str() == b.variant_name.clone().as_str())) + && (a.field_name.clone().as_str() == b.field_name.clone().as_str())) && recursion_shape_eq(a.shape.clone(), b.shape.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(a.element_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(b.element_type.clone()))) + && (a.element_type.clone().as_str() == b.element_type.clone().as_str())) } pub fn inductive_field_to_dimension( field: Rc, - param: Rc>, + param: String, ) -> Rc { Rc::new(RankingDimension::TreeSize { param: param }) } @@ -113,7 +109,7 @@ pub enum SubValueRelation { field: Rc, }, ArithmeticDescent { - param: Rc>, + param: String, factor: Rc, }, PreservedValue, @@ -198,8 +194,7 @@ pub fn sub_value_structural_eq(a: Rc, b: Rc) factor: fac_b, .. } => { - ((crate::v2_std_text::host_string_text_to_rust_host(pa.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(pb.clone())) + ((pa.clone().as_str() == pb.clone().as_str()) && shrink_factor_eq(fac_a.clone(), fac_b.clone())) } _ => false, @@ -546,15 +541,15 @@ pub fn poly_exp_degree_one() -> Rc { #[serde(tag = "_variant")] pub enum AtomicCost { PolyCost { - param: Rc>, + param: String, exponent: Rc, }, LogCost { - param: Rc>, + param: String, }, } impl AtomicCost { - pub fn param(&self) -> Rc> { + pub fn param(&self) -> String { match self { AtomicCost::PolyCost { param: __val, .. } => __val.clone(), AtomicCost::LogCost { param: __val, .. } => __val.clone(), @@ -607,7 +602,7 @@ pub fn cost_constant() -> Rc { Rc::new(CostBound::ConstantBound) } -pub fn cost_linear(param: Rc>) -> Rc { +pub fn cost_linear(param: String) -> Rc { Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::PolyCost { param: param, @@ -616,7 +611,7 @@ pub fn cost_linear(param: Rc>) -> Rc { }) } -pub fn cost_poly(param: Rc>, degree: i64) -> Rc { +pub fn cost_poly(param: String, degree: i64) -> Rc { if (degree.clone() < 0) { Rc::new(CostBound::ErrorBound) } else { @@ -643,7 +638,7 @@ pub fn cost_poly(param: Rc>, degree: i64) -> Rc { } } -pub fn cost_root(param: Rc>, k: i64) -> Rc { +pub fn cost_root(param: String, k: i64) -> Rc { if (k.clone() <= 0) { Rc::new(CostBound::ErrorBound) } else { @@ -662,21 +657,21 @@ pub fn cost_root(param: Rc>, k: i64) -> Rc { } } -pub fn cost_sqrt(param: Rc>) -> Rc { +pub fn cost_sqrt(param: String) -> Rc { cost_root(param, 2) } -pub fn cost_cbrt(param: Rc>) -> Rc { +pub fn cost_cbrt(param: String) -> Rc { cost_root(param, 3) } -pub fn cost_log(param: Rc>) -> Rc { +pub fn cost_log(param: String) -> Rc { Rc::new(CostBound::AtomicBound { cost: Rc::new(AtomicCost::LogCost { param: param }), }) } -pub fn cost_nlogn(param: Rc>) -> Rc { +pub fn cost_nlogn(param: String) -> Rc { Rc::new(CostBound::ProductBound { factors: Rc::new(vec![ Rc::new(AtomicCost::PolyCost { @@ -690,10 +685,7 @@ pub fn cost_nlogn(param: Rc>) -> Rc { }) } -pub fn cost_graph_linear( - v_param: Rc>, - e_param: Rc>, -) -> Rc { +pub fn cost_graph_linear(v_param: String, e_param: String) -> Rc { Rc::new(CostBound::SumOfProductsBound { terms: Rc::new(vec![ Rc::new(vec![Rc::new(AtomicCost::PolyCost { @@ -710,7 +702,7 @@ pub fn cost_graph_linear( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RecurrenceForm { - pub param: Rc>, + pub param: String, pub branches: i64, pub divisor: i64, pub work_exponent: i64, @@ -944,7 +936,7 @@ pub fn master_theorem(form: Rc) -> Rc { } } -pub fn catamorphism_bound(param: Rc>, nesting_depth: i64) -> Rc { +pub fn catamorphism_bound(param: String, nesting_depth: i64) -> Rc { if (nesting_depth.clone() < 0) { Rc::new(CostBound::ErrorBound) } else { @@ -957,7 +949,7 @@ pub fn catamorphism_bound(param: Rc>, nesting_depth: i64) -> Rc< } pub fn derive_bound( - param: Rc>, + param: String, branches: i64, factor: Rc, work_exponent: i64, @@ -1110,9 +1102,3 @@ pub fn bellman_ford_bound() -> Rc { pub fn floyd_warshall_bound() -> Rc { cost_poly("V".to_string(), 3) } - -pub struct DirectRecursion; -pub struct ListRecursion; -pub struct OptionalRecursion; -pub struct SetRecursion; -pub struct MapValueRecursion; diff --git a/src/v1/stage0/src/std_node.rs b/src/v1/stage0/src/std_node.rs index 6684584366a..7ca1fbee5f6 100644 --- a/src/v1/stage0/src/std_node.rs +++ b/src/v1/stage0/src/std_node.rs @@ -105,17 +105,17 @@ pub fn compiler_recursive_types() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Node"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("InferredNode"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("MatchPattern"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("MethodSemantics"), true); + __m.insert("Node".to_string(), true); + __m.insert("InferredNode".to_string(), true); + __m.insert("MatchPattern".to_string(), true); + __m.insert("MethodSemantics".to_string(), true); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_compiler_recursive_type(name: Rc>) -> bool { +pub fn is_compiler_recursive_type(name: String) -> bool { match v1_rt::map_get(&compiler_recursive_types(), name) { Some(_) => true, None => false, diff --git a/src/v1/stage0/src/std_syntax.rs b/src/v1/stage0/src/std_syntax.rs index 939f3613c86..019ae09f706 100644 --- a/src/v1/stage0/src/std_syntax.rs +++ b/src/v1/stage0/src/std_syntax.rs @@ -39,12 +39,12 @@ pub enum BinOp { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum LiteralValue { - LitStr { value: Rc> }, + LitStr { value: String }, LitInt { value: i64 }, - LitFloat { value: Rc> }, + LitFloat { value: String }, LitBool { value: bool }, LitNull, - LitSymbol { value: Rc> }, + LitSymbol { value: String }, } #[derive( @@ -77,7 +77,7 @@ pub enum ItemFormKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemForm { pub kind: ItemFormKind, - pub keyword: Rc>, + pub keyword: String, pub has_type_params: bool, pub has_params: bool, pub has_return_type: bool, @@ -104,7 +104,7 @@ pub enum AlgebraFieldKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct AlgebraFieldEntry { pub kind: AlgebraFieldKind, - pub field_name: Rc>, + pub field_name: String, } pub fn algebra_field_entries() -> Rc>> { @@ -142,7 +142,7 @@ pub fn algebra_field_entries() -> Rc>> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OperatorSpec { - pub symbol: Rc>, + pub symbol: String, pub left_bp: i64, pub right_bp: i64, pub binop: Option, @@ -156,39 +156,3 @@ pub struct SyntaxSpec { pub keyword_literals: Rc>>, pub keyword_set: Rc>, } - -pub struct Add; -pub struct Sub; -pub struct Mul; -pub struct Div; -pub struct Mod; -pub struct Eq; -pub struct Ne; -pub struct Lt; -pub struct Gt; -pub struct Le; -pub struct Ge; -pub struct And; -pub struct Or; -pub struct NullCoalesce; -pub struct ExprBody; -pub struct BlockBody; -pub struct TypeBody; -pub struct ValueBody; -pub struct NoBody; -pub struct ServiceBody; -pub struct ResourceBody; -pub struct FuncForm; -pub struct StructForm; -pub struct EnumForm; -pub struct TypeAliasForm; -pub struct ModuleForm; -pub struct OtherForm; -pub struct AlgAdd; -pub struct AlgMul; -pub struct AlgReciprocal; -pub struct AlgQuotient; -pub struct AlgRemainder; -pub struct AlgCompare; -pub struct AlgMeet; -pub struct AlgJoin; diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index 773cebea86e..3c3f23e0a92 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -99,7 +99,7 @@ pub fn optional_evidence_meet( pub fn map_evidence_merge_at( base: Rc>, - key: Rc>, + key: String, new_val: DescentEvidence, ) -> Rc> { match v1_rt::map_get(&base, key.clone()) { @@ -115,14 +115,14 @@ pub fn map_evidence_merge_at( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum RankingDimension { - TreeSize { param: Rc> }, - ListLength { param: Rc> }, - ArithmeticValue { param: Rc> }, - TokenPosition { param: Rc> }, - SetCardinality { param: Rc> }, + TreeSize { param: String }, + ListLength { param: String }, + ArithmeticValue { param: String }, + TokenPosition { param: String }, + SetCardinality { param: String }, } impl RankingDimension { - pub fn param(&self) -> Rc> { + pub fn param(&self) -> String { match self { RankingDimension::TreeSize { param: __val, .. } => __val.clone(), RankingDimension::ListLength { param: __val, .. } => __val.clone(), @@ -236,12 +236,12 @@ pub fn proportional_divisor_from_int_at_least_two(k: i64) -> Option> }, + ChildAccessor { accessor: String }, ListShrink { amount: Rc }, ArithmeticSubtractDescent { steps: Rc }, ArithmeticDivideDescent { divisor: Rc }, - ParserAdvance { witness: Rc> }, - SetRemoval { element: Rc> }, + ParserAdvance { witness: String }, + SetRemoval { element: String }, FoldIteration, } @@ -252,11 +252,7 @@ pub struct TerminationProof { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ProofEdge { - pub caller: Rc>, - pub callee: Rc>, + pub caller: String, + pub callee: String, pub evidence: Rc>, } - -pub struct Strict; -pub struct NonIncreasing; -pub struct DescentUnknown; diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index f5615714124..1500f5a4251 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -22,21 +22,21 @@ pub fn kernel_type_set() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("String"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Int"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Bool"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Float"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Secret"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Json"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Unit"), true); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Bytes"), true); + __m.insert("String".to_string(), true); + __m.insert("Int".to_string(), true); + __m.insert("Bool".to_string(), true); + __m.insert("Float".to_string(), true); + __m.insert("Secret".to_string(), true); + __m.insert("Json".to_string(), true); + __m.insert("Unit".to_string(), true); + __m.insert("Bytes".to_string(), true); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_kernel_type(name: Rc>) -> bool { +pub fn is_kernel_type(name: String) -> bool { match v1_rt::map_get(&kernel_type_set(), name) { Some(_) => true, None => false, @@ -47,31 +47,29 @@ pub fn container_type_arity() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), 1); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), 1); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), 2); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Witness"), 1); + __m.insert("List".to_string(), 1); + __m.insert("Set".to_string(), 1); + __m.insert("Map".to_string(), 2); + __m.insert("Witness".to_string(), 1); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_container_type(name: Rc>) -> bool { +pub fn is_container_type(name: String) -> bool { match container_expected_arity(name) { Some(_) => true, None => false, } } -pub fn container_expected_arity(name: Rc>) -> Option { +pub fn container_expected_arity(name: String) -> Option { v1_rt::map_get(&container_type_arity(), name) } -pub fn container_param_names_for(kind_name: Rc>) -> Rc> { - if (crate::v2_std_text::host_string_text_to_rust_host(kind_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) - { +pub fn container_param_names_for(kind_name: String) -> Rc> { + if (kind_name.clone().as_str() == "Witness".to_string().as_str()) { Rc::new(vec!["T".to_string()]) } else { match v1_rt::map_get(&kernel_algebra_profile(), kind_name.clone()) { @@ -81,7 +79,7 @@ pub fn container_param_names_for(kind_name: Rc>) -> Rc>, index: i64) -> Rc> { +pub fn container_param_name(kind_name: String, index: i64) -> Option { { let names = container_param_names_for(kind_name); match Rc::new({ @@ -125,14 +123,14 @@ pub fn ordered_element_collections() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), true); + __m.insert("List".to_string(), true); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn is_ordered_element_collection(name: Rc>) -> bool { +pub fn is_ordered_element_collection(name: String) -> bool { v1_rt::map_contains_key(&ordered_element_collections(), name) } @@ -140,18 +138,18 @@ pub fn container_template_algebra_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), "FreeMonoid".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "FreeMonoid".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), "BooleanAlgebra".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "BooleanAlgebra".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), "PartialFunction".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "PartialFunction".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("FreeMonoid"), "FreeMonoid".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("free_monoid"), "FreeMonoid".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("BooleanAlgebra"), "BooleanAlgebra".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("boolean_algebra"), "BooleanAlgebra".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("PartialFunction"), "PartialFunction".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("partial_function"), "PartialFunction".to_string()); + __m.insert("List".to_string(), "FreeMonoid".to_string()); + __m.insert("list".to_string(), "FreeMonoid".to_string()); + __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("Map".to_string(), "PartialFunction".to_string()); + __m.insert("map".to_string(), "PartialFunction".to_string()); + __m.insert("FreeMonoid".to_string(), "FreeMonoid".to_string()); + __m.insert("free_monoid".to_string(), "FreeMonoid".to_string()); + __m.insert("BooleanAlgebra".to_string(), "BooleanAlgebra".to_string()); + __m.insert("boolean_algebra".to_string(), "BooleanAlgebra".to_string()); + __m.insert("PartialFunction".to_string(), "PartialFunction".to_string()); + __m.insert("partial_function".to_string(), "PartialFunction".to_string()); Rc::new(__m) }; } @@ -162,23 +160,23 @@ pub fn container_template_alias_rows() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("List"), "FreeMonoid".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("list"), "FreeMonoid".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Set"), "BooleanAlgebra".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("set"), "BooleanAlgebra".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("Map"), "PartialFunction".to_string()); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("map"), "PartialFunction".to_string()); + __m.insert("List".to_string(), "FreeMonoid".to_string()); + __m.insert("list".to_string(), "FreeMonoid".to_string()); + __m.insert("Set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("set".to_string(), "BooleanAlgebra".to_string()); + __m.insert("Map".to_string(), "PartialFunction".to_string()); + __m.insert("map".to_string(), "PartialFunction".to_string()); Rc::new(__m) }; } CACHED.with(|c: &Rc>| c.clone()) } -pub fn container_template_algebra(name: Rc>) -> Rc> { +pub fn container_template_algebra(name: String) -> Option { v1_rt::map_get(&container_template_algebra_rows(), name) } -pub fn container_template_alias_algebra(name: Rc>) -> Rc> { +pub fn container_template_alias_algebra(name: String) -> Option { v1_rt::map_get(&container_template_alias_rows(), name) } @@ -194,34 +192,6 @@ pub fn canonical_container_names() -> Rc> { ]) } -pub fn string_list_eq(mut left: Rc>, mut right: Rc>) -> bool { - loop { - if ((left.clone().len() as i64) != (right.clone().len() as i64)) { - break false; - } else { - if ((left.clone().len() as i64) == 0) { - break true; - } else { - if (left.clone().first().cloned().as_deref() - != right.clone().first().cloned().as_deref()) - { - break false; - } else { - { - let __tco_0 = - Rc::new(left.iter().cloned().skip(1 as usize).collect::>()); - let __tco_1 = - Rc::new(right.iter().cloned().skip(1 as usize).collect::>()); - left = __tco_0; - right = __tco_1; - continue; - } - } - } - } - } -} - #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, )] @@ -237,27 +207,27 @@ pub type Bytes = Vec; pub type Char = i64; -pub type CommitSha = Rc>; +pub type CommitSha = String; -pub type Sha256 = Rc>; +pub type Sha256 = String; pub type RetryCount = i64; pub type HttpStatus = i64; -pub type Email = Rc>; +pub type Email = String; pub type Port = i64; -pub type GistId = Rc>; +pub type GistId = String; -pub type Secret = Rc>; +pub type Secret = String; pub type SecretValue = String; -pub type Url = Rc>; +pub type Url = String; -pub type SemVer = Rc>; +pub type SemVer = String; pub type NonEmptyStr = String; @@ -288,7 +258,7 @@ pub struct SourceSpan { pub end: i64, } -pub type Timestamp = Rc>; +pub type Timestamp = String; pub type EpochMs = i64; @@ -365,7 +335,7 @@ pub type TextFilePath = String; pub type BinaryFilePath = String; -pub type MimeType = Rc>; +pub type MimeType = String; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, @@ -385,8 +355,8 @@ pub enum HttpMethod { #[serde(tag = "_variant")] pub enum AuthScheme { Bearer, - Header { name: Rc> }, - Basic { username: Rc> }, + Header { name: String }, + Basic { username: String }, ApiKey, } @@ -401,8 +371,8 @@ pub struct AccessToken { pub struct Credential { pub token: String, pub scheme: Rc, - pub header_name: Rc>, - pub source_id: Rc>, + pub header_name: Option, + pub source_id: String, pub required_scopes: Rc>, pub expires_in: Option, } @@ -416,30 +386,30 @@ pub type ToolHandle = String; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TransportRequest { pub method: HttpMethod, - pub url: Rc>, + pub url: String, pub headers: serde_json::Value, - pub body: Rc>, + pub body: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TransportResponse { pub status: i64, pub headers: serde_json::Value, - pub body: Rc>, + pub body: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FileResponse { - pub path: Rc>, + pub path: String, pub success: bool, - pub content: Rc>, + pub content: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ShellResponse { pub exit_code: i64, - pub stdout: Rc>, - pub stderr: Rc>, + pub stdout: String, + pub stderr: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -451,10 +421,10 @@ pub struct RestResponse { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TestResult { - pub name: Rc>, + pub name: String, pub ok: bool, - pub stdout: Rc>, - pub stderr: Rc>, + pub stdout: String, + pub stderr: String, pub duration_ms: Milliseconds, } @@ -467,53 +437,53 @@ pub struct Summary { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StageResult { - pub name: Rc>, + pub name: String, pub success: bool, - pub stdout: Rc>, - pub stderr: Rc>, + pub stdout: String, + pub stderr: String, pub skipped: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DocumentLine { - pub text: Rc>, + pub text: String, pub is_comment: bool, pub is_blank: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DocumentSection { - pub title: Rc>, + pub title: String, pub has_title: bool, pub lines: Rc>>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Document { - pub header: Rc>, + pub header: String, pub has_header: bool, - pub comment_prefix: Rc>, + pub comment_prefix: String, pub sections: Rc>>, pub trailing_newline: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TextFile { - pub path: Rc>, + pub path: String, pub document: Rc, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RenderedTextFile { - pub path: Rc>, - pub content: Rc>, + pub path: String, + pub content: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ToolEntry { - pub name: Rc>, - pub command: Rc>, - pub description: Rc>, + pub name: String, + pub command: String, + pub description: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -530,17 +500,17 @@ pub struct DagTopology { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TopologyNode { - pub id: Rc>, - pub label: Rc>, + pub id: String, + pub label: String, pub kind: TopologyNodeKind, - pub parent: Rc>, + pub parent: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TopologyEdge { - pub from: Rc>, - pub to: Rc>, - pub port: Rc>, + pub from: String, + pub to: String, + pub port: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -552,9 +522,9 @@ pub struct DagDiff { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct PragmaDirective { - pub key: Rc>, - pub value: Rc>, - pub scope: Rc>, + pub key: String, + pub value: String, + pub scope: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -562,25 +532,3 @@ pub struct DocSource { pub path: FilePath, pub kind: DocSourceKind, } - -pub struct True; -pub struct False; -pub struct Pure; -pub struct Transport; -pub struct SubDag; -pub struct Env; -pub struct Template; -pub struct Generated; -pub struct Static; -pub struct Xs; -pub struct S; -pub struct M; -pub struct L; -pub struct Xl; -pub struct GET; -pub struct POST; -pub struct PUT; -pub struct PATCH; -pub struct DELETE; -pub struct HEAD; -pub struct OPTIONS; diff --git a/src/v1/stage0/src/v1_compiler_artifact.rs b/src/v1/stage0/src/v1_compiler_artifact.rs index 497279471b2..8b235a5ebfd 100644 --- a/src/v1/stage0/src/v1_compiler_artifact.rs +++ b/src/v1/stage0/src/v1_compiler_artifact.rs @@ -41,7 +41,7 @@ pub enum ArtifactKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Artifact { - pub name: Rc>, + pub name: String, pub kind: ArtifactKind, pub target: RenderTarget, pub entry_modules: Rc>, @@ -62,10 +62,10 @@ pub enum BoundaryKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Boundary { - pub from_artifact: Rc>, - pub to_artifact: Rc>, + pub from_artifact: String, + pub to_artifact: String, pub kind: BoundaryKind, - pub contract: Rc>, + pub contract: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -121,7 +121,7 @@ pub fn default_artifact_plan( })) } -pub type DagNodeId = Rc>; +pub type DagNodeId = String; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] @@ -130,10 +130,10 @@ pub enum DagInferredRecord { node: Box, }, TypeVariableRef { - id: Rc>, + id: String, }, CompilerErrorRecord { - message: Rc>, + message: String, span: Rc, }, } @@ -147,33 +147,19 @@ pub struct DagModuleRef { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DagDiagnosticRecord { - pub severity: Rc>, - pub message: Rc>, + pub severity: String, + pub message: String, pub span: Rc, - pub module_name: Rc>, - pub category: Rc>, + pub module_name: Option, + pub category: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DagArtifact { - pub version: Rc>, + pub version: String, pub nodes: Rc>, pub modules: Rc>, pub item_registry_keys: Rc>, pub diagnostics: Rc>, pub files: Rc>, } - -pub struct Rust; -pub struct Python; -pub struct Go; -pub struct Dag; -pub struct ServiceBinary; -pub struct Library; -pub struct Frontend; -pub struct GeneratedSupport; -pub struct DirectCall; -pub struct HttpJson; -pub struct MessageQueue; -pub struct Ffi; -pub struct FileProtocol; diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index 5c9cda519ac..d86d3d71511 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -59,7 +59,7 @@ pub fn target_callable(target: RenderTarget) -> Rc { } } -pub fn target_optional_template(target: RenderTarget) -> Rc> { +pub fn target_optional_template(target: RenderTarget) -> String { match target { RenderTarget::Rust => rust_optional_template(), RenderTarget::Python => python_optional_template(), @@ -77,19 +77,13 @@ pub fn target_cast_syntax(target: RenderTarget) -> Option> { } } -pub fn can_cast( - target: RenderTarget, - source_type: Rc>, - target_type: Rc>, -) -> bool { +pub fn can_cast(target: RenderTarget, source_type: String, target_type: String) -> bool { match target_cast_syntax(target) { Some(syntax) => { let mut __found = false; for r in syntax.cast_rules.clone().iter().cloned() { - if ((crate::v2_std_text::host_string_text_to_rust_host(r.from_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(source_type.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(r.to_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(target_type.clone()))) + if ((r.from_type.clone().as_str() == source_type.clone().as_str()) + && (r.to_type.clone().as_str() == target_type.clone().as_str())) { __found = true; break; @@ -101,11 +95,7 @@ pub fn can_cast( } } -pub fn render_cast( - expr_str: Rc>, - type_str: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn render_cast(expr_str: String, type_str: String, target: RenderTarget) -> String { { let syntax = match target_cast_syntax(target) { Some(s) => s.clone(), @@ -122,16 +112,11 @@ pub fn render_cast( } } -pub fn lookup_checkpoint( - target: RenderTarget, - dag_name: Rc>, -) -> Option> { +pub fn lookup_checkpoint(target: RenderTarget, dag_name: String) -> Option> { Rc::new({ let mut __result = Vec::new(); for cp in target_checkpoints(target).iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(cp.dag_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(dag_name.clone())) - { + if (cp.dag_name.clone().as_str() == dag_name.clone().as_str()) { __result.push(cp); } } @@ -141,24 +126,21 @@ pub fn lookup_checkpoint( .cloned() } -pub fn coerce_primitive_type( - target: RenderTarget, - dag_name: Rc>, -) -> Rc> { +pub fn coerce_primitive_type(target: RenderTarget, dag_name: String) -> String { match lookup_checkpoint(target, dag_name.clone()) { Some(cp) => cp.target_type.clone(), None => dag_name.clone(), } } -pub fn is_copy(target: RenderTarget, dag_name: Rc>) -> Option { +pub fn is_copy(target: RenderTarget, dag_name: String) -> Option { match lookup_checkpoint(target, dag_name) { Some(cp) => cp.is_copy.clone(), None => None, } } -pub fn literal_suffix(target: RenderTarget, dag_name: Rc>) -> Rc> { +pub fn literal_suffix(target: RenderTarget, dag_name: String) -> Option { match lookup_checkpoint(target, dag_name) { Some(cp) => match cp.literal_suffix.clone() { Some(s) => Some(s.clone()), @@ -168,16 +150,11 @@ pub fn literal_suffix(target: RenderTarget, dag_name: Rc>) -> Rc } } -pub fn lookup_inhabitant( - target: RenderTarget, - algebra: Rc>, -) -> Option> { +pub fn lookup_inhabitant(target: RenderTarget, algebra: String) -> Option> { Rc::new({ let mut __result = Vec::new(); for inh in target_inhabitants(target).iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(inh.algebra.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(algebra.clone())) - { + if (inh.algebra.clone().as_str() == algebra.clone().as_str()) { __result.push(inh); } } @@ -187,10 +164,7 @@ pub fn lookup_inhabitant( .cloned() } -pub fn coerce_container_template( - target: RenderTarget, - container_name: Rc>, -) -> Rc> { +pub fn coerce_container_template(target: RenderTarget, container_name: String) -> Option { match container_template_algebra(container_name) { Some(algebra) => match lookup_inhabitant(target, algebra.clone()) { Some(inh) => Some(inh.template.clone()), @@ -200,18 +174,11 @@ pub fn coerce_container_template( } } -pub fn apply_inhabitant_template1( - template: Rc>, - inner: Rc>, -) -> Rc> { +pub fn apply_inhabitant_template1(template: String, inner: String) -> String { v1_rt::replace(template, "{0}".to_string(), inner) } -pub fn apply_inhabitant_template2( - template: Rc>, - first: Rc>, - second: Rc>, -) -> Rc> { +pub fn apply_inhabitant_template2(template: String, first: String, second: String) -> String { v1_rt::replace( v1_rt::replace(template, "{0}".to_string(), first), "{1}".to_string(), @@ -224,33 +191,33 @@ pub fn apply_inhabitant_template2( pub enum CoercionAssertion { CheckpointAssertion { target: RenderTarget, - dag_name: Rc>, - expected_type: Rc>, + dag_name: String, + expected_type: String, }, ContainerAssertion { target: RenderTarget, - container_name: Rc>, - expected_template: Rc>, + container_name: String, + expected_template: String, }, CopyAssertion { target: RenderTarget, - dag_name: Rc>, + dag_name: String, expected_copy: bool, }, TemplateAssertion { - template: Rc>, + template: String, args: Rc>, - expected: Rc>, + expected: String, }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CoercionTestEntry { - pub test_name: Rc>, + pub test_name: String, pub assertions: Rc>>, } -pub fn target_label(target: RenderTarget) -> Rc> { +pub fn target_label(target: RenderTarget) -> String { match target { RenderTarget::Rust => "rust".to_string(), RenderTarget::Python => "python".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs index d783f317a48..9ead7dea419 100644 --- a/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs +++ b/src/v1/stage0/src/v1_compiler_compiler_tests_rust.rs @@ -17,7 +17,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn ct_module_header() -> Rc> { +pub fn ct_module_header() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -30,55 +30,55 @@ pub fn ct_module_header() -> Rc> { ) } -pub fn ct_workspace_helpers() -> Rc> { +pub fn ct_workspace_helpers() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Find workspace root by walking up from the current directory looking for Cargo.toml + dsl/\n".to_string(), " fn workspace_root() -> std::path::PathBuf {\n".to_string()), " let mut dir = std::env::current_dir().expect(\"no current dir\");\n".to_string()), " loop {\n".to_string()), " if dir.join(\"Cargo.toml\").exists() && dir.join(\"dsl\").exists() {\n".to_string()), " return dir;\n".to_string()), " }\n".to_string()), " if !dir.pop() {\n".to_string()), " panic!(\"could not find workspace root (no Cargo.toml + dsl/ found)\");\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " /// Read a .dag file from the workspace\n".to_string()), " fn read_dag(path: &str) -> String {\n".to_string()), " let full = workspace_root().join(path);\n".to_string()), " std::fs::read_to_string(&full)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {}: {}\", full.display(), e))\n".to_string()), " }\n\n".to_string()) } -pub fn ct_file_discovery_helpers() -> Rc> { +pub fn ct_file_discovery_helpers() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Discover all .dag files under a directory, returning (relative_path, content) pairs.\n".to_string(), " /// The relative path is relative to the workspace root.\n".to_string()), " fn discover_dag_files(dir: &str) -> Vec<(String, String)> {\n".to_string()), " let root = workspace_root();\n".to_string()), " let base = root.join(dir);\n".to_string()), " let mut results = Vec::new();\n".to_string()), " collect_dag_recursive(&base, &root, &mut results);\n".to_string()), " results.sort_by(|a, b| a.0.cmp(&b.0));\n".to_string()), " results\n".to_string()), " }\n\n".to_string()), " fn collect_dag_recursive(\n".to_string()), " dir: &std::path::Path,\n".to_string()), " root: &std::path::Path,\n".to_string()), " out: &mut Vec<(String, String)>,\n".to_string()), " ) {\n".to_string()), " if let Ok(entries) = std::fs::read_dir(dir) {\n".to_string()), " for entry in entries.flatten() {\n".to_string()), " let path = entry.path();\n".to_string()), " if path.is_dir() {\n".to_string()), " collect_dag_recursive(&path, root, out);\n".to_string()), " } else if path.extension().map_or(false, |e| e == \"dag\") {\n".to_string()), " let rel = path\n".to_string()), " .strip_prefix(root)\n".to_string()), " .unwrap()\n".to_string()), " .to_string_lossy()\n".to_string()), " .to_string();\n".to_string()), " // Test fixtures (e.g. fact_cardinality_split_brace.dag) are not modules.\n".to_string()), " if rel.contains(\"/tests/\") {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {}: {}\", path.display(), e));\n".to_string()), " out.push((rel, content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n\n".to_string()) } -pub fn ct_source_builders() -> Rc> { +pub fn ct_source_builders() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Build SourceFile vec from discovered .dag files.\n".to_string(), " fn source_files_from(\n".to_string()), " pairs: &[(String, String)],\n".to_string()), " ) -> Vec> {\n".to_string()), " pairs\n".to_string()), " .iter()\n".to_string()), " .map(|(path, content)| {\n".to_string()), " std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " })\n".to_string()), " })\n".to_string()), " .collect()\n".to_string()), " }\n\n".to_string()), " fn parse_module_or_panic(path: &str, content: &str) -> std::rc::Rc {\n".to_string()), " let tokens = tokenize(content.to_string(), path.to_string());\n".to_string()), " let mut source_indices = HashMap::new();\n".to_string()), " source_indices.insert(\n".to_string()), " path.to_string(),\n".to_string()), " crate::v1_std_core::build_newline_index(path.to_string(), content.to_string()),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " std::rc::Rc::new(source_indices),\n".to_string()), " crate::v1_std_core::empty_intern_table(),\n".to_string()), " );\n".to_string()), " if let Some(err) = parsed.result.error.as_ref() {\n".to_string()), " panic!(\n".to_string()), " \"failed to parse {} while building source closure: {}\",\n".to_string()), " path,\n".to_string()), " crate::v1_std_core::diagnostic_to_message(err.diagnostic.clone())\n".to_string()), " );\n".to_string()), " }\n".to_string()), " parsed.result.module.clone().unwrap_or_else(|| {\n".to_string()), " panic!(\"{} produced no module while building source closure\", path)\n".to_string()), " })\n".to_string()), " }\n\n".to_string()), " fn module_path_from_source(path: &str, content: &str) -> String {\n".to_string()), " parse_module_or_panic(path, content).name.clone()\n".to_string()), " }\n\n".to_string()), " fn import_paths_from_source(path: &str, content: &str) -> Vec {\n".to_string()), " let module = parse_module_or_panic(path, content);\n".to_string()), " crate::v1_std_core::module_imports(module)\n".to_string()), " .iter()\n".to_string()), " .map(|imp| imp.name.clone())\n".to_string()), " .collect()\n".to_string()), " }\n\n".to_string()), " fn build_source_index(\n".to_string()), " roots: &[&str],\n".to_string()), " ) -> HashMap {\n".to_string()), " let mut index = HashMap::new();\n".to_string()), " for root in roots {\n".to_string()), " for (path, content) in discover_dag_files(root) {\n".to_string()), " let module_path = module_path_from_source(&path, &content);\n".to_string()), " if let Some((existing, _)) = index.get(&module_path) {\n".to_string()), " panic!(\n".to_string()), " \"duplicate module path '{}': declared in both {} and {}\",\n".to_string()), " module_path,\n".to_string()), " existing,\n".to_string()), " path\n".to_string()), " );\n".to_string()), " }\n".to_string()), " index.insert(module_path, (path, content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " index\n".to_string()), " }\n\n".to_string()), " fn resolve_source_closure(\n".to_string()), " entry_pairs: Vec<(String, String)>,\n".to_string()), " roots: &[&str],\n".to_string()), " ) -> Vec> {\n".to_string()), " let index = build_source_index(roots);\n".to_string()), " let mut seen = HashMap::>::new();\n".to_string()), " let mut queue = Vec::new();\n\n".to_string()), " for (path, content) in entry_pairs {\n".to_string()), " let module_path = module_path_from_source(&path, &content);\n".to_string()), " seen.insert(\n".to_string()), " module_path,\n".to_string()), " std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: content.clone(),\n".to_string()), " }),\n".to_string()), " );\n".to_string()), " queue.push((path, content));\n".to_string()), " }\n\n".to_string()), " while let Some((_path, content)) = queue.pop() {\n".to_string()), " for module_path in import_paths_from_source(&_path, &content) {\n".to_string()), " if seen.contains_key(&module_path) {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " if let Some((path, file_content)) = index.get(&module_path).cloned() {\n".to_string()), " seen.insert(\n".to_string()), " module_path,\n".to_string()), " std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: path.clone(),\n".to_string()), " content: file_content.clone(),\n".to_string()), " }),\n".to_string()), " );\n".to_string()), " queue.push((path, file_content));\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " let mut result: Vec<_> = seen.into_values().collect();\n".to_string()), " result.sort_by(|a, b| a.path.cmp(&b.path));\n".to_string()), " result\n".to_string()), " }\n\n".to_string()), ct_self_compile_sources()) } -pub fn ct_self_compile_sources() -> Rc> { +pub fn ct_self_compile_sources() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Build the self-compile source closure from src/v1 entry modules with dsl as a dependency pool.\n".to_string(), " fn self_compile_sources() -> Vec> {\n".to_string()), " resolve_source_closure(discover_dag_files(\"src/v1\"), &[\"src/v1\", \"dsl\"])\n".to_string()), " }\n\n".to_string()) } -pub fn ct_tokenizer_tests() -> Rc> { +pub fn ct_tokenizer_tests() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn tokenize_produces_tokens() {\n".to_string()), " let tokens = tokenize(\"fn foo() -> Int { 42 }\".to_string(), \"test.dag\".to_string());\n".to_string()), " assert!(\n".to_string()), " !tokens.is_empty(),\n".to_string()), " \"tokenize should produce at least one token\"\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn tokenize_ends_with_eof() {\n".to_string()), " let tokens = tokenize(\"type Foo { x: Int }\".to_string(), \"test.dag\".to_string());\n".to_string()), " let last = tokens.last().expect(\"should have tokens\");\n".to_string()), " assert!(\n".to_string()), " matches!(last.shape, crate::v1_std_core::TokenShape::ShEof),\n".to_string()), " \"last token should be Eof, got {:?}\",\n".to_string()), " last.shape\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn tokenize_fn_keyword() {\n".to_string()), " let tokens = tokenize(\"fn\".to_string(), \"test.dag\".to_string());\n".to_string()), " assert!(\n".to_string()), " tokens.len() >= 2,\n".to_string()), " \"expected at least 2 tokens, got {}\",\n".to_string()), " tokens.len()\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " matches!(tokens[0].shape, crate::v1_std_core::TokenShape::ShKeyword),\n".to_string()), " \"first token should be KwFn, got {:?}\",\n".to_string()), " tokens[0].shape\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn tokenize_count_stable() {\n".to_string()), " let tokens = tokenize(\n".to_string()), " \"module test\\ntype Foo { x: Int }\".to_string(),\n".to_string()), " \"test.dag\".to_string(),\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " tokens.len() > 5,\n".to_string()), " \"non-trivial input should produce multiple tokens, got {}\",\n".to_string()), " tokens.len()\n".to_string()), " );\n".to_string()), " }\n\n".to_string()) } -pub fn ct_parse_tests() -> Rc> { +pub fn ct_parse_tests() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn parse_trivial_module() {\n".to_string()), " let tokens = tokenize(\n".to_string()), " \"module test\\ntype Foo { x: Int }\\n\".to_string(),\n".to_string()), " \"test.dag\".to_string(),\n".to_string()), " );\n".to_string()), " let result = crate::v1_compiler_parse::parse(tokens, std::rc::Rc::new(std::collections::HashMap::new()));\n".to_string()), " assert!(\n".to_string()), " result.module.is_some(),\n".to_string()), " \"valid module should parse successfully\"\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn self_parse_tokenize_dag() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(16 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let source = read_dag(\"src/v1/01_tokenize.dag\");\n".to_string()), " let tokens = tokenize(source, \"src/v1/01_tokenize.dag\".to_string());\n\n".to_string()), " assert!(\n".to_string()), " !tokens.is_empty(),\n".to_string()), " \"tokenizing 01_tokenize.dag should produce tokens\"\n".to_string()), " );\n\n".to_string()), " let last = tokens.last().expect(\"should have tokens\");\n".to_string()), " assert!(\n".to_string()), " matches!(last.shape, crate::v1_std_core::TokenShape::ShEof),\n".to_string()), " \"last token should be Eof, got {:?}\",\n".to_string()), " last.shape\n".to_string()), " );\n\n".to_string()), " let result = crate::v1_compiler_parse::parse(tokens, std::rc::Rc::new(std::collections::HashMap::new()));\n\n".to_string()), " assert!(\n".to_string()), " result.module.is_some(),\n".to_string()), " \"parsing 01_tokenize.dag should produce a module\"\n".to_string()), " );\n\n".to_string()), " let module = result.module.as_ref().unwrap();\n".to_string()), " assert_eq!(\n".to_string()), " module.name, \"v1.compiler.tokenize\",\n".to_string()), " \"module name should be v1.compiler.tokenize, got {}\",\n".to_string()), " module.name\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-parse test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_pipeline_test() -> Rc> { +pub fn ct_pipeline_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn pipeline_trivial_module() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(16 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let source = std::rc::Rc::new(crate::v1_compiler_compile::SourceFile {\n".to_string()), " path: \"test.dag\".to_string(),\n".to_string()), " content: \"module test\\ntype Foo { x: Int, name: String }\\nfn add(a: Int, b: Int) -> Int { a + b }\\n\".to_string(),\n".to_string()), " });\n".to_string()), " let result = crate::v1_compiler_compile::compile_sources(std::rc::Rc::new(vec![source]), crate::v1_compiler_artifact::RenderTarget::Rust);\n\n".to_string()), " assert!(\n".to_string()), " !result.files.is_empty(),\n".to_string()), " \"compile_sources should produce output files, got none\"\n".to_string()), " );\n\n".to_string()), " let errors: Vec<_> = result.diagnostics.iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .collect();\n".to_string()), " assert!(\n".to_string()), " errors.is_empty(),\n".to_string()), " \"compile_sources should produce no errors, got {:?}\",\n".to_string()), " errors\n".to_string()), " );\n\n".to_string()), " let has_content = result.files.iter().any(|f| !f.content.is_empty());\n".to_string()), " assert!(\n".to_string()), " has_content,\n".to_string()), " \"at least one output file should have non-empty content\"\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"pipeline_trivial_module test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_parse_all_test() -> Rc> { +pub fn ct_self_parse_all_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn self_parse_all_modules() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let v1_files = discover_dag_files(\"src/v1\");\n".to_string()), " assert!(\n".to_string()), " !v1_files.is_empty(),\n".to_string()), " \"should discover at least one .dag file in src/v1/\"\n".to_string()), " );\n\n".to_string()), " for (file, source) in &v1_files {\n".to_string()), " let tokens = tokenize(source.to_string(), file.to_string());\n".to_string()), " assert!(!tokens.is_empty(), \"{} should produce tokens\", file);\n".to_string()), " assert!(\n".to_string()), " matches!(\n".to_string()), " tokens.last().unwrap().shape,\n".to_string()), " crate::v1_std_core::TokenShape::ShEof\n".to_string()), " ),\n".to_string()), " \"{} should end with Eof\",\n".to_string()), " file\n".to_string()), " );\n".to_string()), " let result = crate::v1_compiler_parse::parse(tokens, std::rc::Rc::new(std::collections::HashMap::new()));\n".to_string()), " assert!(\n".to_string()), " result.module.is_some(),\n".to_string()), " \"{} should parse successfully, error: {:?}\",\n".to_string()), " file,\n".to_string()), " result.error\n".to_string()), " );\n".to_string()), " let module = result.module.as_ref().unwrap();\n".to_string()), " assert!(\n".to_string()), " !module.name.is_empty(),\n".to_string()), " \"{} should have a non-empty module name\",\n".to_string()), " file\n".to_string()), " );\n".to_string()), " }\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-parse-all test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_resolve_test() -> Rc> { +pub fn ct_self_resolve_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn self_resolve_all_modules() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let sources = std::rc::Rc::new(self_compile_sources());\n".to_string()), " let result = crate::v1_compiler_compile::resolve_sources(sources);\n\n".to_string()), " let errors: Vec<_> = result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .collect();\n".to_string()), " let error_count = errors.len();\n\n".to_string()), " eprintln!(\"self-resolve error count: {}\", error_count);\n".to_string()), " for e in &errors {\n".to_string()), " eprintln!(\" {:?}\", e.diagnostic);\n".to_string()), " }\n\n".to_string()), " assert!(\n".to_string()), " error_count == 0,\n".to_string()), " \"self-resolve errors: {} errors (expected 0): {:?}\",\n".to_string()), " error_count,\n".to_string()), " errors\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-resolve-all test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_compile_test() -> Rc> { +pub fn ct_self_compile_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn self_compile_all_modules() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let sources = std::rc::Rc::new(self_compile_sources());\n".to_string()), " let source_count = sources.len();\n".to_string()), " let result = crate::v1_compiler_compile::compile_sources(\n".to_string()), " sources,\n".to_string()), " crate::v1_compiler_artifact::RenderTarget::Rust,\n".to_string()), " );\n\n".to_string()), " let errors: Vec<_> = result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .collect();\n".to_string()), " let error_count = errors.len();\n\n".to_string()), " eprintln!(\n".to_string()), " \"self-compile completed: {} errors, {} files emitted from {} sources\",\n".to_string()), " error_count,\n".to_string()), " result.files.len(),\n".to_string()), " source_count\n".to_string()), " );\n".to_string()), " for (i, e) in errors.iter().enumerate() {\n".to_string()), " eprintln!(\" error[{}]: {:?}\", i, e.diagnostic);\n".to_string()), " }\n\n".to_string()), " assert!(\n".to_string()), " source_count >= 13,\n".to_string()), " \"self-compile should process at least 13 sources, got {}\",\n".to_string()), " source_count\n".to_string()), " );\n\n".to_string()), " if !result.files.is_empty() {\n".to_string()), " assert!(\n".to_string()), " result.files.iter().all(|f| !f.content.is_empty()),\n".to_string()), " \"all self-compiled output files must have non-empty content\"\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " const SELF_COMPILE_ERROR_RATCHET: usize = 2700;\n".to_string()), " assert!(\n".to_string()), " error_count <= SELF_COMPILE_ERROR_RATCHET,\n".to_string()), " \"self-compile error count regression: {} > {} ratchet\",\n".to_string()), " error_count,\n".to_string()), " SELF_COMPILE_ERROR_RATCHET\n".to_string()), " );\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-compile-all test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_self_compile_cargo_check_test() -> Rc> { +pub fn ct_self_compile_cargo_check_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn self_compile_cargo_check() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " let sources = std::rc::Rc::new(self_compile_sources());\n\n".to_string()), " let result = crate::v1_compiler_compile::compile_sources(\n".to_string()), " sources,\n".to_string()), " crate::v1_compiler_artifact::RenderTarget::Rust,\n".to_string()), " );\n\n".to_string()), " if result.files.is_empty() {\n".to_string()), " eprintln!(\"self-compile-cargo-check: 0 files emitted (resolve errors gate emission), skipping cargo check\");\n".to_string()), " return;\n".to_string()), " }\n\n".to_string()), " let tmp_dir = std::env::temp_dir().join(\"v2-self-compile-check\");\n".to_string()), " let _ = std::fs::remove_dir_all(&tmp_dir);\n".to_string()), " std::fs::create_dir_all(tmp_dir.join(\"src\"))\n".to_string()), " .expect(\"failed to create temp src dir\");\n\n".to_string()), " for file in result.files.iter() {\n".to_string()), " let dest = tmp_dir.join(&file.path);\n".to_string()), " if let Some(parent) = dest.parent() {\n".to_string()), " std::fs::create_dir_all(parent).expect(\"failed to create parent dir\");\n".to_string()), " }\n".to_string()), " std::fs::write(&dest, &file.content)\n".to_string()), " .expect(&format!(\"failed to write {}\", file.path));\n".to_string()), " }\n\n".to_string()), " let cargo_toml = tmp_dir.join(\"Cargo.toml\");\n".to_string()), " if !cargo_toml.exists() {\n".to_string()), " std::fs::write(&cargo_toml,\n".to_string()), " \"[package]\\nname = \\\"v2-self-compile-check\\\"\\nversion = \\\"0.1.0\\\"\\nedition = \\\"2021\\\"\\n\"\n".to_string()), " ).expect(\"failed to write Cargo.toml\");\n".to_string()), " }\n\n".to_string()), " eprintln!(\"self-compile-cargo-check: wrote {} files to {}\",\n".to_string()), " result.files.len(), tmp_dir.display());\n\n".to_string()), " let output = std::process::Command::new(\"cargo\")\n".to_string()), " .arg(\"check\")\n".to_string()), " .current_dir(&tmp_dir)\n".to_string()), " .output()\n".to_string()), " .expect(\"failed to run cargo check\");\n\n".to_string()), " let stderr = String::from_utf8_lossy(&output.stderr);\n".to_string()), " eprintln!(\"cargo check stderr:\\n{}\", stderr);\n\n".to_string()), " if !output.status.success() {\n".to_string()), " panic!(\n".to_string()), " \"cargo check failed on self-compiled output (dir: {}):\\n{}\",\n".to_string()), " tmp_dir.display(),\n".to_string()), " stderr\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " let _ = std::fs::remove_dir_all(&tmp_dir);\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"self-compile-cargo-check test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_type_size_test() -> Rc> { +pub fn ct_type_size_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " fn type_size_regression_check() {\n".to_string()), " let node_size = std::mem::size_of::();\n".to_string()), " let expr_size = std::mem::size_of::();\n".to_string()), " eprintln!(\" Node: {} bytes\", node_size);\n".to_string()), " eprintln!(\" Expr: {} bytes\", expr_size);\n".to_string()), " assert!(\n".to_string()), " node_size <= 192,\n".to_string()), " \"Node size regression: {} bytes (limit: 192). Check for unboxed rare fields.\",\n".to_string()), " node_size\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " expr_size <= 800,\n".to_string()), " \"ExprData size regression: {} bytes (limit: 800). Node size likely regressed.\",\n".to_string()), " expr_size\n".to_string()), " );\n".to_string()), " }\n\n".to_string()) } -pub fn ct_coercion_tests() -> Rc> { +pub fn ct_coercion_tests() -> String { { let entries = extract_coercion_tests(); let test_fns = Rc::new({ @@ -92,11 +92,11 @@ pub fn ct_coercion_tests() -> Rc> { } } -pub fn ct_rust_btree_set_ord_eligibility_test() -> Rc> { +pub fn ct_rust_btree_set_ord_eligibility_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" fn shaped_type_node(name: &str, children: Vec>) -> std::rc::Rc {\n".to_string(), " let span = crate::v1_std_core::make_span(0, name.len() as i64);\n".to_string()), " std::rc::Rc::new(crate::v1_std_core::Node {\n".to_string()), " name: name.to_string(),\n".to_string()), " ident: None,\n".to_string()), " span: span.clone(),\n".to_string()), " ident_span: Some(span),\n".to_string()), " children: std::rc::Rc::new(children),\n".to_string()), " connective: crate::v1_std_core::Connective::NoConnective,\n".to_string()), " params: std::rc::Rc::new(Vec::new()),\n".to_string()), " inferred: None,\n".to_string()), " return_cardinality: crate::v1_std_core::Cardinality::Required,\n".to_string()), " uses: std::rc::Rc::new(Vec::new()),\n".to_string()), " body: None,\n".to_string()), " transport: None,\n".to_string()), " properties: std::rc::Rc::new(Vec::new()),\n".to_string()), " type_annotation: None,\n".to_string()), " is_self_recursive: false,\n".to_string()), " has_non_tail_self_call: false,\n".to_string()), " match_pattern: None,\n".to_string()), " expr_data: std::rc::Rc::new(crate::v1_std_core::ExprData::NoExprData),\n".to_string()), " })\n".to_string()), " }\n\n".to_string()), " fn named_type_node(name: &str) -> std::rc::Rc {\n".to_string()), " shaped_type_node(name, Vec::new())\n".to_string()), " }\n\n".to_string()), " #[test]\n".to_string()), " fn rust_btree_set_ord_eligibility_requires_nominal_carrier_shape() {\n".to_string()), " let source_indices = std::rc::Rc::new(HashMap::new());\n".to_string()), " let symbol = named_type_node(\"Symbol\");\n".to_string()), " let diff_id = shaped_type_node(\"DiffId\", vec![symbol.clone()]);\n".to_string()), " assert!(\n".to_string()), " crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " symbol.clone(),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " diff_id.clone(),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " !crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " shaped_type_node(\"Symbol\", vec![named_type_node(\"Float\")]),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " !crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " shaped_type_node(\"DiffId\", vec![named_type_node(\"Float\")]),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " assert!(\n".to_string()), " !crate::v1_compiler_emit_rust::rust_btree_set_element_ord_eligible(\n".to_string()), " named_type_node(\"TestClaimId\"),\n".to_string()), " source_indices.clone()\n".to_string()), " )\n".to_string()), " );\n".to_string()), " }\n\n".to_string()) } -pub fn render_target_rust_enum(target: RenderTarget) -> Rc> { +pub fn render_target_rust_enum(target: RenderTarget) -> String { match target { RenderTarget::Rust => "RenderTarget::Rust".to_string(), RenderTarget::Python => "RenderTarget::Python".to_string(), @@ -105,7 +105,7 @@ pub fn render_target_rust_enum(target: RenderTarget) -> Rc> { } } -pub fn render_coercion_test_rust(entry: Rc) -> Rc> { +pub fn render_coercion_test_rust(entry: Rc) -> String { { let assertions = Rc::new({ let mut __result = Vec::new(); @@ -133,21 +133,21 @@ pub fn render_coercion_test_rust(entry: Rc) -> Rc>) -> Rc> { +pub fn first_or_empty(items: Rc>) -> String { match items.first().cloned() { Some(v) => v.clone(), None => "".to_string(), } } -pub fn second_or_empty(items: Rc>) -> Rc> { +pub fn second_or_empty(items: Rc>) -> String { match items.get(1 as usize).cloned() { Some(v) => v.clone(), None => "".to_string(), } } -pub fn render_coercion_assertion_rust(a: Rc) -> Rc> { +pub fn render_coercion_assertion_rust(a: Rc) -> String { match (*a).clone() { CoercionAssertion::CheckpointAssertion { target: t, @@ -270,27 +270,27 @@ pub fn render_coercion_assertion_rust(a: Rc) -> Rc Rc> { +pub fn ct_profile_helpers() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" /// Return current process RSS in bytes (macOS via mach_task_basic_info).\n".to_string(), " fn get_rss_bytes() -> u64 {\n".to_string()), " #[cfg(target_os = \"macos\")]\n".to_string()), " {\n".to_string()), " #[allow(non_camel_case_types)]\n".to_string()), " #[repr(C)]\n".to_string()), " struct mach_task_basic_info {\n".to_string()), " virtual_size: u64,\n".to_string()), " resident_size: u64,\n".to_string()), " resident_size_max: u64,\n".to_string()), " user_time: [u64; 2],\n".to_string()), " system_time: [u64; 2],\n".to_string()), " policy: i32,\n".to_string()), " suspend_count: i32,\n".to_string()), " }\n".to_string()), " extern \"C\" {\n".to_string()), " fn mach_task_self() -> u32;\n".to_string()), " fn task_info(\n".to_string()), " target_task: u32,\n".to_string()), " flavor: u32,\n".to_string()), " task_info_out: *mut mach_task_basic_info,\n".to_string()), " task_info_count: *mut u32,\n".to_string()), " ) -> i32;\n".to_string()), " }\n".to_string()), " const MACH_TASK_BASIC_INFO: u32 = 20;\n".to_string()), " const MACH_TASK_BASIC_INFO_COUNT: u32 =\n".to_string()), " (std::mem::size_of::() / std::mem::size_of::()) as u32;\n".to_string()), " let mut info: mach_task_basic_info = unsafe { std::mem::zeroed() };\n".to_string()), " let mut count = MACH_TASK_BASIC_INFO_COUNT;\n".to_string()), " let kr = unsafe {\n".to_string()), " task_info(\n".to_string()), " mach_task_self(),\n".to_string()), " MACH_TASK_BASIC_INFO,\n".to_string()), " &mut info,\n".to_string()), " &mut count,\n".to_string()), " )\n".to_string()), " };\n".to_string()), " if kr == 0 {\n".to_string()), " info.resident_size\n".to_string()), " } else {\n".to_string()), " 0\n".to_string()), " }\n".to_string()), " }\n".to_string()), " #[cfg(not(target_os = \"macos\"))]\n".to_string()), " {\n".to_string()), " 0\n".to_string()), " }\n".to_string()), " }\n\n".to_string()), " fn format_bytes(bytes: u64) -> String {\n".to_string()), " if bytes >= 1_073_741_824 {\n".to_string()), " format!(\"{:.1} GB\", bytes as f64 / 1_073_741_824.0)\n".to_string()), " } else if bytes >= 1_048_576 {\n".to_string()), " format!(\"{:.1} MB\", bytes as f64 / 1_048_576.0)\n".to_string()), " } else if bytes >= 1024 {\n".to_string()), " format!(\"{:.1} KB\", bytes as f64 / 1024.0)\n".to_string()), " } else {\n".to_string()), " format!(\"{} B\", bytes)\n".to_string()), " }\n".to_string()), " }\n\n".to_string()) } -pub fn ct_profile_self_compile_test() -> Rc> { +pub fn ct_profile_self_compile_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn profile_self_compile() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " use std::collections::HashMap;\n".to_string()), " use std::time::Instant;\n\n".to_string()), " let sources = self_compile_sources();\n\n".to_string()), " let source_count = sources.len();\n".to_string()), " let rss_start = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \"\\n=== SELF-COMPILE PIPELINE PROFILE ({} sources) ===\",\n".to_string()), " source_count\n".to_string()), " );\n".to_string()), " eprintln!(\" RSS at start: {}\\n\", format_bytes(rss_start));\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let mut token_lists = Vec::new();\n".to_string()), " let phase1_diags = 0usize;\n".to_string()), " for source in &sources {\n".to_string()), " let t = Instant::now();\n".to_string()), " let tokens = crate::v1_compiler_tokenize::tokenize(\n".to_string()), " source.content.clone(),\n".to_string()), " source.path.clone(),\n".to_string()), " );\n".to_string()), " let elapsed = t.elapsed();\n".to_string()), " eprintln!(\n".to_string()), " \" tokenize {:>40}: {:>8.2?} ({:>5} tokens, {:>6} chars)\",\n".to_string()), " source.path,\n".to_string()), " elapsed,\n".to_string()), " tokens.len(),\n".to_string()), " source.content.len()\n".to_string()), " );\n".to_string()), " token_lists.push(tokens);\n".to_string()), " }\n".to_string()), " let tokenize_total = t_stage.elapsed();\n".to_string()), " let rss_after_tokenize = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" TOKENIZE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " tokenize_total,\n".to_string()), " format_bytes(rss_after_tokenize),\n".to_string()), " phase1_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let mut modules = Vec::new();\n".to_string()), " let mut intern_table_p = crate::v1_std_core::empty_intern_table();\n".to_string()), " let mut phase2_diags = 0usize;\n".to_string()), " for (i, tokens) in token_lists.iter().enumerate() {\n".to_string()), " let t = Instant::now();\n".to_string()), " let si = crate::v1_std_core::build_newline_index(\n".to_string()), " sources[i].path.clone(),\n".to_string()), " sources[i].content.clone(),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " crate::v1_rt::rc_map_insert(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " si.file.clone(),\n".to_string()), " si.clone(),\n".to_string()), " ),\n".to_string()), " intern_table_p.clone(),\n".to_string()), " );\n".to_string()), " let result = parsed.result.clone();\n".to_string()), " intern_table_p = parsed.intern_table.clone();\n".to_string()), " let elapsed = t.elapsed();\n".to_string()), " let ok = result.module.is_some();\n".to_string()), " if result.error.is_some() {\n".to_string()), " phase2_diags += 1;\n".to_string()), " }\n".to_string()), " eprintln!(\n".to_string()), " \" parse {:>40}: {:>8.2?} (ok={})\",\n".to_string()), " sources[i].path, elapsed, ok\n".to_string()), " );\n".to_string()), " let m = result.module.clone()\n".to_string()), " .unwrap_or_else(|| panic!(\"parse failed for source {}\", sources[i].path));\n".to_string()), " modules.push(m);\n".to_string()), " }\n".to_string()), " let parse_total = t_stage.elapsed();\n".to_string()), " let rss_after_parse = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" PARSE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " parse_total,\n".to_string()), " format_bytes(rss_after_parse),\n".to_string()), " phase2_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let resolve_si = sources.iter().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, s| crate::v1_rt::rc_map_insert(acc, s.path.clone(), crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())),\n".to_string()), " );\n".to_string()), " let graph = crate::v1_compiler_resolve::resolve_modules(std::rc::Rc::new(modules), resolve_si);\n".to_string()), " let resolve_total = t_stage.elapsed();\n".to_string()), " let phase3_diags: usize = graph\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " let rss_after_resolve = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" RESOLVE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " resolve_total,\n".to_string()), " format_bytes(rss_after_resolve),\n".to_string()), " phase3_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let source_indices = sources.iter().fold(\n".to_string()), " HashMap::>::new(),\n".to_string()), " |mut acc, source| {\n".to_string()), " acc.insert(\n".to_string()), " source.path.clone(),\n".to_string()), " crate::v1_std_core::build_newline_index(\n".to_string()), " source.path.clone(),\n".to_string()), " source.content.clone(),\n".to_string()), " ),\n".to_string()), " );\n".to_string()), " acc\n".to_string()), " },\n".to_string()), " );\n".to_string()), " let typed = crate::v1_compiler_infer::reconcile(graph, std::rc::Rc::new(source_indices), intern_table_p.clone());\n".to_string()), " let reconcile_total = t_stage.elapsed();\n".to_string()), " let phase4_diags: usize = typed\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " let rss_after_reconcile = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" RECONCILE TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " reconcile_total,\n".to_string()), " format_bytes(rss_after_reconcile),\n".to_string()), " phase4_diags\n".to_string()), " );\n\n".to_string()), " let t_stage = Instant::now();\n".to_string()), " let emit_result = crate::v1_compiler_emit_rust::emit_rust(typed);\n".to_string()), " let emit_total = t_stage.elapsed();\n".to_string()), " let phase5_diags: usize = emit_result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " let emitted_files = emit_result.files.len();\n".to_string()), " let emitted_bytes: usize = emit_result.files.iter().map(|f| f.content.len()).sum();\n".to_string()), " let rss_after_emit = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" EMIT TOTAL: {:?} | RSS: {} | diags: {}\\n\",\n".to_string()), " emit_total,\n".to_string()), " format_bytes(rss_after_emit),\n".to_string()), " phase5_diags\n".to_string()), " );\n\n".to_string()), " let total =\n".to_string()), " tokenize_total + parse_total + resolve_total + reconcile_total + emit_total;\n".to_string()), " let total_diags =\n".to_string()), " phase1_diags + phase2_diags + phase3_diags + phase4_diags + phase5_diags;\n".to_string()), " eprintln!(\"=== SUMMARY ===\");\n".to_string()), " eprintln!(\" Tokenize: {:?}\", tokenize_total);\n".to_string()), " eprintln!(\" Parse: {:?}\", parse_total);\n".to_string()), " eprintln!(\" Resolve: {:?}\", resolve_total);\n".to_string()), " eprintln!(\" Reconcile: {:?}\", reconcile_total);\n".to_string()), " eprintln!(\" Emit: {:?}\", emit_total);\n".to_string()), " eprintln!(\" Total: {:?}\", total);\n".to_string()), " eprintln!(\" Diagnostics: {}\", total_diags);\n".to_string()), " eprintln!(\n".to_string()), " \" Emitted: {} files, {}\",\n".to_string()), " emitted_files,\n".to_string()), " format_bytes(emitted_bytes as u64)\n".to_string()), " );\n".to_string()), " eprintln!(\"\");\n".to_string()), " eprintln!(\"=== RSS CHECKPOINTS ===\");\n".to_string()), " eprintln!(\" Start: {}\", format_bytes(rss_start));\n".to_string()), " eprintln!(\" After tokenize: {}\", format_bytes(rss_after_tokenize));\n".to_string()), " eprintln!(\" After parse: {}\", format_bytes(rss_after_parse));\n".to_string()), " eprintln!(\" After resolve: {}\", format_bytes(rss_after_resolve));\n".to_string()), " eprintln!(\" After reconcile:{}\", format_bytes(rss_after_reconcile));\n".to_string()), " eprintln!(\" After emit: {}\", format_bytes(rss_after_emit));\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"profile_self_compile test panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_profile_full_pipeline_test() -> Rc> { +pub fn ct_profile_full_pipeline_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn profile_full_pipeline() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " use std::time::Instant;\n\n".to_string()), " let sources = self_compile_sources();\n".to_string()), " let source_count = sources.len();\n".to_string()), " let total_chars: usize = sources.iter().map(|s| s.content.len()).sum();\n\n".to_string()), " eprintln!(\"\\n=== FULL PIPELINE PROFILE ({} sources, {} chars) ===\\n\", source_count, total_chars);\n\n".to_string()), " // 1a. Tokenize + parse\n".to_string()), " let t = Instant::now();\n".to_string()), " let mut token_lists = Vec::new();\n".to_string()), " for source in &sources {\n".to_string()), " let tokens = crate::v1_compiler_tokenize::tokenize(\n".to_string()), " source.content.clone(), source.path.clone(),\n".to_string()), " );\n".to_string()), " token_lists.push(tokens);\n".to_string()), " }\n".to_string()), " let tokenize_elapsed = t.elapsed();\n\n".to_string()), " let t = Instant::now();\n".to_string()), " let mut modules = Vec::new();\n".to_string()), " let mut intern_table_fp = crate::v1_std_core::empty_intern_table();\n".to_string()), " for (i, tokens) in token_lists.iter().enumerate() {\n".to_string()), " let si = crate::v1_std_core::build_newline_index(\n".to_string()), " sources[i].path.clone(),\n".to_string()), " sources[i].content.clone(),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " crate::v1_rt::rc_map_insert(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " si.file.clone(),\n".to_string()), " si.clone(),\n".to_string()), " ),\n".to_string()), " intern_table_fp.clone(),\n".to_string()), " );\n".to_string()), " let result = parsed.result.clone();\n".to_string()), " intern_table_fp = parsed.intern_table.clone();\n".to_string()), " let m = result.module.clone()\n".to_string()), " .unwrap_or_else(|| panic!(\"parse failed for source {}\", sources[i].path));\n".to_string()), " modules.push(m);\n".to_string()), " }\n".to_string()), " let parse_elapsed = t.elapsed();\n".to_string()), " // 1b. Resolve\n".to_string()), " let t = Instant::now();\n".to_string()), " let resolve_si = sources.iter().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, s| crate::v1_rt::rc_map_insert(acc, s.path.clone(), crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())),\n".to_string()), " );\n".to_string()), " let graph = crate::v1_compiler_resolve::resolve_modules(std::rc::Rc::new(modules), resolve_si);\n".to_string()), " let resolve_elapsed = t.elapsed();\n".to_string()), " let resolve_errors: usize = graph.diagnostics.iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n\n".to_string()), " // 1c. Newline indices\n".to_string()), " let t = Instant::now();\n".to_string()), " let newline_indices: Vec<_> = sources.iter().map(|s| {\n".to_string()), " crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())\n".to_string()), " }).collect();\n".to_string()), " let newline_elapsed = t.elapsed();\n\n".to_string()), " let frontend_elapsed = tokenize_elapsed + parse_elapsed + resolve_elapsed + newline_elapsed;\n".to_string()), " eprintln!(\" Tokenize: {:>8.2?}\", tokenize_elapsed);\n".to_string()), " eprintln!(\" Parse: {:>8.2?}\", parse_elapsed);\n".to_string()), " eprintln!(\" Resolve: {:>8.2?} ({} resolve errors)\", resolve_elapsed, resolve_errors);\n".to_string()), " eprintln!(\" Newline indices: {:>8.2?}\", newline_elapsed);\n".to_string()), " eprintln!(\" Frontend total: {:>8.2?}\", frontend_elapsed);\n\n".to_string()), " // 2. Normalize\n".to_string()), " let t = Instant::now();\n".to_string()), " let source_indices = newline_indices.iter().cloned().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, index| crate::v1_rt::rc_map_insert(acc, index.file.clone(), index.clone()),\n".to_string()), " );\n".to_string()), " let norm = crate::v1_compiler_normalize::normalize_graph(graph.clone(), source_indices.clone());\n".to_string()), " let normalize_elapsed = t.elapsed();\n".to_string()), " eprintln!(\" Normalize: {:>8.2?}\", normalize_elapsed);\n\n".to_string()), " // 3. Reconcile\n".to_string()), " let t = Instant::now();\n".to_string()), " let typed = crate::v1_compiler_infer::reconcile(norm.graph.clone(), source_indices.clone(), intern_table_fp.clone());\n".to_string()), " let reconcile_elapsed = t.elapsed();\n".to_string()), " let type_errors: usize = typed.diagnostics.iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n".to_string()), " eprintln!(\" Reconcile: {:>8.2?} ({} type errors)\", reconcile_elapsed, type_errors);\n\n".to_string()), " // 4. Complexity\n".to_string()), " let t = Instant::now();\n".to_string()), " let func_entries = crate::v1_compiler_compile::extract_func_entries(typed.clone());\n".to_string()), " let func_count = func_entries.len();\n".to_string()), " let recursion_ctx = crate::v1_compiler_compile::build_recursion_context(typed.clone());\n".to_string()), " let complexity = crate::v1_compiler_complexity::build_complexity_report(\n".to_string()), " func_entries, recursion_ctx, source_indices.clone(),\n".to_string()), " );\n".to_string()), " let complexity_elapsed = t.elapsed();\n".to_string()), " let cx_diags = crate::v1_compiler_compile::complexity_diagnostics(complexity.clone());\n".to_string()), " eprintln!(\" Complexity: {:>8.2?} ({} funcs, {} diagnostics)\", complexity_elapsed, func_count, cx_diags.len());\n\n".to_string()), " // 5. Ownership\n".to_string()), " let t = Instant::now();\n".to_string()), " let ownership = crate::v1_compiler_compile::extract_ownership_proofs(typed.clone());\n".to_string()), " let ownership_elapsed = t.elapsed();\n".to_string()), " let own_diags = crate::v1_compiler_compile::ownership_diagnostics(ownership.clone());\n".to_string()), " eprintln!(\" Ownership: {:>8.2?} ({} proofs, {} diagnostics)\", ownership_elapsed, ownership.len(), own_diags.len());\n\n".to_string()), " // 6. Emit\n".to_string()), " let artifact_plan = crate::v1_compiler_compile::default_artifact_plan(\n".to_string()), " std::rc::Rc::new(typed.modules.iter().map(|m| m.module.clone().name.clone()).collect()),\n".to_string()), " crate::v1_compiler_artifact::RenderTarget::Rust,\n".to_string()), " );\n".to_string()), " let t = Instant::now();\n".to_string()), " let emit_result = crate::v1_compiler_compile::emit_from_artifact_plan(typed.clone(), artifact_plan);\n".to_string()), " let emit_elapsed = t.elapsed();\n".to_string()), " let emitted_files = emit_result.files.len();\n".to_string()), " let emitted_bytes: usize = emit_result.files.iter().map(|f| f.content.len()).sum();\n".to_string()), " eprintln!(\" Emit: {:>8.2?} ({} files, {} bytes)\", emit_elapsed, emitted_files, emitted_bytes);\n\n".to_string()), " let total = frontend_elapsed + normalize_elapsed + reconcile_elapsed\n".to_string()), " + complexity_elapsed + ownership_elapsed + emit_elapsed;\n".to_string()), " eprintln!(\"\\n=== SUMMARY ===\");\n".to_string()), " eprintln!(\" Tokenize: {:>8.2?} ({:.0}%)\", tokenize_elapsed, tokenize_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Parse: {:>8.2?} ({:.0}%)\", parse_elapsed, parse_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Resolve: {:>8.2?} ({:.0}%)\", resolve_elapsed, resolve_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Newline: {:>8.2?} ({:.0}%)\", newline_elapsed, newline_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Normalize: {:>8.2?} ({:.0}%)\", normalize_elapsed, normalize_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Reconcile: {:>8.2?} ({:.0}%)\", reconcile_elapsed, reconcile_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Complexity: {:>8.2?} ({:.0}%)\", complexity_elapsed, complexity_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Ownership: {:>8.2?} ({:.0}%)\", ownership_elapsed, ownership_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" Emit: {:>8.2?} ({:.0}%)\", emit_elapsed, emit_elapsed.as_secs_f64() / total.as_secs_f64() * 100.0);\n".to_string()), " eprintln!(\" TOTAL: {:>8.2?}\", total);\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"profile_full_pipeline panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_profile_reconcile_test() -> Rc> { +pub fn ct_profile_reconcile_test() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" #[test]\n".to_string(), " #[ignore]\n".to_string()), " fn profile_reconcile_per_module() {\n".to_string()), " let result = std::thread::Builder::new()\n".to_string()), " .stack_size(64 * 1024 * 1024)\n".to_string()), " .spawn(|| {\n".to_string()), " use std::collections::HashMap;\n".to_string()), " use std::time::Instant;\n\n".to_string()), " let sources = self_compile_sources();\n\n".to_string()), " eprintln!(\n".to_string()), " \"\\n=== PER-MODULE RECONCILE PROFILE ({} sources) ===\",\n".to_string()), " sources.len()\n".to_string()), " );\n\n".to_string()), " let t0 = Instant::now();\n".to_string()), " let mut modules = Vec::new();\n".to_string()), " let mut intern_table = crate::v1_std_core::empty_intern_table();\n".to_string()), " for source in &sources {\n".to_string()), " let tokens = crate::v1_compiler_tokenize::tokenize(\n".to_string()), " source.content.clone(),\n".to_string()), " source.path.clone(),\n".to_string()), " );\n".to_string()), " let si = crate::v1_std_core::build_newline_index(\n".to_string()), " source.path.clone(),\n".to_string()), " source.content.clone(),\n".to_string()), " );\n".to_string()), " let parsed = crate::v1_compiler_parse::parse_with_table(\n".to_string()), " tokens.clone(),\n".to_string()), " crate::v1_rt::rc_map_insert(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " si.file.clone(),\n".to_string()), " si.clone(),\n".to_string()), " ),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let result = parsed.result.clone();\n".to_string()), " intern_table = parsed.intern_table.clone();\n".to_string()), " let m = result.module.clone()\n".to_string()), " .unwrap_or_else(|| panic!(\"parse failed for source {}\", source.path));\n".to_string()), " modules.push(m);\n".to_string()), " }\n".to_string()), " let resolve_si = sources.iter().fold(\n".to_string()), " crate::v1_rt::rc_empty_map::>(),\n".to_string()), " |acc, s| crate::v1_rt::rc_map_insert(acc, s.path.clone(), crate::v1_std_core::build_newline_index(s.path.clone(), s.content.clone())),\n".to_string()), " );\n".to_string()), " let graph = crate::v1_compiler_resolve::resolve_modules(std::rc::Rc::new(modules), resolve_si);\n".to_string()), " let setup_time = t0.elapsed();\n".to_string()), " let rss_baseline = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \" Setup (tok+parse+resolve): {:?} | RSS: {}\",\n".to_string()), " setup_time,\n".to_string()), " format_bytes(rss_baseline)\n".to_string()), " );\n".to_string()), " eprintln!(\" Modules to reconcile: {}\\n\", graph.modules.len());\n\n".to_string()), " let mut mi_raw = HashMap::<\n".to_string()), " String,\n".to_string()), " std::rc::Rc,\n".to_string()), " >::new();\n".to_string()), " let source_indices = std::rc::Rc::new(sources.iter().fold(\n".to_string()), " HashMap::>::new(),\n".to_string()), " |mut acc, source| {\n".to_string()), " acc.insert(\n".to_string()), " source.path.clone(),\n".to_string()), " crate::v1_std_core::build_newline_index(\n".to_string()), " source.path.clone(),\n".to_string()), " source.content.clone(),\n".to_string()), " ),\n".to_string()), " );\n".to_string()), " acc\n".to_string()), " },\n".to_string()), " ));\n\n".to_string()), " for resolved in graph.modules.iter() {\n".to_string()), " let name = resolved.module.name.to_string();\n".to_string()), " let item_count =\n".to_string()), " crate::v1_std_core::module_items(resolved.module.clone()).len();\n".to_string()), " let rss_before = get_rss_bytes();\n\n".to_string()), " eprint!(\" {:>35} ({:>3} items) ... \", name, item_count);\n\n".to_string()), " let module_index = std::rc::Rc::new(mi_raw.clone());\n\n".to_string()), " let t_unres = Instant::now();\n".to_string()), " let _unres = crate::v1_compiler_infer::build_type_env_unresolved(\n".to_string()), " resolved.clone(),\n".to_string()), " module_index.clone(),\n".to_string()), " source_indices.clone(),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let unres_elapsed = t_unres.elapsed();\n".to_string()), " let rss_after_unres = get_rss_bytes();\n".to_string()), " let unres_delta = rss_after_unres.saturating_sub(rss_before);\n\n".to_string()), " eprint!(\n".to_string()), " \"cycles={:>8.2?}(+{}) \",\n".to_string()), " unres_elapsed,\n".to_string()), " format_bytes(unres_delta)\n".to_string()), " );\n\n".to_string()), " if unres_delta > 256 * 1024 * 1024 {\n".to_string()), " eprintln!(\"\");\n".to_string()), " panic!(\n".to_string()), " \"ABORT: '{}' cycle detection grew RSS by {}\",\n".to_string()), " name,\n".to_string()), " format_bytes(unres_delta)\n".to_string()), " );\n".to_string()), " }\n\n".to_string()), " let t_env = Instant::now();\n".to_string()), " let env_result = crate::v1_compiler_infer::build_type_env(\n".to_string()), " resolved.clone(),\n".to_string()), " module_index.clone(),\n".to_string()), " source_indices.clone(),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let env_elapsed = t_env.elapsed();\n".to_string()), " let rss_after_env = get_rss_bytes();\n".to_string()), " let env_delta = rss_after_env.saturating_sub(rss_before);\n".to_string()), " let env_errs: usize = env_result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n\n".to_string()), " eprint!(\n".to_string()), " \"env={:>8.2?}(+{},e={}) \",\n".to_string()), " env_elapsed,\n".to_string()), " format_bytes(env_delta),\n".to_string()), " env_errs\n".to_string()), " );\n\n".to_string()), " if env_delta > 512 * 1024 * 1024 {\n".to_string()), " eprintln!(\"\");\n".to_string()), " panic!(\n".to_string()), " \"ABORT: '{}' build_type_env grew RSS by {}\",\n".to_string()), " name,\n".to_string()), " format_bytes(env_delta)\n".to_string()), " );\n".to_string()), " }\n".to_string()), " if env_elapsed.as_secs() > 10 {\n".to_string()), " eprintln!(\"\");\n".to_string()), " panic!(\"ABORT: '{}' build_type_env took {:?}\", name, env_elapsed);\n".to_string()), " }\n\n".to_string()), " let t_full = Instant::now();\n".to_string()), " let tc_result = crate::v1_compiler_infer::typecheck_module(\n".to_string()), " resolved.clone(),\n".to_string()), " module_index.clone(),\n".to_string()), " source_indices.clone(),\n".to_string()), " intern_table.clone(),\n".to_string()), " );\n".to_string()), " let full_elapsed = t_full.elapsed();\n".to_string()), " let rss_after = get_rss_bytes();\n".to_string()), " let delta = rss_after.saturating_sub(rss_before);\n".to_string()), " let diag_count: usize = tc_result\n".to_string()), " .diagnostics\n".to_string()), " .iter()\n".to_string()), " .filter(|d| crate::v1_std_core::is_error_diagnostic(d.diagnostic.clone()))\n".to_string()), " .count();\n\n".to_string()), " eprintln!(\n".to_string()), " \"full={:>8.2?} | RSS: {} (+{}) | errs: {}\",\n".to_string()), " full_elapsed,\n".to_string()), " format_bytes(rss_after),\n".to_string()), " format_bytes(delta),\n".to_string()), " diag_count\n".to_string()), " );\n\n".to_string()), " if delta > 512 * 1024 * 1024 {\n".to_string()), " panic!(\n".to_string()), " \"ABORT: '{}' grew RSS by {} (>512MB)\",\n".to_string()), " name,\n".to_string()), " format_bytes(delta)\n".to_string()), " );\n".to_string()), " }\n".to_string()), " if full_elapsed.as_secs() > 10 {\n".to_string()), " panic!(\"ABORT: '{}' took {:?} (>10s)\", name, full_elapsed);\n".to_string()), " }\n\n".to_string()), " let typed = tc_result.typed.clone();\n".to_string()), " mi_raw.insert(name, typed);\n".to_string()), " }\n\n".to_string()), " let rss_final = get_rss_bytes();\n".to_string()), " eprintln!(\n".to_string()), " \"\\n RSS final: {} (from baseline: +{})\",\n".to_string()), " format_bytes(rss_final),\n".to_string()), " format_bytes(rss_final.saturating_sub(rss_baseline))\n".to_string()), " );\n".to_string()), " eprintln!(\"=== DONE ===\\n\");\n".to_string()), " })\n".to_string()), " .expect(\"failed to spawn thread\")\n".to_string()), " .join();\n".to_string()), " result.expect(\"profile_reconcile_per_module panicked\");\n".to_string()), " }\n\n".to_string()) } -pub fn ct_module_footer() -> Rc> { +pub fn ct_module_footer() -> String { "}\n".to_string() } -pub fn compiler_tests_source() -> Rc> { +pub fn compiler_tests_source() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index 95b931b1f67..ae8d86f6d14 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -103,10 +103,10 @@ pub enum SizeExpr { value: i64, }, SizeVar { - name: Rc>, + name: String, }, SizeLen { - collection: Rc>, + collection: String, }, SizeAdd { left: Rc, @@ -137,7 +137,7 @@ pub enum CostExpr { right: Rc, }, CostSum { - binder: Rc>, + binder: String, upper: Rc, body: Rc, }, @@ -146,10 +146,10 @@ pub enum CostExpr { argument: Rc, }, CostExtern { - name: Rc>, + name: String, }, CostUnknown { - reason: Rc>, + reason: String, }, } @@ -177,13 +177,13 @@ pub struct CostInternTable { pub fn empty_intern_table() -> Rc { Rc::new(CostInternTable { - summaries: v1_rt::rc_empty_map::>, Rc>(), + summaries: v1_rt::rc_empty_map::>(), }) } pub fn cache_summary( table: Rc, - func_name: Rc>, + func_name: String, summary: Rc, ) -> Rc { Rc::new(CostInternTable { @@ -193,22 +193,19 @@ pub fn cache_summary( pub fn lookup_summary( table: Rc, - func_name: Rc>, + func_name: String, ) -> Option> { v1_rt::map_get(&table.summaries.clone(), func_name) } -pub fn evict_summary( - table: Rc, - func_name: Rc>, -) -> Rc { +pub fn evict_summary(table: Rc, func_name: String) -> Rc { cache_summary( table, func_name, Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), ) @@ -216,8 +213,8 @@ pub fn evict_summary( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CallEdge { - pub caller: Rc>, - pub callee: Rc>, + pub caller: String, + pub callee: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -243,7 +240,7 @@ pub struct SccResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ParserStateParam { - pub name: Rc>, + pub name: String, pub index: i64, } @@ -261,7 +258,7 @@ pub enum ParserResultSource { }, ParserResultCall { input: DescentEvidence, - callee: Rc>, + callee: String, }, ParserResultDirectState { input: DescentEvidence, @@ -283,8 +280,8 @@ impl ParserResultSource { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ParserProgressEdge { - pub caller: Rc>, - pub callee: Rc>, + pub caller: String, + pub callee: String, pub progress: DescentEvidence, } @@ -355,7 +352,7 @@ pub fn iteration_element_name( method_semantics: Option>, lambda: Rc, si: Rc>>, -) -> Rc> { +) -> Option { { let params = lambda_param_names_at(lambda, si); match method_callback_element_position(method_semantics) { @@ -373,7 +370,7 @@ pub fn proof_has_non_descending_cycle( (is_valid_proof(proof, edges) == false) } -pub fn set_has(m: Rc>, key: Rc>) -> bool { +pub fn set_has(m: Rc>, key: String) -> bool { (v1_rt::map_get(&m, key) != None) } @@ -386,8 +383,8 @@ pub fn strict_after_parser_witness(input: DescentEvidence) -> DescentEvidence { pub fn empty_parser_progress_env() -> Rc { Rc::new(ParserProgressEnv { - state_aliases: v1_rt::rc_empty_map::>, DescentEvidence>(), - result_sources: v1_rt::rc_empty_map::>, Rc>(), + state_aliases: v1_rt::rc_empty_map::(), + result_sources: v1_rt::rc_empty_map::>(), }) } @@ -412,12 +409,9 @@ pub fn parser_state_param( { let idx = pair.0.clone(); let param = pair.1.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - si.clone(), - param_node_type_expr(param.clone()), - )) == crate::v2_std_text::host_string_text_to_rust_host( - "ParserState".to_string(), - )) { + if (authored_name_at(si.clone(), param_node_type_expr(param.clone())).as_str() + == "ParserState".to_string().as_str()) + { Some(Rc::new(ParserStateParam { name: param_node_name_at(param.clone(), si.clone()), index: idx.clone(), @@ -433,7 +427,7 @@ pub fn parser_state_param( pub fn parser_state_base_var( expr: Rc, si: Rc>>, -) -> Rc> { +) -> Option { match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => match expr.children.clone().first().cloned() { Some(base) => match (*base.expr_data.clone()).clone() { @@ -452,7 +446,7 @@ pub fn parser_result_state_progress( source: Rc, parser_always_advancing: Rc>, consumed_true_set: Rc>, - result_name: Rc>, + result_name: String, ) -> DescentEvidence { match (*source).clone() { ParserResultSource::ParserResultAdvance { input, .. } => { @@ -507,13 +501,10 @@ pub fn parser_state_arg_expr( let idx = pair.0.clone(); let arg_node = pair.1.clone(); let matches_state = if (arg_name_at(arg_node.clone(), si.clone()).as_deref() - != Some(crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - ))) { + != Some("".to_string().as_str())) + { (arg_name_at(arg_node.clone(), si.clone()).as_deref() - == Some(crate::v2_std_text::host_string_text_to_rust_host( - state_param.name.clone(), - ))) + == Some(state_param.name.clone().as_str())) } else { (idx.clone() == state_param.index.clone()) }; @@ -541,9 +532,7 @@ pub fn parser_state_expr_progress( binding_kind: _, .. } => { let name = expr_var_name_at(expr.clone(), si.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(state_param.name.clone())) - { + if (name.clone().as_str() == state_param.name.clone().as_str()) { DescentEvidence::NonIncreasing } else { match v1_rt::map_get(&env.state_aliases.clone(), name.clone()) { @@ -553,10 +542,8 @@ pub fn parser_state_expr_progress( } } ExprData::ExprFieldAccess { .. } => { - if (crate::v2_std_text::host_string_text_to_rust_host(field_access_field_at( - expr.clone(), - si.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host("state".to_string())) + if (field_access_field_at(expr.clone(), si.clone()).as_str() + == "state".to_string().as_str()) { match parser_state_base_var(expr.clone(), si.clone()) { Some(result_name) => { @@ -810,7 +797,7 @@ pub fn parser_result_source_for_expr( } pub fn parser_env_with_binding( - name: Rc>, + name: String, value_expr: Rc, env: Rc, state_param: Rc, @@ -882,7 +869,7 @@ pub fn parser_call_edge_progress( } pub fn collect_parser_progress_block_edges( - caller: Rc>, + caller: String, stmts: Rc>>, state_param: Rc, scc_name_set: Rc>, @@ -965,7 +952,7 @@ pub fn collect_parser_progress_block_edges( } pub fn collect_parser_progress_edges( - caller: Rc>, + caller: String, body: Rc, state_param: Rc, scc_name_set: Rc>, @@ -1166,7 +1153,7 @@ pub fn collect_parser_progress_edges( pub fn parser_record_field_value( expr: Rc, - field_name: Rc>, + field_name: String, si: Rc>>, ) -> Option> { Rc::new({ @@ -1174,10 +1161,8 @@ pub fn parser_record_field_value( for child in Rc::new({ let mut __result = Vec::new(); for child in expr.children.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( - child.clone(), - si.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone())) + if (field_init_node_name_at(child.clone(), si.clone()).as_str() + == field_name.clone().as_str()) { __result.push(child); } @@ -1396,7 +1381,7 @@ pub fn parser_member_is_always_advancing( parser_name_set, empty_parser_progress_env(), proven.clone(), - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), si.clone(), ); ({ @@ -1416,7 +1401,7 @@ pub fn parser_member_is_always_advancing( state_param.clone(), empty_parser_progress_env(), proven.clone(), - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), si.clone(), ) == DescentEvidence::Strict)) } @@ -1499,8 +1484,8 @@ pub fn infer_parser_always_advancing_members( ) -> Rc> { { let parser_name_set = members.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -1525,7 +1510,7 @@ pub fn infer_parser_always_advancing_members( func_index.clone(), parser_name_set, reverse_graph, - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), si.clone(), ) } @@ -1559,45 +1544,23 @@ pub fn infer_all_parser_always_advancing( } } -pub fn seed_string_map( - key: Rc>, - value: Rc>, -) -> Rc> { - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>>(), - key, - value, - ) +pub fn seed_string_map(key: String, value: String) -> Rc> { + v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, value) } -pub fn seed_bool_map(key: Rc>) -> Rc> { - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, bool>(), - key, - true, - ) +pub fn seed_bool_map(key: String) -> Rc> { + v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, true) } -pub fn seed_cost_map( - key: Rc>, - value: Rc, -) -> Rc>> { - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>(), - key, - value, - ) +pub fn seed_cost_map(key: String, value: Rc) -> Rc>> { + v1_rt::rc_map_insert(v1_rt::rc_empty_map::>(), key, value) } pub fn seed_func_entry_map( - key: Rc>, + key: String, value: Rc, ) -> Rc>> { - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>(), - key, - value, - ) + v1_rt::rc_map_insert(v1_rt::rc_empty_map::>(), key, value) } pub fn build_call_graph_from_parser_edges( @@ -1610,9 +1573,7 @@ pub fn build_call_graph_from_parser_edges( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) - != crate::v2_std_text::host_string_text_to_rust_host(edge.callee.clone())) - { + if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { __result.push(edge); } } @@ -1648,9 +1609,7 @@ pub fn same_progress_subgraph_has_cycle( let has_self_cycle = { let mut __found = false; for edge in same_edges.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(edge.callee.clone())) - { + if (edge.caller.clone().as_str() == edge.callee.clone().as_str()) { __found = true; break; } @@ -1664,11 +1623,7 @@ pub fn same_progress_subgraph_has_cycle( let same_cross_edges = Rc::new({ let mut __result = Vec::new(); for edge in same_edges.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - edge.callee.clone(), - )) - { + if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { __result.push(edge); } } @@ -1725,7 +1680,7 @@ pub fn collect_parser_edges_for_scc( scc_name_set.clone(), empty_parser_progress_env(), parser_always_advancing.clone(), - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), si.clone(), ), None => Rc::new(vec![]), @@ -1751,8 +1706,8 @@ pub fn classify_parser_scc_recursion_pattern( ) -> Option> { { let scc_name_set = members.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -1789,16 +1744,14 @@ pub fn classify_parser_scc_recursion_pattern( pub fn count_self_calls( body: Rc, - func_name: Rc>, + func_name: String, si: Rc>>, ) -> i64 { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let own = match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(f) - == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) - { + if (f.as_str() == func_name.clone().as_str()) { 1 } else { 0 @@ -1820,7 +1773,7 @@ pub fn count_self_calls( pub fn max_path_self_calls( body: Rc, - func_name: Rc>, + func_name: String, si: Rc>>, ) -> i64 { max_path_self_calls_with_cont(body, func_name, 0, si) @@ -1828,7 +1781,7 @@ pub fn max_path_self_calls( pub fn max_path_self_calls_with_cont( body: Rc, - func_name: Rc>, + func_name: String, continue_calls: i64, si: Rc>>, ) -> i64 { @@ -1836,9 +1789,7 @@ pub fn max_path_self_calls_with_cont( match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at(body.clone(), si.clone()); - let own = if (crate::v2_std_text::host_string_text_to_rust_host(f) - == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) - { + let own = if (f.as_str() == func_name.clone().as_str()) { 1 } else { 0 @@ -2025,7 +1976,7 @@ pub fn max_path_self_calls_with_cont( pub fn max_path_self_calls_block( stmts: Rc>>, - func_name: Rc>, + func_name: String, continue_calls: i64, si: Rc>>, ) -> i64 { @@ -2256,20 +2207,17 @@ pub fn build_scc_measure_params( si: Rc>>, ) -> Rc>>> { members.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), - |acc: Rc>>>, name: Rc>| { - match v1_rt::map_get(&func_index, name.clone()) { - Some(entry) => v1_rt::rc_map_insert( - acc.clone(), - name.clone(), - recursive_measure_param_names( - entry.body.clone(), - entry.params.clone(), - si.clone(), - ), - ), - None => acc.clone(), - } + v1_rt::rc_empty_map::>>(), + |acc: Rc>>>, name: String| match v1_rt::map_get( + &func_index, + name.clone(), + ) { + Some(entry) => v1_rt::rc_map_insert( + acc.clone(), + name.clone(), + recursive_measure_param_names(entry.body.clone(), entry.params.clone(), si.clone()), + ), + None => acc.clone(), }, ) } @@ -2291,9 +2239,7 @@ pub fn target_call_has_arithmetic_descent( let callee_measure_params = match v1_rt::map_get(&scc_measure_params, callee.clone()) { Some(params) => params.clone(), - None => { - v1_rt::rc_empty_map::>, Rc>>() - } + None => v1_rt::rc_empty_map::(), }; { let mut __found = false; @@ -2401,14 +2347,12 @@ pub fn scc_calls_have_arithmetic_descent( pub fn descending_name_set_without_key( names: Rc>, - key: Rc>, + key: String, ) -> Rc> { Rc::new(v1_rt::map_keys(&names)).iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), - |acc: Rc>, name: Rc>| { - if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(key.clone())) - { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { + if (name.clone().as_str() == key.clone().as_str()) { acc.clone() } else { match v1_rt::map_get(&names, name.clone()) { @@ -2424,7 +2368,7 @@ pub fn expr_descending_witness_source( mut expr: Rc, mut descending_witness_names: Rc>, mut si: Rc>>, -) -> Rc> { +) -> Option { loop { match (*expr.expr_data.clone()).clone() { ExprData::ExprVar { @@ -2470,11 +2414,11 @@ pub fn condition_param_names( let name = expr_var_name_at(expr.clone(), si.clone()); match v1_rt::map_get(¶m_set, name.clone()) { Some(_) => seed_string_map(name.clone(), name.clone()), - None => v1_rt::rc_empty_map::>, Rc>>(), + None => v1_rt::rc_empty_map::(), } } _ => expr.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, child: Rc| { v1_rt::rc_map_merge( acc, @@ -2493,7 +2437,7 @@ pub fn recursive_measure_param_names( ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let param_set = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, param: Rc| { v1_rt::rc_map_insert( acc, @@ -2513,7 +2457,7 @@ pub fn recursive_measure_param_names( Some(eb) => { recursive_measure_param_names(eb.clone(), params.clone(), si.clone()) } - None => v1_rt::rc_empty_map::>, Rc>>(), + None => v1_rt::rc_empty_map::(), }; v1_rt::rc_map_merge( v1_rt::rc_map_merge( @@ -2527,7 +2471,7 @@ pub fn recursive_measure_param_names( let scrut_names = condition_param_names(match_scrutinee(body.clone()), param_set, si.clone()); let arm_names = match_arm_nodes(body.clone()).iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, arm_node: Rc| { v1_rt::rc_map_merge( acc, @@ -2543,10 +2487,10 @@ pub fn recursive_measure_param_names( } ExprData::ExprLet => match let_body(body.clone()) { Some(b) => recursive_measure_param_names(b.clone(), params.clone(), si.clone()), - None => v1_rt::rc_empty_map::>, Rc>>(), + None => v1_rt::rc_empty_map::(), }, ExprData::ExprBlock => body.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, stmt: Rc| { v1_rt::rc_map_merge( acc, @@ -2555,7 +2499,7 @@ pub fn recursive_measure_param_names( }, ), _ => body.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, child: Rc| { v1_rt::rc_map_merge( acc, @@ -2572,7 +2516,7 @@ pub fn recursive_param_name_for_arg( arg_node: Rc, params: Rc>>, si: Rc>>, -) -> Rc> { +) -> Option { match arg_name_at(arg_node, si.clone()) { Some(name) => Some(name.clone()), None => Rc::new({ @@ -2631,17 +2575,15 @@ pub fn is_descending_expr(expr: Rc) -> bool { pub fn has_arithmetic_descent( body: Rc, - func_name: Rc>, + func_name: String, si: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*body.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - let own_ok = if (crate::v2_std_text::host_string_text_to_rust_host( - expr_call_func_at(body.clone(), si.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - )) { + let own_ok = if (expr_call_func_at(body.clone(), si.clone()).as_str() + == func_name.clone().as_str()) + { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -2686,7 +2628,7 @@ pub fn has_arithmetic_descent( pub fn is_accessor_of_param( expr: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, si: Rc>>, ) -> bool { @@ -2701,10 +2643,7 @@ pub fn is_accessor_of_param( binding_kind: _, .. } => { let vname = expr_var_name_at(arg_value(arg_node.clone()), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + ((vname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), vname.clone())) } _ => false, @@ -2722,7 +2661,7 @@ pub fn is_accessor_of_param( pub fn is_children_of_param( mut expr: Rc, - mut param_name: Rc>, + mut param_name: String, mut vars: Rc>, mut si: Rc>>, ) -> bool { @@ -2736,10 +2675,8 @@ pub fn is_children_of_param( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( - base.clone(), - si.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) + (expr_var_name_at(base.clone(), si.clone()).as_str() + == param_name.as_str()) } _ => false, }); @@ -2771,7 +2708,7 @@ pub fn is_children_of_param( pub fn is_structural_children( expr: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, si: Rc>>, ) -> bool { @@ -2814,7 +2751,7 @@ pub fn is_structural_children( pub fn is_child_descent_expr( expr: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, si: Rc>>, ) -> bool { @@ -2878,7 +2815,7 @@ pub fn extractor_inner_arg(expr: Rc) -> Rc { pub fn is_list_shrink_expr( expr: Rc, - param_name: Rc>, + param_name: String, si: Rc>>, ) -> bool { match (*expr.expr_data.clone()).clone() { @@ -2895,10 +2832,8 @@ pub fn is_list_shrink_expr( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( - method_receiver(expr.clone()), - si, - )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) + (expr_var_name_at(method_receiver(expr.clone()), si).as_str() + == param_name.as_str()) } _ => false, }) @@ -2971,7 +2906,7 @@ pub fn list_passthrough_inner_arg( pub fn is_tokens_consuming_call( expr: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, si: Rc>>, ) -> bool { @@ -2998,9 +2933,7 @@ pub fn consuming_tokens_arg( Some(_) => acc.clone(), None => match arg_name_at(child.clone(), si.clone()) { Some(name) => { - if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("tokens".to_string())) - { + if (name.clone().as_str() == "tokens".to_string().as_str()) { Some(arg_value(child.clone())) } else { None @@ -3013,7 +2946,7 @@ pub fn consuming_tokens_arg( pub fn is_tokens_input_expr( mut expr: Rc, - mut param_name: Rc>, + mut param_name: String, mut vars: Rc>, mut si: Rc>>, ) -> bool { @@ -3023,15 +2956,12 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let vname = expr_var_name_at(expr.clone(), si.clone()); - break ((crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) + break ((vname.clone().as_str() == param_name.clone().as_str()) || set_has(vars, vname.clone())); } ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), si.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(field) - == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) - { + if (field.as_str() == param_name.clone().as_str()) { break true; } else { let base = field_access_base(expr.clone()); @@ -3040,11 +2970,8 @@ pub fn is_tokens_input_expr( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - break ((crate::v2_std_text::host_string_text_to_rust_host( - bname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || set_has(vars, bname.clone())); + break ((bname.clone().as_str() == param_name.clone().as_str()) + || set_has(vars, bname.clone())); } _ => { break false; @@ -3099,7 +3026,7 @@ pub fn is_tokens_input_expr( pub fn is_descent_arg( expr: Rc, - param_name: Rc>, + param_name: String, descent_vars: Rc>, check_child: bool, check_list: bool, @@ -3128,7 +3055,7 @@ pub fn is_descent_arg( pub fn expr_contains_descent( expr: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, check_child: bool, check_list: bool, @@ -3186,10 +3113,7 @@ pub fn expr_contains_descent( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host(bname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + ((bname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), bname.clone())) } _ => false, @@ -3261,7 +3185,7 @@ pub fn collect_field_binding_names( pub fn is_if_option_descent( val: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, check_child: bool, check_list: bool, @@ -3283,12 +3207,8 @@ pub fn is_if_option_descent( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( - eb.clone(), - si.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - "none".to_string(), - )) + (expr_var_name_at(eb.clone(), si.clone()).as_str() + == "none".to_string().as_str()) } ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitNull => true, @@ -3306,7 +3226,7 @@ pub fn is_if_option_descent( pub fn is_match_option_descent( val: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, check_child: bool, check_list: bool, @@ -3334,7 +3254,7 @@ pub fn is_match_option_descent( .. } => { let binding_names = bindings.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, fb: Rc| { collect_field_binding_names(fb.clone(), acc) }, @@ -3367,11 +3287,8 @@ pub fn is_match_option_descent( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at(arm_b.clone(), si.clone()), - ) != crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + (expr_var_name_at(arm_b.clone(), si.clone()).as_str() + != param_name.clone().as_str()) } _ => true, } @@ -3394,7 +3311,7 @@ pub fn is_match_option_descent( pub fn collect_descent_vars( body: Rc, - param_name: Rc>, + param_name: String, vars: Rc>, check_child: bool, check_list: bool, @@ -3489,11 +3406,8 @@ pub fn collect_descent_vars( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at(inner.clone(), si.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + (expr_var_name_at(inner.clone(), si.clone()).as_str() + == param_name.clone().as_str()) } _ => false, }; @@ -3512,11 +3426,8 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host( - bname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || set_has(vars.clone(), bname.clone())) + ((bname.clone().as_str() == param_name.clone().as_str()) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3605,10 +3516,7 @@ pub fn collect_descent_vars( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host(sname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + ((sname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3713,8 +3621,8 @@ pub fn collect_descent_vars( pub fn all_self_calls_descend( body: Rc, - func_name: Rc>, - param_name: Rc>, + func_name: String, + param_name: String, check_child: bool, check_list: bool, si: Rc>>, @@ -3723,7 +3631,7 @@ pub fn all_self_calls_descend( body, func_name, param_name, - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), check_child, check_list, si, @@ -3732,8 +3640,8 @@ pub fn all_self_calls_descend( pub fn all_self_calls_descend_inc( body: Rc, - func_name: Rc>, - param_name: Rc>, + func_name: String, + param_name: String, vars: Rc>, check_child: bool, check_list: bool, @@ -3786,11 +3694,8 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host( - bname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || set_has(vars.clone(), bname.clone())) + ((bname.clone().as_str() == param_name.clone().as_str()) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -3844,10 +3749,7 @@ pub fn all_self_calls_descend_inc( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host(sname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + ((sname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -3976,9 +3878,7 @@ pub fn all_self_calls_descend_inc( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_ok = if (crate::v2_std_text::host_string_text_to_rust_host(callee) - == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) - { + let own_ok = if (callee.as_str() == func_name.clone().as_str()) { { let mut __found = false; for arg_node in body.children.clone().iter().cloned() { @@ -4176,7 +4076,7 @@ pub fn unwrap_to_match(mut body: Rc) -> Option> { pub fn matches_on_sub_value_field( body: Rc, - param_name: Rc>, + param_name: String, si: Rc>>, ) -> bool { match unwrap_to_match(body) { @@ -4191,9 +4091,8 @@ pub fn matches_on_sub_value_field( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at(base.clone(), si.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) + (expr_var_name_at(base.clone(), si.clone()).as_str() + == param_name.as_str()) } _ => false, }) @@ -4207,7 +4106,7 @@ pub fn matches_on_sub_value_field( pub fn is_container_child_descent( body: Rc, - func_name: Rc>, + func_name: String, params: Rc>>, si: Rc>>, ) -> bool { @@ -4236,7 +4135,7 @@ pub fn is_container_child_descent( pub fn is_list_shrinkage_descent( body: Rc, - func_name: Rc>, + func_name: String, params: Rc>>, si: Rc>>, ) -> bool { @@ -4264,7 +4163,7 @@ pub fn is_list_shrinkage_descent( pub fn is_arithmetic_descent_expr( expr: Rc, - param_name: Rc>, + param_name: String, si: Rc>>, ) -> bool { match (*expr.expr_data.clone()).clone() { @@ -4275,10 +4174,7 @@ pub fn is_arithmetic_descent_expr( ExprData::ExprVar { binding_kind: _, .. } => { - ((crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( - left.clone(), - si, - )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) + ((expr_var_name_at(left.clone(), si).as_str() == param_name.as_str()) && match (*right.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: n, .. } = value.as_ref() else { @@ -4298,7 +4194,7 @@ pub fn is_arithmetic_descent_expr( pub fn classify_self_call_evidence( arg_expr: Rc, - param_name: Rc>, + param_name: String, descent_vars: Rc>, check_child: bool, check_list: bool, @@ -4333,11 +4229,7 @@ pub fn classify_self_call_evidence( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - vname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) { + if (vname.clone().as_str() == param_name.clone().as_str()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -4402,22 +4294,18 @@ pub fn classify_self_call_evidence( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (crate::v2_std_text::host_string_text_to_rust_host( - bname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - ))) + || (bname.clone().as_str() == param_name.clone().as_str())) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(field) == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) { - DescentEvidence::NonIncreasing - } else { - DescentEvidence::DescentUnknown - } + if (field.as_str() == param_name.clone().as_str()) { + DescentEvidence::NonIncreasing + } else { + DescentEvidence::DescentUnknown + } } } } @@ -4461,8 +4349,8 @@ pub fn classify_self_call_evidence( pub fn try_dimension_for_param( body: Rc, - func_name: Rc>, - param_name: Rc>, + func_name: String, + param_name: String, check_child: bool, check_list: bool, si: Rc>>, @@ -4471,7 +4359,7 @@ pub fn try_dimension_for_param( body, func_name, param_name, - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), check_child, check_list, false, @@ -4481,8 +4369,8 @@ pub fn try_dimension_for_param( pub fn try_branching_dimension_for_param( body: Rc, - func_name: Rc>, - param_name: Rc>, + func_name: String, + param_name: String, check_child: bool, check_list: bool, si: Rc>>, @@ -4491,7 +4379,7 @@ pub fn try_branching_dimension_for_param( body, func_name, param_name, - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), check_child, check_list, true, @@ -4508,8 +4396,8 @@ pub fn merge_optional_evidence( pub fn collect_evidence_incremental( body: Rc, - func_name: Rc>, - param_name: Rc>, + func_name: String, + param_name: String, vars: Rc>, check_child: bool, check_list: bool, @@ -4615,11 +4503,8 @@ pub fn collect_evidence_incremental( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at(inner.clone(), si.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + (expr_var_name_at(inner.clone(), si.clone()).as_str() + == param_name.clone().as_str()) } _ => false, }; @@ -4638,11 +4523,8 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host( - bname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || set_has(vars.clone(), bname.clone())) + ((bname.clone().as_str() == param_name.clone().as_str()) + || set_has(vars.clone(), bname.clone())) } _ => false, }) @@ -4743,10 +4625,7 @@ pub fn collect_evidence_incremental( binding_kind: _, .. } => { let sname = expr_var_name_at(scrut.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host(sname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + ((sname.clone().as_str() == param_name.clone().as_str()) || set_has(vars.clone(), sname.clone())) } _ => false, @@ -4875,9 +4754,7 @@ pub fn collect_evidence_incremental( } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own_evidence = if (crate::v2_std_text::host_string_text_to_rust_host(callee) - == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) - { + let own_evidence = if (callee.as_str() == func_name.clone().as_str()) { { let arg_evidence = body.children.clone().iter().cloned().fold( DescentEvidence::DescentUnknown, @@ -5072,8 +4949,8 @@ pub fn collect_evidence_incremental( pub fn try_type_directed_dimension( body: Rc, - func_name: Rc>, - param_name: Rc>, + func_name: String, + param_name: String, dim: IterationDimension, si: Rc>>, ) -> Option> { @@ -5112,7 +4989,7 @@ pub fn try_type_directed_dimension( } pub fn construct_termination_proof( - func_name: Rc>, + func_name: String, body: Rc, params: Rc>>, parser_always_advancing: Rc>, @@ -5213,7 +5090,7 @@ pub fn construct_termination_proof( self_set.clone(), empty_parser_progress_env(), parser_always_advancing, - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), si.clone(), ); if (((edges.clone().len() as i64) > 0) && { @@ -5262,7 +5139,7 @@ pub fn construct_termination_proof( } pub fn construct_branching_termination_proof( - func_name: Rc>, + func_name: String, body: Rc, params: Rc>>, si: Rc>>, @@ -5387,7 +5264,7 @@ pub fn proof_to_call_pattern(proof: Rc) -> Rc { } pub fn classify_recursion_pattern( - func_name: Rc>, + func_name: String, body: Rc, params: Rc>>, parser_always_advancing: Rc>, @@ -5701,7 +5578,7 @@ pub fn classify_recursion_pattern( pub fn bounded_recursive_cost( target: Rc, per_iter: Rc, - func_name: Rc>, + func_name: String, ) -> Rc { { let p = size_bound_param(target.bound.clone()); @@ -5767,7 +5644,7 @@ pub fn is_unknown_cost(expr: Rc) -> bool { }) } -pub fn extract_unknown_reason(mut expr: Rc) -> Rc> { +pub fn extract_unknown_reason(mut expr: Rc) -> String { loop { match (*expr).clone() { CostExpr::CostUnknown { reason: r, .. } => { @@ -5837,7 +5714,7 @@ pub fn extract_unknown_reason(mut expr: Rc) -> Rc> { } pub fn collect_local_call_edges_in_expr( - caller: Rc>, + caller: String, body: Rc, local_func_set: Rc>, si: Rc>>, @@ -5890,8 +5767,8 @@ pub fn build_call_graph( __result }); let local_func_set = names.iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -5917,11 +5794,7 @@ pub fn build_call_graph( for edge in Rc::new({ let mut __result = Vec::new(); for edge in edges.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(edge.caller.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - edge.callee.clone(), - )) - { + if (edge.caller.clone().as_str() != edge.callee.clone().as_str()) { __result.push(edge); } } @@ -5941,7 +5814,7 @@ pub fn build_call_graph( } } -pub fn scc_label(members: Rc>) -> Rc> { +pub fn scc_label(members: Rc>) -> String { match members.first().cloned() { Some(name) => name.clone(), None => "scc".to_string(), @@ -5950,7 +5823,7 @@ pub fn scc_label(members: Rc>) -> Rc> { pub fn classify_scc_call_progress( arg_expr: Rc, - param_name: Rc>, + param_name: String, descent_vars: Rc>, si: Rc>>, ) -> DescentEvidence { @@ -5974,11 +5847,7 @@ pub fn classify_scc_call_progress( if set_has(descent_vars.clone(), vname.clone()) { DescentEvidence::Strict } else { - if (crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) - { + if (vname.clone().as_str() == param_name.clone().as_str()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -6032,22 +5901,14 @@ pub fn classify_scc_call_progress( } => { let bname = expr_var_name_at(base.clone(), si.clone()); if (set_has(descent_vars.clone(), bname.clone()) - || (crate::v2_std_text::host_string_text_to_rust_host( - bname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - ))) + || (bname.clone().as_str() == param_name.clone().as_str())) { DescentEvidence::Strict } else { { let field = field_access_field_at(arg_expr.clone(), si.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host( - field, - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) { + if (field.as_str() == param_name.clone().as_str()) { DescentEvidence::NonIncreasing } else { DescentEvidence::DescentUnknown @@ -6092,8 +5953,8 @@ pub fn classify_scc_call_progress( pub fn collect_scc_child_edges( body: Rc, - caller: Rc>, - param_name: Rc>, + caller: String, + param_name: String, descent_vars: Rc>, target_set: Rc>, check_child: bool, @@ -6111,10 +5972,7 @@ pub fn collect_scc_child_edges( let callee_params = match v1_rt::map_get(&scc_measure_params, callee.clone()) { Some(p) => p.clone(), - None => { - v1_rt::rc_empty_map::>, Rc>>( - ) - } + None => v1_rt::rc_empty_map::(), }; let progress = body.children.clone().iter().cloned().fold( DescentEvidence::DescentUnknown, @@ -6388,11 +6246,8 @@ pub fn collect_scc_child_edges( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at(inner.clone(), si.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) + (expr_var_name_at(inner.clone(), si.clone()).as_str() + == param_name.clone().as_str()) } _ => false, }; @@ -6411,11 +6266,8 @@ pub fn collect_scc_child_edges( binding_kind: _, .. } => { let bname = expr_var_name_at(base.clone(), si.clone()); - ((crate::v2_std_text::host_string_text_to_rust_host( - bname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || set_has(descent_vars.clone(), bname.clone())) + ((bname.clone().as_str() == param_name.clone().as_str()) + || set_has(descent_vars.clone(), bname.clone())) } _ => false, }) @@ -6650,7 +6502,7 @@ pub fn is_scc_container_child_descent( let descent_vars = collect_descent_vars( entry.body.clone(), pname.clone(), - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), true, true, si.clone(), @@ -6747,11 +6599,11 @@ pub fn collect_scc_proof_edges_for_dim( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best: Rc>, p: Rc| { + let best_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), check_child.clone(), check_list.clone(), si.clone()); +let descent_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), check_child.clone(), check_list.clone(), si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), descent_vars.clone(), scc_name_set.clone(), check_child.clone(), check_list.clone(), measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best, param_map.clone()) }); Rc::new({ let mut __result = Vec::new(); for callee in Rc::new(v1_rt::map_keys(&best_map)).iter().cloned() { __result.push({ @@ -6822,22 +6674,22 @@ pub fn collect_scc_independent_dim_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best_map: Rc>, p: Rc| { + let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), true, false, si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); -let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best_map: Rc>, p: Rc| { +let list_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), false, true, si.clone()); +let list_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), false, true, si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), list_vars.clone(), scc_name_set.clone(), false, true, measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); let all_keys = v1_rt::concat(Rc::new(v1_rt::map_keys(&tree_edge_map)), Rc::new(v1_rt::map_keys(&list_edge_map))); -let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, k: Rc>| v1_rt::rc_map_insert(acc, k.clone(), true)); +let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |acc: Rc>, k: String| v1_rt::rc_map_insert(acc, k.clone(), true)); Rc::new({ let mut __result = Vec::new(); for callee in Rc::new(v1_rt::map_keys(&unique_keys)).iter().cloned() { __result.push({ let tree_ev = match v1_rt::map_get(&tree_edge_map, callee.clone()) { Some(ev) => ev.clone(), @@ -6904,17 +6756,17 @@ pub fn collect_scc_tree_parser_dim_edges( for name in members.clone().iter().cloned() { __result.extend((*match v1_rt::map_get(&func_index, name.clone()) { Some(entry) => { - let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |best_map: Rc>, p: Rc| { + let tree_edge_map = entry.params.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |best_map: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), si.clone()); -let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::>, bool>(), true, false, si.clone()); +let tree_vars = collect_descent_vars(entry.body.clone(), pname.clone(), v1_rt::rc_empty_map::(), true, false, si.clone()); let param_edges = collect_scc_child_edges(entry.body.clone(), name.clone(), pname.clone(), tree_vars.clone(), scc_name_set.clone(), true, false, measure_params.clone(), si.clone()); -let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let param_map = param_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); pick_best_param_edges(best_map, param_map.clone()) }); -let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(pe.caller.clone()) == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { __result.push(pe); } } __result }); -let parser_edge_map = my_parser_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, DescentEvidence>(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); +let my_parser_edges = Rc::new({ let mut __result = Vec::new(); for pe in all_parser_edges.clone().iter().cloned() { if (pe.caller.clone().as_str() == name.clone().as_str()) { __result.push(pe); } } __result }); +let parser_edge_map = my_parser_edges.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |bm: Rc>, pe: Rc| merge_edge_evidence(bm, pe.clone())); let all_keys = v1_rt::concat(Rc::new(v1_rt::map_keys(&tree_edge_map)), Rc::new(v1_rt::map_keys(&parser_edge_map))); -let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::>, bool>(), |acc: Rc>, k: Rc>| v1_rt::rc_map_insert(acc, k.clone(), true)); +let unique_keys = all_keys.clone().iter().cloned().fold(v1_rt::rc_empty_map::(), |acc: Rc>, k: String| v1_rt::rc_map_insert(acc, k.clone(), true)); Rc::new({ let mut __result = Vec::new(); for callee in Rc::new(v1_rt::map_keys(&unique_keys)).iter().cloned() { __result.push({ let tree_ev = match v1_rt::map_get(&tree_edge_map, callee.clone()) { Some(ev) => ev.clone(), @@ -6964,7 +6816,7 @@ let self_all_structural = (self_has_calls.clone() && { let mut __all = true; for _ => false, } { __found = true; break; } } __found }) { __all = false; break; } } __all }); let descending_param = match self_evidence.clone().first().cloned() { - Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: Rc>, rel: Rc| if (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + Some(call_ev) => call_ev.clone().iter().cloned().fold("".to_string(), |found: String, rel: Rc| if (found.clone().as_str() != "".to_string().as_str()) { found.clone() } else { match (*rel.clone()).clone() { @@ -7008,7 +6860,7 @@ Rc::new(vec![Rc::new(ProofEdge { } else { Rc::new(vec![]) }; -let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(m.clone()) != crate::v2_std_text::host_string_text_to_rust_host(name.clone())) { __result.push(m); } } __result }); +let other_members = Rc::new({ let mut __result = Vec::new(); for m in Rc::new(v1_rt::map_keys(&scc_name_set)).iter().cloned() { if (m.clone().as_str() != name.clone().as_str()) { __result.push(m); } } __result }); let cross_edges = Rc::new({ let mut __result = Vec::new(); for callee in other_members.clone().iter().cloned() { __result.extend((*{ let callee_evidence = collect_callee_evidence(entry.body.clone(), callee.clone(), si.clone()); if ((callee_evidence.clone().len() as i64) > 0) { @@ -7038,13 +6890,12 @@ pub fn scc_descending_param( members: Rc>, func_index: Rc>>, si: Rc>>, -) -> Rc> { - members.iter().cloned().fold( - "".to_string(), - |found: Rc>, name: Rc>| { - if (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { +) -> String { + members + .iter() + .cloned() + .fold("".to_string(), |found: String, name: String| { + if (found.clone().as_str() != "".to_string().as_str()) { found.clone() } else { match v1_rt::map_get(&func_index, name.clone()) { @@ -7057,12 +6908,8 @@ pub fn scc_descending_param( match evidence.clone().first().cloned() { Some(call_ev) => call_ev.clone().iter().cloned().fold( "".to_string(), - |p: Rc>, rel: Rc| { - if (crate::v2_std_text::host_string_text_to_rust_host( - p.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { + |p: String, rel: Rc| { + if (p.clone().as_str() != "".to_string().as_str()) { p.clone() } else { match (*rel.clone()).clone() { @@ -7087,8 +6934,7 @@ pub fn scc_descending_param( None => "".to_string(), } } - }, - ) + }) } pub fn construct_scc_termination_proof( @@ -7120,9 +6966,7 @@ pub fn construct_scc_termination_proof( let cx_l2_param = scc_descending_param(members.clone(), func_index.clone(), si.clone()); let cx_l2_proof = Rc::new(TerminationProof { dimensions: Rc::new(vec![Rc::new(RankingDimension::TreeSize { - param: if (crate::v2_std_text::host_string_text_to_rust_host(cx_l2_param.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + param: if (cx_l2_param.clone().as_str() != "".to_string().as_str()) { cx_l2_param.clone() } else { "scc".to_string() @@ -7365,8 +7209,8 @@ pub fn classify_scc_recursion_pattern( ) -> Rc { { let scc_name_set = members.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -7467,46 +7311,78 @@ pub fn build_scc_index( visited: v1_rt::rc_empty_set::(), order: Rc::new(vec![]), }), - |acc: Rc, name: Rc>| { + |acc: Rc, name: String| { dfs_finish_order(name.clone(), adjacency.clone(), acc) }, ); let topo_order = v1_rt::reverse(finish.order.clone()); - let result = topo_order.clone().iter().cloned().fold(Rc::new(SccBuildAcc { - assigned: v1_rt::rc_empty_set::(), - index: v1_rt::rc_empty_map::>, Rc>(), -}), |acc: Rc, name: Rc>| if v1_rt::set_contains(&acc.assigned.clone(), name.clone()) { - acc.clone() - } else { - { - let component = dfs_collect_component(name.clone(), reverse_graph.clone(), Rc::new(SccComponentAcc { - visited: acc.assigned.clone(), - members: Rc::new(vec![]), -})); -let member_set = component.members.clone().iter().cloned().fold(v1_rt::rc_empty_set::<_>(), |inner: _, member: Rc>| v1_rt::rc_set_insert(inner, member.clone())); -let members = Rc::new({ let mut __result = Vec::new(); for member in names.clone().iter().cloned() { if v1_rt::set_contains(&member_set, member.clone()) { __result.push(member); } } __result }); -let next_assigned = component.visited.clone(); -if ((members.clone().len() as i64) > 1) { - { - let info = Rc::new(SccInfo { - members: members.clone(), - member_set: member_set.clone(), - pattern: classify_scc_recursion_pattern(members.clone(), func_index.clone(), si.clone()), -}); -let next_index = members.clone().iter().cloned().fold(acc.index.clone(), |inner: Rc>>, member: Rc>| v1_rt::rc_map_insert(inner, member.clone(), info.clone())); -Rc::new(SccBuildAcc { - assigned: next_assigned.clone(), - index: next_index.clone(), -}) -} + let result = topo_order.clone().iter().cloned().fold( + Rc::new(SccBuildAcc { + assigned: v1_rt::rc_empty_set::(), + index: v1_rt::rc_empty_map::>(), + }), + |acc: Rc, name: String| { + if v1_rt::set_contains(&acc.assigned.clone(), name.clone()) { + acc.clone() } else { - Rc::new(SccBuildAcc { - assigned: next_assigned.clone(), - index: acc.index.clone(), -}) + { + let component = dfs_collect_component( + name.clone(), + reverse_graph.clone(), + Rc::new(SccComponentAcc { + visited: acc.assigned.clone(), + members: Rc::new(vec![]), + }), + ); + let member_set = + component.members.clone().iter().cloned().fold( + v1_rt::rc_empty_set::<_>(), + |inner: _, member: String| { + v1_rt::rc_set_insert(inner, member.clone()) + }, + ); + let members = Rc::new({ + let mut __result = Vec::new(); + for member in names.clone().iter().cloned() { + if v1_rt::set_contains(&member_set, member.clone()) { + __result.push(member); + } + } + __result + }); + let next_assigned = component.visited.clone(); + if ((members.clone().len() as i64) > 1) { + { + let info = Rc::new(SccInfo { + members: members.clone(), + member_set: member_set.clone(), + pattern: classify_scc_recursion_pattern( + members.clone(), + func_index.clone(), + si.clone(), + ), + }); + let next_index = members.clone().iter().cloned().fold( + acc.index.clone(), + |inner: Rc>>, member: String| { + v1_rt::rc_map_insert(inner, member.clone(), info.clone()) + }, + ); + Rc::new(SccBuildAcc { + assigned: next_assigned.clone(), + index: next_index.clone(), + }) + } + } else { + Rc::new(SccBuildAcc { + assigned: next_assigned.clone(), + index: acc.index.clone(), + }) + } + } } -} - }); + }, + ); Rc::new(SccResult { index: result.index.clone(), topo_order: topo_order.clone(), @@ -7542,11 +7418,7 @@ pub fn cost_par(a: Rc, b: Rc) -> Rc { } } -pub fn cost_loop( - binder: Rc>, - iterations: Rc, - body: Rc, -) -> Rc { +pub fn cost_loop(binder: String, iterations: Rc, body: Rc) -> Rc { match (*body.clone()).clone() { CostExpr::CostConst { value: 0, .. } => Rc::new(CostExpr::CostConst { value: 0 }), _ => Rc::new(CostExpr::CostSum { @@ -7567,10 +7439,7 @@ pub fn cost_conditional(condition: Rc, branches: Rc>> } } -pub fn collection_output( - binder: Rc>, - size: Rc, -) -> Rc>> { +pub fn collection_output(binder: String, size: Rc) -> Rc>> { { let result = seed_cost_map( "result".to_string(), @@ -7581,7 +7450,7 @@ pub fn collection_output( } pub fn scalar_output() -> Rc>> { - v1_rt::rc_empty_map::>, Rc>() + v1_rt::rc_empty_map::>() } pub fn method_preserves_collection_size(method_semantics: Option>) -> bool { @@ -7646,7 +7515,7 @@ pub fn receiver_size_var( } } -pub fn size_binder_name(size: Rc) -> Rc> { +pub fn size_binder_name(size: Rc) -> String { match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => v1_rt::concat("_".to_string(), c.clone()), SizeExpr::SizeVar { name: n, .. } => n.clone(), @@ -7662,11 +7531,7 @@ pub fn resolve_lambda_arg( let f_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_arg_nodes.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - si.clone(), - a.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host("f".to_string())) - { + if (authored_name_at(si.clone(), a.clone()).as_str() == "f".to_string().as_str()) { __result.push(a); } } @@ -7737,7 +7602,7 @@ pub fn resolve_callback_cost( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }), table: recv_r.table.clone(), @@ -7751,7 +7616,7 @@ pub fn cost_of_method_by_shape( recv_r: Rc, mc_args: Rc>>, size: Rc, - binder: Rc>, + binder: String, func_index: Rc>>, scc_index: Rc>>, parser_always_advancing: Rc>, @@ -7816,7 +7681,7 @@ pub fn cost_of_method_by_shape( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: recv_r.table.clone(), @@ -7865,7 +7730,7 @@ pub fn cost_of_method_by_shape( ), ) } else { - v1_rt::rc_empty_map::>, Rc>() + v1_rt::rc_empty_map::>() }; Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { @@ -7887,7 +7752,7 @@ pub fn cost_of_method_by_shape( recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), table: recv_r.table.clone(), @@ -7897,15 +7762,15 @@ pub fn cost_of_method_by_shape( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ComplexityViolation { - pub func_name: Rc>, - pub reason: Rc>, + pub func_name: String, + pub reason: String, pub span: Rc, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StructuralBoundResult { - pub func_name: Rc>, - pub param: Rc>, + pub func_name: String, + pub param: String, pub recurrence_bound: Rc, pub stack_bound: Rc, pub span: Rc, @@ -7920,7 +7785,7 @@ pub struct ComplexityReport { pub fn empty_complexity_report() -> Rc { Rc::new(ComplexityReport { - function_classes: v1_rt::rc_empty_map::>, Rc>>(), + function_classes: v1_rt::rc_empty_map::(), violations: Rc::new(vec![]), structural_bounds: Rc::new(vec![]), }) @@ -8043,15 +7908,13 @@ pub fn simplify_cost(expr: Rc) -> Rc { }) } -pub fn format_size(size: Rc) -> Rc> { +pub fn format_size(size: Rc) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { v1_rt::concat(v1_rt::concat("|".to_string(), c.clone()), "|".to_string()) } SizeExpr::SizeVar { name: n, .. } => n.clone(), - SizeExpr::SizeConst { value: v, .. } => { - crate::v2_std_text::host_string_text_from_rust_host((v.clone()).to_string()) - } + SizeExpr::SizeConst { value: v, .. } => (v.clone()).to_string(), SizeExpr::SizeAdd { left: l, right: r, .. } => v1_rt::concat( @@ -8196,7 +8059,7 @@ pub fn normalize_asymptotic(expr: Rc) -> Rc { }) } -pub fn format_cost_class(expr: Rc) -> Rc> { +pub fn format_cost_class(expr: Rc) -> String { match (*expr).clone() { CostExpr::CostConst { value: _, .. } => "O(1)".to_string(), CostExpr::CostExtern { name: n, .. } => v1_rt::concat( @@ -8265,7 +8128,7 @@ pub fn format_cost_class(expr: Rc) -> Rc> { } } -pub fn format_cost_inner(expr: Rc) -> Rc> { +pub fn format_cost_inner(expr: Rc) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*expr).clone() { CostExpr::CostConst { value: _, .. } => "1".to_string(), CostExpr::CostSum { @@ -8325,7 +8188,7 @@ pub fn format_cost_inner(expr: Rc) -> Rc> { }) } -pub fn parenthesize_additive_cost(expr: Rc) -> Rc> { +pub fn parenthesize_additive_cost(expr: Rc) -> String { match (*expr.clone()).clone() { CostExpr::CostAdd { .. } => v1_rt::concat( v1_rt::concat("(".to_string(), format_cost_inner(expr.clone())), @@ -8335,7 +8198,7 @@ pub fn parenthesize_additive_cost(expr: Rc) -> Rc> { } } -pub fn short_var_name(index: i64) -> Rc> { +pub fn short_var_name(index: i64) -> String { if (index.clone() == 0) { "n".to_string() } else { @@ -8368,9 +8231,7 @@ pub fn short_var_name(index: i64) -> Rc> { } else { v1_rt::concat( "x".to_string(), - crate::v2_std_text::host_string_text_from_rust_host( - (index.clone()).to_string(), - ), + (index.clone()).to_string(), ) } } @@ -8387,7 +8248,7 @@ pub fn short_var_name(index: i64) -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Legend { pub substitution: Rc>, - pub suffix: Rc>, + pub suffix: String, } pub fn build_legend(size_names: Rc>) -> Rc { @@ -8395,7 +8256,7 @@ pub fn build_legend(size_names: Rc>) -> Rc { let unique = deduplicate(size_names); if ((unique.clone().len() as i64) == 0) { Rc::new(Legend { - substitution: v1_rt::rc_empty_map::>, Rc>>(), + substitution: v1_rt::rc_empty_map::(), suffix: "".to_string(), }) } else { @@ -8403,15 +8264,14 @@ pub fn build_legend(size_names: Rc>) -> Rc { match unique.clone().first().cloned() { Some(name) => Rc::new(Legend { substitution: v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), name.clone(), "n".to_string(), ), suffix: "".to_string(), }), None => Rc::new(Legend { - substitution: v1_rt::rc_empty_map::>, Rc>>( - ), + substitution: v1_rt::rc_empty_map::(), suffix: "".to_string(), }), } @@ -8419,13 +8279,10 @@ pub fn build_legend(size_names: Rc>) -> Rc { { let indexed = unique.clone().iter().cloned().fold( Rc::new(Legend { - substitution: v1_rt::rc_empty_map::< - Rc>, - Rc>, - >(), + substitution: v1_rt::rc_empty_map::(), suffix: "".to_string(), }), - |acc: Rc, name: Rc>| { + |acc: Rc, name: String| { let idx = (Rc::new(v1_rt::map_keys(&acc.substitution.clone())).len() as i64); let short = short_var_name(idx.clone()); @@ -8435,11 +8292,8 @@ pub fn build_legend(size_names: Rc>) -> Rc { name.clone(), short.clone(), ), - suffix: if (crate::v2_std_text::host_string_text_to_rust_host( - acc.suffix.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { + suffix: if (acc.suffix.clone().as_str() == "".to_string().as_str()) + { v1_rt::concat( v1_rt::concat( v1_rt::concat(" where ".to_string(), short.clone()), @@ -8547,7 +8401,7 @@ pub fn substitute_cost(expr: Rc, legend: Rc>) }) } -pub fn classify_complexity(expr: Rc) -> Rc> { +pub fn classify_complexity(expr: Rc) -> String { { let normalized = normalize_asymptotic(simplify_cost(expr)); let size_names = collect_size_vars(normalized.clone()); @@ -8560,18 +8414,14 @@ pub fn classify_complexity(expr: Rc) -> Rc> { pub fn collect_size_vars_from_size(size: Rc) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || match (*size).clone() { SizeExpr::SizeLen { collection: c, .. } => { - if (crate::v2_std_text::host_string_text_to_rust_host(c.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("__expr".to_string())) - { + if (c.clone().as_str() == "__expr".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![c.clone()]) } } SizeExpr::SizeVar { name: n, .. } => { - if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("__k".to_string())) - { + if (n.clone().as_str() == "__k".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![n.clone()]) @@ -8625,10 +8475,10 @@ pub fn deduplicate(items: Rc>) -> Rc> { { let result = items.iter().cloned().fold( Rc::new(DeduplicateAcc { - seen: v1_rt::rc_empty_map::>, bool>(), + seen: v1_rt::rc_empty_map::(), out: Rc::new(vec![]), }), - |acc: Rc, item: Rc>| match v1_rt::map_get( + |acc: Rc, item: String| match v1_rt::map_get( &acc.seen.clone(), item.clone(), ) { @@ -8645,7 +8495,7 @@ pub fn deduplicate(items: Rc>) -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FuncEntry { - pub name: Rc>, + pub name: String, pub body: Rc, pub params: Rc>>, pub span: Rc, @@ -8691,7 +8541,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: table, @@ -8700,7 +8550,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: table, @@ -8709,7 +8559,7 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: table, @@ -8751,7 +8601,7 @@ pub fn cost_of_expr( rr.summary.clone().span.clone(), ), ), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: rr.table.clone(), @@ -8773,36 +8623,49 @@ pub fn cost_of_expr( summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: table, }), }; - let args_result = texpr.children.clone().iter().cloned().fold(Rc::new(SummaryResult { - summary: Rc::new(ComplexitySummary { - work: Rc::new(CostExpr::CostConst { - value: 0, -}), - span: Rc::new(CostExpr::CostConst { - value: 0, -}), - output_size: v1_rt::rc_empty_map::>, Rc>(), - certainty: Certainty::Proven, -}), - table: callee_result.table.clone(), -}), |acc: Rc, a: Rc| { - let ar = cost_of_expr(arg_value(a.clone()), func_index.clone(), scc_index.clone(), acc.table.clone(), parser_always_advancing.clone(), recursion_ctx.clone(), si.clone()); -Rc::new(SummaryResult { - summary: Rc::new(ComplexitySummary { - work: cost_seq(acc.summary.clone().work.clone(), ar.summary.clone().work.clone()), - span: cost_seq(acc.summary.clone().span.clone(), ar.summary.clone().span.clone()), - output_size: v1_rt::rc_empty_map::>, Rc>(), - certainty: Certainty::Proven, -}), - table: ar.table.clone(), -}) -}); + let args_result = texpr.children.clone().iter().cloned().fold( + Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: Rc::new(CostExpr::CostConst { value: 0 }), + span: Rc::new(CostExpr::CostConst { value: 0 }), + output_size: v1_rt::rc_empty_map::>(), + certainty: Certainty::Proven, + }), + table: callee_result.table.clone(), + }), + |acc: Rc, a: Rc| { + let ar = cost_of_expr( + arg_value(a.clone()), + func_index.clone(), + scc_index.clone(), + acc.table.clone(), + parser_always_advancing.clone(), + recursion_ctx.clone(), + si.clone(), + ); + Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: cost_seq( + acc.summary.clone().work.clone(), + ar.summary.clone().work.clone(), + ), + span: cost_seq( + acc.summary.clone().span.clone(), + ar.summary.clone().span.clone(), + ), + output_size: v1_rt::rc_empty_map::>(), + certainty: Certainty::Proven, + }), + table: ar.table.clone(), + }) + }, + ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq( @@ -8870,10 +8733,7 @@ Rc::new(SummaryResult { recv_r.summary.clone().span.clone(), Rc::new(CostExpr::CostConst { value: 1 }), ), - output_size: v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + output_size: v1_rt::rc_empty_map::>(), certainty: recv_r.summary.clone().certainty.clone(), }), table: recv_r.table.clone(), @@ -8891,10 +8751,7 @@ Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: recv_r.table.clone(), @@ -8919,10 +8776,7 @@ Rc::new(SummaryResult { acc.summary.clone().span.clone(), ar.summary.clone().span.clone(), ), - output_size: v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: ar.table.clone(), @@ -8945,8 +8799,7 @@ Rc::new(SummaryResult { args_result.summary.clone().span.clone(), ), ), - output_size: v1_rt::rc_empty_map::>, Rc>( - ), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: args_result.table.clone(), @@ -8966,56 +8819,52 @@ Rc::new(SummaryResult { recursion_ctx.clone(), si.clone(), ); - let arms_accum = - arm_nodes.iter().cloned().fold( + let arms_accum = arm_nodes.iter().cloned().fold( + Rc::new(MatchCostAccum { + result: Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: Rc::new(CostExpr::CostConst { value: 0 }), + span: Rc::new(CostExpr::CostConst { value: 0 }), + output_size: v1_rt::rc_empty_map::>(), + certainty: Certainty::Proven, + }), + table: s_r.table.clone(), + }), + branch_costs: Rc::new(vec![]), + }), + |acc: Rc, arm_node: Rc| { + let ar = cost_of_expr( + arm_body(arm_node.clone()), + func_index.clone(), + scc_index.clone(), + acc.result.clone().table.clone(), + parser_always_advancing.clone(), + recursion_ctx.clone(), + si.clone(), + ); Rc::new(MatchCostAccum { result: Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { - work: Rc::new(CostExpr::CostConst { value: 0 }), - span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), - certainty: Certainty::Proven, + work: cost_par( + acc.result.clone().summary.clone().work.clone(), + ar.summary.clone().work.clone(), + ), + span: cost_par( + acc.result.clone().summary.clone().span.clone(), + ar.summary.clone().span.clone(), + ), + output_size: ar.summary.clone().output_size.clone(), + certainty: ar.summary.clone().certainty.clone(), }), - table: s_r.table.clone(), + table: ar.table.clone(), }), - branch_costs: Rc::new(vec![]), - }), - |acc: Rc, arm_node: Rc| { - let ar = cost_of_expr( - arm_body(arm_node.clone()), - func_index.clone(), - scc_index.clone(), - acc.result.clone().table.clone(), - parser_always_advancing.clone(), - recursion_ctx.clone(), - si.clone(), - ); - Rc::new(MatchCostAccum { - result: Rc::new(SummaryResult { - summary: Rc::new(ComplexitySummary { - work: cost_par( - acc.result.clone().summary.clone().work.clone(), - ar.summary.clone().work.clone(), - ), - span: cost_par( - acc.result.clone().summary.clone().span.clone(), - ar.summary.clone().span.clone(), - ), - output_size: ar.summary.clone().output_size.clone(), - certainty: ar.summary.clone().certainty.clone(), - }), - table: ar.table.clone(), - }), - branch_costs: v1_rt::concat( - acc.branch_costs.clone(), - Rc::new(vec![ar.summary.clone().work.clone()]), - ), - }) - }, - ); + branch_costs: v1_rt::concat( + acc.branch_costs.clone(), + Rc::new(vec![ar.summary.clone().work.clone()]), + ), + }) + }, + ); Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_conditional( @@ -9079,7 +8928,7 @@ Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: t_r.table.clone(), @@ -9153,7 +9002,7 @@ Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: table, @@ -9213,7 +9062,7 @@ Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: cost_seq(c_r.summary.clone().work.clone(), loop_work.clone()), span: cost_seq(c_r.summary.clone().span.clone(), loop_work.clone()), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: bd_r.summary.clone().certainty.clone(), }), table: bd_r.table.clone(), @@ -9224,7 +9073,7 @@ Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: table, @@ -9261,7 +9110,7 @@ Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 1 }), span: Rc::new(CostExpr::CostConst { value: 1 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Proven, }), table: table, @@ -9315,7 +9164,7 @@ pub fn estimate_expr_size(texpr: Rc, budget: i64) -> i64 { } pub fn get_or_compute_summary( - func_name: Rc>, + func_name: String, func_index: Rc>>, scc_index: Rc>>, table: Rc, @@ -9338,7 +9187,7 @@ pub fn get_or_compute_summary( let zero_placeholder = Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }); let table_prepped = if is_recursive { @@ -9426,7 +9275,7 @@ pub fn get_or_compute_summary( func_name.clone(), ), }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }); Rc::new(SummaryResult { @@ -9443,7 +9292,7 @@ pub fn get_or_compute_summary( span: Rc::new(CostExpr::CostExtern { name: func_name.clone(), }), - output_size: v1_rt::rc_empty_map::>, Rc>(), + output_size: v1_rt::rc_empty_map::>(), certainty: Certainty::Conservative, }); Rc::new(SummaryResult { @@ -9503,32 +9352,24 @@ pub fn collect_call_evidence( pub fn collect_self_call_evidence( body: Rc, - fn_name: Rc>, + fn_name: String, si: Rc>>, ) -> Rc>>>> { collect_call_evidence( body, - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, bool>(), - fn_name, - true, - ), + v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), fn_name, true), si, ) } pub fn collect_callee_evidence( body: Rc, - callee_name: Rc>, + callee_name: String, si: Rc>>, ) -> Rc>>>> { collect_call_evidence( body, - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, bool>(), - callee_name, - true, - ), + v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), callee_name, true), si, ) } @@ -9625,7 +9466,7 @@ pub fn extract_shrink_factor( pub fn max_path_descending( body: Rc, - fn_name: Rc>, + fn_name: String, param_index: i64, si: Rc>>, ) -> i64 { @@ -9636,9 +9477,7 @@ pub fn max_path_descending( .. } => { let callee = expr_call_func_at(body.clone(), si.clone()); - let own = if (crate::v2_std_text::host_string_text_to_rust_host(callee) - == crate::v2_std_text::host_string_text_to_rust_host(fn_name.clone())) - { + let own = if (callee.as_str() == fn_name.clone().as_str()) { match de.clone() { Some(evidence) => { match evidence.clone().get(param_index.clone() as usize).cloned() { @@ -9747,7 +9586,7 @@ pub fn distinct_descended_fields( ) -> i64 { { let field_set = all_calls.iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, call_evidence: Rc>>| { match call_evidence .clone() @@ -9892,7 +9731,7 @@ pub fn build_complexity_report( { let si = source_indices; let func_index = func_entries.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, entry: Rc| { v1_rt::rc_map_insert(acc, entry.name.clone(), entry.clone()) }, @@ -9945,21 +9784,21 @@ pub fn build_complexity_report( scc_result.call_graph.clone(), ); let fan_in = func_entries.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, i64>(), + v1_rt::rc_empty_map::(), |acc: Rc>, entry: Rc| { let callees = match v1_rt::map_get(&call_forward, entry.name.clone()) { Some(cs) => cs.clone(), None => Rc::new(vec![]), }; let unique_set = callees.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |s: Rc>, c: Rc>| { + v1_rt::rc_empty_map::(), + |s: Rc>, c: String| { v1_rt::rc_map_insert(s, c.clone(), true) }, ); Rc::new(v1_rt::map_keys(&unique_set)).iter().cloned().fold( acc, - |inner: Rc>, callee: Rc>| { + |inner: Rc>, callee: String| { let current = match v1_rt::map_get(&inner, callee.clone()) { Some(v) => v.clone(), None => 0, @@ -9972,12 +9811,12 @@ pub fn build_complexity_report( let result = scc_result.processing_order.clone().iter().cloned().fold( Rc::new(TopoBuildAcc { table: empty_intern_table(), - classes: v1_rt::rc_empty_map::>, Rc>>(), + classes: v1_rt::rc_empty_map::(), violations: Rc::new(vec![]), fan_in: fan_in, - processed: v1_rt::rc_empty_map::>, bool>(), + processed: v1_rt::rc_empty_map::(), }), - |acc: Rc, func_name: Rc>| match v1_rt::map_get( + |acc: Rc, func_name: String| match v1_rt::map_get( &func_index, func_name.clone(), ) { @@ -10016,15 +9855,15 @@ pub fn build_complexity_report( None => Rc::new(vec![]), }; let unique_set = callees.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |s: Rc>, c: Rc>| { + v1_rt::rc_empty_map::(), + |s: Rc>, c: String| { v1_rt::rc_map_insert(s, c.clone(), true) }, ); let unique_callees = Rc::new(v1_rt::map_keys(&unique_set)); let new_fan_in = unique_callees.clone().iter().cloned().fold( acc.fan_in.clone(), - |fi: Rc>, callee: Rc>| { + |fi: Rc>, callee: String| { let current = match v1_rt::map_get(&fi, callee.clone()) { Some(v) => v.clone(), None => 0, @@ -10034,7 +9873,7 @@ pub fn build_complexity_report( ); let evicted_table = unique_callees.clone().iter().cloned().fold( sr.table.clone(), - |t: Rc, callee: Rc>| { + |t: Rc, callee: String| { let remaining = match v1_rt::map_get(&new_fan_in, callee.clone()) { Some(v) => v.clone(), None => 0, @@ -10076,6 +9915,3 @@ pub fn build_complexity_report( }) } } - -pub struct Proven; -pub struct Conservative; diff --git a/src/v1/stage0/src/v1_compiler_effect_derivation.rs b/src/v1/stage0/src/v1_compiler_effect_derivation.rs index f16d2ef4b17..3c53f8f8d38 100644 --- a/src/v1/stage0/src/v1_compiler_effect_derivation.rs +++ b/src/v1/stage0/src/v1_compiler_effect_derivation.rs @@ -34,7 +34,7 @@ use std::collections::HashMap; use std::rc::Rc; pub fn re_export_derive_op_effect( - operation_name: Rc>, + operation_name: String, method: HttpMethod, path: Rc, ) -> Rc { @@ -49,7 +49,7 @@ pub fn re_export_check_modifier( check_modifier_vs_derivation(op, declared_idempotent, declared_readonly) } -pub fn re_export_parse_path_template(raw: Rc>) -> Rc { +pub fn re_export_parse_path_template(raw: String) -> Rc { parse_path_template(raw) } diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index a698fa9d958..9471d8bd69f 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -159,7 +159,7 @@ pub enum BackendCapability { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct BackendInfo { - pub target_name: Rc>, + pub target_name: String, pub capabilities: Rc>, } @@ -192,11 +192,7 @@ pub fn derive_module_imports( ImportTrigger::TypeUsageTrigger { type_name: t, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - n.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - t.clone(), - )) { + if (n.clone().as_str() == t.clone().as_str()) { __found = true; break; } @@ -208,11 +204,7 @@ pub fn derive_module_imports( ImportTrigger::ContainerUsageTrigger { container: c, .. } => { let mut __found = false; for n in type_names.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - n.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - c.clone(), - )) { + if (n.clone().as_str() == c.clone().as_str()) { __found = true; break; } @@ -236,9 +228,7 @@ pub fn derive_module_imports( .iter() .cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(path.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (path.clone().as_str() != "".to_string().as_str()) { __result.push(path); } } @@ -291,15 +281,15 @@ pub fn collect_type_names_from_node( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct InterpPart { - pub format_segment: Rc>, - pub arg_expr: Rc>, + pub format_segment: String, + pub arg_expr: String, } pub fn emit_simple_expr( expr: Rc, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => emit_literal(v.clone(), target.clone()), @@ -453,7 +443,7 @@ pub fn emit_simple_string_interp( parts: Rc>>, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); let interp = spec.string_interp.clone(); @@ -522,9 +512,7 @@ pub fn emit_simple_string_interp( .iter() .cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(a.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (a.clone().as_str() != "".to_string().as_str()) { __result.push(a); } } @@ -582,20 +570,19 @@ pub fn empty_emit_scope() -> Rc { bindings: v1_rt::rc_empty_map::>(), recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( - ), - source_indices: v1_rt::rc_empty_map::>, Rc>(), + inductive_fields: v1_rt::rc_empty_map::>>>(), + source_indices: v1_rt::rc_empty_map::>(), intern_table: empty_intern_table(), }), func_env: Rc::new(ResolvedFuncEnv { - signatures: v1_rt::rc_empty_map::>, Rc>(), + signatures: v1_rt::rc_empty_map::>(), }), - locals: v1_rt::rc_empty_map::>, Rc>(), - match_bound_names: v1_rt::rc_empty_map::>, bool>(), + locals: v1_rt::rc_empty_map::>(), + match_bound_names: v1_rt::rc_empty_map::(), module_name: "".to_string(), - service_registry: v1_rt::rc_empty_map::>, Rc>>>(), - item_registry: v1_rt::rc_empty_map::>, Rc>(), - lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>(), + service_registry: v1_rt::rc_empty_map::>>>(), + item_registry: v1_rt::rc_empty_map::>(), + lambda_param_provenance: v1_rt::rc_empty_map::>(), }) } @@ -603,15 +590,15 @@ pub fn module_emit_scope(typed_module: Rc) -> Rc { Rc::new(InferScope { type_env: typed_module.type_env.clone(), func_env: typed_module.func_env.clone(), - locals: v1_rt::rc_empty_map::>, Rc>(), - match_bound_names: v1_rt::rc_empty_map::>, bool>(), + locals: v1_rt::rc_empty_map::>(), + match_bound_names: v1_rt::rc_empty_map::(), module_name: authored_name_at( typed_module.type_env.clone().source_indices.clone(), typed_module.module.clone(), ), - service_registry: v1_rt::rc_empty_map::>, Rc>>>(), + service_registry: v1_rt::rc_empty_map::>>>(), item_registry: typed_module.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>(), + lambda_param_provenance: v1_rt::rc_empty_map::>(), }) } @@ -643,21 +630,21 @@ pub fn scope_after_expr(texpr: Rc, scope: Rc) -> Rc>>, - name: Rc>, + name: String, ) -> Option> { v1_rt::map_get(®istry, name) } pub fn lookup_func_sig_in_scope( scope: Rc, - name: Rc>, + name: String, ) -> Option> { v1_rt::map_get(&scope.func_env.clone().signatures.clone(), name) } pub fn typed_named_arg_matches( arg: Rc, - name: Rc>, + name: String, source_indices: Rc>>, ) -> bool { { @@ -665,15 +652,14 @@ pub fn typed_named_arg_matches( if (n.clone() == None) { false } else { - (crate::v2_std_text::host_string_text_to_rust_host(n.clone().unwrap()) - == crate::v2_std_text::host_string_text_to_rust_host(name)) + (n.clone().unwrap().as_str() == name.as_str()) } } } pub fn order_typed_call_args( args: Rc>>, - func: Rc>, + func: String, scope: Rc, ) -> Rc>> { { @@ -695,7 +681,7 @@ pub fn order_typed_call_args( None => args.clone(), Some(sig) => { let arg_map = args.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, arg: Rc| { let n = arg_name_at( arg.clone(), @@ -709,7 +695,7 @@ pub fn order_typed_call_args( }, ); let param_name_set = sig.params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, param: Rc| { v1_rt::rc_map_insert( acc, @@ -826,7 +812,7 @@ pub fn has_nested_records_node( pub fn emit_data_value_json( value: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*value.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { @@ -838,9 +824,7 @@ pub fn emit_data_value_json( v1_rt::concat("\"".to_string(), escape_json_string(s.clone())), "\"".to_string(), ), - LiteralValue::LitInt { value: i, .. } => { - crate::v2_std_text::host_string_text_from_rust_host((i.clone()).to_string()) - } + LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { if b.clone() { @@ -913,7 +897,7 @@ pub fn emit_data_value_json( }) } -pub fn to_camel(name: Rc>) -> Rc> { +pub fn to_camel(name: String) -> String { { let parts = Rc::new( name.clone() @@ -974,7 +958,7 @@ pub fn to_camel(name: Rc>) -> Rc> { } } -pub fn apply_naming_case(name: Rc>, case_style: NamingCase) -> Rc> { +pub fn apply_naming_case(name: String, case_style: NamingCase) -> String { match case_style { NamingCase::PascalCase => { let parts = Rc::new( @@ -997,10 +981,7 @@ pub fn apply_naming_case(name: Rc>, case_style: NamingCase) -> R } } -pub fn test_file_path( - module_name: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn test_file_path(module_name: String, target: RenderTarget) -> String { { let conventions = test_conventions_for_target(target.clone()); let file_dir = match conventions.file_dir.clone() { @@ -1025,7 +1006,7 @@ pub fn test_file_path( } } -pub fn reserved_prefix(target: RenderTarget) -> Rc> { +pub fn reserved_prefix(target: RenderTarget) -> String { match (*language_spec(target) .reserved_words .clone() @@ -1038,7 +1019,7 @@ pub fn reserved_prefix(target: RenderTarget) -> Rc> { } } -pub fn reserved_suffix(target: RenderTarget) -> Rc> { +pub fn reserved_suffix(target: RenderTarget) -> String { match (*language_spec(target) .reserved_words .clone() @@ -1051,7 +1032,7 @@ pub fn reserved_suffix(target: RenderTarget) -> Rc> { } } -pub fn escape_rust_interp_text(s: Rc>) -> Rc> { +pub fn escape_rust_interp_text(s: String) -> String { { let escaped = Rc::new( escape_string_literal_body(s) @@ -1070,7 +1051,7 @@ pub fn escape_rust_interp_text(s: Rc>) -> Rc> { } } -pub fn escape_go_interp_text(s: Rc>) -> Rc> { +pub fn escape_go_interp_text(s: String) -> String { Rc::new( escape_string_literal_body(s) .split(&"%".to_string()) @@ -1080,7 +1061,7 @@ pub fn escape_go_interp_text(s: Rc>) -> Rc> { .join(&"%%".to_string()) } -pub fn escape_python_interp_text(s: Rc>) -> Rc> { +pub fn escape_python_interp_text(s: String) -> String { { let escaped = Rc::new( escape_string_literal_body(s) @@ -1099,27 +1080,21 @@ pub fn escape_python_interp_text(s: Rc>) -> Rc> } } -pub fn apply_escape_pairs( - s: Rc>, - pairs: Rc>>, -) -> Rc> { - pairs.iter().cloned().fold( - s.clone(), - |acc: Rc>, pair: Rc| { +pub fn apply_escape_pairs(s: String, pairs: Rc>>) -> String { + pairs + .iter() + .cloned() + .fold(s.clone(), |acc: String, pair: Rc| { Rc::new( acc.split(&pair.from.clone()) .map(|s| s.to_string()) .collect::>(), ) .join(&pair.to.clone()) - }, - ) + }) } -pub fn emit_string_literal( - s: Rc>, - suffix: Rc>, -) -> Rc> { +pub fn emit_string_literal(s: String, suffix: String) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat("\"".to_string(), escape_string_literal_body(s)), @@ -1136,15 +1111,13 @@ pub fn is_null_coalesce(op: BinOp) -> bool { } } -pub fn rust_literal_for_pattern(value: Rc) -> Rc> { +pub fn rust_literal_for_pattern(value: Rc) -> String { match (*value).clone() { LiteralValue::LitStr { value: s, .. } => emit_string_literal(s.clone(), "".to_string()), LiteralValue::LitSymbol { value: s, .. } => { emit_string_literal(s.clone(), ".to_string()".to_string()) } - LiteralValue::LitInt { value: i, .. } => { - crate::v2_std_text::host_string_text_from_rust_host((i.clone()).to_string()) - } + LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { if b.clone() { @@ -1157,11 +1130,11 @@ pub fn rust_literal_for_pattern(value: Rc) -> Rc> } } -pub fn emit_keyword(key: Rc>, target: RenderTarget) -> Rc> { +pub fn emit_keyword(key: String, target: RenderTarget) -> String { target_keyword(target, key) } -pub fn emit_literal(value: Rc, target: RenderTarget) -> Rc> { +pub fn emit_literal(value: Rc, target: RenderTarget) -> String { match (*value).clone() { LiteralValue::LitStr { value: s, .. } => { let suffix = match literal_suffix(target.clone(), "String".to_string()) { @@ -1173,9 +1146,7 @@ pub fn emit_literal(value: Rc, target: RenderTarget) -> Rc { - crate::v2_std_text::host_string_text_from_rust_host((i.clone()).to_string()) - } + LiteralValue::LitInt { value: i, .. } => (i.clone()).to_string(), LiteralValue::LitFloat { value: f, .. } => f.clone(), LiteralValue::LitBool { value: b, .. } => { if b.clone() { @@ -1205,7 +1176,7 @@ pub fn emit_bin_op_symbol( op: BinOp, target: RenderTarget, algebra_field: Option, -) -> Rc> { +) -> String { match binop_symbol(target.clone(), op, algebra_field) { Some(sym) => sym.clone(), None => emit_error_expr( @@ -1215,14 +1186,8 @@ pub fn emit_bin_op_symbol( } } -pub fn emit_container( - kind: Rc>, - inner: Rc>, - target: RenderTarget, -) -> Rc> { - if (crate::v2_std_text::host_string_text_to_rust_host(kind.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("optional".to_string())) - { +pub fn emit_container(kind: String, inner: String, target: RenderTarget) -> String { + if (kind.clone().as_str() == "optional".to_string().as_str()) { apply_type_template1(target_optional_template(target.clone()), inner) } else { match coerce_container_template(target.clone(), kind.clone()) { @@ -1241,11 +1206,7 @@ pub fn emit_container( } } -pub fn emit_map_type( - key_type: Rc>, - val_type: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn emit_map_type(key_type: String, val_type: String, target: RenderTarget) -> String { match coerce_container_template(target, "map".to_string()) { Some(template) => apply_type_template2(template.clone(), key_type, val_type), None => v1_rt::concat( @@ -1265,7 +1226,7 @@ pub fn emit_node_type( n: Rc, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { render_node_type(n, target, v1_rt::rc_empty_set::(), source_indices) } @@ -1309,7 +1270,7 @@ pub fn render_named_type_base( n: Rc, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { { let tn = authored_name_at(source_indices.clone(), n.clone()); let base = coerce_primitive_type(target.clone(), tn); @@ -1353,7 +1314,7 @@ pub fn render_node_type( target: RenderTarget, shared_types: Rc>, source_indices: Rc>>, -) -> Rc> { +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tn = authored_name_at(source_indices.clone(), n.clone()); let n_is_error = if (n.inferred.clone() != None) { @@ -1372,12 +1333,8 @@ pub fn render_node_type( { let is_named_type_var = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::TypeVariable { id: var_id, .. }) => { - ((crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - && (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - var_id.clone(), - ))) + ((tn.clone().as_str() != "".to_string().as_str()) + && (tn.clone().as_str() == var_id.clone().as_str())) } _ => false, }; @@ -1431,9 +1388,7 @@ pub fn render_node_type( ret_str.clone(), ), None => { - if (crate::v2_std_text::host_string_text_to_rust_host(ret_str.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (ret_str.clone().as_str() == "".to_string().as_str()) { { let void_template = v1_rt::replace( repr.template.clone(), @@ -1575,12 +1530,8 @@ pub fn render_node_type( }; if has_template { { - let base = if (crate::v2_std_text::host_string_text_to_rust_host( - snake.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "map".to_string(), - )) { + let base = if (snake.clone().as_str() == "map".to_string().as_str()) + { emit_map_type("_".to_string(), "_".to_string(), target.clone()) } else { emit_container(snake.clone(), "_".to_string(), target.clone()) @@ -1625,8 +1576,7 @@ pub fn render_node_type( if ((n.children.clone().len() as i64) == 0) { { let bare_is_map = (is_container_type(tn.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(to_snake(tn.clone())) - == crate::v2_std_text::host_string_text_to_rust_host("map".to_string()))); + && (to_snake(tn.clone()).as_str() == "map".to_string().as_str())); let bare_is_collection = (is_declared_container_alias_spelling(tn.clone()) && !bare_is_map.clone()); let has_container_template = match container_template_algebra(to_snake(tn.clone())) @@ -1682,11 +1632,7 @@ pub fn render_node_type( ) } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - tuple_type_name(), - )) - { + if (tn.clone().as_str() == tuple_type_name().as_str()) { render_tuple_parts(Rc::new(vec![]), target.clone()) } else { coerce_primitive_type(target.clone(), tn.clone()) @@ -1780,9 +1726,7 @@ pub fn render_node_type( } __result }); - if (crate::v2_std_text::host_string_text_to_rust_host(tn.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(tuple_type_name())) - { + if (tn.clone().as_str() == tuple_type_name().as_str()) { { let multi_tuple_str = render_tuple_parts(child_strs.clone(), target.clone()); return multi_tuple_str; @@ -1806,7 +1750,7 @@ pub fn render_node_type( }) } -pub fn render_tuple_parts(parts: Rc>, target: RenderTarget) -> Rc> { +pub fn render_tuple_parts(parts: Rc>, target: RenderTarget) -> String { { let spec = language_spec(target); let ts = spec.tuple_syntax.clone(); @@ -2100,27 +2044,16 @@ pub fn service_field_ctors(fs: ServiceFieldSet, t: Rc) -> pub fn emit_unified_transport_dispatch( transport: Rc, - op_name: Rc>, + op_name: String, source_indices: Rc>>, depth: i64, target: RenderTarget, - render_rest: impl Fn( - Rc>, - Rc, - i64, - Rc>>, - ) -> Rc> - + Clone, - render_shell: impl Fn( - Rc>, - Rc, - i64, - Rc>>, - ) -> Rc> + render_rest: impl Fn(String, Rc, i64, Rc>>) -> String + Clone, + render_shell: impl Fn(String, Rc, i64, Rc>>) -> String + Clone, - render_file: impl Fn(Rc>, i64) -> Rc> + Clone, - render_local: impl Fn(Rc>, i64) -> Rc> + Clone, -) -> Rc> { + render_file: impl Fn(String, i64) -> String + Clone, + render_local: impl Fn(String, i64) -> String + Clone, +) -> String { if is_rest_transport(transport.clone(), source_indices.clone()) { render_rest(op_name, transport.clone(), depth, source_indices.clone()) } else { @@ -2141,34 +2074,25 @@ pub fn emit_unified_transport_dispatch( } pub fn emit_unified_operation_method( - service_name: Rc>, + service_name: String, fallback_transport: Rc, op_node: Rc, target: RenderTarget, registry: Rc>>, env: Rc, - render_transport_body: impl Fn( - Rc, - Rc>, - Rc>>, - i64, - ) -> Rc> + render_transport_body: impl Fn(Rc, String, Rc>>, i64) -> String + Clone, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); let si = env.source_indices.clone(); let op_text = authored_name(env.clone(), op_node.clone()); let params_str = emit_params_shared(op_node.params.clone(), target.clone(), si.clone()); let sp = service_self_param(spec.clone()); - let all_params = if (crate::v2_std_text::host_string_text_to_rust_host(sp.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + let all_params = if (sp.clone().as_str() == "".to_string().as_str()) { params_str.clone() } else { - if (crate::v2_std_text::host_string_text_to_rust_host(params_str.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (params_str.clone().as_str() == "".to_string().as_str()) { sp.clone() } else { v1_rt::concat( @@ -2250,21 +2174,11 @@ pub fn emit_unified_service_def( target: RenderTarget, registry: Rc>>, env: Rc, - render_service_fields: impl Fn( - Rc>, - Rc, - Rc>>, - Rc>>, - ) -> Rc> + render_service_fields: impl Fn(String, Rc, Rc>>, Rc>>) -> String + Clone, - render_transport_body: impl Fn( - Rc, - Rc>, - Rc>>, - i64, - ) -> Rc> + render_transport_body: impl Fn(Rc, String, Rc>>, i64) -> String + Clone, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); let safe_name = sanitize_service_name(authored_name(env.clone(), item.clone())); @@ -2374,7 +2288,7 @@ pub fn classify_expr(texpr: Rc) -> ExprCategory { #[serde(tag = "_variant")] pub enum FuncBodyShape { FuncBodyLet { - name: Rc>, + name: String, value: Rc, rest: Option>, }, @@ -2412,7 +2326,7 @@ pub fn classify_func_body( #[serde(tag = "_variant")] pub enum TcoExprShape { TcoCall { - func: Rc>, + func: String, args: Rc>>, }, TcoIf { @@ -2425,7 +2339,7 @@ pub enum TcoExprShape { arms: Rc>>, }, TcoLet { - name: Rc>, + name: String, value: Rc, body: Option>, }, @@ -2499,7 +2413,7 @@ pub fn block_stmts_init(stmts: Rc>>) -> Rc>> { } pub fn is_tco_eligible( - name: Rc>, + name: String, body: Rc, registry: Rc>>, source_indices: Rc>>, @@ -2521,7 +2435,7 @@ pub fn is_tco_eligible( } pub fn is_self_recursive( - name: Rc>, + name: String, body: Rc, registry: Rc>>, source_indices: Rc>>, @@ -2535,12 +2449,12 @@ pub fn is_self_recursive( pub fn tco_reassign_core( ordered_args: Rc>, param_names: Rc>, - temp_var_prefix: Rc>, - temp_decl_prefix: Rc>, - temp_assign_op: Rc>, - stmt_terminator: Rc>, - continue_str: Rc>, - line_prefix: Rc>, + temp_var_prefix: String, + temp_decl_prefix: String, + temp_assign_op: String, + stmt_terminator: String, + continue_str: String, + line_prefix: String, ) -> Rc> { { let temp_lets = Rc::new({ @@ -2564,9 +2478,7 @@ pub fn tco_reassign_core( v1_rt::concat(line_prefix.clone(), temp_decl_prefix.clone()), temp_var_prefix.clone(), ), - crate::v2_std_text::host_string_text_from_rust_host( - (pair.0.clone()).to_string(), - ), + (pair.0.clone()).to_string(), ), temp_assign_op.clone(), ), @@ -2599,9 +2511,7 @@ pub fn tco_reassign_core( ), temp_var_prefix.clone(), ), - crate::v2_std_text::host_string_text_from_rust_host( - (pair.0.clone()).to_string(), - ), + (pair.0.clone()).to_string(), ), stmt_terminator.clone(), )); @@ -2617,24 +2527,20 @@ pub fn tco_reassign_core( pub fn emit_shared_tco_expr( mut frame: Rc, - mut fn_name: Rc>, - mut emit_self_call_reassign: impl Fn(Rc) -> Rc> + Clone, - mut emit_non_self_call: impl Fn(Rc) -> Rc> + Clone, - mut emit_if: impl Fn(Rc) -> Rc> + Clone, - mut emit_match: impl Fn(Rc) -> Rc> + Clone, - mut emit_let: impl Fn(Rc) -> Rc> + Clone, - mut emit_block: impl Fn(Rc) -> Rc> + Clone, - mut emit_default_return: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + mut fn_name: String, + mut emit_self_call_reassign: impl Fn(Rc) -> String + Clone, + mut emit_non_self_call: impl Fn(Rc) -> String + Clone, + mut emit_if: impl Fn(Rc) -> String + Clone, + mut emit_match: impl Fn(Rc) -> String + Clone, + mut emit_let: impl Fn(Rc) -> String + Clone, + mut emit_block: impl Fn(Rc) -> String + Clone, + mut emit_default_return: impl Fn(Rc) -> String + Clone, +) -> String { loop { let si = frame.scope.clone().type_env.clone().source_indices.clone(); match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - if (crate::v2_std_text::host_string_text_to_rust_host(expr_call_func_at( - frame.expr.clone(), - si, - )) == crate::v2_std_text::host_string_text_to_rust_host(fn_name)) - { + if (expr_call_func_at(frame.expr.clone(), si).as_str() == fn_name.as_str()) { break emit_self_call_reassign(Rc::new(TcoReassignInput { args: frame.expr.clone().children.clone(), scope: frame.scope.clone(), @@ -2675,11 +2581,7 @@ pub fn emit_shared_tco_expr( } } -pub fn shared_tco_body( - inner: Rc>, - depth: i64, - spec: Rc, -) -> Rc> { +pub fn shared_tco_body(inner: String, depth: i64, spec: Rc) -> String { { let syntax = spec.block_syntax.clone(); let tco = spec.tco.clone(); @@ -2712,8 +2614,8 @@ pub fn shared_tco_body( pub fn shared_tco_default_return( frame: Rc, spec: Rc, - recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, -) -> Rc> { + recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, +) -> String { { let val_str = recurse_expr(frame.expr.clone(), frame.scope.clone(), frame.depth.clone()); v1_rt::concat( @@ -2727,9 +2629,8 @@ pub fn shared_tco_non_self_call( frame: Rc, target: RenderTarget, spec: Rc, - recurse_call: impl Fn(Rc>, Rc>>, Rc, i64) -> Rc> - + Clone, -) -> Rc> { + recurse_call: impl Fn(String, Rc>>, Rc, i64) -> String + Clone, +) -> String { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let f = expr_call_func_at( @@ -2756,13 +2657,13 @@ pub fn shared_tco_non_self_call( pub fn shared_tco_if( frame: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, spec: Rc, - recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, - recurse_tco: impl Fn(Rc, Rc, i64) -> Rc> + Clone, -) -> Rc> { + recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, + recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, +) -> String { { let syntax = spec.block_syntax.clone(); match (*frame.expr.clone().expr_data.clone()).clone() { @@ -2884,12 +2785,12 @@ pub fn shared_tco_if( pub fn shared_tco_let( frame: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, - recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, - recurse_tco: impl Fn(Rc, Rc, i64) -> Rc> + Clone, -) -> Rc> { + recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, + recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, +) -> String { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprLet => { let n = let_binding_name_at( @@ -2920,13 +2821,13 @@ pub fn shared_tco_let( pub fn shared_tco_block( frame: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, spec: Rc, emit_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, - recurse_tco: impl Fn(Rc, Rc, i64) -> Rc> + Clone, -) -> Rc> { + recurse_tco: impl Fn(Rc, Rc, i64) -> String + Clone, +) -> String { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprBlock => { let ss = frame.expr.clone().children.clone(); @@ -2966,7 +2867,7 @@ pub fn shared_tco_reassign( ordered_args: Rc>, param_names: Rc>, spec: Rc, -) -> Rc> { +) -> String { { let all_lines = tco_reassign_core( ordered_args, @@ -2986,14 +2887,14 @@ pub fn unified_tco_recurse( expr: Rc, scope: Rc, depth: i64, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, registry: Rc>>, - recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, - render_match: impl Fn(Rc) -> Rc> + Clone, + recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, + render_match: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> Rc> { +) -> String { emit_unified_tco_expr( Rc::new(TcoFrame { expr: expr, @@ -3012,14 +2913,14 @@ pub fn unified_tco_recurse( pub fn emit_unified_tco_expr( frame: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, registry: Rc>>, - recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, - render_match: impl Fn(Rc) -> Rc> + Clone, + recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, + render_match: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); emit_shared_tco_expr( @@ -3130,16 +3031,16 @@ pub fn emit_unified_tco_expr( pub fn emit_unified_tco_body( texpr: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - recurse_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, - render_match: impl Fn(Rc) -> Rc> + Clone, + recurse_expr: impl Fn(Rc, Rc, i64) -> String + Clone, + render_match: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); let inner = emit_unified_tco_expr( @@ -3167,7 +3068,7 @@ pub fn emit_unified_init_block_stmts( depth: i64, target: RenderTarget, registry: Rc>>, - render_pattern: impl Fn(Rc) -> Rc> + Clone, + render_pattern: impl Fn(Rc) -> String + Clone, ) -> Rc { { let prepend = if language_spec(target.clone()) @@ -3195,16 +3096,16 @@ pub fn emit_unified_init_block_stmts( } pub fn emit_tco_match_go( - scrutinee_str: Rc>, + scrutinee_str: String, arms: Rc>>, depth: i64, - fn_name: Rc>, + fn_name: String, params: Rc>>, registry: Rc>>, scope: Rc, - render_pattern: impl Fn(Rc) -> Rc> + Clone, + render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> Rc> { +) -> String { { let si = scope.type_env.clone().source_indices.clone(); let bs = language_spec(RenderTarget::Go).block_syntax.clone(); @@ -3299,13 +3200,13 @@ pub fn emit_tco_match_go( pub fn emit_unified_tco_match( frame: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, registry: Rc>>, - render_pattern: impl Fn(Rc) -> Rc> + Clone, + render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> Rc> { +) -> String { match (*frame.expr.clone().expr_data.clone()).clone() { ExprData::ExprMatch => { let s = match_scrutinee(frame.expr.clone()); @@ -3351,9 +3252,7 @@ pub fn emit_unified_tco_match( }); let arms_str = arm_strs.join(&"\n".to_string()); let bs = language_spec(target.clone()).block_syntax.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(bs.block_close.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (bs.block_close.clone().as_str() == "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrut_str), @@ -3388,15 +3287,15 @@ pub fn emit_unified_tco_match( pub fn emit_unified_tco_match_arm( arm: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - render_pattern: impl Fn(Rc) -> Rc> + Clone, + render_pattern: impl Fn(Rc) -> String + Clone, render_init_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> Rc> { +) -> String { { let bs = language_spec(target.clone()).block_syntax.clone(); let case_depth = if bs.significant_whitespace.clone() { @@ -3467,14 +3366,14 @@ pub fn emit_unified_tco_match_arm( pub fn emit_tco_unified( texpr: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - render_pattern: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + render_pattern: impl Fn(Rc) -> String + Clone, +) -> String { emit_unified_tco_body( texpr, fn_name.clone(), @@ -3535,7 +3434,7 @@ pub fn emit_unified_typed_func_body( registry: Rc>>, scope: Rc, depth: i64, -) -> Rc> { +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let es = language_spec(target.clone()).expression_semantics.clone(); let bs = language_spec(target.clone()).block_syntax.clone(); @@ -3689,16 +3588,14 @@ pub fn emit_unified_typed_func_body( pub fn is_tco_candidate( texpr: Rc, - func_name: Rc>, + func_name: String, source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(expr_call_func_at( - texpr.clone(), - source_indices.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(func_name.clone())) + (expr_call_func_at(texpr.clone(), source_indices.clone()).as_str() + == func_name.clone().as_str()) } ExprData::ExprReturn => is_tco_candidate( return_value(texpr.clone()), @@ -3763,8 +3660,8 @@ pub fn is_tco_candidate( } pub fn suffix_escape_collides_with_reserved_chain( - mut name: Rc>, - mut suffix: Rc>, + mut name: String, + mut suffix: String, mut keywords: Rc>, ) -> bool { loop { @@ -3773,11 +3670,13 @@ pub fn suffix_escape_collides_with_reserved_chain( if ((suffix_len.clone() == 0) || (name_len.clone() < suffix_len.clone())) { break false; } else { - if (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( + if (v1_rt::substring( &name, (name_len.clone() - suffix_len.clone()), name_len.clone(), - )) != crate::v2_std_text::host_string_text_to_rust_host(suffix.clone())) + ) + .as_str() + != suffix.clone().as_str()) { break false; } else { @@ -3785,9 +3684,7 @@ pub fn suffix_escape_collides_with_reserved_chain( if { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(base.clone())) - { + if (r.clone().as_str() == base.clone().as_str()) { __found = true; break; } @@ -3808,17 +3705,15 @@ pub fn suffix_escape_collides_with_reserved_chain( } pub fn emit_suffix_escape_ident( - converted: Rc>, - suffix: Rc>, + converted: String, + suffix: String, keywords: Rc>, -) -> Rc> { +) -> String { { let is_reserved = { let mut __found = false; for r in keywords.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(converted.clone())) - { + if (r.clone().as_str() == converted.clone().as_str()) { __found = true; break; } @@ -3839,7 +3734,7 @@ pub fn emit_suffix_escape_ident( } } -pub fn emit_ident(name: Rc>, target: RenderTarget) -> Rc> { +pub fn emit_ident(name: String, target: RenderTarget) -> String { { let spec = language_spec(target); let converted = match spec.naming_case.clone() { @@ -3851,9 +3746,7 @@ pub fn emit_ident(name: Rc>, target: RenderTarget) -> Rc>, target: RenderTarget) -> Rc>, target: RenderTarget) -> Rc> { +pub fn emit_export_ident(name: String, target: RenderTarget) -> String { { let spec = language_spec(target.clone()); match (*spec.visibility.clone()).clone() { @@ -3896,9 +3789,7 @@ pub fn emit_export_ident(name: Rc>, target: RenderTarget) -> Rc< let is_reserved = { let mut __found = false; for r in spec.reserved_words.clone().keywords.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(result.clone())) - { + if (r.clone().as_str() == result.clone().as_str()) { __found = true; break; } @@ -3938,9 +3829,9 @@ pub fn emit_export_ident(name: Rc>, target: RenderTarget) -> Rc< } pub fn apply_bridge_method_overrides( - name: Rc>, + name: String, overrides: Rc>, -) -> Rc> { +) -> String { match v1_rt::lookup(&overrides, name.clone()) { v1_rt::Witness::Holds { value: replacement, .. @@ -3949,11 +3840,7 @@ pub fn apply_bridge_method_overrides( } } -pub fn emit_let_binding( - name: Rc>, - value: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn emit_let_binding(name: String, value: String, target: RenderTarget) -> String { { let spec = language_spec(target.clone()); apply_type_template2( @@ -3965,11 +3852,11 @@ pub fn emit_let_binding( } pub fn emit_let_binding_annotated( - name: Rc>, - type_str: Rc>, - value: Rc>, + name: String, + type_str: String, + value: String, target: RenderTarget, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); apply_type_template3( @@ -3981,15 +3868,11 @@ pub fn emit_let_binding_annotated( } } -pub fn emit_return(value: Rc>, target: RenderTarget) -> Rc> { +pub fn emit_return(value: String, target: RenderTarget) -> String { v1_rt::concat("return ".to_string(), value) } -pub fn emit_unary_op( - op: UnaryOpKind, - operand_str: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn emit_unary_op(op: UnaryOpKind, operand_str: String, target: RenderTarget) -> String { match op { UnaryOpKind::Not => v1_rt::concat(emit_keyword("not".to_string(), target), operand_str), UnaryOpKind::Neg => v1_rt::concat("-".to_string(), operand_str), @@ -4003,18 +3886,14 @@ pub fn go_lambda_emits_statement_body(body: Rc) -> bool { } } -pub fn emit_lambda( - params_str: Rc>, - body_str: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn emit_lambda(params_str: String, body_str: String, target: RenderTarget) -> String { { let spec = language_spec(target); apply_type_template2(spec.lambda_template.clone(), params_str, body_str) } } -pub fn emit_error_expr(message: Rc>, target: RenderTarget) -> Rc> { +pub fn emit_error_expr(message: String, target: RenderTarget) -> String { { let msg = emit_string_literal(message, "".to_string()); let spec = language_spec(target); @@ -4022,10 +3901,7 @@ pub fn emit_error_expr(message: Rc>, target: RenderTarget) -> Rc } } -pub fn emit_lambda_params( - param_names: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn emit_lambda_params(param_names: Rc>, target: RenderTarget) -> String { { let spec = language_spec(target.clone()); let param_strs = Rc::new({ @@ -4042,10 +3918,7 @@ pub fn emit_lambda_params( } } -pub fn emit_list_lit_expr( - element_strs: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn emit_list_lit_expr(element_strs: Rc>, target: RenderTarget) -> String { { let spec = language_spec(target); if ((element_strs.clone().len() as i64) == 0) { @@ -4059,11 +3932,7 @@ pub fn emit_list_lit_expr( } } -pub fn emit_null_coalesce( - l_str: Rc>, - r_str: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn emit_null_coalesce(l_str: String, r_str: String, target: RenderTarget) -> String { { let spec = language_spec(target); apply_type_template2(spec.null_coalesce_template.clone(), l_str, r_str) @@ -4074,18 +3943,14 @@ pub fn emit_expr_var_shared( expr: Rc, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { { let n = expr_var_name_at(expr, source_indices); - if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("none".to_string())) - { + if (n.clone().as_str() == "none".to_string().as_str()) { emit_keyword("null".to_string(), target) } else { - if ((crate::v2_std_text::host_string_text_to_rust_host(n.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("true".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("false".to_string()))) + if ((n.clone().as_str() == "true".to_string().as_str()) + || (n.clone().as_str() == "false".to_string().as_str())) { emit_keyword(n.clone(), target) } else { @@ -4098,9 +3963,9 @@ pub fn emit_expr_var_shared( pub fn emit_expr_field_access_shared( expr: Rc, target: RenderTarget, - emit_field: impl Fn(Rc) -> Rc> + Clone, + emit_field: impl Fn(Rc) -> String + Clone, source_indices: Rc>>, -) -> Rc> { +) -> String { if is_typed_service_call_receiver(expr.clone(), source_indices.clone()) { match extract_typed_service_name(expr.clone(), source_indices.clone()) { Some(svc_name) => service_var_name(svc_name.clone()), @@ -4137,9 +4002,9 @@ pub fn emit_typed_cast_shared( expr: Rc, cast_target_node: Rc, target: RenderTarget, - recurse: impl Fn(Rc) -> Rc> + Clone, + recurse: impl Fn(Rc) -> String + Clone, source_indices: Rc>>, -) -> Rc> { +) -> String { { let expr_str = recurse(expr.clone()); let ty_str = emit_node_type(cast_target_node, target.clone(), source_indices.clone()); @@ -4149,10 +4014,8 @@ pub fn emit_typed_cast_shared( } _ => "".to_string(), }; - if ((crate::v2_std_text::host_string_text_to_rust_host(src_ty.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - && (crate::v2_std_text::host_string_text_to_rust_host(src_ty.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(ty_str.clone()))) + if ((src_ty.clone().as_str() != "".to_string().as_str()) + && (src_ty.clone().as_str() == ty_str.clone().as_str())) { expr_str } else { @@ -4175,15 +4038,15 @@ pub fn emit_typed_cast_shared( } pub fn emit_typed_for_each_shared( - variable: Rc>, + variable: String, collection: Rc, body: Rc, target: RenderTarget, depth: i64, source_indices: Rc>>, - recurse: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + recurse: impl Fn(Rc, Rc, i64) -> String + Clone, scope: Rc, -) -> Rc> { +) -> String { { let coll_str = recurse(collection.clone(), scope.clone(), depth.clone()); let elem_type = @@ -4254,9 +4117,9 @@ pub fn emit_typed_index_shared( base: Rc, index: Rc, target: RenderTarget, - recurse: impl Fn(Rc) -> Rc> + Clone, + recurse: impl Fn(Rc) -> String + Clone, source_indices: Rc>>, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); let base_str = recurse(base.clone()); @@ -4291,9 +4154,9 @@ pub fn emit_typed_slice_shared( start: Rc, end: Rc, target: RenderTarget, - recurse: impl Fn(Rc) -> Rc> + Clone, + recurse: impl Fn(Rc) -> String + Clone, source_indices: Rc>>, -) -> Rc> { +) -> String { { let spec = language_spec(target.clone()); let base_str = recurse(base.clone()); @@ -4321,24 +4184,24 @@ pub fn emit_shared_expr( texpr: Rc, target: RenderTarget, source_indices: Rc>>, - wrap_result: impl Fn(Rc>) -> Rc> + Clone, - recurse: impl Fn(Rc) -> Rc> + Clone, - emit_var: impl Fn(Rc) -> Rc> + Clone, - emit_field_access: impl Fn(Rc) -> Rc> + Clone, - emit_call: impl Fn(Rc) -> Rc> + Clone, - emit_method_call: impl Fn(Rc) -> Rc> + Clone, - emit_match: impl Fn(Rc) -> Rc> + Clone, - emit_if: impl Fn(Rc) -> Rc> + Clone, - emit_let: impl Fn(Rc) -> Rc> + Clone, - emit_record_lit: impl Fn(Rc) -> Rc> + Clone, - emit_string_interp: impl Fn(Rc) -> Rc> + Clone, - emit_block: impl Fn(Rc) -> Rc> + Clone, - emit_cast: impl Fn(Rc) -> Rc> + Clone, - emit_for_each: impl Fn(Rc) -> Rc> + Clone, - emit_index: impl Fn(Rc) -> Rc> + Clone, - emit_slice: impl Fn(Rc) -> Rc> + Clone, - emit_bin_op: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + wrap_result: impl Fn(String) -> String + Clone, + recurse: impl Fn(Rc) -> String + Clone, + emit_var: impl Fn(Rc) -> String + Clone, + emit_field_access: impl Fn(Rc) -> String + Clone, + emit_call: impl Fn(Rc) -> String + Clone, + emit_method_call: impl Fn(Rc) -> String + Clone, + emit_match: impl Fn(Rc) -> String + Clone, + emit_if: impl Fn(Rc) -> String + Clone, + emit_let: impl Fn(Rc) -> String + Clone, + emit_record_lit: impl Fn(Rc) -> String + Clone, + emit_string_interp: impl Fn(Rc) -> String + Clone, + emit_block: impl Fn(Rc) -> String + Clone, + emit_cast: impl Fn(Rc) -> String + Clone, + emit_for_each: impl Fn(Rc) -> String + Clone, + emit_index: impl Fn(Rc) -> String + Clone, + emit_slice: impl Fn(Rc) -> String + Clone, + emit_bin_op: impl Fn(Rc) -> String + Clone, +) -> String { match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => { wrap_result(emit_literal(v.clone(), target.clone())) @@ -4414,9 +4277,9 @@ pub fn emit_default_bin_op( texpr: Rc, target: RenderTarget, source_indices: Rc>>, - recurse: impl Fn(Rc) -> Rc> + Clone, - wrap_result: impl Fn(Rc>) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc) -> String + Clone, + wrap_result: impl Fn(String) -> String + Clone, +) -> String { match (*texpr.expr_data.clone()).clone() { ExprData::ExprBinOp { op, @@ -4464,7 +4327,7 @@ pub fn emit_block_stmts_shared( mut scope: Rc, mut depth: i64, mut prepend_indent: bool, - mut emit_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + mut emit_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> Rc { loop { match remaining.clone().first().cloned() { @@ -4508,7 +4371,7 @@ pub fn emit_init_block_stmts_shared( mut scope: Rc, mut depth: i64, mut prepend_indent: bool, - mut emit_expr: impl Fn(Rc, Rc, i64) -> Rc> + Clone, + mut emit_expr: impl Fn(Rc, Rc, i64) -> String + Clone, ) -> Rc { loop { match remaining.clone().first().cloned() { @@ -4559,14 +4422,14 @@ pub fn emit_init_block_stmts_shared( } pub fn emit_typed_let_shared( - name: Rc>, - value_str: Rc>, + name: String, + value_str: String, body: Option>, target: RenderTarget, - recurse: impl Fn(Rc, Rc) -> Rc> + Clone, + recurse: impl Fn(Rc, Rc) -> String + Clone, scope: Rc, value_node: Rc, -) -> Rc> { +) -> String { { let let_line = emit_let_binding(name.clone(), value_str, target); match body { @@ -4588,15 +4451,15 @@ pub fn emit_typed_let_shared( } pub fn emit_typed_if_shared( - cond_str: Rc>, + cond_str: String, then_branch: Rc, else_branch: Option>, if_result_type: Option>, depth: i64, target: RenderTarget, source_indices: Rc>>, - recurse: impl Fn(Rc, i64) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc, i64) -> String + Clone, +) -> String { { let spec = language_spec(target.clone()); let es = spec.expression_semantics.clone(); @@ -4726,7 +4589,7 @@ pub fn emit_param_shared( param: Rc, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { { let ty = emit_node_type( param_node_type_expr(param.clone()), @@ -4754,7 +4617,7 @@ pub fn emit_params_shared( params: Rc>>, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { { let strs = Rc::new({ let mut __result = Vec::new(); @@ -4781,7 +4644,7 @@ pub fn emit_inferred_shared( inferred: Rc, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { if language_spec(target.clone()) .expression_semantics .clone() @@ -4817,7 +4680,7 @@ pub fn emit_typed_block_join( scope: Rc, depth: i64, emit_block_stmts: impl Fn(Rc>>, Rc, i64) -> Rc + Clone, -) -> Rc> { +) -> String { { let state = emit_block_stmts(stmts, scope, depth); state.text.clone().join(&"\n".to_string()) @@ -4836,11 +4699,11 @@ pub fn method_template_emit_for_target( } pub fn emit_algebra_method_template( - method_name: Rc>, - recv_str: Rc>, - first_arg_str: Rc>, + method_name: String, + recv_str: String, + first_arg_str: String, target: RenderTarget, -) -> Rc> { +) -> Option { match method_template_emit_for_target(target) { Some(templates) => match v1_rt::map_get(&templates, method_name) { Some(tmpl) => { @@ -4860,8 +4723,8 @@ pub fn emit_algebra_method_template( pub fn emit_typed_first_arg_shared( args: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc) -> String + Clone, +) -> String { match args.first().cloned() { Some(a) => recurse(arg_value(a.clone())), None => emit_error_expr("missing method argument".to_string(), target), @@ -4871,8 +4734,8 @@ pub fn emit_typed_first_arg_shared( pub fn emit_typed_string_interp_unified( parts: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc) -> String + Clone, +) -> String { { let spec = language_spec(target); let interp = spec.string_interp.clone(); @@ -4937,9 +4800,7 @@ pub fn emit_typed_string_interp_unified( .iter() .cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(a.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (a.clone().as_str() != "".to_string().as_str()) { __result.push(a); } } @@ -4985,12 +4846,12 @@ pub fn emit_typed_string_interp_unified( } pub fn emit_typed_record_lit_unified( - type_name: Rc>, + type_name: Option, fields: Rc>>, target: RenderTarget, source_indices: Rc>>, - recurse: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc) -> String + Clone, +) -> String { { let rls = language_spec(target.clone()).record_lit.clone(); match type_name { @@ -5074,7 +4935,7 @@ pub fn emit_typed_record_lit_unified( } } -pub fn is_go_v2rt_free_function(name: Rc>) -> bool { +pub fn is_go_v2rt_free_function(name: String) -> bool { match name.as_str() { "concat" => true, "to_string" => true, @@ -5083,10 +4944,7 @@ pub fn is_go_v2rt_free_function(name: Rc>) -> bool { } } -pub fn emit_go_v2rt_free_call( - func: Rc>, - arg_strs: Rc>, -) -> Rc> { +pub fn emit_go_v2rt_free_call(func: String, arg_strs: Rc>) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -5106,13 +4964,13 @@ pub fn emit_go_v2rt_free_call( } pub fn emit_typed_call_unified( - func: Rc>, + func: String, args: Rc>>, target: RenderTarget, registry: Rc>>, scope: Rc, - recurse: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc) -> String + Clone, +) -> String { { let spec = language_spec(target.clone()); let ordered_args = order_typed_call_args(args, func.clone(), scope); @@ -5197,10 +5055,7 @@ pub fn emit_typed_call_unified( } } -pub fn bridge_method_name_unified( - method_name: Rc>, - target: RenderTarget, -) -> Rc> { +pub fn bridge_method_name_unified(method_name: String, target: RenderTarget) -> String { { let spec = language_spec(target); let overridden = @@ -5210,13 +5065,13 @@ pub fn bridge_method_name_unified( } pub fn emit_algebra_method_call_unified( - method_name: Rc>, + method_name: String, receiver: Rc, args: Rc>>, target: RenderTarget, - first_arg_str: Rc>, - recurse: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + first_arg_str: String, + recurse: impl Fn(Rc) -> String + Clone, +) -> String { { let spec = language_spec(target.clone()); let recv_str = recurse(receiver); @@ -5257,11 +5112,11 @@ pub fn emit_algebra_method_call_unified( pub fn emit_plain_method_call_unified( receiver: Rc, - method: Rc>, + method: String, args: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc) -> String + Clone, +) -> String { { let recv_str = recurse(receiver); let arg_strs = Rc::new({ @@ -5290,15 +5145,15 @@ pub fn emit_plain_method_call_unified( pub fn emit_typed_method_call_unified( receiver: Rc, - method: Rc>, + method: String, args: Rc>>, method_semantics: Option>, target: RenderTarget, registry: Rc>>, scope: Rc, depth: i64, - recurse: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + recurse: impl Fn(Rc) -> String + Clone, +) -> String { { let spec = language_spec(target.clone()); let source_indices = scope.type_env.clone().source_indices.clone(); @@ -5406,7 +5261,7 @@ pub fn emit_unified_pattern( pattern: Rc, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { match (*pattern).clone() { MatchPattern::Bind { name: n, .. } => emit_ident(n.clone(), target), MatchPattern::LitPattern { value: v, .. } => emit_literal(v.clone(), target), @@ -5422,10 +5277,7 @@ pub fn emit_unified_pattern( } } -pub fn go_variant_case_type( - name: Rc>, - parent_enum: Rc>, -) -> Rc> { +pub fn go_variant_case_type(name: String, parent_enum: Option) -> String { match parent_enum { Some(parent) => v1_rt::concat(parent.clone(), name), None => name, @@ -5433,12 +5285,12 @@ pub fn go_variant_case_type( } pub fn emit_unified_variant_pattern( - name: Rc>, - parent_enum: Rc>, + name: String, + parent_enum: Option, field_bindings: Rc>>, target: RenderTarget, source_indices: Rc>>, -) -> Rc> { +) -> String { { let es = language_spec(target.clone()).expression_semantics.clone(); match es.variant_pattern.clone() { @@ -5497,10 +5349,7 @@ pub fn emit_unified_variant_pattern( } } -pub fn emit_match_arm_body_stmt( - target: RenderTarget, - body_str: Rc>, -) -> Rc> { +pub fn emit_match_arm_body_stmt(target: RenderTarget, body_str: String) -> String { match language_spec(target) .expression_semantics .clone() @@ -5517,10 +5366,10 @@ pub fn emit_match_arm_line( target: RenderTarget, case_depth: i64, body_depth: i64, - body_str: Rc>, - guard_str: Rc>, - render_pattern: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + body_str: String, + guard_str: String, + render_pattern: impl Fn(Rc) -> String + Clone, +) -> String { { let spec = language_spec(target); let bs = spec.block_syntax.clone(); @@ -5549,8 +5398,8 @@ pub fn emit_match_arm_line( pub fn emit_arm_guard( arm: Rc, target: RenderTarget, - render_guard_expr: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + render_guard_expr: impl Fn(Rc) -> String + Clone, +) -> String { { let es = language_spec(target.clone()).expression_semantics.clone(); match arm_guard(arm) { @@ -5570,7 +5419,7 @@ pub fn emit_go_match_arm_bindings( arm: Rc, indent_level: i64, source_indices: Rc>>, -) -> Rc> { +) -> String { match (*arm_pattern(arm)).clone() { MatchPattern::VariantPattern { field_bindings: fbs, @@ -5615,13 +5464,13 @@ pub fn emit_go_match_arm_bindings( } pub fn emit_typed_match_go( - scrutinee_str: Rc>, + scrutinee_str: String, arms: Rc>>, depth: i64, - recurse: impl Fn(Rc, i64) -> Rc> + Clone, - render_pattern: impl Fn(Rc) -> Rc> + Clone, + recurse: impl Fn(Rc, i64) -> String + Clone, + render_pattern: impl Fn(Rc) -> String + Clone, source_indices: Rc>>, -) -> Rc> { +) -> String { { let bs = language_spec(RenderTarget::Go).block_syntax.clone(); let case_depth = (depth.clone() + 1); @@ -5678,14 +5527,14 @@ pub fn emit_typed_match_go( } pub fn emit_typed_match_unified( - scrutinee_str: Rc>, + scrutinee_str: String, arms: Rc>>, target: RenderTarget, depth: i64, - recurse: impl Fn(Rc, i64) -> Rc> + Clone, - render_pattern: impl Fn(Rc) -> Rc> + Clone, + recurse: impl Fn(Rc, i64) -> String + Clone, + render_pattern: impl Fn(Rc) -> String + Clone, source_indices: Rc>>, -) -> Rc> { +) -> String { match target.clone() { RenderTarget::Go => emit_typed_match_go( scrutinee_str, @@ -5728,9 +5577,7 @@ pub fn emit_typed_match_unified( __result }); let arms_str = arm_strs.join(&"\n".to_string()); - if (crate::v2_std_text::host_string_text_to_rust_host(bs.block_close.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (bs.block_close.clone().as_str() == "".to_string().as_str()) { v1_rt::concat( v1_rt::concat( v1_rt::concat(bs.match_keyword.clone(), scrutinee_str), @@ -5761,11 +5608,11 @@ pub fn emit_typed_match_unified( } pub fn emit_field_access_unified( - base_str: Rc>, - field: Rc>, + base_str: String, + field: String, summary: Option>, target: RenderTarget, -) -> Rc> { +) -> String { { let ts = language_spec(target.clone()).tuple_syntax.clone(); match summary { @@ -5794,8 +5641,8 @@ pub fn emit_unified_typed_expr( scope: Rc, depth: i64, fuel: i64, - render_pattern: impl Fn(Rc) -> Rc> + Clone, -) -> Rc> { + render_pattern: impl Fn(Rc) -> String + Clone, +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let si = scope.type_env.clone().source_indices.clone(); let spec = language_spec(target.clone()); @@ -6170,18 +6017,13 @@ pub fn emit_unified_typed_expr( pub fn is_tco_identity_passthrough( arg_val: Rc, - param_name: Rc>, + param_name: String, si: Rc>>, ) -> bool { match (*arg_val.expr_data.clone()).clone() { ExprData::ExprVar { binding_kind: _, .. - } => { - (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( - arg_val.clone(), - si, - )) == crate::v2_std_text::host_string_text_to_rust_host(param_name)) - } + } => (expr_var_name_at(arg_val.clone(), si).as_str() == param_name.as_str()), _ => false, } } @@ -6190,9 +6032,9 @@ pub fn emit_typed_tco_reassign_shared( args: Rc>>, params: Rc>>, target: RenderTarget, - recurse: impl Fn(Rc) -> Rc> + Clone, + recurse: impl Fn(Rc) -> String + Clone, source_indices: Rc>>, -) -> Rc> { +) -> String { { let arg_values = Rc::new({ let mut __result = Vec::new(); @@ -6260,25 +6102,6 @@ pub fn emit_typed_tco_reassign_shared( } } -pub fn seed_bindings( - key: Rc>, - value: Rc>, -) -> Rc> { - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>>(), - key, - value, - ) +pub fn seed_bindings(key: String, value: String) -> Rc> { + v1_rt::rc_map_insert(v1_rt::rc_empty_map::(), key, value) } - -pub struct CapServiceEmit; -pub struct CapAsyncTransport; -pub struct CapTestGeneration; -pub struct CapDryRunMode; -pub struct CapRcOwnership; -pub struct ExprCatLeaf; -pub struct ExprCatCompound; -pub struct ExprCatControlFlow; -pub struct ExprCatBinding; -pub struct ExprCatService; -pub struct ExprCatNone; diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index 0a0d5edf8b0..35da76811db 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -29,16 +29,16 @@ pub struct EmitResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TestProjection { - pub module_name: Rc>, - pub service_name: Rc>, - pub operation_name: Rc>, + pub module_name: String, + pub service_name: String, + pub operation_name: String, pub inferred: Rc, pub params: Rc>>, pub mock_field_inits: Rc>>, pub source_indices: Rc>>, } -pub fn escape_json_string(s: Rc>) -> Rc> { +pub fn escape_json_string(s: String) -> String { Rc::new( Rc::new( Rc::new( @@ -65,7 +65,7 @@ pub fn escape_json_string(s: Rc>) -> Rc> { .join(&"\\t".to_string()) } -pub fn module_to_filename(name: Rc>) -> Rc> { +pub fn module_to_filename(name: String) -> String { Rc::new( name.split(&".".to_string()) .map(|s| s.to_string()) @@ -74,7 +74,7 @@ pub fn module_to_filename(name: Rc>) -> Rc> { .join(&"_".to_string()) } -pub fn make_indent(level: i64) -> Rc> { +pub fn make_indent(level: i64) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if (level.clone() <= 0) { "".to_string() @@ -88,10 +88,10 @@ pub fn unique_strings(items: Rc>) -> Rc> { { let result = items.iter().cloned().fold( Rc::new(UniqueAccum { - seen: v1_rt::rc_empty_map::>, bool>(), + seen: v1_rt::rc_empty_map::(), result: Rc::new(vec![]), }), - |acc: Rc, item: Rc>| { + |acc: Rc, item: String| { if emit_map_has(acc.seen.clone(), item.clone()) { acc.clone() } else { @@ -106,15 +106,10 @@ pub fn unique_strings(items: Rc>) -> Rc> { } } -pub fn to_string(value: i64) -> Rc> { +pub fn to_string(value: i64) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if (value.clone() < 0) { - v1_rt::concat( - "-".to_string(), - crate::v2_std_text::host_string_text_from_rust_host( - (0 - value.clone()).to_string(), - ), - ) + v1_rt::concat("-".to_string(), (0 - value.clone()).to_string()) } else { if (value.clone() == 0) { "0".to_string() @@ -194,7 +189,7 @@ pub fn to_string_helper(mut value: i64, mut acc: Rc>) -> Rc>) -> Rc> { +pub fn to_snake(name: String) -> String { { let chars_list = Rc::new(name.chars().map(|c| c as i64).collect::>()); let result = Rc::new({ @@ -230,7 +225,7 @@ pub fn to_snake(name: Rc>) -> Rc> { } } -pub fn to_screaming_snake(name: Rc>) -> Rc> { +pub fn to_screaming_snake(name: String) -> String { { let snake = to_snake(name); Rc::new({ @@ -251,7 +246,7 @@ pub fn is_upper(ch: i64) -> bool { ((ch.clone() >= 65) && (ch.clone() <= 90)) } -pub fn to_lower_char(ch: i64) -> Rc> { +pub fn to_lower_char(ch: i64) -> String { { let cp = ch.clone(); if ((cp.clone() >= 65) && (cp.clone() <= 90)) { @@ -265,7 +260,7 @@ pub fn to_lower_char(ch: i64) -> Rc> { } } -pub fn to_upper_char(ch: i64) -> Rc> { +pub fn to_upper_char(ch: i64) -> String { { let cp = ch.clone(); if ((cp.clone() >= 97) && (cp.clone() <= 122)) { @@ -279,7 +274,7 @@ pub fn to_upper_char(ch: i64) -> Rc> { } } -pub fn sanitize_service_name(name: Rc>) -> Rc> { +pub fn sanitize_service_name(name: String) -> String { { let parts = Rc::new( name.split(&".".to_string()) @@ -297,7 +292,7 @@ pub fn sanitize_service_name(name: Rc>) -> Rc> { } } -pub fn capitalize_first(s: Rc>) -> Rc> { +pub fn capitalize_first(s: String) -> String { { let chars_list = Rc::new(s.chars().map(|c| c as i64).collect::>()); if ((chars_list.clone().len() as i64) == 0) { @@ -330,11 +325,11 @@ pub fn capitalize_first(s: Rc>) -> Rc> { } } -pub fn service_var_name(service_name: Rc>) -> Rc> { +pub fn service_var_name(service_name: String) -> String { to_snake(sanitize_service_name(service_name)) } -pub fn to_pascal(name: Rc>) -> Rc> { +pub fn to_pascal(name: String) -> String { { let snake = to_snake(name); let parts = Rc::new( @@ -354,10 +349,7 @@ pub fn to_pascal(name: Rc>) -> Rc> { } } -pub fn test_function_name( - projection: Rc, - target: RenderTarget, -) -> Rc> { +pub fn test_function_name(projection: Rc, target: RenderTarget) -> String { { let conventions = test_conventions_for_target(target); let formatted = match conventions.name_style.clone() { @@ -377,10 +369,7 @@ pub fn test_function_name( } } -pub fn apply_type_template1( - template: Rc>, - arg0: Rc>, -) -> Rc> { +pub fn apply_type_template1(template: String, arg0: String) -> String { Rc::new( template .split(&"{0}".to_string()) @@ -390,11 +379,7 @@ pub fn apply_type_template1( .join(&arg0) } -pub fn apply_type_template2( - template: Rc>, - arg0: Rc>, - arg1: Rc>, -) -> Rc> { +pub fn apply_type_template2(template: String, arg0: String, arg1: String) -> String { { let parts = Rc::new( template @@ -421,12 +406,7 @@ pub fn apply_type_template2( } } -pub fn apply_type_template3( - template: Rc>, - arg0: Rc>, - arg1: Rc>, - arg2: Rc>, -) -> Rc> { +pub fn apply_type_template3(template: String, arg0: String, arg1: String, arg2: String) -> String { { let parts0 = Rc::new( template @@ -468,10 +448,7 @@ pub fn apply_type_template3( } } -pub fn apply_named_template( - template: Rc>, - bindings: Rc>, -) -> Rc> { +pub fn apply_named_template(template: String, bindings: Rc>) -> String { apply_named_template_nested( template, bindings.clone(), @@ -480,10 +457,10 @@ pub fn apply_named_template( } pub fn apply_named_template_nested( - template: Rc>, + template: String, bindings: Rc>, keys: Rc>, -) -> Rc> { +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match keys.clone().first().cloned() { None => template, @@ -531,7 +508,7 @@ pub fn language_spec(target: RenderTarget) -> Rc { language_spec_for_target(target) } -pub fn escape_string_literal_body(s: Rc>) -> Rc> { +pub fn escape_string_literal_body(s: String) -> String { { let escaped_backslash = Rc::new( s.split(&"\\".to_string()) @@ -570,12 +547,11 @@ pub fn escape_string_literal_body(s: Rc>) -> Rc> } } -pub fn has_mock_prefix(name: Rc>) -> bool { +pub fn has_mock_prefix(name: String) -> bool { if (v1_rt::string_length(&name) < 5) { false } else { - (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring(&name, 0, 5)) - == crate::v2_std_text::host_string_text_to_rust_host("mock_".to_string())) + (v1_rt::substring(&name, 0, 5).as_str() == "mock_".to_string().as_str()) } } @@ -675,8 +651,7 @@ pub fn is_type_alias_return_node( n: Rc, source_indices: Rc>>, ) -> bool { - (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at(source_indices, n)) - != crate::v2_std_text::host_string_text_to_rust_host("Unit".to_string())) + (authored_name_at(source_indices, n).as_str() != "Unit".to_string().as_str()) } pub fn is_service_item(item: Rc) -> bool { diff --git a/src/v1/stage0/src/v1_compiler_emit_go.rs b/src/v1/stage0/src/v1_compiler_emit_go.rs index 1ab0fd176f2..fb593f98367 100644 --- a/src/v1/stage0/src/v1_compiler_emit_go.rs +++ b/src/v1/stage0/src/v1_compiler_emit_go.rs @@ -103,11 +103,11 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn go_emit_module_root() -> Rc> { +pub fn go_emit_module_root() -> String { "generated".to_string() } -pub fn go_v2rt_import_path() -> Rc> { +pub fn go_v2rt_import_path() -> String { v1_rt::concat(go_emit_module_root(), "/v2rt".to_string()) } @@ -135,14 +135,13 @@ pub fn emit_go(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - p.module_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at( + if (p.module_name.clone().as_str() + == authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ), - )) { + ) + .as_str()) + { __result.push(p); } } @@ -155,9 +154,7 @@ pub fn emit_go(typed: Rc) -> Rc { .iter() .cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(f.path.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (f.path.clone().as_str() != "".to_string().as_str()) { __result.push(f); } } @@ -183,7 +180,7 @@ pub fn emit_go_v2rt_module() -> Rc { }) } -pub fn emit_go_mod(module_name: Rc>) -> Rc { +pub fn emit_go_mod(module_name: String) -> Rc { { let manifest_path = match scaffold_for_target(RenderTarget::Go).manifest_file.clone() { Some(path) => path.clone(), @@ -217,7 +214,7 @@ pub fn go_mock_expr_uses_fmt( } } -pub fn go_test_import_block(projections: Rc>>) -> Rc> { +pub fn go_test_import_block(projections: Rc>>) -> String { { let needs_fmt = { let mut __found = false; @@ -249,7 +246,7 @@ pub fn go_test_import_block(projections: Rc>>) -> Rc) -> Rc> { +pub fn go_test_signature_comment(projection: Rc) -> String { { let params_str = Rc::new({ let mut __result = Vec::new(); @@ -299,7 +296,7 @@ pub fn go_test_signature_comment(projection: Rc) -> Rc>, + module_name: String, projections: Rc>>, ) -> Rc { if ((projections.clone().len() as i64) == 0) { @@ -362,7 +359,7 @@ pub fn emit_go_test_file( } } -pub fn emit_go_operation_test(projection: Rc, depth: i64) -> Rc> { +pub fn emit_go_operation_test(projection: Rc, depth: i64) -> String { { let test_name = test_function_name(projection.clone(), RenderTarget::Go); let struct_name = sanitize_service_name(projection.service_name.clone()); @@ -444,7 +441,7 @@ pub fn emit_go_mock_prop_setup( mock_prop: Rc, depth: i64, source_indices: Rc>>, -) -> Rc> { +) -> String { v1_rt::concat( v1_rt::concat( emit_ident( @@ -487,14 +484,11 @@ pub fn emit_go_module( module_imports(m.clone()), si.clone(), ); - let imports_section = - if (crate::v2_std_text::host_string_text_to_rust_host(imports_str.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { - "".to_string() - } else { - v1_rt::concat("\n\n".to_string(), imports_str.clone()) - }; + let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { + "".to_string() + } else { + v1_rt::concat("\n\n".to_string(), imports_str.clone()) + }; let items_str = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -555,7 +549,7 @@ pub fn emit_go_module( } } -pub fn go_package_name(module_name: Rc>) -> Rc> { +pub fn go_package_name(module_name: String) -> String { { let parts = Rc::new( module_name @@ -590,7 +584,7 @@ pub fn emit_go_imports( items: Rc>>, imports: Rc>>, source_indices: Rc>>, -) -> Rc> { +) -> String { { let has_services = { let mut __found = false; @@ -700,7 +694,7 @@ pub fn emit_go_typed_item( item: Rc, registry: Rc>>, scope: Rc, -) -> Rc> { +) -> String { { let env = scope.type_env.clone(); let item_text = authored_name(env.clone(), item.clone()); @@ -780,7 +774,7 @@ pub fn emit_go_typed_item( } } -pub fn emit_go_type_def_from_connective(item: Rc, env: Rc) -> Rc> { +pub fn emit_go_type_def_from_connective(item: Rc, env: Rc) -> String { { let item_text = authored_name(env.clone(), item.clone()); let is_product = (item.connective.clone() == Connective::Conj); @@ -793,10 +787,10 @@ pub fn emit_go_type_def_from_connective(item: Rc, env: Rc) -> Rc< } pub fn emit_go_struct_from_children( - name: Rc>, + name: String, children: Rc>>, env: Rc, -) -> Rc> { +) -> String { if ((children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat( @@ -866,7 +860,7 @@ pub fn emit_go_struct_from_children( } } -pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> Rc> { +pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> String { { let child_text = authored_name(env.clone(), child.clone()); let ty = emit_node_type( @@ -892,10 +886,10 @@ pub fn emit_go_struct_field_from_child(child: Rc, env: Rc) -> Rc< } pub fn emit_go_sum_from_children( - name: Rc>, + name: String, children: Rc>>, env: Rc, -) -> Rc> { +) -> String { { let has_data = { let mut __found = false; @@ -1013,11 +1007,7 @@ pub fn emit_go_sum_from_children( } } -pub fn emit_go_variant_struct( - parent_name: Rc>, - child: Rc, - env: Rc, -) -> Rc> { +pub fn emit_go_variant_struct(parent_name: String, child: Rc, env: Rc) -> String { { let struct_name = v1_rt::concat( parent_name.clone(), @@ -1120,10 +1110,10 @@ pub fn emit_go_variant_struct( } pub fn emit_go_type_alias( - name: Rc>, + name: String, base: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1144,13 +1134,13 @@ pub fn emit_go_type_alias( } pub fn emit_go_fn_def( - name: Rc>, + name: String, params: Rc>>, inferred: Rc, body: Rc, registry: Rc>>, scope: Rc, -) -> Rc> { +) -> String { { let si = scope.type_env.clone().source_indices.clone(); let params_str = emit_params_shared(params.clone(), RenderTarget::Go, si.clone()); @@ -1249,14 +1239,14 @@ pub fn emit_go_fn_def( } pub fn emit_go_func_def( - name: Rc>, + name: String, params: Rc>>, inferred: Rc, uses: Rc>>, body: Rc, registry: Rc>>, scope: Rc, -) -> Rc> { +) -> String { { let service_names = match lookup_item(registry.clone(), name.clone()) { Some(info) => info.service_names.clone(), @@ -1333,7 +1323,7 @@ pub fn emit_go_func_params( uses: Rc>>, service_names: Rc>, source_indices: Rc>>, -) -> Rc> { +) -> String { { let param_strs = Rc::new({ let mut __result = Vec::new(); @@ -1387,7 +1377,7 @@ pub fn emit_go_typed_expr( scope: Rc, depth: i64, fuel: i64, -) -> Rc> { +) -> String { emit_unified_typed_expr( texpr, RenderTarget::Go, @@ -1407,10 +1397,10 @@ pub fn emit_go_typed_expr( pub fn emit_go_transport_body( transport: Rc, - op_name: Rc>, + op_name: String, source_indices: Rc>>, depth: i64, -) -> Rc> { +) -> String { emit_unified_transport_dispatch( transport, op_name, @@ -1428,7 +1418,7 @@ pub fn emit_go_service_def( item: Rc, registry: Rc>>, env: Rc, -) -> Rc> { +) -> String { emit_unified_service_def( item, RenderTarget::Go, @@ -1449,11 +1439,11 @@ pub fn emit_go_service_def( } pub fn emit_go_service_struct( - name: Rc>, + name: String, fallback_transport: Rc, op_children: Rc>>, source_indices: Rc>>, -) -> Rc> { +) -> String { { let fs = compute_service_fields(fallback_transport, op_children, source_indices); let decls = service_field_decls(fs, language_spec(RenderTarget::Go).service_fields.clone()); @@ -1518,11 +1508,11 @@ pub fn emit_go_service_struct( } pub fn emit_go_rest_call( - op_name: Rc>, + op_name: String, transport: Rc, depth: i64, source_indices: Rc>>, -) -> Rc> { +) -> String { { let prefix = make_indent(depth); let url_line = v1_rt::concat( @@ -1591,9 +1581,7 @@ pub fn emit_go_rest_call( v1_rt::concat( v1_rt::concat( Rc::new(vec![url_line, body_line, req_line]), - if (crate::v2_std_text::host_string_text_to_rust_host(auth_line.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (auth_line.clone().as_str() == "".to_string().as_str()) { Rc::new(vec![]) } else { Rc::new(vec![auth_line.clone()]) @@ -1608,11 +1596,11 @@ pub fn emit_go_rest_call( } pub fn emit_go_shell_call( - op_name: Rc>, + op_name: String, transport: Rc, depth: i64, source_indices: Rc>>, -) -> Rc> { +) -> String { { let prefix = make_indent(depth); let cmd_line = v1_rt::concat( @@ -1666,7 +1654,7 @@ pub fn emit_go_shell_call( } } -pub fn emit_go_file_call(op_name: Rc>, depth: i64) -> Rc> { +pub fn emit_go_file_call(op_name: String, depth: i64) -> String { { let prefix = make_indent(depth); v1_rt::concat( @@ -1689,7 +1677,7 @@ pub fn emit_go_file_call(op_name: Rc>, depth: i64) -> Rc>, depth: i64) -> Rc> { +pub fn emit_go_local_call(op_name: String, depth: i64) -> String { { let prefix = make_indent(depth); v1_rt::concat( @@ -1708,7 +1696,7 @@ pub fn emit_go_local_call(op_name: Rc>, depth: i64) -> Rc, env: Rc) -> Rc> { +pub fn emit_go_resource_def(item: Rc, env: Rc) -> String { { let item_text = authored_name(env.clone(), item.clone()); let cap_children = Rc::new({ @@ -1751,11 +1739,7 @@ pub fn emit_go_resource_def(item: Rc, env: Rc) -> Rc, - depth: i64, - env: Rc, -) -> Rc> { +pub fn emit_go_capability_method(cap_node: Rc, depth: i64, env: Rc) -> String { { let input_params = Rc::new({ let mut __result = Vec::new(); @@ -1806,13 +1790,13 @@ pub fn emit_go_capability_method( } pub fn emit_go_data_def( - name: Rc>, + name: String, type_node: Rc, value: Rc, registry: Rc>>, scope: Rc, depth: i64, -) -> Rc> { +) -> String { { let ty_str = emit_node_type( type_node, @@ -1836,7 +1820,7 @@ pub fn emit_go_data_def( } } -pub fn go_export_ident(name: Rc>) -> Rc> { +pub fn go_export_ident(name: String) -> String { match (*language_spec(RenderTarget::Go).visibility.clone()).clone() { VisibilitySpec::CaseVisibility { export_case: ec, .. @@ -1845,9 +1829,7 @@ pub fn go_export_ident(name: Rc>) -> Rc> { if { let mut __found = false; for r in go_reserved().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(r.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(result.clone())) - { + if (r.clone().as_str() == result.clone().as_str()) { __found = true; break; } diff --git a/src/v1/stage0/src/v1_compiler_emit_python.rs b/src/v1/stage0/src/v1_compiler_emit_python.rs index e0f79c73835..6c00b21f8fb 100644 --- a/src/v1/stage0/src/v1_compiler_emit_python.rs +++ b/src/v1/stage0/src/v1_compiler_emit_python.rs @@ -123,14 +123,13 @@ pub fn emit_python(typed: Rc) -> Rc { Rc::new({ let mut __result = Vec::new(); for p in test_projections.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - p.module_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at( + if (p.module_name.clone().as_str() + == authored_name_at( tm.type_env.clone().source_indices.clone(), tm.module.clone(), - ), - )) { + ) + .as_str()) + { __result.push(p); } } @@ -143,9 +142,7 @@ pub fn emit_python(typed: Rc) -> Rc { .iter() .cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(f.path.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (f.path.clone().as_str() != "".to_string().as_str()) { __result.push(f); } } @@ -164,7 +161,7 @@ pub fn emit_python(typed: Rc) -> Rc { } } -pub fn py_derive_attribute() -> Rc> { +pub fn py_derive_attribute() -> String { match serialization_for_target(RenderTarget::Python) .derive_attribute .clone() @@ -174,7 +171,7 @@ pub fn py_derive_attribute() -> Rc> { } } -pub fn py_default_value() -> Rc> { +pub fn py_default_value() -> String { match serialization_for_target(RenderTarget::Python) .default_value .clone() @@ -230,7 +227,7 @@ pub fn emit_init_py(modules: Rc>>) -> Rc { } } -pub fn python_test_signature_comment(projection: Rc) -> Rc> { +pub fn python_test_signature_comment(projection: Rc) -> String { { let params_str = Rc::new({ let mut __result = Vec::new(); @@ -280,7 +277,7 @@ pub fn python_test_signature_comment(projection: Rc) -> Rc>, + module_name: String, projections: Rc>>, ) -> Rc { if ((projections.clone().len() as i64) == 0) { @@ -322,7 +319,7 @@ pub fn emit_py_test_file( } } -pub fn emit_py_operation_test(projection: Rc, depth: i64) -> Rc> { +pub fn emit_py_operation_test(projection: Rc, depth: i64) -> String { { let test_name = test_function_name(projection.clone(), RenderTarget::Python); let indent = make_indent((depth.clone() + 1)); @@ -346,7 +343,7 @@ pub fn emit_py_mock_prop_setup( mock_prop: Rc, depth: i64, source_indices: Rc>>, -) -> Rc> { +) -> String { v1_rt::concat( v1_rt::concat( emit_ident( @@ -374,14 +371,11 @@ pub fn emit_py_module( let mod_name_str = authored_name_at(si.clone(), m.clone()); let prelude = emit_py_prelude(typed_module.clone()); let imports_str = emit_py_imports(module_imports(m.clone()), si.clone()); - let imports_section = - if (crate::v2_std_text::host_string_text_to_rust_host(imports_str.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { - "".to_string() - } else { - v1_rt::concat("\n".to_string(), imports_str.clone()) - }; + let imports_section = if (imports_str.clone().as_str() == "".to_string().as_str()) { + "".to_string() + } else { + v1_rt::concat("\n".to_string(), imports_str.clone()) + }; let items_str = Rc::new({ let mut __result = Vec::new(); for item in typed_module.items.clone().iter().cloned() { @@ -435,7 +429,7 @@ pub fn emit_py_module( pub fn emit_py_imports( imports: Rc>>, source_indices: Rc>>, -) -> Rc> { +) -> String { if ((imports.clone().len() as i64) == 0) { "".to_string() } else { @@ -506,9 +500,7 @@ pub fn emit_py_imports( Rc::new({ let mut __result = Vec::new(); for line in import_lines.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(line.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (line.clone().as_str() != "".to_string().as_str()) { __result.push(line); } } @@ -519,7 +511,7 @@ pub fn emit_py_imports( } } -pub fn emit_py_prelude(typed_module: Rc) -> Rc> { +pub fn emit_py_prelude(typed_module: Rc) -> String { { let items = typed_module.items.clone(); let has_structs = { @@ -589,7 +581,7 @@ pub fn emit_py_typed_item( item: Rc, registry: Rc>>, scope: Rc, -) -> Rc> { +) -> String { { let env = scope.type_env.clone(); let item_text = authored_name(env.clone(), item.clone()); @@ -657,7 +649,7 @@ pub fn emit_py_typed_item( } } -pub fn emit_py_type_def_from_connective(item: Rc, env: Rc) -> Rc> { +pub fn emit_py_type_def_from_connective(item: Rc, env: Rc) -> String { { let item_text = authored_name(env.clone(), item.clone()); let is_product = (item.connective.clone() == Connective::Conj); @@ -670,10 +662,10 @@ pub fn emit_py_type_def_from_connective(item: Rc, env: Rc) -> Rc< } pub fn emit_py_dataclass_from_children( - name: Rc>, + name: String, children: Rc>>, env: Rc, -) -> Rc> { +) -> String { if ((children.clone().len() as i64) == 0) { v1_rt::concat( v1_rt::concat( @@ -709,10 +701,7 @@ pub fn emit_py_dataclass_from_children( } } -pub fn emit_py_dataclass_field_from_child( - child: Rc, - env: Rc, -) -> Rc> { +pub fn emit_py_dataclass_field_from_child(child: Rc, env: Rc) -> String { { let ty = emit_node_type( resolved_type(child.clone()), @@ -746,10 +735,10 @@ pub fn emit_py_dataclass_field_from_child( } pub fn emit_py_enum_from_children( - name: Rc>, + name: String, children: Rc>>, env: Rc, -) -> Rc> { +) -> String { { let has_data = { let mut __found = false; @@ -839,10 +828,10 @@ pub fn emit_py_enum_from_children( } pub fn emit_py_variant_class_from_child( - parent_name: Rc>, + parent_name: String, child: Rc, env: Rc, -) -> Rc> { +) -> String { { let class_name = v1_rt::concat(parent_name, authored_name(env.clone(), child.clone())); if ((child.children.clone().len() as i64) == 0) { @@ -879,13 +868,13 @@ pub fn emit_py_variant_class_from_child( } pub fn emit_py_fn_def( - name: Rc>, + name: String, params: Rc>>, inferred: Rc, body: Rc, registry: Rc>>, scope: Rc, -) -> Rc> { +) -> String { { let depth = 0; let si = scope.type_env.clone().source_indices.clone(); @@ -984,14 +973,14 @@ pub fn emit_py_fn_def( } pub fn emit_py_func_def( - name: Rc>, + name: String, params: Rc>>, inferred: Rc, uses: Rc>>, body: Rc, registry: Rc>>, scope: Rc, -) -> Rc> { +) -> String { { let depth = 0; let service_names = match lookup_item(registry.clone(), name.clone()) { @@ -1069,7 +1058,7 @@ pub fn emit_py_func_params( uses: Rc>>, service_names: Rc>, source_indices: Rc>>, -) -> Rc> { +) -> String { { let param_strs = Rc::new({ let mut __result = Vec::new(); @@ -1123,7 +1112,7 @@ pub fn emit_py_typed_expr( scope: Rc, depth: i64, fuel: i64, -) -> Rc> { +) -> String { emit_unified_typed_expr( texpr, RenderTarget::Python, @@ -1143,10 +1132,10 @@ pub fn emit_py_typed_expr( pub fn emit_py_transport_body( transport: Rc, - op_name: Rc>, + op_name: String, source_indices: Rc>>, depth: i64, -) -> Rc> { +) -> String { emit_unified_transport_dispatch( transport, op_name, @@ -1164,7 +1153,7 @@ pub fn emit_py_service_def( item: Rc, registry: Rc>>, env: Rc, -) -> Rc> { +) -> String { emit_unified_service_def( item, RenderTarget::Python, @@ -1186,7 +1175,7 @@ pub fn emit_py_service_init( fallback_transport: Rc, op_children: Rc>>, source_indices: Rc>>, -) -> Rc> { +) -> String { { let fs = compute_service_fields(fallback_transport, op_children, source_indices); let params = service_field_decls( @@ -1224,10 +1213,10 @@ pub fn emit_py_service_init( } pub fn emit_py_rest_call( - op_name: Rc>, + op_name: String, transport: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { { let self_base_url = v1_rt::concat( v1_rt::concat("{".to_string(), "self.base_url".to_string()), @@ -1264,7 +1253,7 @@ pub fn emit_py_rest_call( pub fn emit_py_headers_dict( transport: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { { let auth_entry = if transport_has_auth(transport.clone(), source_indices.clone()) { { @@ -1302,9 +1291,7 @@ pub fn emit_py_headers_dict( } __result }); - let all_entries = if (crate::v2_std_text::host_string_text_to_rust_host(auth_entry.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + let all_entries = if (auth_entry.clone().as_str() == "".to_string().as_str()) { header_entries.join(&", ".to_string()) } else { v1_rt::concat(auth_entry.clone(), header_entries.join(&", ".to_string())) @@ -1317,10 +1304,10 @@ pub fn emit_py_headers_dict( } pub fn emit_py_shell_call( - op_name: Rc>, + op_name: String, transport: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { { let envs = transport_env(transport, source_indices.clone()); let env_dict_entries = Rc::new({ @@ -1384,7 +1371,7 @@ pub fn emit_py_shell_call( } } -pub fn emit_py_file_call(op_name: Rc>) -> Rc> { +pub fn emit_py_file_call(op_name: String) -> String { { let self_base_path = v1_rt::concat( v1_rt::concat("{".to_string(), "self.base_path".to_string()), @@ -1409,7 +1396,7 @@ pub fn emit_py_file_call(op_name: Rc>) -> Rc> { } } -pub fn emit_py_local_call(op_name: Rc>) -> Rc> { +pub fn emit_py_local_call(op_name: String) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1422,7 +1409,7 @@ pub fn emit_py_local_call(op_name: Rc>) -> Rc> { ) } -pub fn emit_py_resource_def(item: Rc, env: Rc) -> Rc> { +pub fn emit_py_resource_def(item: Rc, env: Rc) -> String { { let item_text = authored_name(env.clone(), item.clone()); let depth = 0; @@ -1461,7 +1448,7 @@ pub fn emit_py_resource_def(item: Rc, env: Rc) -> Rc, env: Rc) -> Rc> { +pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> String { { let input_params = Rc::new({ let mut __result = Vec::new(); @@ -1484,9 +1471,7 @@ pub fn emit_py_capability_method(cap_node: Rc, env: Rc) -> Rc, env: Rc) -> Rc>, + name: String, type_node: Rc, value: Rc, registry: Rc>>, scope: Rc, -) -> Rc> { +) -> String { { let ty_str = emit_node_type( type_node, diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index f155161bd79..ec4d51a09a6 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -162,11 +162,9 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn is_witness_type_name(name: Rc>) -> bool { - ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("witness".to_string()))) +pub fn is_witness_type_name(name: String) -> bool { + ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -201,7 +199,7 @@ pub struct InferScope { pub func_env: Rc, pub locals: Rc>>, pub match_bound_names: Rc>, - pub module_name: Rc>, + pub module_name: String, pub service_registry: Rc>>>>, pub item_registry: Rc>>, pub lambda_param_provenance: Rc>>, @@ -519,11 +517,11 @@ pub fn merge_scope_from_imports( } } -pub fn nominal_leaf_type(name: Rc>) -> Rc { +pub fn nominal_leaf_type(name: String) -> Rc { nominal_type_ref(name) } -pub fn nominal_type_binding(name: Rc>) -> Rc { +pub fn nominal_type_binding(name: String) -> Rc { Rc::new(TypeBinding { name: name.clone(), resolved: nominal_leaf_type(name.clone()), @@ -534,12 +532,12 @@ pub fn nominal_type_binding(name: Rc>) -> Rc { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FieldRecursionResult { pub shape: RecursionShape, - pub element_type: Rc>, + pub element_type: String, } pub fn classify_field_recursion( field_node: Rc, - parent_name: Rc>, + parent_name: String, recursive_type_set: Rc>, source_indices: Rc>>, ) -> Option> { @@ -549,9 +547,7 @@ pub fn classify_field_recursion( _ => field_node_type_expr(field_node.clone()), }; let field_type_name = authored_name_at(source_indices.clone(), type_expr.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(field_type_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(parent_name.clone())) - { + if (field_type_name.clone().as_str() == parent_name.clone().as_str()) { match field_node.return_cardinality.clone() { Cardinality::CardOptional => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::OptionalRecursion, @@ -579,23 +575,17 @@ pub fn classify_field_recursion( Some(t) => authored_name_at(source_indices.clone(), t.clone()), None => "".to_string(), }; - let is_recursive_element = - ((crate::v2_std_text::host_string_text_to_rust_host(value_type.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - parent_name.clone(), - )) - || v1_rt::set_contains(&recursive_type_set, value_type.clone())); + let is_recursive_element = ((value_type.clone().as_str() + == parent_name.clone().as_str()) + || v1_rt::set_contains(&recursive_type_set, value_type.clone())); if is_recursive_element { { - let elem = if (crate::v2_std_text::host_string_text_to_rust_host( - value_type.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - parent_name.clone(), - )) { - parent_name.clone() - } else { - value_type.clone() - }; + let elem = + if (value_type.clone().as_str() == parent_name.clone().as_str()) { + parent_name.clone() + } else { + value_type.clone() + }; match field_type_name.clone().as_str() { "List" => Some(Rc::new(FieldRecursionResult { shape: RecursionShape::ListRecursion, @@ -638,8 +628,8 @@ pub fn classify_field_recursion( pub fn collect_fields_inductive( fields: Rc>>, - parent_name: Rc>, - variant_name: Rc>, + parent_name: String, + variant_name: String, recursive_type_set: Rc>, acc: Rc>>>>, source_indices: Rc>>, @@ -676,7 +666,7 @@ pub fn collect_item_inductive_fields( let item_name = authored_name_at(source_indices.clone(), item.clone()); match item.connective.clone() { Connective::Disj => item.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), |variant_acc: Rc>>>>, variant_node: Rc| { collect_fields_inductive( @@ -694,10 +684,10 @@ pub fn collect_item_inductive_fields( item_name.clone(), "".to_string(), recursive_type_set.clone(), - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), source_indices.clone(), ), - _ => v1_rt::rc_empty_map::>, Rc>>>(), + _ => v1_rt::rc_empty_map::>>>(), } } } @@ -708,7 +698,7 @@ pub fn build_item_inductive_fields( source_indices: Rc>>, ) -> Rc>>>> { items.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, item: Rc| { merge_inductive_fields( acc, @@ -723,7 +713,7 @@ pub fn build_item_inductive_fields( } pub fn nominal_ref_node( - name: Rc>, + name: String, span: Rc, ident_span: Option>, ) -> Rc { @@ -757,18 +747,15 @@ pub fn resolved_callable_type(func_params: Rc>>, ret: Rc) -> pub fn namespace_root_from_properties( properties: Rc>>, - name: Rc>, + name: String, source_indices: Rc>>, -) -> Rc> { +) -> String { match Rc::new({ let mut __result = Vec::new(); for p in properties.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( - p.clone(), - source_indices.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - "namespace_root".to_string(), - )) { + if (field_init_node_name_at(p.clone(), source_indices.clone()).as_str() + == "namespace_root".to_string().as_str()) + { __result.push(p); } } @@ -803,18 +790,15 @@ pub fn ok_infer(texpr: Rc) -> Rc { }) } -pub fn semantic_expr_error_node(message: Rc>, span: Rc) -> Rc { +pub fn semantic_expr_error_node(message: String, span: Rc) -> Rc { make_expr_error_node(ExprErrorKind::SemanticExprError, message, span) } -pub fn internal_expr_error_node(message: Rc>, span: Rc) -> Rc { +pub fn internal_expr_error_node(message: String, span: Rc) -> Rc { make_expr_error_node(ExprErrorKind::InternalExprError, message, span) } -pub fn lookup_variant_parent_enum( - scope: Rc, - name: Rc>, -) -> Rc> { +pub fn lookup_variant_parent_enum(scope: Rc, name: String) -> Option { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { Some(binding) => match lookup_type_for(scope.type_env.clone(), binding.resolved.clone()) { Some(parent) => { @@ -842,10 +826,7 @@ pub fn lookup_variant_parent_enum( } } -pub fn infer_var_binding_kind( - scope: Rc, - name: Rc>, -) -> Rc { +pub fn infer_var_binding_kind(scope: Rc, name: String) -> Rc { match lookup_variant_parent_enum(scope.clone(), name.clone()) { Some(parent_enum) => Rc::new(VarBindingKind::VariantValueBinding { parent_enum: parent_enum.clone(), @@ -864,9 +845,9 @@ pub fn infer_var_binding_kind( } pub fn inference_error( - message: Rc>, + message: String, span: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::InternalError { @@ -878,10 +859,10 @@ pub fn inference_error( } pub fn type_mismatch_error( - expected: Rc>, - got: Rc>, + expected: String, + got: String, span: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::TypeMismatch { @@ -904,16 +885,13 @@ pub fn rejects_string_for_optional_coproduct_field( == Cardinality::CardOptional) && (expected_inner.connective.clone() == Connective::Disj)); let got_is_string = - (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices, - got, - )) == crate::v2_std_text::host_string_text_to_rust_host("String".to_string())); + (authored_name_at(source_indices, got).as_str() == "String".to_string().as_str()); (expected_is_optional_coproduct && got_is_string) } } pub fn record_lit_expected_fields( - type_name: Rc>, + type_name: Option, scope: Rc, ) -> Rc>> { match type_name { @@ -925,14 +903,13 @@ pub fn record_lit_expected_fields( Some(parent) => match Rc::new({ let mut __result = Vec::new(); for v in parent.children.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at( - scope.type_env.clone().source_indices.clone(), - v.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host( - tn.clone(), - )) { + if (authored_name_at( + scope.type_env.clone().source_indices.clone(), + v.clone(), + ) + .as_str() + == tn.clone().as_str()) + { __result.push(v); } } @@ -955,17 +932,19 @@ pub fn record_lit_expected_fields( } pub fn record_lit_expanded_from_expected( - type_name: Rc>, + type_name: Option, expected: Option>, scope: Rc, ) -> Option> { match type_name { Some(tn) => match expected { Some(exp) => { - if (((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + if (((authored_name_at( scope.type_env.clone().source_indices.clone(), exp.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) + ) + .as_str() + == tn.clone().as_str()) && (exp.connective.clone() == Connective::Conj)) && ((exp.children.clone().len() as i64) > 0)) { @@ -973,12 +952,12 @@ pub fn record_lit_expanded_from_expected( } else { match exp.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: expanded, .. }) => { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at( - scope.type_env.clone().source_indices.clone(), - expanded.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) + if (authored_name_at( + scope.type_env.clone().source_indices.clone(), + expanded.clone(), + ) + .as_str() + == tn.clone().as_str()) { Some(expanded.clone()) } else { @@ -987,12 +966,12 @@ pub fn record_lit_expanded_from_expected( } _ => { let rt = resolved_type(exp.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at( - scope.type_env.clone().source_indices.clone(), - rt.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) + if (authored_name_at( + scope.type_env.clone().source_indices.clone(), + rt.clone(), + ) + .as_str() + == tn.clone().as_str()) { Some(rt.clone()) } else { @@ -1009,7 +988,7 @@ pub fn record_lit_expanded_from_expected( } pub fn record_lit_fields_from_expected( - type_name: Rc>, + type_name: Option, expected: Option>, scope: Rc, ) -> Option>>> { @@ -1028,17 +1007,16 @@ pub fn record_lit_fields_from_expected( } pub fn record_lit_instantiated_fields( - type_name: Rc>, + type_name: Option, expected: Option>, scope: Rc, ) -> Option>>> { match type_name.clone() { Some(tn) => match expected { Some(exp) => { - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - scope.type_env.clone().source_indices.clone(), - exp.clone(), - )) != crate::v2_std_text::host_string_text_to_rust_host(tn.clone())) + if (authored_name_at(scope.type_env.clone().source_indices.clone(), exp.clone()) + .as_str() + != tn.clone().as_str()) { None } else { @@ -1053,7 +1031,7 @@ pub fn record_lit_instantiated_fields( None } else { { - let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pair: (i64, Rc)| { + let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { let slot = authored_name_at(scope.type_env.clone().source_indices.clone(), pair.1.clone()); match exp.children.clone().get(pair.0.clone() as usize).cloned() { Some(arg) => v1_rt::rc_map_insert(acc.clone(), slot.clone(), resolved_type(arg.clone())), @@ -1205,22 +1183,13 @@ pub fn type_node_is_callable(n: Rc) -> bool { ((n.params.clone().len() as i64) > 0) } -pub fn module_skips_direct_call_arg_check(module_name: Rc>) -> bool { +pub fn module_skips_direct_call_arg_check(module_name: String) -> bool { { let is_v4 = ((v1_rt::string_length(&module_name) >= 3) - && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( - &module_name, - 0, - 3, - )) == crate::v2_std_text::host_string_text_to_rust_host("v2.".to_string()))); + && (v1_rt::substring(&module_name, 0, 3).as_str() == "v2.".to_string().as_str())); let is_compiler_substrate = ((v1_rt::string_length(&module_name) >= 13) - && (crate::v2_std_text::host_string_text_to_rust_host(v1_rt::substring( - &module_name, - 0, - 13, - )) == crate::v2_std_text::host_string_text_to_rust_host( - "v1.compiler.".to_string(), - ))); + && (v1_rt::substring(&module_name, 0, 13).as_str() + == "v1.compiler.".to_string().as_str())); (is_v4 || is_compiler_substrate) } } @@ -1235,17 +1204,13 @@ pub fn nominal_call_arg_brand_mismatch( let actual_name = authored_name_at(source_indices.clone(), actual.clone()); ((((((((formal.connective.clone() != Connective::Arrow) && (actual.connective.clone() != Connective::Arrow)) - && (crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) - && (crate::v2_std_text::host_string_text_to_rust_host(actual_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) - && (crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host(actual_name.clone()))) - && (crate::v2_std_text::host_string_text_to_rust_host( - structural_carrier_template_name(formal.clone(), source_indices.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - structural_carrier_template_name(actual.clone(), source_indices.clone()), - ))) + && (formal_name.clone().as_str() != "".to_string().as_str())) + && (actual_name.clone().as_str() != "".to_string().as_str())) + && (formal_name.clone().as_str() != actual_name.clone().as_str())) + && (structural_carrier_template_name(formal.clone(), source_indices.clone()) + .as_str() + == structural_carrier_template_name(actual.clone(), source_indices.clone()) + .as_str())) && !is_declared_container_alias_spelling(formal_name.clone())) && !is_declared_container_alias_spelling(actual_name.clone())) } @@ -1255,18 +1220,13 @@ pub fn container_element_nominal_brand_mismatch( formal: Rc, actual: Rc, type_env: Rc, - module_name: Rc>, + module_name: String, source_indices: Rc>>, ) -> bool { if ((node_is_element_collection(formal.clone(), source_indices.clone()) && node_is_element_collection(actual.clone(), source_indices.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - formal.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - actual.clone(), - )))) + && (authored_name_at(source_indices.clone(), formal.clone()).as_str() + == authored_name_at(source_indices.clone(), actual.clone()).as_str())) { match formal.children.clone().first().cloned() { Some(formal_ch) => match actual.children.clone().first().cloned() { @@ -1296,7 +1256,7 @@ pub fn direct_call_arg_type_mismatch( formal: Rc, actual: Rc, type_env: Rc, - module_name: Rc>, + module_name: String, source_indices: Rc>>, ) -> bool { if (type_node_is_callable(formal.clone()) || type_node_is_callable(actual.clone())) { @@ -1318,7 +1278,7 @@ pub fn direct_call_arg_mismatch_diags( typed_args: Rc>>, call_subst: Rc>>, type_env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc>> { { let source_indices = type_env.source_indices.clone(); @@ -1392,15 +1352,13 @@ pub struct Tier2bBt { } pub fn infer_tier2b_builtin_with_kernel_diags( - func_name: Rc>, + func_name: String, typed_args: Rc>>, scope: Rc, span: Rc, ) -> Rc { - if ((crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("lookup".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("map_get".to_string()))) + if ((func_name.clone().as_str() == "lookup".to_string().as_str()) + || (func_name.clone().as_str() == "map_get".to_string().as_str())) { Rc::new(Tier2bBt { bt: match typed_args.clone().first().cloned() { @@ -1416,11 +1374,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }) => { match map_value_type_in_env(receiver_type.clone(), scope.type_env.clone()) { Some(value_type) => { - if (crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "lookup".to_string(), - )) { + if (func_name.clone().as_str() == "lookup".to_string().as_str()) { witness_of_element(value_type.clone()) } else { with_optional_cardinality(value_type.clone()) @@ -1436,9 +1390,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( kernel_diags: Rc::new(vec![]), }) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("map_keys".to_string())) - { + if (func_name.clone().as_str() == "map_keys".to_string().as_str()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1475,9 +1427,7 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("map_values".to_string())) - { + if (func_name.clone().as_str() == "map_values".to_string().as_str()) { match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1515,31 +1465,15 @@ pub fn infer_tier2b_builtin_with_kernel_diags( }), } } else { - if (((crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "set_insert".to_string(), - )) - || (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "set_union".to_string(), - ))) - || (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "set_contains".to_string(), - ))) + if (((func_name.clone().as_str() == "set_insert".to_string().as_str()) + || (func_name.clone().as_str() == "set_union".to_string().as_str())) + || (func_name.clone().as_str() == "set_contains".to_string().as_str())) { { - let operand_elem = if ((crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "set_insert".to_string(), - )) - || (crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "set_contains".to_string(), - ))) { + let operand_elem = if ((func_name.clone().as_str() + == "set_insert".to_string().as_str()) + || (func_name.clone().as_str() == "set_contains".to_string().as_str())) + { match typed_args.clone().get(1 as usize).cloned() { Some(insert_arg) => match arg_value(insert_arg.clone()) .inferred @@ -1582,22 +1516,18 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } None => false, }; - let union_other_bad = if (crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "set_union".to_string(), - )) { - match typed_args.clone().get(1 as usize).cloned() { - Some(other_arg) => set_union_other_operand_is_resolved_non_set( - other_arg.clone(), - scope.clone(), - ), - None => false, - } - } else { - false - }; + let union_other_bad = + if (func_name.clone().as_str() == "set_union".to_string().as_str()) { + match typed_args.clone().get(1 as usize).cloned() { + Some(other_arg) => set_union_other_operand_is_resolved_non_set( + other_arg.clone(), + scope.clone(), + ), + None => false, + } + } else { + false + }; let recv_elem = match typed_args.clone().first().cloned() { Some(receiver_arg) => match arg_value(receiver_arg.clone()) .inferred @@ -1660,11 +1590,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( } else { Rc::new(vec![]) }; - let result_bt = if (crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "set_contains".to_string(), - )) { + let result_bt = if (func_name.clone().as_str() + == "set_contains".to_string().as_str()) + { if (recv_is_set.clone() && !elem_mismatch.clone()) { bool_type() } else { @@ -1707,12 +1635,9 @@ pub fn infer_tier2b_builtin_with_kernel_diags( None => resolve_builtin_call_type(func_name.clone()), } }; - let build_diags = if (crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "set_contains".to_string(), - )) { + let build_diags = if (func_name.clone().as_str() + == "set_contains".to_string().as_str()) + { Rc::new(vec![]) } else { match operand_elem.clone() { @@ -1760,13 +1685,11 @@ pub struct MethodPipeFallback { pub fn method_pipe_map_keys_values_fallback( recv_rt: Rc, - method_name: Rc>, + method_name: String, scope: Rc, span: Rc, ) -> Rc { - if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("map_keys".to_string())) - { + if (method_name.clone().as_str() == "map_keys".to_string().as_str()) { match map_key_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(key_type) => { let lk = list_kernel_ty_from_element(key_type.clone()); @@ -1781,9 +1704,7 @@ pub fn method_pipe_map_keys_values_fallback( }), } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("map_values".to_string())) - { + if (method_name.clone().as_str() == "map_values".to_string().as_str()) { match map_value_type_in_env(recv_rt.clone(), scope.type_env.clone()) { Some(value_type) => { let lv = list_kernel_ty_from_element(value_type.clone()); @@ -1807,10 +1728,10 @@ pub fn method_pipe_map_keys_values_fallback( } pub fn categorized_error( - message: Rc>, + message: String, span: Rc, - module_name: Rc>, - category: Rc>, + module_name: String, + category: String, ) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::InternalError { @@ -1823,17 +1744,15 @@ pub fn categorized_error( pub fn validate_cast( source_inferred: Option>, - target_name: Rc>, + target_name: String, span: Rc, source_indices: Rc>>, - module_name: Rc>, + module_name: String, ) -> Option> { match source_inferred.as_deref().cloned() { Some(InferredNode::Resolved { node: src_node, .. }) => { let source_name = authored_name_at(source_indices, src_node.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(source_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(target_name.clone())) - { + if (source_name.clone().as_str() == target_name.clone().as_str()) { None } else { if !is_dag_cast_domain_type(source_name.clone()) { @@ -1871,7 +1790,7 @@ pub fn validate_cast( } } -pub fn type_variable_node(id: Rc>) -> Rc { +pub fn type_variable_node(id: String) -> Rc { Rc::new(Node { name: "".to_string(), span: make_span(0, 0), @@ -1903,7 +1822,7 @@ pub fn is_type_variable(inferred: Rc) -> bool { pub fn inferred_or_error( result: Option>, - fallback_message: Rc>, + fallback_message: String, fallback_span: Rc, ) -> Rc { match result { @@ -1961,48 +1880,23 @@ pub fn annotate_pattern_parent_enums( let optional_cardinality_subject = ((resolved_scrut_node.return_cardinality.clone() == Cardinality::CardOptional) - && (crate::v2_std_text::host_string_text_to_rust_host( - scrutinee_name.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "Optional".to_string(), - ))); - let optional_coproduct_subject = - ((crate::v2_std_text::host_string_text_to_rust_host( - scrutinee_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Optional".to_string(), - )) && ((crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Present".to_string(), - )) || (crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "Absent".to_string(), - )))); + && (scrutinee_name.clone().as_str() + != "Optional".to_string().as_str())); + let optional_coproduct_subject = ((scrutinee_name.clone().as_str() + == "Optional".to_string().as_str()) + && ((variant_name.clone().as_str() == "Present".to_string().as_str()) + || (variant_name.clone().as_str() + == "Absent".to_string().as_str()))); let witness_container_subject = (is_witness_type_name(scrutinee_name.clone()) - && ((crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Holds".to_string(), - )) || (crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "Violates".to_string(), - )))); + && ((variant_name.clone().as_str() + == "Holds".to_string().as_str()) + || (variant_name.clone().as_str() + == "Violates".to_string().as_str()))); if ((optional_cardinality_subject || optional_coproduct_subject) - && ((crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Present".to_string(), - )) || (crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Absent".to_string(), - )))) + && ((variant_name.clone().as_str() == "Present".to_string().as_str()) + || (variant_name.clone().as_str() + == "Absent".to_string().as_str()))) { Some("Optional".to_string()) } else { @@ -2109,15 +2003,14 @@ pub fn build_params_scope(scope: Rc, params: Rc>>) -> R module_name: scope.module_name.clone(), service_registry: scope.service_registry.clone(), item_registry: scope.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>( - ), + lambda_param_provenance: v1_rt::rc_empty_map::>(), }) } } pub fn extend_scope( scope: Rc, - name: Rc>, + name: String, resolved: Rc, provenance: Rc, ) -> Rc { @@ -2143,7 +2036,7 @@ pub fn extend_scope( pub fn extend_scope_match_bound( scope: Rc, - name: Rc>, + name: String, resolved: Rc, provenance: Rc, ) -> Rc { @@ -2175,7 +2068,7 @@ pub fn extend_scope_with_params(scope: Rc, params: Rc>) { let new_locals = params.iter().cloned().fold( scope.locals.clone(), - |acc: Rc>>, p: Rc>| { + |acc: Rc>>, p: String| { v1_rt::rc_map_insert( acc, p.clone(), @@ -2235,8 +2128,8 @@ pub fn derive_field_provenance( scope: Rc, scrutinee_provenance: Rc, scrutinee_subject: Rc, - variant_name: Rc>, - field_name: Rc>, + variant_name: String, + field_name: String, ) -> Rc { match (*scrutinee_provenance.clone()).clone() { SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), @@ -2248,9 +2141,7 @@ pub fn derive_field_provenance( ), _ => "".to_string(), }; - if (crate::v2_std_text::host_string_text_to_rust_host(scrut_type_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (scrut_type_name.clone().as_str() == "".to_string().as_str()) { Rc::new(SubValueRelation::SubValueUnknown) } else { { @@ -2259,15 +2150,9 @@ pub fn derive_field_provenance( let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((crate::v2_std_text::host_string_text_to_rust_host( - f.variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - )) && (crate::v2_std_text::host_string_text_to_rust_host( - f.field_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - field_name.clone(), - ))) { + if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) + && (f.field_name.clone().as_str() == field_name.clone().as_str())) + { __result.push(f); } } @@ -2390,18 +2275,17 @@ pub fn extend_scope_with_pattern_node( }) } -pub fn method_name_is(opt: Rc>, expected: Rc>) -> bool { +pub fn method_name_is(opt: Option, expected: String) -> bool { if (opt.clone() == None) { false } else { - (crate::v2_std_text::host_string_text_to_rust_host(opt.clone().unwrap()) - == crate::v2_std_text::host_string_text_to_rust_host(expected)) + (opt.clone().unwrap().as_str() == expected.as_str()) } } pub fn arg_has_name( arg: Rc, - name: Rc>, + name: String, source_indices: Rc>>, ) -> bool { { @@ -2409,14 +2293,13 @@ pub fn arg_has_name( if (n.clone() == None) { false } else { - (crate::v2_std_text::host_string_text_to_rust_host(n.clone().unwrap()) - == crate::v2_std_text::host_string_text_to_rust_host(name)) + (n.clone().unwrap().as_str() == name.as_str()) } } } pub fn extract_fold_init_info( - method_name: Rc>, + method_name: Option, method_args: Rc>>, min_args: i64, scope: Rc, @@ -2481,10 +2364,12 @@ pub fn derive_element_provenance( match (*coll_prov).clone() { SubValueRelation::SubValueUnknown => Rc::new(SubValueRelation::SubValueUnknown), _ => { - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + if (authored_name_at( scope.type_env.clone().source_indices.clone(), elem_type.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + ) + .as_str() + == "".to_string().as_str()) { Rc::new(SubValueRelation::SubValueUnknown) } else { @@ -2524,7 +2409,7 @@ pub fn derive_element_provenance( } pub fn infer_method_args_with_fold( - method_name: Rc>, + method_name: Option, method_args: Rc>>, fold_info: Option>, fold_acc_type: Rc, @@ -2609,16 +2494,11 @@ pub fn infer_method_args_with_fold( }); let lam_value = arg_value(a.clone()); let prov_map = match (*elem_provenance.clone()).clone() { - SubValueRelation::SubValueUnknown => v1_rt::rc_empty_map::< - Rc>, - Rc, - >( - ), + SubValueRelation::SubValueUnknown => { + v1_rt::rc_empty_map::>() + } _ => v1_rt::rc_map_insert( - v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + v1_rt::rc_empty_map::>(), "elem".to_string(), elem_provenance.clone(), ), @@ -2655,16 +2535,11 @@ pub fn infer_method_args_with_fold( { let nf_lam_value = arg_value(a.clone()); let nf_prov_map = match (*elem_provenance.clone()).clone() { - SubValueRelation::SubValueUnknown => v1_rt::rc_empty_map::< - Rc>, - Rc, - >( - ), + SubValueRelation::SubValueUnknown => { + v1_rt::rc_empty_map::>() + } _ => v1_rt::rc_map_insert( - v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + v1_rt::rc_empty_map::>(), "elem".to_string(), elem_provenance.clone(), ), @@ -2714,17 +2589,14 @@ pub fn is_record_lit_expr(e: Rc) -> bool { pub fn seed_override_map() -> Rc>> { Rc::new(vec!["".to_string()]).iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), - |acc: Rc>>, k: Rc>| { + v1_rt::rc_empty_map::>(), + |acc: Rc>>, k: String| { v1_rt::rc_map_insert(acc, k.clone(), unit_type()) }, ) } -pub fn fold_override_map( - key: Rc>, - value: Rc, -) -> Rc>> { +pub fn fold_override_map(key: String, value: Rc) -> Rc>> { v1_rt::rc_map_insert(seed_override_map(), key, value) } @@ -3071,7 +2943,7 @@ pub fn infer_expr( && (sig.clone() == None)) { Rc::new(ArgGenericFoldState { - subst: v1_rt::rc_empty_map::>, Rc>(), + subst: v1_rt::rc_empty_map::>(), results: match call_args.clone().first().cloned() { Some(first_arg) => { let first_result = @@ -3166,7 +3038,7 @@ pub fn infer_expr( .fold( Rc::new(ArgGenericFoldState { results: Rc::new(vec![]), - subst: v1_rt::rc_empty_map::>, Rc>(), + subst: v1_rt::rc_empty_map::>(), }), |st: Rc, pair: (i64, Rc)| { let a = pair.1.clone(); @@ -3553,11 +3425,7 @@ pub fn infer_expr( }) } } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "empty_map".to_string(), - )) { + if (func_name.clone().as_str() == "empty_map".to_string().as_str()) { { let bare_m = bare_map_node(); match expected.clone() { @@ -3621,11 +3489,8 @@ match bare_m { } } } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - func_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "empty_set".to_string(), - )) { + if (func_name.clone().as_str() == "empty_set".to_string().as_str()) + { { let bare_s = bare_set_node(); match expected.clone() { @@ -3698,11 +3563,13 @@ match bare_s { span.clone(), ); let bt = tier2b.bt.clone(); - let call_semantics = if (crate::v2_std_text::host_string_text_to_rust_host(func_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("lookup".to_string())) { - Some(CallSemantics::LookupCallSemantics) - } else { - Some(CallSemantics::PlainCallSemantics) - }; + let call_semantics = if (func_name.clone().as_str() + == "lookup".to_string().as_str()) + { + Some(CallSemantics::LookupCallSemantics) + } else { + Some(CallSemantics::PlainCallSemantics) + }; Rc::new(InferResult { typed: make_named_expr_node( func_name.clone(), @@ -4430,12 +4297,12 @@ match bare_s { ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + (authored_name_at( scope.type_env.clone().source_indices.clone(), bd.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - let_name.clone(), - )) + ) + .as_str() + == let_name.clone().as_str()) } _ => false, }, @@ -4811,10 +4678,7 @@ match bare_s { module_name: lam_scope.module_name.clone(), service_registry: lam_scope.service_registry.clone(), item_registry: lam_scope.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let body_result = infer_expr(lam_body, body_scope, body_expected); let body_typed = body_result.typed.clone(); @@ -5222,7 +5086,7 @@ match bare_s { } pub fn infer_variant_constructor_call( - func_name: Rc>, + func_name: String, call_args: Rc>>, span: Rc, name_span: Rc, @@ -5383,7 +5247,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { pub fn peel_alias_once_for_field_access( mut n: Rc, mut env: Rc, - mut module_name: Rc>, + mut module_name: String, ) -> Rc { loop { let once = resolve_node(n, env.clone(), module_name.clone()) @@ -5442,11 +5306,7 @@ pub fn record_field_type_is_unresolved_param( let in_params = { let mut __found = false; for pn in param_names.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(pn.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - fname.clone(), - )) - { + if (pn.clone().as_str() == fname.clone().as_str()) { __found = true; break; } @@ -5494,8 +5354,8 @@ pub fn record_has_unresolved_param_field(record: Rc, env: Rc) -> pub fn expand_alias_chain_for_field_access( mut n: Rc, mut env: Rc, - mut module_name: Rc>, - mut origin_name: Rc>, + mut module_name: String, + mut origin_name: String, mut seen: Rc>, mut lossy: bool, ) -> Rc { @@ -5520,9 +5380,7 @@ pub fn expand_alias_chain_for_field_access( } else { let next_name = structural.name.clone(); let is_optional = (structural.return_cardinality.clone() == Cardinality::CardOptional); - let stop = ((is_optional - || (crate::v2_std_text::host_string_text_to_rust_host(next_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + let stop = ((is_optional || (next_name.clone().as_str() == "".to_string().as_str())) || emit_map_has(seen.clone(), next_name.clone())); if stop { break structural.clone(); @@ -5554,7 +5412,7 @@ pub fn expand_alias_chain_for_field_access( pub fn expand_type_for_field_access( n: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { if is_deferred_field_access_base(n.clone(), env.clone()) { n.clone() @@ -5566,7 +5424,7 @@ pub fn expand_type_for_field_access( env.clone(), module_name, origin_name, - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), false, ) } @@ -5574,7 +5432,7 @@ pub fn expand_type_for_field_access( } pub fn record_lit_alias_struct_fields( - type_name: Rc>, + type_name: String, scope: Rc, ) -> Option>>> { match lookup_type_by_name(scope.type_env.clone(), type_name) { @@ -5702,7 +5560,7 @@ pub fn field_in_any_variant_named(type_name: String, field: String, scope: Rc>, + type_name: Option, field_inits: Rc>>, span: Rc, name_span: Rc, @@ -5797,14 +5655,13 @@ pub fn infer_record_lit( let field_expected = match Rc::new({ let mut __result = Vec::new(); for sf in struct_fields.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at( - scope.type_env.clone().source_indices.clone(), - sf.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host( - fi_name.clone(), - )) { + if (authored_name_at( + scope.type_env.clone().source_indices.clone(), + sf.clone(), + ) + .as_str() + == fi_name.clone().as_str()) + { __result.push(sf); } } @@ -5979,25 +5836,22 @@ pub fn infer_record_lit( None => error_type(), }; let expected_optional_parent = Some("Optional".to_string()); - let is_present_ctor = ((crate::v2_std_text::host_string_text_to_rust_host( - type_name.clone().unwrap(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Present".to_string(), - )) && (local_variant_parent.clone().as_deref() - == expected_optional_parent.as_deref())); + let is_present_ctor = ((type_name.clone().unwrap().as_str() + == "Present".to_string().as_str()) + && (local_variant_parent.clone().as_deref() + == expected_optional_parent.as_deref())); let resolved_node = if is_present_ctor { { let val_field = Rc::new({ let mut __result = Vec::new(); for fir in fi_infer_results.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - field_init_node_name_at( - fir.typed_field.clone(), - scope.type_env.clone().source_indices.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "value".to_string(), - )) { + if (field_init_node_name_at( + fir.typed_field.clone(), + scope.type_env.clone().source_indices.clone(), + ) + .as_str() + == "value".to_string().as_str()) + { __result.push(fir); } } @@ -6055,16 +5909,11 @@ pub fn infer_record_lit( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum SizeExpr { - ParamSize { - param: Rc>, - }, - DividedSize { - param: Rc>, - divisor: i64, - }, + ParamSize { param: String }, + DividedSize { param: String, divisor: i64 }, } impl SizeExpr { - pub fn param(&self) -> Rc> { + pub fn param(&self) -> String { match self { SizeExpr::ParamSize { param: __val, .. } => __val.clone(), SizeExpr::DividedSize { param: __val, .. } => __val.clone(), @@ -6074,7 +5923,7 @@ impl SizeExpr { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DescentContext { - pub fn_name: Rc>, + pub fn_name: String, pub param_names: Rc>, pub param_order: Rc>, pub type_env: Rc, @@ -6093,9 +5942,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option { let mname = expr_method_name_at(val.clone(), ctx.type_env.clone().source_indices.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(mname) - == crate::v2_std_text::host_string_text_to_rust_host("count".to_string())) - { + if (mname.as_str() == "count".to_string().as_str()) { { let receiver = method_receiver(val.clone()); match (*receiver.expr_data.clone()).clone() { @@ -6172,7 +6019,7 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option, lit_expr: Rc, - param_name: Rc>, + param_name: String, ctx: Rc, ) -> Option> { match (*alias_expr.expr_data.clone()).clone() { @@ -6192,9 +6039,7 @@ pub fn proportional_skip_alias_plus_literal( divisor: d, .. }) => { - if (crate::v2_std_text::host_string_text_to_rust_host(p.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) - { + if (p.clone().as_str() == param_name.clone().as_str()) { match (*lit_expr.expr_data.clone()).clone() { ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { @@ -6238,7 +6083,7 @@ pub fn proportional_skip_alias_plus_literal( pub fn classify_collection_shrink( arg_expr: Rc, - param_name: Rc>, + param_name: String, ctx: Rc, ) -> Rc { match (*arg_expr.expr_data.clone()).clone() { @@ -6250,10 +6095,8 @@ pub fn classify_collection_shrink( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("take".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string()))) + if ((mname.clone().as_str() == "take".to_string().as_str()) + || (mname.clone().as_str() == "skip".to_string().as_str())) { { let receiver = method_receiver(arg_expr.clone()); @@ -6265,19 +6108,24 @@ pub fn classify_collection_shrink( receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (crate::v2_std_text::host_string_text_to_rust_host(rname) - == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) - { + if (rname.as_str() == param_name.clone().as_str()) { { let args = method_arg_nodes(arg_expr.clone()); match args.first().cloned() { Some(arg_node) => { let arg_val = arg_value(arg_node.clone()); match (*arg_val.expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { unreachable!() }; if ((k.clone() > 0) && (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string()))) { - match positive_descent_amount_from_positive_int(k.clone()) { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: k, .. } = + value.as_ref() + else { + unreachable!() + }; + if ((k.clone() > 0) + && (mname.clone().as_str() + == "skip".to_string().as_str())) + { + match positive_descent_amount_from_positive_int(k.clone()) { Some(steps) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), @@ -6295,14 +6143,33 @@ Rc::new(SubValueRelation::StrictSubValue { }, None => Rc::new(SubValueRelation::SubValueUnknown), } - } else { - Rc::new(SubValueRelation::SubValueUnknown) - } }, - ExprData::ExprVar { binding_kind: _, .. } => { - let aname = expr_var_name_at(arg_val.clone(), ctx.type_env.clone().source_indices.clone()); -match v1_rt::map_get(&ctx.size_aliases.clone(), aname).as_deref().cloned() { - Some(SizeExpr::DividedSize { param: p, divisor: d, .. }) => if (crate::v2_std_text::host_string_text_to_rust_host(p.clone()) == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) { - match proportional_divisor_from_int_at_least_two(d.clone()) { + } else { + Rc::new(SubValueRelation::SubValueUnknown) + } + } + ExprData::ExprVar { + binding_kind: _, .. + } => { + let aname = expr_var_name_at( + arg_val.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + match v1_rt::map_get( + &ctx.size_aliases.clone(), + aname, + ) + .as_deref() + .cloned() + { + Some(SizeExpr::DividedSize { + param: p, + divisor: d, + .. + }) => { + if (p.clone().as_str() + == param_name.clone().as_str()) + { + match proportional_divisor_from_int_at_least_two(d.clone()) { Some(div_w) => { let synth_field = Rc::new(InductiveField { type_name: param_name.clone(), @@ -6320,33 +6187,49 @@ Rc::new(SubValueRelation::StrictSubValue { }, None => Rc::new(SubValueRelation::SubValueUnknown), } - } else { - Rc::new(SubValueRelation::SubValueUnknown) - }, - _ => Rc::new(SubValueRelation::SubValueUnknown), -} -}, - ExprData::ExprBinOp { op, .. } => match op.clone() { - BinOp::Add => if (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string())) { - { - let left = binop_left(arg_val.clone()); -let right = binop_right(arg_val.clone()); -match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { + } else { + Rc::new(SubValueRelation::SubValueUnknown) + } + } + _ => Rc::new( + SubValueRelation::SubValueUnknown, + ), + } + } + ExprData::ExprBinOp { op, .. } => { + match op.clone() { + BinOp::Add => { + if (mname.clone().as_str() + == "skip".to_string().as_str()) + { + { + let left = + binop_left(arg_val.clone()); + let right = binop_right( + arg_val.clone(), + ); + match proportional_skip_alias_plus_literal(left.clone(), right.clone(), param_name.clone(), ctx.clone()) { Some(rel) => rel.clone(), None => match proportional_skip_alias_plus_literal(right.clone(), left.clone(), param_name.clone(), ctx.clone()) { Some(rel) => rel.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), }, } -} - } else { - Rc::new(SubValueRelation::SubValueUnknown) - }, - BinOp::Sub => Rc::new(SubValueRelation::SubValueUnknown), - _ => Rc::new(SubValueRelation::SubValueUnknown), -}, - _ => Rc::new(SubValueRelation::SubValueUnknown), -} + } + } else { + Rc::new(SubValueRelation::SubValueUnknown) + } + } + BinOp::Sub => Rc::new( + SubValueRelation::SubValueUnknown, + ), + _ => Rc::new( + SubValueRelation::SubValueUnknown, + ), + } + } + _ => Rc::new(SubValueRelation::SubValueUnknown), + } } None => Rc::new(SubValueRelation::SubValueUnknown), } @@ -6387,7 +6270,7 @@ pub fn method_callback_element_position(semantics: Option>) pub fn maybe_insert_composed_field_relation( acc: Rc>>, - fname: Rc>, + fname: String, composed: Option>, ) -> Rc>> { match composed { @@ -6402,7 +6285,7 @@ pub fn maybe_insert_composed_field_relation( pub fn maybe_insert_output_field_relation( acc: Rc>>, idx: i64, - fname: Rc>, + fname: String, sig: Rc, val: Rc, ctx: Rc, @@ -6418,9 +6301,9 @@ pub fn maybe_insert_output_field_relation( pub fn maybe_insert_match_field_relation( fp_acc: Rc>>, - pname: Rc>, - field_label: Rc>, - vname: Rc>, + pname: String, + field_label: String, + vname: String, scrut_rel: Option>, param_types: Rc>, type_env: Rc, @@ -6438,28 +6321,16 @@ pub fn maybe_insert_match_field_relation( SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), _ => "".to_string(), }; - if (crate::v2_std_text::host_string_text_to_rust_host(lookup_type.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (lookup_type.clone().as_str() != "".to_string().as_str()) { { let ind_fields = inductive_fields_for(type_env, lookup_type.clone()); let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.iter().cloned() { - if ((crate::v2_std_text::host_string_text_to_rust_host( - f.field_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - field_label.clone(), - )) && ((crate::v2_std_text::host_string_text_to_rust_host( - f.variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - vname.clone(), - )) || (crate::v2_std_text::host_string_text_to_rust_host( - f.variant_name.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )))) + if ((f.field_name.clone().as_str() == field_label.clone().as_str()) + && ((f.variant_name.clone().as_str() == vname.clone().as_str()) + || (f.variant_name.clone().as_str() + == "".to_string().as_str()))) { __result.push(f); } @@ -6487,7 +6358,7 @@ pub fn maybe_insert_match_field_relation( pub fn build_per_field_for_let( val: Rc, - binding_name: Rc>, + binding_name: String, ctx: Rc, ) -> Rc>>>> { match (*val.expr_data.clone()).clone() { @@ -6512,7 +6383,7 @@ pub fn build_per_field_for_let( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); @@ -6572,7 +6443,7 @@ pub fn build_per_field_for_let( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); @@ -6651,9 +6522,7 @@ pub fn resolve_collection_field( } } }; - if (crate::v2_std_text::host_string_text_to_rust_host(base_type.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (base_type.clone().as_str() != "".to_string().as_str()) { break Rc::new({ let mut __result = Vec::new(); for f in Rc::new({ @@ -6665,11 +6534,8 @@ pub fn resolve_collection_field( .iter() .cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - f.field_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - fname.clone(), - )) { + if (f.field_name.clone().as_str() == fname.clone().as_str()) + { __result.push(f); } } @@ -6740,28 +6606,12 @@ pub fn resolve_collection_field( } => { let inner_mname = expr_method_name_at(expr.clone(), ctx.type_env.clone().source_indices.clone()); - let is_collection_preserving = - (((((crate::v2_std_text::host_string_text_to_rust_host( - inner_mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "enumerate".to_string(), - )) || (crate::v2_std_text::host_string_text_to_rust_host( - inner_mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "skip".to_string(), - ))) || (crate::v2_std_text::host_string_text_to_rust_host( - inner_mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "take".to_string(), - ))) || (crate::v2_std_text::host_string_text_to_rust_host( - inner_mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "filter".to_string(), - ))) || (crate::v2_std_text::host_string_text_to_rust_host( - inner_mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "reverse".to_string(), - ))); + let is_collection_preserving = (((((inner_mname.clone().as_str() + == "enumerate".to_string().as_str()) + || (inner_mname.clone().as_str() == "skip".to_string().as_str())) + || (inner_mname.clone().as_str() == "take".to_string().as_str())) + || (inner_mname.clone().as_str() == "filter".to_string().as_str())) + || (inner_mname.clone().as_str() == "reverse".to_string().as_str())); if is_collection_preserving { { let __tco_0 = method_receiver(expr); @@ -6815,11 +6665,7 @@ pub fn classify_binding_provenance(val: Rc, scope: Rc) -> Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (crate::v2_std_text::host_string_text_to_rust_host( - type_name.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { + if (type_name.clone().as_str() != "".to_string().as_str()) { { let fields = inductive_fields_for( ctx.type_env.clone(), type_name.clone(), ); - let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field.clone())) { __result.push(f); } } __result }).first().cloned(); + let matching = Rc::new({ + let mut __result = Vec::new(); + for f in fields.iter().cloned() { + if (f.field_name.clone().as_str() + == field.clone().as_str()) + { + __result.push(f); + } + } + __result + }) + .first() + .cloned(); match matching { Some(ind_field) => { Some(Rc::new(SubValueRelation::StrictSubValue { @@ -6974,24 +6828,42 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option "".to_string(), }, }; - if (crate::v2_std_text::host_string_text_to_rust_host(inner_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - { - let fields = inductive_fields_for(ctx.type_env.clone(), inner_type.clone()); -let cf = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { if match f.shape.clone() { + if (inner_type.clone().as_str() + != "".to_string().as_str()) + { + { + let fields = inductive_fields_for( + ctx.type_env.clone(), + inner_type.clone(), + ); + let cf = + Rc::new({ + let mut __result = Vec::new(); + for f in fields.iter().cloned() { + if match f.shape.clone() { RecursionShape::ListRecursion => true, _ => false, -} { __result.push(f); } } __result }).first().cloned(); -match cf { - Some(ind_field) => Some(Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), - factor: Rc::new(ShrinkFactor::UnitShrink), -})), - None => None, -} -} - } else { - None - } +} { __result.push(f); } + } + __result + }) + .first() + .cloned(); + match cf { + Some(ind_field) => Some(Rc::new( + SubValueRelation::StrictSubValue { + field: ind_field.clone(), + factor: Rc::new( + ShrinkFactor::UnitShrink, + ), + }, + )), + None => None, + } + } + } else { + None + } } _ => None, } @@ -7020,10 +6892,7 @@ match cf { ), None => "".to_string(), }; - if ((crate::v2_std_text::host_string_text_to_rust_host(elem.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) + if ((elem.clone().as_str() != "".to_string().as_str()) && is_recursive_type_by_name(ctx.type_env.clone(), elem.clone())) { { @@ -7065,211 +6934,222 @@ match cf { }; match type_based.clone() { Some(_) => type_based.clone(), - None => { - match (*val.expr_data.clone()).clone() { - ExprData::ExprBinOp { op: op, .. } => { - let left = binop_left(val.clone()); - let right = binop_right(val.clone()); - match op.clone() { - BinOp::Sub => { - match (*left.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => { - let lname = expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - if ((v1_rt::map_get( - &ctx.param_names.clone(), - lname.clone(), - ) != None) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - lname.clone(), - ) != None)) - { - match (*right.expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { - value: k, .. - } = value.as_ref() - else { - unreachable!() - }; - match positive_descent_amount_from_positive_int(k.clone()) { - Some(steps) => Some(Rc::new(SubValueRelation::ArithmeticDescent { - param: lname.clone(), - factor: Rc::new(ShrinkFactor::ConstantShrink { - steps: steps.clone(), -}), -})), - None => None, -} - } - _ => None, + None => match (*val.expr_data.clone()).clone() { + ExprData::ExprBinOp { op: op, .. } => { + let left = binop_left(val.clone()); + let right = binop_right(val.clone()); + match op.clone() { + BinOp::Sub => match (*left.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => { + let lname = expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + if ((v1_rt::map_get(&ctx.param_names.clone(), lname.clone()) + != None) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + lname.clone(), + ) != None)) + { + match (*right.expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: k, .. } = + value.as_ref() + else { + unreachable!() + }; + match positive_descent_amount_from_positive_int( + k.clone(), + ) { + Some(steps) => Some(Rc::new( + SubValueRelation::ArithmeticDescent { + param: lname.clone(), + factor: Rc::new( + ShrinkFactor::ConstantShrink { + steps: steps.clone(), + }, + ), + }, + )), + None => None, } - } else { - None } + _ => None, } - _ => None, + } else { + None } } - BinOp::Div => { - let left_name = match (*left.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => { - let lname = expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - if ((v1_rt::map_get( - &ctx.param_names.clone(), - lname.clone(), - ) != None) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - lname.clone(), - ) != None)) - { - lname.clone() - } else { - "".to_string() - } + _ => None, + }, + BinOp::Div => { + let left_name = match (*left.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => { + let lname = expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + if ((v1_rt::map_get( + &ctx.param_names.clone(), + lname.clone(), + ) != None) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + lname.clone(), + ) != None)) + { + lname.clone() + } else { + "".to_string() } - ExprData::ExprBinOp { op: BinOp::Sub, .. } => { - let inner_left = binop_left(left.clone()); - match (*inner_left.expr_data.clone()).clone() { - ExprData::ExprVar { - binding_kind: _, .. - } => { - let lname = expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - if ((v1_rt::map_get( - &ctx.param_names.clone(), + } + ExprData::ExprBinOp { op: BinOp::Sub, .. } => { + let inner_left = binop_left(left.clone()); + match (*inner_left.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, .. + } => { + let lname = expr_var_name_at( + inner_left.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + if ((v1_rt::map_get( + &ctx.param_names.clone(), + lname.clone(), + ) != None) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), lname.clone(), - ) != None) - || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - lname.clone(), - ) != None)) - { - lname.clone() - } else { - "".to_string() - } + ) != None)) + { + lname.clone() + } else { + "".to_string() } - _ => "".to_string(), } + _ => "".to_string(), } - _ => "".to_string(), - }; - if (crate::v2_std_text::host_string_text_to_rust_host( - left_name.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { - match (*right.expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { - let LiteralValue::LitInt { value: k, .. } = - value.as_ref() - else { - unreachable!() - }; - match proportional_divisor_from_int_at_least_two( - k.clone(), - ) { - Some(div_w) => Some(Rc::new( - SubValueRelation::ArithmeticDescent { - param: left_name.clone(), - factor: Rc::new( - ShrinkFactor::ProportionalShrink { - divisor: div_w.clone(), - }, - ), - }, - )), - None => None, - } + } + _ => "".to_string(), + }; + if (left_name.clone().as_str() != "".to_string().as_str()) { + match (*right.expr_data.clone()).clone() { + ExprData::ExprLiteral { ref value, .. } => { + let LiteralValue::LitInt { value: k, .. } = + value.as_ref() + else { + unreachable!() + }; + match proportional_divisor_from_int_at_least_two( + k.clone(), + ) { + Some(div_w) => Some(Rc::new( + SubValueRelation::ArithmeticDescent { + param: left_name.clone(), + factor: Rc::new( + ShrinkFactor::ProportionalShrink { + divisor: div_w.clone(), + }, + ), + }, + )), + None => None, } - _ => None, } - } else { - None + _ => None, } + } else { + None } - BinOp::Add => None, - _ => None, } + BinOp::Add => None, + _ => None, } - ExprData::ExprMethodCall { - method_semantics: _, - .. - } => { - let mname = expr_method_name_at( - val.clone(), - ctx.type_env.clone().source_indices.clone(), - ); - let is_collection_preserving = - (((((crate::v2_std_text::host_string_text_to_rust_host( - mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "skip".to_string(), - )) || (crate::v2_std_text::host_string_text_to_rust_host( - mname.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "filter".to_string(), - ))) - || (crate::v2_std_text::host_string_text_to_rust_host( - mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "take".to_string(), - ))) - || (crate::v2_std_text::host_string_text_to_rust_host( - mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "enumerate".to_string(), - ))) - || (crate::v2_std_text::host_string_text_to_rust_host( - mname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "reverse".to_string(), - ))); - if is_collection_preserving { - { - let receiver = method_receiver(val.clone()); - let coll_field = - resolve_collection_field(receiver.clone(), ctx.clone()); - match coll_field { - Some(ind_field) => Some(Rc::new(SubValueRelation::StrictSubValue { - field: ind_field.clone(), - factor: Rc::new(ShrinkFactor::UnitShrink), -})), - None => if (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("skip".to_string())) { - { - let skip_args = method_arg_nodes(val.clone()); -let skip_amount = match skip_args.first().cloned() { - Some(a) => match (*arg_value(a.clone()).expr_data.clone()).clone() { - ExprData::ExprLiteral { ref value, .. } => { let LiteralValue::LitInt { value: k, .. } = value.as_ref() else { unreachable!() }; if (k.clone() > 0) { - k.clone() - } else { - 0 - } }, - _ => 0, -}, - None => 0, -}; -if (skip_amount.clone() > 0) { - match (*receiver.expr_data.clone()).clone() { - ExprData::ExprVar { binding_kind: _, .. } => { - let rname = expr_var_name_at(receiver.clone(), ctx.type_env.clone().source_indices.clone()); -if ((v1_rt::map_get(&ctx.param_names.clone(), rname.clone()) != None) || (v1_rt::map_get(&ctx.sub_value_vars.clone(), rname.clone()) != None)) { - match positive_descent_amount_from_positive_int(skip_amount.clone()) { + } + ExprData::ExprMethodCall { + method_semantics: _, + .. + } => { + let mname = expr_method_name_at( + val.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + let is_collection_preserving = (((((mname.clone().as_str() + == "skip".to_string().as_str()) + || (mname.clone().as_str() == "filter".to_string().as_str())) + || (mname.clone().as_str() == "take".to_string().as_str())) + || (mname.clone().as_str() == "enumerate".to_string().as_str())) + || (mname.clone().as_str() == "reverse".to_string().as_str())); + if is_collection_preserving { + { + let receiver = method_receiver(val.clone()); + let coll_field = + resolve_collection_field(receiver.clone(), ctx.clone()); + match coll_field { + Some(ind_field) => { + Some(Rc::new(SubValueRelation::StrictSubValue { + field: ind_field.clone(), + factor: Rc::new(ShrinkFactor::UnitShrink), + })) + } + None => { + if (mname.clone().as_str() == "skip".to_string().as_str()) { + { + let skip_args = method_arg_nodes(val.clone()); + let skip_amount = match skip_args.first().cloned() { + Some(a) => match (*arg_value(a.clone()) + .expr_data + .clone()) + .clone() + { + ExprData::ExprLiteral { + ref value, .. + } => { + let LiteralValue::LitInt { + value: k, + .. + } = value.as_ref() + else { + unreachable!() + }; + if (k.clone() > 0) { + k.clone() + } else { + 0 + } + } + _ => 0, + }, + None => 0, + }; + if (skip_amount.clone() > 0) { + match (*receiver.expr_data.clone()).clone() { + ExprData::ExprVar { + binding_kind: _, + .. + } => { + let rname = expr_var_name_at( + receiver.clone(), + ctx.type_env + .clone() + .source_indices + .clone(), + ); + if ((v1_rt::map_get( + &ctx.param_names.clone(), + rname.clone(), + ) != None) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + rname.clone(), + ) != None)) + { + match positive_descent_amount_from_positive_int(skip_amount.clone()) { Some(steps) => { let synth_field = Rc::new(InductiveField { type_name: rname.clone(), @@ -7287,28 +7167,28 @@ Some(Rc::new(SubValueRelation::StrictSubValue { }, None => None, } - } else { - None + } else { + None + } + } + _ => None, + } + } else { + None + } + } + } else { + None + } } -}, - _ => None, -} - } else { - None - } -} - } else { - None - }, -} } - } else { - None } + } else { + None } - _ => None, } - } + _ => None, + }, } } } @@ -7322,7 +7202,7 @@ pub fn classify_call_via_provenance( { let call_args = call.children.clone(); let arg_by_name = call_args.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), ctx.type_env.clone().source_indices.clone(), @@ -7335,10 +7215,8 @@ pub fn classify_call_via_provenance( ); Rc::new(v1_rt::map_keys(¶m_map)).iter().cloned().fold( None, - |result: _, callee_pname: Rc>| match v1_rt::map_get( - ¶m_map, - callee_pname.clone(), - ) { + |result: _, callee_pname: String| match v1_rt::map_get(¶m_map, callee_pname.clone()) + { Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { Some(arg_expr) => { let arg_rel = classify_call_arg_provenance(arg_expr.clone(), ctx.clone()); @@ -7407,7 +7285,7 @@ pub fn merge_argument_relations(rels: Rc>>) -> Rc, - param_name: Rc>, + param_name: String, ctx: Rc, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -7419,9 +7297,7 @@ pub fn classify_argument( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(param_name.clone())) - { + if (vname.clone().as_str() == param_name.clone().as_str()) { Rc::new(SubValueRelation::PreservedValue) } else { match v1_rt::map_get(&ctx.sub_value_vars.clone(), vname.clone()) { @@ -7467,11 +7343,7 @@ pub fn classify_argument( let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - f.field_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - field.clone(), - )) { + if (f.field_name.clone().as_str() == field.clone().as_str()) { __result.push(f); } } @@ -7612,20 +7484,19 @@ pub fn classify_argument( ExprData::ExprVar { binding_kind: _, .. } => { - ((crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) != None)) + ((expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ) + .as_str() + == param_name.clone().as_str()) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) != None)) } _ => false, }; @@ -7659,20 +7530,19 @@ pub fn classify_argument( ExprData::ExprVar { binding_kind: _, .. } => { - ((crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - expr_var_name_at( - left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) != None)) + ((expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ) + .as_str() + == param_name.clone().as_str()) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + expr_var_name_at( + left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) != None)) } ExprData::ExprBinOp { op: BinOp::Sub, .. } => { let inner_left = binop_left(left.clone()); @@ -7680,20 +7550,19 @@ pub fn classify_argument( ExprData::ExprVar { binding_kind: _, .. } => { - ((crate::v2_std_text::host_string_text_to_rust_host( - expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) == crate::v2_std_text::host_string_text_to_rust_host( - param_name.clone(), - )) || (v1_rt::map_get( - &ctx.sub_value_vars.clone(), - expr_var_name_at( - inner_left.clone(), - ctx.type_env.clone().source_indices.clone(), - ), - ) != None)) + ((expr_var_name_at( + inner_left.clone(), + ctx.type_env.clone().source_indices.clone(), + ) + .as_str() + == param_name.clone().as_str()) + || (v1_rt::map_get( + &ctx.sub_value_vars.clone(), + expr_var_name_at( + inner_left.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + ) != None)) } _ => false, } @@ -7779,7 +7648,7 @@ pub fn classify_argument( pub fn read_arg_provenance( arg_expr: Rc, - param_name: Rc>, + param_name: String, ctx: Rc, ) -> Rc { match (*arg_expr.expr_data.clone()).clone() { @@ -7813,30 +7682,39 @@ pub fn read_arg_provenance( let bname = expr_var_name_at(base.clone(), ctx.type_env.clone().source_indices.clone()); match v1_rt::map_get(&ctx.scope_locals.clone(), bname) { - Some(binding) => { - match (*binding.provenance.clone()).clone() { - SubValueRelation::SubValueUnknown => { - classify_argument(arg_expr.clone(), param_name, ctx.clone()) - } - _ => { - let fields = inductive_fields_for( - ctx.type_env.clone(), - authored_name_at( - ctx.type_env.clone().source_indices.clone(), - binding.resolved.clone(), - ), - ); - let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field.clone())) { __result.push(f); } } __result }).first().cloned(); - match matching { - Some(ind_field) => compose_sub_value( - binding.provenance.clone(), - ind_field.clone(), - ), - None => Rc::new(SubValueRelation::SubValueUnknown), + Some(binding) => match (*binding.provenance.clone()).clone() { + SubValueRelation::SubValueUnknown => { + classify_argument(arg_expr.clone(), param_name, ctx.clone()) + } + _ => { + let fields = inductive_fields_for( + ctx.type_env.clone(), + authored_name_at( + ctx.type_env.clone().source_indices.clone(), + binding.resolved.clone(), + ), + ); + let matching = Rc::new({ + let mut __result = Vec::new(); + for f in fields.iter().cloned() { + if (f.field_name.clone().as_str() == field.clone().as_str()) + { + __result.push(f); + } } + __result + }) + .first() + .cloned(); + match matching { + Some(ind_field) => compose_sub_value( + binding.provenance.clone(), + ind_field.clone(), + ), + None => Rc::new(SubValueRelation::SubValueUnknown), } } - } + }, None => classify_argument(arg_expr.clone(), param_name, ctx.clone()), } } @@ -7879,7 +7757,7 @@ pub fn build_call_evidence( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let arg_node = pair.1.clone(); @@ -7959,14 +7837,8 @@ pub fn build_call_evidence( } } -pub fn descent_source_type( - found: Rc>, - arg_node: Rc, - ctx: Rc, -) -> Rc> { - if (crate::v2_std_text::host_string_text_to_rust_host(found.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { +pub fn descent_source_type(found: String, arg_node: Rc, ctx: Rc) -> String { + if (found.clone().as_str() != "".to_string().as_str()) { found.clone() } else { match (*arg_value(arg_node.clone()).expr_data.clone()).clone() { @@ -8002,7 +7874,7 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let evidence = build_call_evidence(body.clone(), ctx.clone()); let source_type = body.children.clone().iter().cloned().fold( "".to_string(), - |found: Rc>, arg_node: Rc| { + |found: String, arg_node: Rc| { descent_source_type(found, arg_node.clone(), ctx.clone()) }, ); @@ -8010,67 +7882,147 @@ pub fn annotate_descent(body: Rc, ctx: Rc) -> Rc { let mut __result = Vec::new(); for child in body.children.clone().iter().cloned() { __result.push({ - let arg_val = arg_value(child.clone()); -match (*arg_val.expr_data.clone()).clone() { - ExprData::ExprLambda => if (crate::v2_std_text::host_string_text_to_rust_host(source_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - { - let lparams = lambda_param_names_at(arg_val.clone(), ctx.type_env.clone().source_indices.clone()); -let p1 = match lparams.clone().first().cloned() { - Some(n) => n.clone(), - None => "".to_string(), -}; -let p2 = match lparams.clone().get(1 as usize).cloned() { - Some(n) => n.clone(), - None => "".to_string(), -}; -let lambda_ctx = Rc::new(DescentContext { - fn_name: ctx.fn_name.clone(), - param_names: if (crate::v2_std_text::host_string_text_to_rust_host(p2.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - v1_rt::rc_map_insert(v1_rt::rc_map_insert(ctx.param_names.clone(), p1.clone(), source_type.clone()), p2.clone(), source_type.clone()) - } else { - if (crate::v2_std_text::host_string_text_to_rust_host(p1.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - v1_rt::rc_map_insert(ctx.param_names.clone(), p1.clone(), source_type.clone()) - } else { - ctx.param_names.clone() - } - }, - param_order: ctx.param_order.clone(), - type_env: ctx.type_env.clone(), - sub_value_vars: if (crate::v2_std_text::host_string_text_to_rust_host(p1.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - { - let source_fields = inductive_fields_for(ctx.type_env.clone(), source_type.clone()); -let cf = Rc::new({ let mut __result = Vec::new(); for f in source_fields.clone().iter().cloned() { if match f.shape.clone() { + let arg_val = arg_value(child.clone()); + match (*arg_val.expr_data.clone()).clone() { + ExprData::ExprLambda => { + if (source_type.clone().as_str() != "".to_string().as_str()) { + { + let lparams = lambda_param_names_at( + arg_val.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + let p1 = match lparams.clone().first().cloned() { + Some(n) => n.clone(), + None => "".to_string(), + }; + let p2 = match lparams.clone().get(1 as usize).cloned() + { + Some(n) => n.clone(), + None => "".to_string(), + }; + let lambda_ctx = Rc::new(DescentContext { + fn_name: ctx.fn_name.clone(), + param_names: if (p2.clone().as_str() + != "".to_string().as_str()) + { + v1_rt::rc_map_insert( + v1_rt::rc_map_insert( + ctx.param_names.clone(), + p1.clone(), + source_type.clone(), + ), + p2.clone(), + source_type.clone(), + ) + } else { + if (p1.clone().as_str() + != "".to_string().as_str()) + { + v1_rt::rc_map_insert( + ctx.param_names.clone(), + p1.clone(), + source_type.clone(), + ) + } else { + ctx.param_names.clone() + } + }, + param_order: ctx.param_order.clone(), + type_env: ctx.type_env.clone(), + sub_value_vars: if (p1.clone().as_str() + != "".to_string().as_str()) + { + { + let source_fields = inductive_fields_for( + ctx.type_env.clone(), + source_type.clone(), + ); + let cf = Rc::new({ + let mut __result = Vec::new(); + for f in source_fields + .clone() + .iter() + .cloned() + { + if match f.shape.clone() { RecursionShape::ListRecursion => true, _ => false, -} { __result.push(f); } } __result }).first().cloned(); -let rel = match cf.clone() { +} { __result.push(f); } + } + __result + }) + .first() + .cloned(); + let rel = match cf.clone() { Some(f) => Rc::new(SubValueRelation::IteratedSubValue { field: f.clone(), }), None => Rc::new(SubValueRelation::PreservedValue), }; -if (crate::v2_std_text::host_string_text_to_rust_host(p2.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - v1_rt::rc_map_insert(v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), p1.clone(), rel.clone()), p2.clone(), rel.clone()) - } else { - v1_rt::rc_map_insert(ctx.sub_value_vars.clone(), p1.clone(), rel.clone()) + if (p2.clone().as_str() + != "".to_string().as_str()) + { + v1_rt::rc_map_insert( + v1_rt::rc_map_insert( + ctx.sub_value_vars.clone(), + p1.clone(), + rel.clone(), + ), + p2.clone(), + rel.clone(), + ) + } else { + v1_rt::rc_map_insert( + ctx.sub_value_vars.clone(), + p1.clone(), + rel.clone(), + ) + } + } + } else { + ctx.sub_value_vars.clone() + }, + size_aliases: ctx.size_aliases.clone(), + scope_locals: ctx.scope_locals.clone(), + func_sigs: ctx.func_sigs.clone(), + per_field_vars: ctx.per_field_vars.clone(), + }); + make_arg_node( + arg_name_at( + child.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + annotate_descent( + arg_val.clone(), + lambda_ctx.clone(), + ), + child.span.clone(), + child.span.clone(), + ) + } + } else { + make_arg_node( + arg_name_at( + child.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + annotate_descent(arg_val.clone(), ctx.clone()), + child.span.clone(), + child.span.clone(), + ) + } } -} - } else { - ctx.sub_value_vars.clone() - }, - size_aliases: ctx.size_aliases.clone(), - scope_locals: ctx.scope_locals.clone(), - func_sigs: ctx.func_sigs.clone(), - per_field_vars: ctx.per_field_vars.clone(), -}); -make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()), annotate_descent(arg_val.clone(), lambda_ctx.clone()), child.span.clone(), child.span.clone()) -} - } else { - make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), child.span.clone()) - }, - _ => make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()), annotate_descent(arg_val.clone(), ctx.clone()), child.span.clone(), child.span.clone()), -} -}); + _ => make_arg_node( + arg_name_at( + child.clone(), + ctx.type_env.clone().source_indices.clone(), + ), + annotate_descent(arg_val.clone(), ctx.clone()), + child.span.clone(), + child.span.clone(), + ), + } + }); } __result }); @@ -8148,17 +8100,25 @@ make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clo Some(t) => t.clone(), None => "".to_string(), }; - if (crate::v2_std_text::host_string_text_to_rust_host( - base_type.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { + if (base_type.clone().as_str() != "".to_string().as_str()) { { let ind_fields = inductive_fields_for( ctx.type_env.clone(), base_type.clone(), ); - Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(fname.clone())) { __result.push(f); } } __result }).first().cloned() + Rc::new({ + let mut __result = Vec::new(); + for f in ind_fields.clone().iter().cloned() { + if (f.field_name.clone().as_str() + == fname.clone().as_str()) + { + __result.push(f); + } + } + __result + }) + .first() + .cloned() } } else { None @@ -8175,14 +8135,8 @@ make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clo scrut.clone(), ctx.type_env.clone().source_indices.clone(), ); - if ((crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "first".to_string(), - )) - || (crate::v2_std_text::host_string_text_to_rust_host(mname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "last".to_string(), - ))) + if ((mname.clone().as_str() == "first".to_string().as_str()) + || (mname.clone().as_str() == "last".to_string().as_str())) { { let receiver = method_receiver(scrut.clone()); @@ -8194,13 +8148,12 @@ make_arg_node(arg_name_at(child.clone(), ctx.type_env.clone().source_indices.clo } _ => None, }; - let scrut_has_inductive = - (((crate::v2_std_text::host_string_text_to_rust_host(scrut_type.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() - as i64) - > 0)) - || (scrut_inducing_field.clone() != None)); + let scrut_has_inductive = (((scrut_type.clone().as_str() + != "".to_string().as_str()) + && ((inductive_fields_for(ctx.type_env.clone(), scrut_type.clone()).len() + as i64) + > 0)) + || (scrut_inducing_field.clone() != None)); let scrut_variant_sig = match (*scrut.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = expr_call_func_at( @@ -8237,7 +8190,7 @@ let arm_ctx = match variant_arm_ctx.clone() { None => if scrut_has_inductive.clone() { match (*arm_pattern(arm_node.clone())).clone() { MatchPattern::VariantPattern { name: vname, field_bindings: bindings, .. } => match scrut_inducing_field.clone() { - Some(ind_field) => if (crate::v2_std_text::host_string_text_to_rust_host(vname.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) { + Some(ind_field) => if (vname.clone().as_str() == "Present".to_string().as_str()) { bindings.clone().iter().cloned().fold(ctx.clone(), |c: Rc, fb: Rc| match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => Rc::new(DescentContext { fn_name: c.fn_name.clone(), @@ -8261,9 +8214,9 @@ let inner_bind_name = match (*field_binding_pattern(inner_fb.clone())).clone() { MatchPattern::Bind { name: ibname, .. } => ibname.clone(), _ => "".to_string(), }; -let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((crate::v2_std_text::host_string_text_to_rust_host(f.variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(inner_vname.clone())) && (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(inner_field_name.clone()))) { __result.push(f); } } __result }).first().cloned(); +let inner_matching = Rc::new({ let mut __result = Vec::new(); for f in inner_ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == inner_vname.clone().as_str()) && (f.field_name.clone().as_str() == inner_field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); match inner_matching.clone() { - Some(inner_ind_field) => if (crate::v2_std_text::host_string_text_to_rust_host(inner_bind_name.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + Some(inner_ind_field) => if (inner_bind_name.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { fn_name: ic.fn_name.clone(), param_names: v1_rt::rc_map_insert(ic.param_names.clone(), inner_bind_name.clone(), inner_ind_field.element_type.clone()), @@ -8298,9 +8251,9 @@ let bind_name = match (*field_binding_pattern(fb.clone())).clone() { MatchPattern::Bind { name: bname, .. } => bname.clone(), _ => "".to_string(), }; -let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((crate::v2_std_text::host_string_text_to_rust_host(f.variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(vname.clone())) && (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()))) { __result.push(f); } } __result }).first().cloned(); +let matching = Rc::new({ let mut __result = Vec::new(); for f in ind_fields.clone().iter().cloned() { if ((f.variant_name.clone().as_str() == vname.clone().as_str()) && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __result.push(f); } } __result }).first().cloned(); match matching.clone() { - Some(ind_field) => if (crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + Some(ind_field) => if (bind_name.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { fn_name: c.fn_name.clone(), param_names: c.param_names.clone(), @@ -8323,7 +8276,7 @@ match matching.clone() { }) }, }, - MatchPattern::Bind { name: bname, .. } => if (crate::v2_std_text::host_string_text_to_rust_host(scrut_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { + MatchPattern::Bind { name: bname, .. } => if (scrut_type.clone().as_str() != "".to_string().as_str()) { Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), param_names: v1_rt::rc_map_insert(ctx.param_names.clone(), bname.clone(), scrut_type.clone()), @@ -8416,11 +8369,7 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }; Rc::new(DescentContext { fn_name: ctx.fn_name.clone(), - param_names: if (crate::v2_std_text::host_string_text_to_rust_host( - sub_type.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { + param_names: if (sub_type.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( ctx.param_names.clone(), binding_name.clone(), @@ -8500,72 +8449,109 @@ make_arm_node(arm_pattern(arm_node.clone()), arm_guard(arm_node.clone()), annota }) } ExprData::ExprBlock => { - let threaded = body.children.clone().iter().cloned().fold(Rc::new(BlockAnnotateAcc { - ctx: ctx.clone(), - children: Rc::new(vec![]), -}), |acc: Rc, child: Rc| { - let annotated = annotate_descent(child.clone(), acc.ctx.clone()); -let next_ctx = match (*child.expr_data.clone()).clone() { - ExprData::ExprLet => { - let val = let_value(child.clone()); -let bname = let_binding_name_at(child.clone(), ctx.type_env.clone().source_indices.clone()); -let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); -let sa = classify_size_expr(val.clone(), acc.ctx.clone()); -let new_sa = match sa.clone() { - Some(se) => v1_rt::rc_map_insert(acc.ctx.clone().size_aliases.clone(), bname.clone(), se.clone()), - None => acc.ctx.clone().size_aliases.clone(), -}; -match val_rel.clone() { - Some(rel) => { - let sub_type = match (*rel.clone()).clone() { - SubValueRelation::StrictSubValue { field: f, .. } => f.element_type.clone(), - SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), - _ => "".to_string(), -}; -Rc::new(DescentContext { - fn_name: acc.ctx.clone().fn_name.clone(), - param_names: if (crate::v2_std_text::host_string_text_to_rust_host(sub_type.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - v1_rt::rc_map_insert(acc.ctx.clone().param_names.clone(), bname.clone(), sub_type.clone()) - } else { - acc.ctx.clone().param_names.clone() - }, - param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), - sub_value_vars: v1_rt::rc_map_insert(acc.ctx.clone().sub_value_vars.clone(), bname.clone(), rel.clone()), - size_aliases: new_sa.clone(), - scope_locals: v1_rt::rc_map_insert(acc.ctx.clone().scope_locals.clone(), bname.clone(), Rc::new(TypeBinding { - name: bname.clone(), - resolved: resolved_type(val.clone()), - provenance: rel.clone(), -})), - func_sigs: acc.ctx.clone().func_sigs.clone(), - per_field_vars: acc.ctx.clone().per_field_vars.clone(), -}) -}, - None => Rc::new(DescentContext { - fn_name: acc.ctx.clone().fn_name.clone(), - param_names: acc.ctx.clone().param_names.clone(), - param_order: acc.ctx.clone().param_order.clone(), - type_env: acc.ctx.clone().type_env.clone(), - sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), - size_aliases: new_sa.clone(), - scope_locals: v1_rt::rc_map_insert(acc.ctx.clone().scope_locals.clone(), bname.clone(), Rc::new(TypeBinding { - name: bname.clone(), - resolved: resolved_type(val.clone()), - provenance: Rc::new(SubValueRelation::SubValueUnknown), -})), - func_sigs: acc.ctx.clone().func_sigs.clone(), - per_field_vars: acc.ctx.clone().per_field_vars.clone(), -}), -} -}, - _ => acc.ctx.clone(), -}; -Rc::new(BlockAnnotateAcc { - ctx: next_ctx.clone(), - children: v1_rt::concat(acc.children.clone(), Rc::new(vec![annotated.clone()])), -}) -}); + let threaded = body.children.clone().iter().cloned().fold( + Rc::new(BlockAnnotateAcc { + ctx: ctx.clone(), + children: Rc::new(vec![]), + }), + |acc: Rc, child: Rc| { + let annotated = annotate_descent(child.clone(), acc.ctx.clone()); + let next_ctx = match (*child.expr_data.clone()).clone() { + ExprData::ExprLet => { + let val = let_value(child.clone()); + let bname = let_binding_name_at( + child.clone(), + ctx.type_env.clone().source_indices.clone(), + ); + let val_rel = classify_let_value(val.clone(), acc.ctx.clone()); + let sa = classify_size_expr(val.clone(), acc.ctx.clone()); + let new_sa = match sa.clone() { + Some(se) => v1_rt::rc_map_insert( + acc.ctx.clone().size_aliases.clone(), + bname.clone(), + se.clone(), + ), + None => acc.ctx.clone().size_aliases.clone(), + }; + match val_rel.clone() { + Some(rel) => { + let sub_type = match (*rel.clone()).clone() { + SubValueRelation::StrictSubValue { + field: f, .. + } => f.element_type.clone(), + SubValueRelation::IteratedSubValue { + field: f, .. + } => f.element_type.clone(), + _ => "".to_string(), + }; + Rc::new(DescentContext { + fn_name: acc.ctx.clone().fn_name.clone(), + param_names: if (sub_type.clone().as_str() + != "".to_string().as_str()) + { + v1_rt::rc_map_insert( + acc.ctx.clone().param_names.clone(), + bname.clone(), + sub_type.clone(), + ) + } else { + acc.ctx.clone().param_names.clone() + }, + param_order: acc.ctx.clone().param_order.clone(), + type_env: acc.ctx.clone().type_env.clone(), + sub_value_vars: v1_rt::rc_map_insert( + acc.ctx.clone().sub_value_vars.clone(), + bname.clone(), + rel.clone(), + ), + size_aliases: new_sa.clone(), + scope_locals: v1_rt::rc_map_insert( + acc.ctx.clone().scope_locals.clone(), + bname.clone(), + Rc::new(TypeBinding { + name: bname.clone(), + resolved: resolved_type(val.clone()), + provenance: rel.clone(), + }), + ), + func_sigs: acc.ctx.clone().func_sigs.clone(), + per_field_vars: acc.ctx.clone().per_field_vars.clone(), + }) + } + None => Rc::new(DescentContext { + fn_name: acc.ctx.clone().fn_name.clone(), + param_names: acc.ctx.clone().param_names.clone(), + param_order: acc.ctx.clone().param_order.clone(), + type_env: acc.ctx.clone().type_env.clone(), + sub_value_vars: acc.ctx.clone().sub_value_vars.clone(), + size_aliases: new_sa.clone(), + scope_locals: v1_rt::rc_map_insert( + acc.ctx.clone().scope_locals.clone(), + bname.clone(), + Rc::new(TypeBinding { + name: bname.clone(), + resolved: resolved_type(val.clone()), + provenance: Rc::new( + SubValueRelation::SubValueUnknown, + ), + }), + ), + func_sigs: acc.ctx.clone().func_sigs.clone(), + per_field_vars: acc.ctx.clone().per_field_vars.clone(), + }), + } + } + _ => acc.ctx.clone(), + }; + Rc::new(BlockAnnotateAcc { + ctx: next_ctx.clone(), + children: v1_rt::concat( + acc.children.clone(), + Rc::new(vec![annotated.clone()]), + ), + }) + }, + ); Rc::new(Node { name: body.name.clone(), span: body.span.clone(), @@ -8606,11 +8592,7 @@ Rc::new(BlockAnnotateAcc { raw_receiver.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (crate::v2_std_text::host_string_text_to_rust_host(inner_mname) - == crate::v2_std_text::host_string_text_to_rust_host( - "enumerate".to_string(), - )) - { + if (inner_mname.as_str() == "enumerate".to_string().as_str()) { method_receiver(raw_receiver.clone()) } else { raw_receiver.clone() @@ -8656,12 +8638,26 @@ Rc::new(BlockAnnotateAcc { None => "".to_string(), }, }; - if (crate::v2_std_text::host_string_text_to_rust_host( - base_type.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { - Rc::new({ let mut __result = Vec::new(); for f in inductive_fields_for(ctx.type_env.clone(), base_type.clone()).iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(fname.clone())) { __result.push(f); } } __result }).first().cloned() + if (base_type.clone().as_str() != "".to_string().as_str()) { + Rc::new({ + let mut __result = Vec::new(); + for f in inductive_fields_for( + ctx.type_env.clone(), + base_type.clone(), + ) + .iter() + .cloned() + { + if (f.field_name.clone().as_str() + == fname.clone().as_str()) + { + __result.push(f); + } + } + __result + }) + .first() + .cloned() } else { None } @@ -8740,10 +8736,7 @@ Rc::new(BlockAnnotateAcc { type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { v1_rt::rc_map_insert( - v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + v1_rt::rc_empty_map::>(), elem_name.clone(), Rc::new(SubValueRelation::IteratedSubValue { field: ind_field.clone(), @@ -8769,10 +8762,7 @@ Rc::new(BlockAnnotateAcc { param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), sub_value_vars: if is_fold { - v1_rt::rc_empty_map::< - Rc>, - Rc, - >() + v1_rt::rc_empty_map::>() } else { ctx.sub_value_vars.clone() }, @@ -8873,7 +8863,7 @@ Rc::new(BlockAnnotateAcc { param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), sub_value_vars: v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), fe_var.clone(), Rc::new(SubValueRelation::IteratedSubValue { field: ind_field.clone(), @@ -8889,10 +8879,7 @@ Rc::new(BlockAnnotateAcc { param_names: ctx.param_names.clone(), param_order: ctx.param_order.clone(), type_env: ctx.type_env.clone(), - sub_value_vars: v1_rt::rc_empty_map::< - Rc>, - Rc, - >(), + sub_value_vars: v1_rt::rc_empty_map::>(), size_aliases: ctx.size_aliases.clone(), scope_locals: ctx.scope_locals.clone(), func_sigs: ctx.func_sigs.clone(), @@ -8932,7 +8919,7 @@ Rc::new(BlockAnnotateAcc { pub fn resolved_type_name( n: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { authored_name_at(source_indices, rt.clone()) @@ -8963,14 +8950,12 @@ pub fn infer_output_provenance( __result }); let param_types = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - && (crate::v2_std_text::host_string_text_to_rust_host(ptype.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + if ((pname.clone().as_str() != "".to_string().as_str()) + && (ptype.clone().as_str() != "".to_string().as_str())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -8984,7 +8969,7 @@ pub fn infer_output_provenance( param_types.clone(), type_env.clone(), func_sigs.clone(), - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), ); if ((Rc::new(v1_rt::map_keys(&scalar)).len() as i64) > 0) { Rc::new(vec![scalar.clone()]) @@ -8996,10 +8981,7 @@ pub fn infer_output_provenance( param_types.clone(), type_env.clone(), func_sigs.clone(), - v1_rt::rc_empty_map::< - Rc>, - Rc>>, - >(), + v1_rt::rc_empty_map::>>>(), ); if (((per_field.clone().len() as i64) > 0) && { let mut __found = false; @@ -9040,11 +9022,7 @@ pub fn classify_body_provenance( if { let mut __found = false; for pn in param_names.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(pn.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - vname.clone(), - )) - { + if (pn.clone().as_str() == vname.clone().as_str()) { __found = true; break; } @@ -9052,12 +9030,12 @@ pub fn classify_body_provenance( __found } { v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), vname.clone(), Rc::new(SubValueRelation::PreservedValue), ) } else { - v1_rt::rc_empty_map::>, Rc>() + v1_rt::rc_empty_map::>() } } } @@ -9073,32 +9051,65 @@ pub fn classify_body_provenance( func_sigs.clone(), let_prov.clone(), ); - Rc::new(v1_rt::map_keys(&base_prov)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pname: Rc>| match v1_rt::map_get(&base_prov, pname.clone()) { - Some(base_rel) => { - let type_for_lookup = match (*base_rel.clone()).clone() { - SubValueRelation::PreservedValue => match v1_rt::map_get(¶m_types, pname.clone()) { - Some(t) => t.clone(), - None => "".to_string(), -}, - SubValueRelation::StrictSubValue { field: f, .. } => f.element_type.clone(), - SubValueRelation::IteratedSubValue { field: f, .. } => f.element_type.clone(), - _ => "".to_string(), -}; -if (crate::v2_std_text::host_string_text_to_rust_host(type_for_lookup.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) { - { - let fields = inductive_fields_for(type_env.clone(), type_for_lookup.clone()); -let matching = Rc::new({ let mut __result = Vec::new(); for f in fields.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(field.clone())) { __result.push(f); } } __result }).first().cloned(); -match matching.clone() { - Some(ind_field) => v1_rt::rc_map_insert(acc.clone(), pname.clone(), compose_sub_value(base_rel.clone(), ind_field.clone())), - None => acc.clone(), -} -} - } else { - acc.clone() - } -}, - None => acc.clone(), -}) + Rc::new(v1_rt::map_keys(&base_prov)).iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, pname: String| { + match v1_rt::map_get(&base_prov, pname.clone()) { + Some(base_rel) => { + let type_for_lookup = match (*base_rel.clone()).clone() { + SubValueRelation::PreservedValue => { + match v1_rt::map_get(¶m_types, pname.clone()) { + Some(t) => t.clone(), + None => "".to_string(), + } + } + SubValueRelation::StrictSubValue { field: f, .. } => { + f.element_type.clone() + } + SubValueRelation::IteratedSubValue { field: f, .. } => { + f.element_type.clone() + } + _ => "".to_string(), + }; + if (type_for_lookup.clone().as_str() != "".to_string().as_str()) { + { + let fields = inductive_fields_for( + type_env.clone(), + type_for_lookup.clone(), + ); + let matching = Rc::new({ + let mut __result = Vec::new(); + for f in fields.clone().iter().cloned() { + if (f.field_name.clone().as_str() + == field.clone().as_str()) + { + __result.push(f); + } + } + __result + }) + .first() + .cloned(); + match matching.clone() { + Some(ind_field) => v1_rt::rc_map_insert( + acc.clone(), + pname.clone(), + compose_sub_value( + base_rel.clone(), + ind_field.clone(), + ), + ), + None => acc.clone(), + } + } + } else { + acc.clone() + } + } + None => acc.clone(), + } + }, + ) } ExprData::ExprCall { .. } => { let callee = expr_call_func_at(expr.clone(), type_env.source_indices.clone()); @@ -9172,22 +9183,35 @@ match matching.clone() { func_sigs.clone(), let_prov.clone(), ); - Rc::new(v1_rt::map_keys(&recv_prov)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, pname: Rc>| match v1_rt::map_get(&recv_prov, pname.clone()) { - Some(recv_rel) => { - let synth_field = Rc::new(InductiveField { - type_name: pname.clone(), - variant_name: "".to_string(), - field_name: mname.clone(), - shape: RecursionShape::ListRecursion, - element_type: pname.clone(), -}); -v1_rt::rc_map_insert(acc.clone(), pname.clone(), compose_sub_value(recv_rel.clone(), synth_field.clone())) -}, - None => acc.clone(), -}) + Rc::new(v1_rt::map_keys(&recv_prov)).iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, + pname: String| { + match v1_rt::map_get(&recv_prov, pname.clone()) { + Some(recv_rel) => { + let synth_field = Rc::new(InductiveField { + type_name: pname.clone(), + variant_name: "".to_string(), + field_name: mname.clone(), + shape: RecursionShape::ListRecursion, + element_type: pname.clone(), + }); + v1_rt::rc_map_insert( + acc.clone(), + pname.clone(), + compose_sub_value( + recv_rel.clone(), + synth_field.clone(), + ), + ) + } + None => acc.clone(), + } + }, + ) } } else { - v1_rt::rc_empty_map::>, Rc>() + v1_rt::rc_empty_map::>() } } } @@ -9214,9 +9238,9 @@ let bind_name = match (*field_binding_pattern(binding.clone())).clone() { MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; -if ((crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) && (crate::v2_std_text::host_string_text_to_rust_host(field_label.clone()) != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) { +if ((bind_name.clone().as_str() != "".to_string().as_str()) && (field_label.clone().as_str() != "".to_string().as_str())) { { - let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: Rc>| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); + let field_prov = Rc::new(v1_rt::map_keys(&scrut_prov)).iter().cloned().fold(empty_prov_map(), |fp_acc: Rc>>, pname: String| maybe_insert_match_field_relation(fp_acc, pname.clone(), field_label.clone(), vname.clone(), v1_rt::map_get(&scrut_prov, pname.clone()), param_types.clone(), type_env.clone())); v1_rt::rc_map_insert(acc.clone(), bind_name.clone(), field_prov.clone()) } } else { @@ -9279,7 +9303,7 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types func_sigs.clone(), updated, ), - None => v1_rt::rc_empty_map::>, Rc>(), + None => v1_rt::rc_empty_map::>(), } } ExprData::ExprBlock => { @@ -9358,9 +9382,9 @@ classify_body_provenance(arm_body(arm.clone()), param_names.clone(), param_types func_sigs.clone(), let_prov.clone(), ), - None => v1_rt::rc_empty_map::>, Rc>(), + None => v1_rt::rc_empty_map::>(), }, - _ => v1_rt::rc_empty_map::>, Rc>(), + _ => v1_rt::rc_empty_map::>(), } }) } @@ -9376,7 +9400,7 @@ pub fn call_args_by_name( source_indices: Rc>>, ) -> Rc>> { call.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, arg_node: Rc| match arg_name_at( arg_node.clone(), source_indices.clone(), @@ -9402,21 +9426,19 @@ pub fn method_call_args_by_name( Some(sig) => match sig.params.clone().first().cloned() { Some(first_p) => { let first_pname = param_node_name_at(first_p.clone(), source_indices.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(first_pname.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (first_pname.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), first_pname.clone(), recv, ) } else { - v1_rt::rc_empty_map::>, Rc>() + v1_rt::rc_empty_map::>() } } - None => v1_rt::rc_empty_map::>, Rc>(), + None => v1_rt::rc_empty_map::>(), }, - None => v1_rt::rc_empty_map::>, Rc>(), + None => v1_rt::rc_empty_map::>(), }; mc_args.iter().cloned().fold( base, @@ -9434,7 +9456,7 @@ pub fn method_call_args_by_name( } pub fn compose_callee_provenance( - callee: Rc>, + callee: String, arg_by_name: Rc>>, param_names: Rc>, param_types: Rc>, @@ -9443,33 +9465,72 @@ pub fn compose_callee_provenance( let_prov: Rc>>>>, ) -> Rc>> { match v1_rt::map_get(&func_sigs, callee) { - Some(sig) => match sig.output_provenance.clone().first().cloned() { - Some(callee_prov) => Rc::new(v1_rt::map_keys(&callee_prov)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>(), |acc: Rc>>, callee_pname: Rc>| match v1_rt::map_get(&callee_prov, callee_pname.clone()) { - Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { - Some(arg) => { - let arg_prov = classify_body_provenance(arg.clone(), param_names.clone(), param_types.clone(), type_env.clone(), func_sigs.clone(), let_prov.clone()); -Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold(acc.clone(), |inner: Rc>>, pname: Rc>| match v1_rt::map_get(&arg_prov, pname.clone()) { - Some(arg_rel) => { - let composed = compose_sub_value_relations(arg_rel.clone(), callee_rel.clone()); -match (*composed.clone()).clone() { - SubValueRelation::SubValueUnknown => inner.clone(), - _ => match v1_rt::map_get(&inner, pname.clone()) { - Some(existing) => v1_rt::rc_map_insert(inner.clone(), pname.clone(), meet_sub_value(existing.clone(), composed.clone())), - None => v1_rt::rc_map_insert(inner.clone(), pname.clone(), composed.clone()), -}, -} -}, - None => inner.clone(), -}) -}, - None => acc.clone(), -}, - None => acc.clone(), -}), - None => v1_rt::rc_empty_map::>, Rc>(), -}, - None => v1_rt::rc_empty_map::>, Rc>(), -} + Some(sig) => match sig.output_provenance.clone().first().cloned() { + Some(callee_prov) => Rc::new(v1_rt::map_keys(&callee_prov)).iter().cloned().fold( + v1_rt::rc_empty_map::>(), + |acc: Rc>>, callee_pname: String| { + match v1_rt::map_get(&callee_prov, callee_pname.clone()) { + Some(callee_rel) => { + match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { + Some(arg) => { + let arg_prov = classify_body_provenance( + arg.clone(), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_sigs.clone(), + let_prov.clone(), + ); + Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold( + acc.clone(), + |inner: Rc>>, + pname: String| { + match v1_rt::map_get(&arg_prov, pname.clone()) { + Some(arg_rel) => { + let composed = compose_sub_value_relations( + arg_rel.clone(), + callee_rel.clone(), + ); + match (*composed.clone()).clone() { + SubValueRelation::SubValueUnknown => { + inner.clone() + } + _ => match v1_rt::map_get( + &inner, + pname.clone(), + ) { + Some(existing) => v1_rt::rc_map_insert( + inner.clone(), + pname.clone(), + meet_sub_value( + existing.clone(), + composed.clone(), + ), + ), + None => v1_rt::rc_map_insert( + inner.clone(), + pname.clone(), + composed.clone(), + ), + }, + } + } + None => inner.clone(), + } + }, + ) + } + None => acc.clone(), + } + } + None => acc.clone(), + } + }, + ), + None => v1_rt::rc_empty_map::>(), + }, + None => v1_rt::rc_empty_map::>(), + } } pub fn classify_body_per_field( @@ -9700,7 +9761,7 @@ pub fn meet_per_field_results( } pub fn empty_prov_map() -> Rc>> { - v1_rt::rc_empty_map::>, Rc>() + v1_rt::rc_empty_map::>() } pub fn meet_body_provenance_maps( @@ -9734,18 +9795,19 @@ pub fn intersect_prov_maps( ) -> Rc>> { Rc::new(v1_rt::map_keys(&a)).iter().cloned().fold( empty_prov_map(), - |result: Rc>>, key: Rc>| { - match v1_rt::map_get(&b, key.clone()) { - Some(b_rel) => match v1_rt::map_get(&a, key.clone()) { - Some(a_rel) => v1_rt::rc_map_insert( - result.clone(), - key.clone(), - meet_sub_value(a_rel.clone(), b_rel.clone()), - ), - None => result.clone(), - }, + |result: Rc>>, key: String| match v1_rt::map_get( + &b, + key.clone(), + ) { + Some(b_rel) => match v1_rt::map_get(&a, key.clone()) { + Some(a_rel) => v1_rt::rc_map_insert( + result.clone(), + key.clone(), + meet_sub_value(a_rel.clone(), b_rel.clone()), + ), None => result.clone(), - } + }, + None => result.clone(), }, ) } @@ -9776,13 +9838,8 @@ pub fn arm_ctx_from_variant_provenance( MatchPattern::Bind { name: bn, .. } => bn.clone(), _ => "".to_string(), }; - if ((crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host( - field_label.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - ))) + if ((bind_name.clone().as_str() == "".to_string().as_str()) + || (field_label.clone().as_str() == "".to_string().as_str())) { c.clone() } else { @@ -9796,7 +9853,7 @@ pub fn arm_ctx_from_variant_provenance( c.type_env.clone(), c.func_sigs.clone(), v1_rt::rc_empty_map::< - Rc>, + String, Rc>>, >(), ); @@ -9858,47 +9915,47 @@ pub fn compose_callee_param_map( let_prov: Rc>>>>, ) -> Rc>> { Rc::new(v1_rt::map_keys(&callee_prov)).iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), - |acc: Rc>>, callee_pname: Rc>| { - match v1_rt::map_get(&callee_prov, callee_pname.clone()) { - Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { - Some(arg) => { - let arg_prov = classify_body_provenance( - arg.clone(), - param_names.clone(), - param_types.clone(), - type_env.clone(), - func_sigs.clone(), - let_prov.clone(), - ); - Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold( - acc.clone(), - |inner: Rc>>, - pname: Rc>| { - match v1_rt::map_get(&arg_prov, pname.clone()) { - Some(arg_rel) => { - let composed = compose_sub_value_relations( - arg_rel.clone(), - callee_rel.clone(), - ); - match (*composed.clone()).clone() { - SubValueRelation::SubValueUnknown => inner.clone(), - _ => v1_rt::rc_map_insert( - inner.clone(), - pname.clone(), - composed.clone(), - ), - } + v1_rt::rc_empty_map::>(), + |acc: Rc>>, callee_pname: String| match v1_rt::map_get( + &callee_prov, + callee_pname.clone(), + ) { + Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { + Some(arg) => { + let arg_prov = classify_body_provenance( + arg.clone(), + param_names.clone(), + param_types.clone(), + type_env.clone(), + func_sigs.clone(), + let_prov.clone(), + ); + Rc::new(v1_rt::map_keys(&arg_prov)).iter().cloned().fold( + acc.clone(), + |inner: Rc>>, pname: String| { + match v1_rt::map_get(&arg_prov, pname.clone()) { + Some(arg_rel) => { + let composed = compose_sub_value_relations( + arg_rel.clone(), + callee_rel.clone(), + ); + match (*composed.clone()).clone() { + SubValueRelation::SubValueUnknown => inner.clone(), + _ => v1_rt::rc_map_insert( + inner.clone(), + pname.clone(), + composed.clone(), + ), } - None => inner.clone(), } - }, - ) - } - None => acc.clone(), - }, + None => inner.clone(), + } + }, + ) + } None => acc.clone(), - } + }, + None => acc.clone(), }, ) } @@ -9934,21 +9991,14 @@ pub fn compute_variant_provenance( __result }); let param_types = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); - if ((crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) - && (crate::v2_std_text::host_string_text_to_rust_host( - ptype.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - ))) + if ((pname.clone().as_str() != "".to_string().as_str()) + && (ptype.clone().as_str() != "".to_string().as_str())) { v1_rt::rc_map_insert(acc.clone(), pname.clone(), ptype.clone()) } else { @@ -9963,23 +10013,20 @@ pub fn compute_variant_provenance( param_types, type_env.clone(), func_sigs, + v1_rt::rc_empty_map::>>>(), v1_rt::rc_empty_map::< - Rc>, - Rc>>, - >(), - v1_rt::rc_empty_map::< - Rc>, + String, Rc>>>>, >(), ) } _ => v1_rt::rc_empty_map::< - Rc>, + String, Rc>>>>, >(), }, None => v1_rt::rc_empty_map::< - Rc>, + String, Rc>>>>, >(), } @@ -9988,7 +10035,7 @@ pub fn compute_variant_provenance( pub fn collect_variant_constructors( body: Rc, - parent_enum: Rc>, + parent_enum: String, param_names: Rc>, param_types: Rc>, type_env: Rc, @@ -10002,14 +10049,12 @@ pub fn collect_variant_constructors( parent_enum: pe, .. } => match pe.clone() { Some(enum_name) => { - if (crate::v2_std_text::host_string_text_to_rust_host(enum_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(parent_enum.clone())) - { + if (enum_name.clone().as_str() == parent_enum.clone().as_str()) { { let variant_name = body.name.clone(); let field_prov_map = body.children.clone().iter().cloned().fold( v1_rt::rc_empty_map::< - Rc>, + String, Rc>>, >(), |m: Rc< @@ -10028,11 +10073,7 @@ pub fn collect_variant_constructors( func_sigs.clone(), let_prov.clone(), ); - if (crate::v2_std_text::host_string_text_to_rust_host( - fname.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { + if (fname.clone().as_str() != "".to_string().as_str()) { v1_rt::rc_map_insert( m.clone(), fname.clone(), @@ -10066,23 +10107,24 @@ pub fn collect_variant_constructors( let callee = expr_call_func_at(body.clone(), type_env.source_indices.clone()); match v1_rt::map_get(&func_sigs, callee) { Some(sig) => { - if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( + if ((authored_name_at( type_env.source_indices.clone(), sig.inferred.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - parent_enum.clone(), - )) && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() - as i64) - > 0)) + ) + .as_str() + == parent_enum.clone().as_str()) + && ((Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).len() + as i64) + > 0)) { { let call_args = call_args_by_name( body.clone(), type_env.source_indices.clone(), ); - Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).iter().cloned().fold(acc.clone(), |variant_acc: Rc>>>>>>, variant_name: Rc>| match v1_rt::map_get(&sig.variant_provenance.clone(), variant_name.clone()) { + Rc::new(v1_rt::map_keys(&sig.variant_provenance.clone())).iter().cloned().fold(acc.clone(), |variant_acc: Rc>>>>>>, variant_name: String| match v1_rt::map_get(&sig.variant_provenance.clone(), variant_name.clone()) { Some(field_map) => { - let composed_field_map = Rc::new(v1_rt::map_keys(&field_map)).iter().cloned().fold(v1_rt::rc_empty_map::>, Rc>>>(), |fm_acc: Rc>>>>, field_name: Rc>| match v1_rt::map_get(&field_map, field_name.clone()) { + let composed_field_map = Rc::new(v1_rt::map_keys(&field_map)).iter().cloned().fold(v1_rt::rc_empty_map::>>>(), |fm_acc: Rc>>>>, field_name: String| match v1_rt::map_get(&field_map, field_name.clone()) { Some(param_map) => { let composed = compose_callee_param_map(param_map.clone(), call_args.clone(), param_names.clone(), param_types.clone(), type_env.clone(), func_sigs.clone(), let_prov.clone()); if ((Rc::new(v1_rt::map_keys(&composed)).len() as i64) > 0) { @@ -10254,9 +10296,9 @@ pub fn merge_field_prov_maps( ) -> Rc>>>> { { let from_a = Rc::new(v1_rt::map_keys(&a)).iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), |result: Rc>>>>, - fname: Rc>| match v1_rt::map_get(&a, fname.clone()) { + fname: String| match v1_rt::map_get(&a, fname.clone()) { Some(a_prov) => match v1_rt::map_get(&b, fname.clone()) { Some(b_prov) => v1_rt::rc_map_insert( result.clone(), @@ -10271,7 +10313,7 @@ pub fn merge_field_prov_maps( Rc::new(v1_rt::map_keys(&b)).iter().cloned().fold( from_a, |result: Rc>>>>, - fname: Rc>| { + fname: String| { if (v1_rt::map_get(&result, fname.clone()) != None) { result.clone() } else { @@ -10294,23 +10336,24 @@ pub fn union_prov_maps( { let from_a = Rc::new(v1_rt::map_keys(&a)).iter().cloned().fold( empty_prov_map(), - |result: Rc>>, key: Rc>| { - match v1_rt::map_get(&a, key.clone()) { - Some(a_rel) => match v1_rt::map_get(&b, key.clone()) { - Some(b_rel) => v1_rt::rc_map_insert( - result.clone(), - key.clone(), - join_sub_value(a_rel.clone(), b_rel.clone()), - ), - None => v1_rt::rc_map_insert(result.clone(), key.clone(), a_rel.clone()), - }, - None => result.clone(), - } + |result: Rc>>, key: String| match v1_rt::map_get( + &a, + key.clone(), + ) { + Some(a_rel) => match v1_rt::map_get(&b, key.clone()) { + Some(b_rel) => v1_rt::rc_map_insert( + result.clone(), + key.clone(), + join_sub_value(a_rel.clone(), b_rel.clone()), + ), + None => v1_rt::rc_map_insert(result.clone(), key.clone(), a_rel.clone()), + }, + None => result.clone(), }, ); Rc::new(v1_rt::map_keys(&b)).iter().cloned().fold( from_a, - |result: Rc>>, key: Rc>| { + |result: Rc>>, key: String| { if (v1_rt::map_get(&result, key.clone()) != None) { result.clone() } else { @@ -10353,16 +10396,8 @@ pub fn populate_output_provenance( first_param.clone(), type_env.source_indices.clone(), ); - if ((crate::v2_std_text::host_string_text_to_rust_host( - ptype.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) && (crate::v2_std_text::host_string_text_to_rust_host( - pname.clone(), - ) - != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - ))) + if ((ptype.clone().as_str() != "".to_string().as_str()) + && (pname.clone().as_str() != "".to_string().as_str())) { { let fields = inductive_fields_for( @@ -10395,7 +10430,7 @@ pub fn populate_output_provenance( let provenance = Rc::new(vec![v1_rt::rc_map_insert( v1_rt::rc_empty_map::< - Rc>, + String, Rc, >( ), @@ -10459,7 +10494,7 @@ pub fn populate_output_provenance( acc.clone(), ), _ => v1_rt::rc_empty_map::< - Rc>, + String, Rc< HashMap< String, @@ -10532,7 +10567,7 @@ pub fn populate_output_provenance( pub fn annotate_descent_evidence( body: Rc, - fn_name: Rc>, + fn_name: String, params: Rc>>, type_env: Rc, scope_locals: Rc>>, @@ -10540,7 +10575,7 @@ pub fn annotate_descent_evidence( ) -> Rc { { let param_name_map = params.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, p: Rc| { let pname = param_node_name_at(p.clone(), type_env.source_indices.clone()); let ptype = resolved_type_name(p.clone(), type_env.source_indices.clone()); @@ -10562,14 +10597,12 @@ pub fn annotate_descent_evidence( param_names: param_name_map, param_order: param_order_list, type_env: type_env.clone(), - sub_value_vars: v1_rt::rc_empty_map::>, Rc>(), - size_aliases: v1_rt::rc_empty_map::>, Rc>(), + sub_value_vars: v1_rt::rc_empty_map::>(), + size_aliases: v1_rt::rc_empty_map::>(), scope_locals: scope_locals, func_sigs: func_sigs, - per_field_vars: v1_rt::rc_empty_map::< - Rc>, - Rc>>, - >(), + per_field_vars: v1_rt::rc_empty_map::>>>( + ), }); annotate_descent(body, ctx) } @@ -10653,12 +10686,13 @@ pub fn infer_auth_source_properties( let mut __result = Vec::new(); for p in props.iter().cloned() { __result.push( - if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + if (field_init_node_name_at( p.clone(), scope.type_env.clone().source_indices.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - "svc_auth_source".to_string(), - )) { + ) + .as_str() + == "svc_auth_source".to_string().as_str()) + { { let val = field_init_node_value(p.clone()); let val_result = infer_expr(val.clone(), scope.clone(), None); @@ -11080,17 +11114,12 @@ pub fn infer_items( }) } -pub fn is_type_variable_name(name: Rc>) -> bool { - (((((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("T".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("K".to_string()))) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("V".to_string()))) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("MappedElement".to_string()))) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("FoldAccumulator".to_string()))) +pub fn is_type_variable_name(name: String) -> bool { + (((((name.clone().as_str() == "T".to_string().as_str()) + || (name.clone().as_str() == "K".to_string().as_str())) + || (name.clone().as_str() == "V".to_string().as_str())) + || (name.clone().as_str() == "MappedElement".to_string().as_str())) + || (name.clone().as_str() == "FoldAccumulator".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -11102,12 +11131,10 @@ pub struct ArgGenericFoldState { pub fn type_node_label( n: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { { let authored = authored_name_at(source_indices, n.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(authored.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + if (authored.clone().as_str() != "".to_string().as_str()) { authored.clone() } else { match n.inferred.clone().as_deref().cloned() { @@ -11132,13 +11159,9 @@ pub fn param_is_generic_decl( }; (((((pt.children.clone().len() as i64) == 0) && (pt.connective.clone() == Connective::NoConnective)) - && (crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) - && ((crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(tname)) - || (type_expr_is_var - && (crate::v2_std_text::host_string_text_to_rust_host(pname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(pt.name.clone()))))) + && (pname.clone().as_str() != "".to_string().as_str())) + && ((pname.clone().as_str() == tname.as_str()) + || (type_expr_is_var && (pname.clone().as_str() == pt.name.clone().as_str())))) } } @@ -11161,9 +11184,7 @@ pub fn unify_generics( && { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(g.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(bind_name.clone())) - { + if (g.clone().as_str() == bind_name.clone().as_str()) { __found = true; break; } @@ -11222,12 +11243,9 @@ pub fn should_unify_record_lit_generics( { let formal_name = type_node_label(formal.clone(), source_indices.clone()); let record_name = type_node_label(arg_expr.clone(), source_indices.clone()); - (((crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - && (crate::v2_std_text::host_string_text_to_rust_host(record_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) - && (crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(record_name.clone()))) + (((formal_name.clone().as_str() != "".to_string().as_str()) + && (record_name.clone().as_str() != "".to_string().as_str())) + && (formal_name.clone().as_str() == record_name.clone().as_str())) } } } @@ -11249,10 +11267,12 @@ pub fn unify_record_lit_field_walk( match Rc::new({ let mut __result = Vec::new(); for fi in record.children.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(field_init_node_name_at( + if (field_init_node_name_at( fi.clone(), scope.type_env.clone().source_indices.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone())) + ) + .as_str() + == field_name.clone().as_str()) { __result.push(fi); } @@ -11307,9 +11327,7 @@ pub fn unify_record_lit_generics( let is_generic_slot = { let mut __found = false; for g in generic_names.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(g.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(formal_name.clone())) - { + if (g.clone().as_str() == formal_name.clone().as_str()) { __found = true; break; } @@ -11331,15 +11349,9 @@ pub fn unify_record_lit_generics( record.clone(), scope.type_env.clone().source_indices.clone(), ); - if ((crate::v2_std_text::host_string_text_to_rust_host( - record_type_name.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) && (crate::v2_std_text::host_string_text_to_rust_host( - formal_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - record_type_name.clone(), - ))) { + if ((record_type_name.clone().as_str() != "".to_string().as_str()) + && (formal_name.clone().as_str() == record_type_name.clone().as_str())) + { unify_record_lit_field_walk( record_lit_expected_fields( Some(record_type_name.clone()), @@ -11529,7 +11541,7 @@ pub fn collect_parent_bindings_filtered( ) } -pub fn kernel_span(name: Rc>) -> Rc { +pub fn kernel_span(name: String) -> Rc { Rc::new(SourceSpan { file: v1_rt::concat( v1_rt::concat(">>, name: Rc>| { + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, v1_rt::concat( @@ -11580,7 +11592,7 @@ pub fn build_type_env( .cloned() .fold( source_indices.clone(), - |acc: Rc>>, name: Rc>| { + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, v1_rt::concat( @@ -11600,12 +11612,9 @@ pub fn build_type_env( let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() - .fold( - intern_table.clone(), - |t: Rc, name: Rc>| { - intern(t, name.clone()).table.clone() - }, - ); + .fold(intern_table.clone(), |t: Rc, name: String| { + intern(t, name.clone()).table.clone() + }); let intern_table = Rc::new(vec![ "Optional".to_string(), "Present".to_string(), @@ -11615,25 +11624,21 @@ pub fn build_type_env( ]) .iter() .cloned() - .fold( - intern_table.clone(), - |t: Rc, name: Rc>| intern(t, name.clone()).table.clone(), - ); + .fold(intern_table.clone(), |t: Rc, name: String| { + intern(t, name.clone()).table.clone() + }); let intern_table = Rc::new(v1_rt::map_keys(&compiler_recursive_types())) .iter() .cloned() - .fold( - intern_table.clone(), - |t: Rc, name: Rc>| { - intern(t, name.clone()).table.clone() - }, - ); + .fold(intern_table.clone(), |t: Rc, name: String| { + intern(t, name.clone()).table.clone() + }); let kernel_bindings_base = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: Rc>| { + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -11802,7 +11807,7 @@ pub fn build_type_env( .cloned() .fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: Rc>| { + |acc: Rc>, name: String| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -11821,9 +11826,7 @@ pub fn build_type_env( let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) - { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { __found = true; break; } @@ -11831,18 +11834,17 @@ pub fn build_type_env( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = - if ((crate::v2_std_text::host_string_text_to_rust_host(module_name_str.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) - && (imports_std_types == false)) - { - match v1_rt::map_get(&parent_index, "std.types".to_string()) { - Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), - None => Rc::new(vec![]), - } - } else { - Rc::new(vec![]) - }; + let std_types_parent_env = if ((module_name_str.clone().as_str() + != "std.types".to_string().as_str()) + && (imports_std_types == false)) + { + match v1_rt::map_get(&parent_index, "std.types".to_string()) { + Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), + None => Rc::new(vec![]), + } + } else { + Rc::new(vec![]) + }; let imported_parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -11866,11 +11868,7 @@ pub fn build_type_env( imp.module_path.clone(), ) { Some(typed_parent) => { - if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "std.types".to_string(), - )) - { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -11924,7 +11922,7 @@ pub fn build_type_env( }, ); let import_inductive_fields = parent_envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, env: Rc| { merge_inductive_fields(acc, env.inductive_fields.clone()) }, @@ -12191,8 +12189,7 @@ pub fn build_type_env( bindings: all_local_bindings, recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( - ), + inductive_fields: v1_rt::rc_empty_map::>>>(), source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); @@ -12201,7 +12198,7 @@ pub fn build_type_env( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::>>(), |acc: Rc>>>, b: Rc| { v1_rt::rc_map_insert( acc, @@ -12214,7 +12211,7 @@ pub fn build_type_env( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, b: Rc| { v1_rt::rc_map_insert(acc, b.name.clone(), b.clone()) }, @@ -12231,13 +12228,16 @@ pub fn build_type_env( cycle_set_str.clone(), Rc::new(v1_rt::map_keys(&compiler_recursive_types())), ); - let cross_type_set_str = cross_type_all_names.clone().iter().cloned().fold( - v1_rt::rc_empty_set::<_>(), - |acc: _, name: Rc>| v1_rt::rc_set_insert(acc, name.clone()), - ); + let cross_type_set_str = cross_type_all_names + .clone() + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { + v1_rt::rc_set_insert(acc, name.clone()) + }); let cross_type_set = cross_type_all_names.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: Rc>| { + |acc: Rc>, name: String| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -12293,23 +12293,22 @@ pub fn build_type_env_unresolved( let intern_table = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() - .fold( - intern_table.clone(), - |t: Rc, name: Rc>| { - intern(t, name.clone()).table.clone() - }, - ); - let intern_table = Rc::new(vec!["Optional".to_string()]).iter().cloned().fold( - intern_table.clone(), - |t: Rc, name: Rc>| intern(t, name.clone()).table.clone(), - ); + .fold(intern_table.clone(), |t: Rc, name: String| { + intern(t, name.clone()).table.clone() + }); + let intern_table = Rc::new(vec!["Optional".to_string()]) + .iter() + .cloned() + .fold(intern_table.clone(), |t: Rc, name: String| { + intern(t, name.clone()).table.clone() + }); let zero_span = make_span(0, 0); let kernel_bindings = Rc::new(v1_rt::map_keys(&kernel_type_set())) .iter() .cloned() .fold( v1_rt::rc_empty_map::>(), - |acc: Rc>>, name: Rc>| { + |acc: Rc>>, name: String| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -12437,17 +12436,14 @@ pub fn build_type_env_unresolved( bindings: kernel_bindings.clone(), recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( - ), + inductive_fields: v1_rt::rc_empty_map::>>>(), source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); let imports_std_types = { let mut __found = false; for imp in module.resolved_imports.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) - { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { __found = true; break; } @@ -12455,18 +12451,17 @@ pub fn build_type_env_unresolved( __found }; let module_name_str = authored_name_at(source_indices.clone(), module.module.clone()); - let std_types_parent_env = - if ((crate::v2_std_text::host_string_text_to_rust_host(module_name_str) - != crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) - && (imports_std_types == false)) - { - match v1_rt::map_get(&parent_index, "std.types".to_string()) { - Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), - None => Rc::new(vec![]), - } - } else { - Rc::new(vec![]) - }; + let std_types_parent_env = if ((module_name_str.as_str() + != "std.types".to_string().as_str()) + && (imports_std_types == false)) + { + match v1_rt::map_get(&parent_index, "std.types".to_string()) { + Some(typed_std) => Rc::new(vec![typed_std.type_env.clone()]), + None => Rc::new(vec![]), + } + } else { + Rc::new(vec![]) + }; let imported_parent_envs = Rc::new({ let mut __result = Vec::new(); for imp in module.resolved_imports.clone().iter().cloned() { @@ -12490,11 +12485,7 @@ pub fn build_type_env_unresolved( imp.module_path.clone(), ) { Some(typed_parent) => { - if (crate::v2_std_text::host_string_text_to_rust_host(imp.module_path.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "std.types".to_string(), - )) - { + if (imp.module_path.clone().as_str() == "std.types".to_string().as_str()) { Rc::new(v1_rt::map_keys( &typed_parent.type_env.clone().bindings.clone(), )) @@ -12548,7 +12539,7 @@ pub fn build_type_env_unresolved( }, ); let import_inductive_fields = parent_envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, env: Rc| { merge_inductive_fields(acc, env.inductive_fields.clone()) }, @@ -12689,8 +12680,7 @@ pub fn build_type_env_unresolved( bindings: local_bindings, recursive_types: Rc::new(vec![]), recursive_type_set: v1_rt::rc_empty_map::(), - inductive_fields: v1_rt::rc_empty_map::>, Rc>>>( - ), + inductive_fields: v1_rt::rc_empty_map::>>>(), source_indices: source_indices.clone(), intern_table: intern_table.clone(), }); @@ -12699,7 +12689,7 @@ pub fn build_type_env_unresolved( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::>>(), |acc: Rc>>>, b: Rc| { v1_rt::rc_map_insert( acc, @@ -12712,7 +12702,7 @@ pub fn build_type_env_unresolved( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, b: Rc| { v1_rt::rc_map_insert(acc, b.name.clone(), b.clone()) }, @@ -12729,13 +12719,16 @@ pub fn build_type_env_unresolved( cycle_set_str.clone(), Rc::new(v1_rt::map_keys(&compiler_recursive_types())), ); - let cross_type_set_str = cross_type_all_names.clone().iter().cloned().fold( - v1_rt::rc_empty_set::<_>(), - |acc: _, name: Rc>| v1_rt::rc_set_insert(acc, name.clone()), - ); + let cross_type_set_str = cross_type_all_names + .clone() + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { + v1_rt::rc_set_insert(acc, name.clone()) + }); let cross_type_set = cross_type_all_names.clone().iter().cloned().fold( v1_rt::rc_empty_map::(), - |acc: Rc>, name: Rc>| { + |acc: Rc>, name: String| { v1_rt::rc_map_insert( acc, intern(intern_table.clone(), name.clone()).id.clone(), @@ -12768,7 +12761,7 @@ pub fn build_type_env_unresolved( pub fn build_item_info( item: Rc, source_indices: Rc>>, - module_name: Rc>, + module_name: String, ) -> Rc { { let kind = item_kind(item.clone()); @@ -12846,11 +12839,7 @@ pub fn build_item_info( } } -pub fn analyze_item( - item: Rc, - env: Rc, - module_name: Rc>, -) -> Rc { +pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc { { let resolved = resolve_item_types(item, env.clone(), module_name.clone()); let ritem = resolved.item.clone(); @@ -12872,7 +12861,7 @@ pub fn analyze_item( is_async: ((ritem.uses.clone().len() as i64) > 0), output_provenance: Rc::new(vec![]), variant_provenance: v1_rt::rc_empty_map::< - Rc>, + String, Rc>>>>, >(), })) @@ -13004,32 +12993,32 @@ pub fn build_module_context( parent_index: Rc>>, resolved_imports: Rc>>, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { { let local = fold_module_contributions( contributions, Rc::new(vec![]), - v1_rt::rc_empty_map::>, Rc>(), - v1_rt::rc_empty_map::>, Rc>>>(), - v1_rt::rc_empty_map::>, Rc>(), - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>>>(), + v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>(), Rc::new(vec![]), env.source_indices.clone(), ); let imported_enum_names = resolved_imports.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, imp: Rc| { imp.specific_names.clone().iter().cloned().fold( acc, - |inner: Rc>, n: Rc>| { + |inner: Rc>, n: String| { v1_rt::rc_map_insert(inner, n.clone(), true) }, ) }, ); let variant_fold = Rc::new(v1_rt::map_values(&env.bindings.clone())).iter().cloned().fold(Rc::new(VariantFoldState { - locals: v1_rt::rc_empty_map::>, Rc>(), + locals: v1_rt::rc_empty_map::>(), collision_errors: Rc::new(vec![]), }), |acc: Rc, binding: Rc| { let is_coproduct = (binding.resolved.clone().connective.clone() == Connective::Disj); @@ -13089,7 +13078,7 @@ if (curr_is_imported.clone() && prev_is_imported.clone()) { resolved_imports.clone(), parent_index, env.clone(), - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), local.svc_registry.clone(), local.svc_locals.clone(), ); @@ -13171,10 +13160,9 @@ pub fn typecheck_module( items: Rc::new(vec![]), type_env: env.clone(), func_env: Rc::new(ResolvedFuncEnv { - signatures: v1_rt::rc_empty_map::>, Rc>( - ), + signatures: v1_rt::rc_empty_map::>(), }), - item_registry: v1_rt::rc_empty_map::>, Rc>(), + item_registry: v1_rt::rc_empty_map::>(), }), diagnostics: v1_rt::concat(env_diags.clone(), seed_diags.clone()), }); @@ -13224,12 +13212,11 @@ pub fn typecheck_module( type_env: env.clone(), func_env: ctx.func_env.clone(), locals: data_locals.clone(), - match_bound_names: v1_rt::rc_empty_map::>, bool>(), + match_bound_names: v1_rt::rc_empty_map::(), module_name: resolved_module_name.clone(), service_registry: ctx.svc_registry.clone(), item_registry: ctx.item_registry.clone(), - lambda_param_provenance: v1_rt::rc_empty_map::>, Rc>( - ), + lambda_param_provenance: v1_rt::rc_empty_map::>(), }); let typed_item_results = infer_items(ctx.resolved_items.clone(), infer_scope); let typed_items = Rc::new({ @@ -13340,7 +13327,7 @@ pub struct BindingsAccum { pub fn resolve_env_bindings( env: Rc, - module_name: Rc>, + module_name: String, local_names: Rc>, deps_map: Rc>>>, ) -> Rc { @@ -13384,7 +13371,7 @@ pub fn resolve_env_bindings( pub fn topo_resolve_types( mut remaining: Rc>, mut env: Rc, - mut module_name: Rc>, + mut module_name: String, mut diagnostics: Rc>>, mut local_names: Rc>, mut deps_map: Rc>>>, @@ -13397,10 +13384,13 @@ pub fn topo_resolve_types( diagnostics: diagnostics.clone(), }); } - let remaining_set = remaining.clone().iter().cloned().fold( - v1_rt::rc_empty_set::<_>(), - |acc: _, name: Rc>| v1_rt::rc_set_insert(acc, name.clone()), - ); + let remaining_set = remaining + .clone() + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, name: String| { + v1_rt::rc_set_insert(acc, name.clone()) + }); let ready = Rc::new({ let mut __result = Vec::new(); for name in remaining.clone().iter().cloned() { @@ -13409,16 +13399,8 @@ pub fn topo_resolve_types( let mut __all = true; for dep in deps.clone().iter().cloned() { if !((((is_kernel_type(dep.clone()) - || (crate::v2_std_text::host_string_text_to_rust_host( - dep.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "None".to_string(), - ))) - || (crate::v2_std_text::host_string_text_to_rust_host( - dep.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - ))) + || (dep.clone().as_str() == "None".to_string().as_str())) + || (dep.clone().as_str() == "".to_string().as_str())) || is_recursive_type_by_name(env.clone(), dep.clone())) || (v1_rt::set_contains(&remaining_set, dep.clone()) == false)) { @@ -13442,7 +13424,7 @@ pub fn topo_resolve_types( bindings: env.bindings.clone(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, name: Rc>| { + |acc: Rc, name: String| { let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { @@ -13496,7 +13478,7 @@ pub fn topo_resolve_types( bindings: env.bindings.clone(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, name: Rc>| { + |acc: Rc, name: String| { let ident = intern(env.intern_table.clone(), name.clone()).id.clone(); match v1_rt::map_get(&env.bindings.clone(), ident.clone()) { Some(binding) => { @@ -13529,8 +13511,8 @@ pub fn topo_resolve_types( }, ); let ready_set = ready.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -13632,10 +13614,7 @@ pub fn variant_has_positional_payload_shape( (((variant.children.clone().len() as i64) == 1) && match variant.children.clone().first().cloned() { Some(f) => { - (crate::v2_std_text::host_string_text_to_rust_host(field_node_name_at( - f.clone(), - source_indices, - )) == crate::v2_std_text::host_string_text_to_rust_host("0".to_string())) + (field_node_name_at(f.clone(), source_indices).as_str() == "0".to_string().as_str()) } None => false, }) @@ -13766,7 +13745,7 @@ pub fn build_positional_payload_variants( pub fn build_emit_graph_info(modules: Rc>>) -> Rc { { let init = Rc::new(EmitInfoBuildState { - type_summaries: v1_rt::rc_empty_map::>, Rc>(), + type_summaries: v1_rt::rc_empty_map::>(), }); let built = modules.clone().iter().cloned().fold( init.clone(), @@ -13809,15 +13788,13 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc(), - ownership_index: v1_rt::rc_empty_map::< - Rc>, - Rc>, - >(), + ownership_index: v1_rt::rc_empty_map::>>( + ), movable: v1_rt::rc_empty_set::(), variant_to_enum: vtoe, owned_bindings: v1_rt::rc_empty_set::(), read_only_params_index: v1_rt::rc_empty_map::< - Rc>, + String, Rc>, >(), read_only_params: v1_rt::rc_empty_set::(), @@ -13833,8 +13810,8 @@ pub fn typecheck( typecheck_modules( graph.modules.clone(), Rc::new(vec![]), - v1_rt::rc_empty_map::>, Rc>(), - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>(), Rc::new(vec![]), source_indices, intern_table, diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index 3ae945462e6..c3d02096a6e 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -35,11 +35,7 @@ pub struct KeyedCollectionParts { pub value_type: Rc, } -pub fn access_error( - message: Rc>, - span: Rc, - module_name: Rc>, -) -> Rc { +pub fn access_error(message: String, span: Rc, module_name: String) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::InternalError { message: message, @@ -53,7 +49,7 @@ pub fn access_result( inferred: Rc, diagnostics: Rc>>, span: Rc, - fallback_message: Rc>, + fallback_message: String, ) -> Rc { if ((diagnostics.clone().len() as i64) == 0) { Rc::new(AccessCheckResultNode { @@ -103,7 +99,7 @@ pub fn check_index_access_node( base_type: Rc, index_type: Rc, span: Rc, - module_name: Rc>, + module_name: String, source_indices: Rc>>, ) -> Rc { { @@ -209,7 +205,7 @@ pub fn check_slice_access_node( start_type: Rc, end_type: Rc, span: Rc, - module_name: Rc>, + module_name: String, source_indices: Rc>>, ) -> Rc { { diff --git a/src/v1/stage0/src/v1_compiler_infer_cycle.rs b/src/v1/stage0/src/v1_compiler_infer_cycle.rs index 0038bb82a79..e06cb29b877 100644 --- a/src/v1/stage0/src/v1_compiler_infer_cycle.rs +++ b/src/v1/stage0/src/v1_compiler_infer_cycle.rs @@ -18,28 +18,26 @@ pub fn compute_in_graph_deps( ) -> Rc>>> { { let result = all_names.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), - |acc: Rc>>>, name: Rc>| { - match v1_rt::map_get(&deps_map, name.clone()) { - Some(deps) => { - let local = Rc::new({ - let mut __result = Vec::new(); - for d in deps.clone().iter().cloned() { - if ((crate::v2_std_text::host_string_text_to_rust_host(d.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - name.clone(), - )) - && v1_rt::set_contains(&name_set, d.clone())) - { - __result.push(d); - } + v1_rt::rc_empty_map::>>(), + |acc: Rc>>>, name: String| match v1_rt::map_get( + &deps_map, + name.clone(), + ) { + Some(deps) => { + let local = Rc::new({ + let mut __result = Vec::new(); + for d in deps.clone().iter().cloned() { + if ((d.clone().as_str() != name.clone().as_str()) + && v1_rt::set_contains(&name_set, d.clone())) + { + __result.push(d); } - __result - }); - v1_rt::rc_map_insert(acc.clone(), name.clone(), local.clone()) - } - None => v1_rt::rc_map_insert(acc.clone(), name.clone(), Rc::new(vec![])), + } + __result + }); + v1_rt::rc_map_insert(acc.clone(), name.clone(), local.clone()) } + None => v1_rt::rc_map_insert(acc.clone(), name.clone(), Rc::new(vec![])), }, ); result @@ -51,14 +49,14 @@ pub fn build_reverse_adj( local_deps: Rc>>>, ) -> Rc>>> { all_names.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), - |acc: Rc>>>, name: Rc>| match v1_rt::map_get( + v1_rt::rc_empty_map::>>(), + |acc: Rc>>>, name: String| match v1_rt::map_get( &local_deps, name.clone(), ) { Some(deps) => deps.clone().iter().cloned().fold( acc.clone(), - |inner_acc: Rc>>>, dep: Rc>| { + |inner_acc: Rc>>>, dep: String| { let existing = match v1_rt::map_get(&inner_acc, dep.clone()) { Some(v) => v.clone(), None => Rc::new(vec![]), @@ -80,8 +78,8 @@ pub fn build_in_degree( local_deps: Rc>>>, ) -> Rc> { all_names.iter().cloned().fold( - v1_rt::rc_empty_map::>, i64>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { let deg = match v1_rt::map_get(&local_deps, name.clone()) { Some(deps) => (deps.clone().len() as i64), None => 0, @@ -161,7 +159,7 @@ pub fn kahn_cycle_drain( in_degree: in_degree.clone(), removed_count: removed_count.clone(), }), - |state: Rc, node: Rc>| { + |state: Rc, node: String| { let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); { let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { @@ -170,7 +168,7 @@ pub fn kahn_cycle_drain( }; let new_deg = dependents.clone().iter().cloned().fold( state.in_degree, - |deg_acc: Rc>, dep: Rc>| { + |deg_acc: Rc>, dep: String| { let old = match v1_rt::map_get(°_acc, dep.clone()) { Some(d) => d.clone(), None => 0, @@ -185,29 +183,32 @@ pub fn kahn_cycle_drain( } }, ); - let next_queue = queue.clone().iter().cloned().fold( - Rc::new(vec![]), - |acc: _, node: Rc>| { - let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { - Some(v) => v.clone(), - None => Rc::new(vec![]), - }; - dependents.clone().iter().cloned().fold( - acc, - |inner_acc: _, dep: Rc>| { - let deg = match v1_rt::map_get(&result.in_degree.clone(), dep.clone()) { - Some(d) => d.clone(), - None => 0, - }; - if (deg.clone() == 0) { - v1_rt::rc_list_push(inner_acc.clone(), dep.clone()) - } else { - inner_acc.clone() - } - }, - ) - }, - ); + let next_queue = + queue + .clone() + .iter() + .cloned() + .fold(Rc::new(vec![]), |acc: _, node: String| { + let dependents = match v1_rt::map_get(&reverse_adj, node.clone()) { + Some(v) => v.clone(), + None => Rc::new(vec![]), + }; + dependents + .clone() + .iter() + .cloned() + .fold(acc, |inner_acc: _, dep: String| { + let deg = match v1_rt::map_get(&result.in_degree.clone(), dep.clone()) { + Some(d) => d.clone(), + None => 0, + }; + if (deg.clone() == 0) { + v1_rt::rc_list_push(inner_acc.clone(), dep.clone()) + } else { + inner_acc.clone() + } + }) + }); { let __tco_0 = next_queue; let __tco_1 = result.in_degree.clone(); @@ -234,10 +235,13 @@ pub fn detect_type_cycles_kahn( } __result }); - let name_set = all_names.clone().iter().cloned().fold( - v1_rt::rc_empty_set::<_>(), - |acc: _, n: Rc>| v1_rt::rc_set_insert(acc, n.clone()), - ); + let name_set = all_names + .clone() + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, n: String| { + v1_rt::rc_set_insert(acc, n.clone()) + }); let local_deps = compute_in_graph_deps(all_names.clone(), deps_map.clone(), name_set); let self_refs = Rc::new({ let mut __result = Vec::new(); @@ -246,9 +250,7 @@ pub fn detect_type_cycles_kahn( Some(deps) => { let mut __found = false; for d in deps.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(d.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) - { + if (d.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -263,14 +265,16 @@ pub fn detect_type_cycles_kahn( __result }); let cycle_members = kahn_remove_loop(all_names.clone(), local_deps); - let sr_set = self_refs.iter().cloned().fold( - v1_rt::rc_empty_set::<_>(), - |acc: _, n: Rc>| v1_rt::rc_set_insert(acc, n.clone()), - ); + let sr_set = self_refs + .iter() + .cloned() + .fold(v1_rt::rc_empty_set::<_>(), |acc: _, n: String| { + v1_rt::rc_set_insert(acc, n.clone()) + }); let cm_set = cycle_members .iter() .cloned() - .fold(sr_set, |acc: _, n: Rc>| { + .fold(sr_set, |acc: _, n: String| { v1_rt::rc_set_insert(acc, n.clone()) }); let result = Rc::new({ diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index c270c9de145..98745ada53b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -53,7 +53,7 @@ impl TypeRepr { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeSummary { - pub name: Rc>, + pub name: String, pub repr: Rc, pub field_summaries: Rc>>, pub field_type_map: Rc>, @@ -84,30 +84,25 @@ pub struct EmitInfoBuildState { pub fn empty_emit_graph_info() -> Rc { Rc::new(EmitGraphInfo { - type_summaries: v1_rt::rc_empty_map::>, Rc>(), + type_summaries: v1_rt::rc_empty_map::>(), recursive_type_set: v1_rt::rc_empty_set::(), fielded_variants: v1_rt::rc_empty_set::(), positional_payload_variants: v1_rt::rc_empty_set::(), shared_types: v1_rt::rc_empty_set::(), - ownership_index: v1_rt::rc_empty_map::< - Rc>, - Rc>, - >(), + ownership_index: v1_rt::rc_empty_map::>>(), movable: v1_rt::rc_empty_set::(), - variant_to_enum: v1_rt::rc_empty_map::>, Rc>>(), + variant_to_enum: v1_rt::rc_empty_map::(), owned_bindings: v1_rt::rc_empty_set::(), - read_only_params_index: v1_rt::rc_empty_map::< - Rc>, - Rc>, - >(), + read_only_params_index: v1_rt::rc_empty_map::>>( + ), read_only_params: v1_rt::rc_empty_set::(), }) } pub fn variant_has_fields( emit_info: Rc, - enum_name: Rc>, - variant_name: Rc>, + enum_name: String, + variant_name: String, ) -> bool { { let key = v1_rt::concat(v1_rt::concat(enum_name, "::".to_string()), variant_name); @@ -115,16 +110,13 @@ pub fn variant_has_fields( } } -pub fn variant_summary_key( - enum_name: Rc>, - variant_name: Rc>, -) -> Rc> { +pub fn variant_summary_key(enum_name: String, variant_name: String) -> String { v1_rt::concat(v1_rt::concat(enum_name, "::".to_string()), variant_name) } pub fn lookup_emit_type_summary( emit_info: Rc, - type_name: Rc>, + type_name: String, ) -> Option> { v1_rt::map_get(&emit_info.type_summaries.clone(), type_name) } @@ -136,7 +128,7 @@ pub fn derive_variant_to_enum( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, summary: Rc| match (*summary .repr .clone()) @@ -148,19 +140,18 @@ pub fn derive_variant_to_enum( .cloned() .fold( acc.clone(), - |inner: Rc>, vn: Rc>| { - match v1_rt::map_get(&inner, vn.clone()) { - Some(_) => v1_rt::rc_map_insert( - inner.clone(), - vn.clone(), - "".to_string(), - ), - None => v1_rt::rc_map_insert( - inner.clone(), - vn.clone(), - summary.name.clone(), - ), + |inner: Rc>, vn: String| match v1_rt::map_get( + &inner, + vn.clone(), + ) { + Some(_) => { + v1_rt::rc_map_insert(inner.clone(), vn.clone(), "".to_string()) } + None => v1_rt::rc_map_insert( + inner.clone(), + vn.clone(), + summary.name.clone(), + ), }, ) } @@ -171,7 +162,7 @@ pub fn derive_variant_to_enum( pub fn is_known_variant( type_summaries: Rc>>, - name: Rc>, + name: String, ) -> bool { { let mut __found = false; @@ -192,8 +183,8 @@ pub fn is_known_variant( pub fn variant_belongs_to_enum( type_summaries: Rc>>, - variant_name: Rc>, - enum_name: Rc>, + variant_name: String, + enum_name: String, ) -> bool { match v1_rt::map_get(&type_summaries, enum_name) { Some(summary) => match (*summary.repr.clone()).clone() { @@ -208,7 +199,7 @@ pub fn variant_belongs_to_enum( pub fn is_enum_in_summaries( type_summaries: Rc>>, - type_name: Rc>, + type_name: String, ) -> bool { match v1_rt::map_get(&type_summaries, type_name) { Some(summary) => match (*summary.repr.clone()).clone() { @@ -221,9 +212,9 @@ pub fn is_enum_in_summaries( pub fn find_variant_parent( type_summaries: Rc>>, - variant_name: Rc>, + variant_name: String, scope_enums: Rc>, -) -> Rc> { +) -> Option { Rc::new({ let mut __result = Vec::new(); for en in scope_enums.iter().cloned() { @@ -273,7 +264,7 @@ pub fn build_struct_field_summaries( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let child = pair.1.clone(); @@ -310,7 +301,7 @@ pub fn build_struct_field_summaries( pub fn find_first_enum_field_node( variants: Rc>>, - field_name: Rc>, + field_name: String, source_indices: Rc>>, ) -> Option> { match variants.first().cloned() { @@ -324,7 +315,7 @@ pub fn find_first_enum_field_node( pub fn enum_field_present_in_all_variants( variants: Rc>>, - field_name: Rc>, + field_name: String, source_indices: Rc>>, ) -> bool { { @@ -341,7 +332,7 @@ pub fn enum_field_present_in_all_variants( pub fn enum_field_type_consistent( variants: Rc>>, - field_name: Rc>, + field_name: String, expected: Rc, source_indices: Rc>>, ) -> bool { @@ -415,8 +406,8 @@ pub fn build_enum_field_summaries( __result }); consistent.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), - |acc: Rc>>, field_name: Rc>| { + v1_rt::rc_empty_map::>(), + |acc: Rc>>, field_name: String| { match find_first_enum_field_node( variants.clone(), field_name.clone(), @@ -444,7 +435,7 @@ pub fn build_field_type_map( source_indices: Rc>>, ) -> Rc> { children.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), |acc: Rc>, child: Rc| match child .inferred .clone() @@ -462,13 +453,9 @@ pub fn build_field_type_map( false }; let key = authored_name_at(source_indices.clone(), child.clone()); - if (((crate::v2_std_text::host_string_text_to_rust_host(resolved_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + if (((resolved_name.clone().as_str() != "".to_string().as_str()) && !ft_is_type_var.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(resolved_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - "Dynamic".to_string(), - ))) + && (resolved_name.clone().as_str() != "Dynamic".to_string().as_str())) { v1_rt::rc_map_insert(acc.clone(), key.clone(), resolved_name.clone()) } else { @@ -520,7 +507,7 @@ pub fn build_type_summary( repr: Rc::new(TypeRepr::StructRepr), field_summaries: build_struct_field_summaries(item.clone(), source_indices.clone()), field_type_map: build_field_type_map(item.children.clone(), source_indices.clone()), - variant_name_set: v1_rt::rc_empty_map::>, bool>(), + variant_name_set: v1_rt::rc_empty_map::(), generic_param_names: gpn, has_fn_fields: has_fn, })) @@ -545,10 +532,9 @@ pub fn build_type_summary( item.children.clone(), source_indices.clone(), ), - field_type_map: v1_rt::rc_empty_map::>, Rc>>( - ), + field_type_map: v1_rt::rc_empty_map::(), variant_name_set: item.children.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, child: Rc| { v1_rt::rc_map_insert( acc, @@ -612,11 +598,7 @@ pub fn add_emit_item_summary( variant.children.clone(), source_indices.clone(), ), - variant_name_set: v1_rt::rc_empty_map::< - Rc>, - bool, - >( - ), + variant_name_set: v1_rt::rc_empty_map::(), generic_param_names: Rc::new(vec![]), has_fn_fields: v_has_fn.clone(), }), diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 95139a95c3d..34a7f135c98 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -30,7 +30,7 @@ pub struct TypeEnv { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TypeBinding { - pub name: Rc>, + pub name: String, pub resolved: Rc, pub provenance: Rc, } @@ -42,7 +42,7 @@ pub fn is_recursive_type(env: Rc, ident: i64) -> bool { } } -pub fn is_recursive_type_by_name(env: Rc, name: Rc>) -> bool { +pub fn is_recursive_type_by_name(env: Rc, name: String) -> bool { match intern_find(env.intern_table.clone(), name) { Some(id) => is_recursive_type(env.clone(), id.clone()), None => false, @@ -56,14 +56,14 @@ pub fn lookup_type(env: Rc, ident: i64) -> Option> { } } -pub fn lookup_type_by_name(env: Rc, name: Rc>) -> Option> { +pub fn lookup_type_by_name(env: Rc, name: String) -> Option> { match intern_find(env.intern_table.clone(), name) { Some(id) => lookup_type(env.clone(), id.clone()), None => None, } } -pub fn authored_name(env: Rc, node: Rc) -> Rc> { +pub fn authored_name(env: Rc, node: Rc) -> String { authored_name_at(env.source_indices.clone(), node) } @@ -81,10 +81,7 @@ pub fn is_recursive_type_for(env: Rc, node: Rc) -> bool { } } -pub fn inductive_fields_for( - env: Rc, - type_name: Rc>, -) -> Rc>> { +pub fn inductive_fields_for(env: Rc, type_name: String) -> Rc>> { match v1_rt::map_get(&env.inductive_fields.clone(), type_name) { Some(fields) => fields.clone(), None => Rc::new(vec![]), @@ -93,17 +90,15 @@ pub fn inductive_fields_for( pub fn is_inductive_field( env: Rc, - type_name: Rc>, - variant_name: Rc>, - field_name: Rc>, + type_name: String, + variant_name: String, + field_name: String, ) -> bool { { let mut __found = false; for f in inductive_fields_for(env, type_name).iter().cloned() { - if ((crate::v2_std_text::host_string_text_to_rust_host(f.variant_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone())) - && (crate::v2_std_text::host_string_text_to_rust_host(f.field_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()))) + if ((f.variant_name.clone().as_str() == variant_name.clone().as_str()) + && (f.field_name.clone().as_str() == field_name.clone().as_str())) { __found = true; break; @@ -115,9 +110,9 @@ pub fn is_inductive_field( pub fn put_inductive_field( fields: Rc>>>>, - type_name: Rc>, - variant_name: Rc>, - field_name: Rc>, + type_name: String, + variant_name: String, + field_name: String, shape: RecursionShape, ) -> Rc>>>> { { @@ -144,11 +139,11 @@ pub fn put_inductive_field( pub fn put_inductive_field_cross( fields: Rc>>>>, - type_name: Rc>, - variant_name: Rc>, - field_name: Rc>, + type_name: String, + variant_name: String, + field_name: String, shape: RecursionShape, - element_type: Rc>, + element_type: String, ) -> Rc>>>> { { let existing = match v1_rt::map_get(&fields, type_name.clone()) { @@ -178,7 +173,7 @@ pub fn merge_inductive_fields( ) -> Rc>>>> { Rc::new(v1_rt::map_keys(&right)).iter().cloned().fold( left.clone(), - |acc: Rc>>>>, type_name: Rc>| { + |acc: Rc>>>>, type_name: String| { match v1_rt::map_get(&right, type_name.clone()) { Some(incoming) => { let existing = match v1_rt::map_get(&acc, type_name.clone()) { @@ -201,7 +196,7 @@ pub fn inductive_fields_list_to_map( fields: Rc>>, ) -> Rc>>>> { fields.iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, field: Rc| { let existing = match v1_rt::map_get(&acc, field.type_name.clone()) { Some(fs) => fs.clone(), @@ -238,13 +233,13 @@ pub fn merge_envs(envs: Rc>>) -> Rc { }, ); let merged_inductive_fields = envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>>(), + v1_rt::rc_empty_map::>>>(), |acc: Rc>>>>, env: Rc| { merge_inductive_fields(acc, env.inductive_fields.clone()) }, ); let merged_source_indices = envs.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, env: Rc| { v1_rt::rc_map_merge(acc, env.source_indices.clone()) }, diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index dc7bb6b8a40..6f94f923962 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -43,8 +43,8 @@ pub enum ItemKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemInfo { - pub name: Rc>, - pub module_name: Rc>, + pub name: String, + pub module_name: String, pub kind: ItemKind, pub service_names: Rc>, pub resource_names: Rc>, @@ -225,10 +225,3 @@ pub fn variant_locals_from_items( }, ) } - -pub struct FnItem; -pub struct FuncItem; -pub struct TypeItem; -pub struct DataItem; -pub struct ServiceItem; -pub struct OtherItem; diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 11d49c60997..72331fe9761 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -56,11 +56,9 @@ pub fn is_type_variable(inferred: Rc) -> bool { } } -pub fn is_witness_type_name(name: Rc>) -> bool { - ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("witness".to_string()))) +pub fn is_witness_type_name(name: String) -> bool { + ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -72,7 +70,7 @@ pub struct KnownMethodResolution { pub fn lookup_in_scope( locals: Rc>>, - name: Rc>, + name: String, ) -> Option> { match v1_rt::map_get(&locals, name) { Some(binding) => Some(binding.resolved.clone()), @@ -80,16 +78,13 @@ pub fn lookup_in_scope( } } -pub fn lookup_func_sig( - func_env: Rc, - name: Rc>, -) -> Option> { +pub fn lookup_func_sig(func_env: Rc, name: String) -> Option> { v1_rt::map_get(&func_env.signatures.clone(), name) } pub fn lookup_field_type_node( n: Rc, - field_name: Rc>, + field_name: String, source_indices: Rc>>, ) -> Option> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -97,9 +92,7 @@ pub fn lookup_field_type_node( if is_optional { { let inner = with_required_cardinality(n.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(field_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("value".to_string())) - { + if (field_name.clone().as_str() == "value".to_string().as_str()) { Some(inner) } else { match lookup_field_type_node(inner, field_name.clone(), source_indices.clone()) @@ -123,11 +116,8 @@ pub fn lookup_field_type_node( ) { Some(field_child) => { if (node_is_keyed_collection(n.clone(), source_indices.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host( - field_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "lookup".to_string(), - ))) + && (field_name.clone().as_str() + == "lookup".to_string().as_str())) { { let value_child = @@ -177,7 +167,7 @@ pub fn lookup_field_type_node( pub fn lookup_coproduct_common_field_node( variants: Rc>>, - field_name: Rc>, + field_name: String, source_indices: Rc>>, ) -> Option> { { @@ -211,7 +201,7 @@ pub fn lookup_coproduct_common_field_node( } pub fn resolve_scrutinee_type_node(env: Rc, n: Rc) -> Rc { - resolve_scrutinee_type_node_seen(env, n, v1_rt::rc_empty_map::>, bool>()) + resolve_scrutinee_type_node_seen(env, n, v1_rt::rc_empty_map::()) } pub fn resolve_scrutinee_type_node_seen( @@ -247,24 +237,16 @@ pub fn resolve_scrutinee_type_node_seen( let canonical = authored_name(env.clone(), normed.clone()); if (normed.inferred.clone() != None) { { - let next_seen = if (crate::v2_std_text::host_string_text_to_rust_host( - canonical.clone(), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { - seen.clone() - } else { - v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) - }; + let next_seen = + if (canonical.clone().as_str() == "".to_string().as_str()) { + seen.clone() + } else { + v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) + }; match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { - if ((((crate::v2_std_text::host_string_text_to_rust_host( - authored_name(env.clone(), target.clone()), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - canonical.clone(), - )) + if ((((authored_name(env.clone(), target.clone()).as_str() + == canonical.clone().as_str()) && (target.inferred.clone() == None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) @@ -282,31 +264,23 @@ pub fn resolve_scrutinee_type_node_seen( } } } else { - if ((crate::v2_std_text::host_string_text_to_rust_host(canonical.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) + if ((canonical.clone().as_str() != "".to_string().as_str()) && emit_map_has(seen.clone(), canonical.clone())) { nominal_type_ref(canonical.clone()) } else { { let next_seen = - if (crate::v2_std_text::host_string_text_to_rust_host( - canonical.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "".to_string(), - )) { + if (canonical.clone().as_str() == "".to_string().as_str()) { seen.clone() } else { v1_rt::rc_map_insert(seen.clone(), canonical.clone(), true) }; match lookup_type_for(env.clone(), normed.clone()) { Some(resolved) => { - if ((((crate::v2_std_text::host_string_text_to_rust_host( - authored_name(env.clone(), resolved.clone()), - ) - == crate::v2_std_text::host_string_text_to_rust_host( - canonical.clone(), - )) + if ((((authored_name(env.clone(), resolved.clone()) + .as_str() + == canonical.clone().as_str()) && (resolved.inferred.clone() == None)) && (resolved.connective.clone() == Connective::NoConnective)) @@ -401,16 +375,13 @@ pub fn set_element_type_in_env(type_node: Rc, env: Rc) -> Option< pub fn field_summary_for_type( base_type: Rc, env: Rc, - field: Rc>, + field: String, ) -> Option> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let resolved = resolve_scrutinee_type_node(env.clone(), base_type); let normed = normalize_access_type_node(resolved.clone()); let normed_opt = (normed.return_cardinality.clone() == Cardinality::CardOptional); - if ((crate::v2_std_text::host_string_text_to_rust_host(field.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("value".to_string())) - && normed_opt.clone()) - { + if ((field.clone().as_str() == "value".to_string().as_str()) && normed_opt.clone()) { Some(Rc::new(FieldSummary { access_style: FieldAccessStyle::OptionalUnwrap, value_shape: FieldValueShape::PlainValue, @@ -498,11 +469,7 @@ pub fn map_lookup_result_type( field: Rc, source_indices: Rc>>, ) -> Option> { - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - product, - )) == crate::v2_std_text::host_string_text_to_rust_host("Map".to_string())) - { + if (authored_name_at(source_indices.clone(), product).as_str() == "Map".to_string().as_str()) { match product_field_result_type(field) { Some(raw) => { if is_witness_type_name(authored_name_at(source_indices.clone(), raw.clone())) { @@ -524,17 +491,15 @@ pub fn map_lookup_result_type( pub fn lookup_field_in_product( product: Rc, - method_name: Rc>, + method_name: String, source_indices: Rc>>, ) -> Option> { { let matching = Rc::new({ let mut __result = Vec::new(); for c in product.children.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - c.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(method_name.clone())) + if (authored_name_at(source_indices.clone(), c.clone()).as_str() + == method_name.clone().as_str()) { __result.push(c); } @@ -542,33 +507,30 @@ pub fn lookup_field_in_product( __result }); match matching.first().cloned() { - Some(field) => { - match if (crate::v2_std_text::host_string_text_to_rust_host(method_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("lookup".to_string())) - { - map_lookup_result_type(product.clone(), field.clone(), source_indices.clone()) - } else { - None - } { - Some(lookup_rt) => Some(Rc::new(MethodFieldResult { + Some(field) => match if (method_name.clone().as_str() == "lookup".to_string().as_str()) + { + map_lookup_result_type(product.clone(), field.clone(), source_indices.clone()) + } else { + None + } { + Some(lookup_rt) => Some(Rc::new(MethodFieldResult { + field_node: field.clone(), + result_type: lookup_rt.clone(), + size_effect: None, + cost_shape: None, + algebra_template: None, + })), + None => match product_field_result_type(field.clone()) { + Some(rt) => Some(Rc::new(MethodFieldResult { field_node: field.clone(), - result_type: lookup_rt.clone(), + result_type: rt.clone(), size_effect: None, cost_shape: None, algebra_template: None, })), - None => match product_field_result_type(field.clone()) { - Some(rt) => Some(Rc::new(MethodFieldResult { - field_node: field.clone(), - result_type: rt.clone(), - size_effect: None, - cost_shape: None, - algebra_template: None, - })), - None => None, - }, - } - } + None => None, + }, + }, None => None, } } @@ -576,7 +538,7 @@ pub fn lookup_field_in_product( pub fn lookup_structural_method( receiver_type: Rc, - method_name: Rc>, + method_name: String, source_indices: Rc>>, ) -> Rc { { @@ -618,7 +580,19 @@ pub fn lookup_structural_method( let template_match = match profile { Some(p) => { let templates = algebra_templates_for_profile(p.clone()); - Rc::new({ let mut __result = Vec::new(); for t in templates.iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(t.name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(method_name.clone())) { __result.push(t); } } __result }).first().cloned() + Rc::new({ + let mut __result = Vec::new(); + for t in templates.iter().cloned() { + if (t.name.clone().as_str() + == method_name.clone().as_str()) + { + __result.push(t); + } + } + __result + }) + .first() + .cloned() } None => None, }; @@ -657,7 +631,7 @@ pub fn lookup_structural_method( pub fn resolve_known_method_node( receiver: Rc, receiver_type: Rc, - method_name: Rc>, + method_name: String, fold_accumulator_type: Option>, service_registry: Rc>>>>, source_indices: Rc>>, diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 792287f3ecd..2cbb1838368 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -20,7 +20,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn type_variable_node(id: Rc>) -> Rc { +pub fn type_variable_node(id: String) -> Rc { Rc::new(Node { name: "".to_string(), span: make_span(0, 0), @@ -52,7 +52,7 @@ pub fn map_of_type_variables() -> Rc { .clone() } -pub fn list_of_type_variable(id: Rc>) -> Rc { +pub fn list_of_type_variable(id: String) -> Rc { make_container_type("List".to_string(), type_variable_node(id)) .ty .clone() @@ -68,12 +68,8 @@ pub fn witness_of_element(element: Rc) -> Rc { .clone() } -pub fn seed_node_map(key: Rc>, value: Rc) -> Rc>> { - v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>(), - key, - value, - ) +pub fn seed_node_map(key: String, value: Rc) -> Rc>> { + v1_rt::rc_map_insert(v1_rt::rc_empty_map::>(), key, value) } pub fn builtin_kernel_seed_diagnostics() -> Rc>> { @@ -196,6 +192,11 @@ pub fn builtin_function_registry() -> Rc>> { "extdeps_dead_param_count_for_operation".to_string(), int_type(), ); + let m = v1_rt::rc_map_insert( + m.clone(), + "shell_materialize_argv_for_operation".to_string(), + list_of_element(string_type()), + ); let m = v1_rt::rc_map_insert( m.clone(), "extdeps_dead_param_count_for_path".to_string(), @@ -251,6 +252,36 @@ pub fn builtin_function_registry() -> Rc>> { "transport_script_literal_violation_count_for_path".to_string(), int_type(), ); + let m = v1_rt::rc_map_insert( + m.clone(), + "layer_import_facts".to_string(), + list_of_type_variable("layer_import_fact_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "import_resolution_facts".to_string(), + list_of_type_variable("import_resolution_fact_elem".to_string()), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_coexistence_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_diverged_fork_count".to_string(), + int_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_is_coexistence".to_string(), + bool_type(), + ); + let m = v1_rt::rc_map_insert( + m.clone(), + "fact_cardinality_cross_tree_is_diverged_fork".to_string(), + bool_type(), + ); let m = v1_rt::rc_map_insert( m.clone(), "languages_consumer_census_data_decl_count".to_string(), @@ -285,11 +316,11 @@ pub fn builtin_function_registry() -> Rc>> { } } -pub fn infer_builtin_call_type(name: Rc>) -> Option> { +pub fn infer_builtin_call_type(name: String) -> Option> { v1_rt::map_get(&builtin_function_registry(), name) } -pub fn resolve_builtin_call_type(name: Rc>) -> Rc { +pub fn resolve_builtin_call_type(name: String) -> Rc { match infer_builtin_call_type(name) { Some(v) => v.clone(), None => unit_type(), diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 91d060a8b25..84910fc453a 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -34,11 +34,9 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn is_witness_type_name(name: Rc>) -> bool { - ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("Witness".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("witness".to_string()))) +pub fn is_witness_type_name(name: String) -> bool { + ((name.clone().as_str() == "Witness".to_string().as_str()) + || (name.clone().as_str() == "witness".to_string().as_str())) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -313,8 +311,8 @@ pub fn pattern_binding_type(subject: Rc) -> Rc { pub fn variant_not_found_result( scrut: Rc, - variant_name: Rc>, - module_name: Rc>, + variant_name: String, + module_name: String, source_indices: Rc>>, ) -> Rc { node_lookup_failed(Rc::new(vec![make_error_node( @@ -329,8 +327,8 @@ pub fn variant_not_found_result( pub fn lookup_variant_in_type( scrut: Rc, - variant_name: Rc>, - module_name: Rc>, + variant_name: String, + module_name: String, source_indices: Rc>>, field_binding_count: i64, ) -> Rc { @@ -358,53 +356,34 @@ pub fn lookup_variant_in_type( } else { { let optional_cardinality_subject = (scrut_opt.clone() - && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - scrut_node.clone(), - )) != crate::v2_std_text::host_string_text_to_rust_host( - "Optional".to_string(), - ))); + && (authored_name_at(source_indices.clone(), scrut_node.clone()).as_str() + != "Optional".to_string().as_str())); let witness_subject = (is_witness_type_name(authored_name_at( source_indices.clone(), scrut_node.clone(), )) && ((scrut_node.children.clone().len() as i64) == 1)); if (optional_cardinality_subject.clone() - && (crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Present".to_string(), - ))) + && (variant_name.clone().as_str() == "Present".to_string().as_str())) { node_lookup_resolved(synthesize_optional_present_variant( scrut_node.clone(), )) } else { if (optional_cardinality_subject.clone() - && (crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Absent".to_string(), - ))) + && (variant_name.clone().as_str() == "Absent".to_string().as_str())) { node_lookup_resolved(none_type()) } else { if (witness_subject.clone() - && (crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Holds".to_string(), - ))) + && (variant_name.clone().as_str() == "Holds".to_string().as_str())) { node_lookup_resolved(synthesize_witness_holds_variant( scrut_node.clone(), )) } else { if (witness_subject.clone() - && (crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "Violates".to_string(), - ))) + && (variant_name.clone().as_str() + == "Violates".to_string().as_str())) { node_lookup_resolved(synthesize_witness_violates_variant( scrut_node.clone(), @@ -415,25 +394,50 @@ pub fn lookup_variant_in_type( source_indices.clone(), scrut_node.clone(), ); - let optional_coproduct_subject = ((crate::v2_std_text::host_string_text_to_rust_host(scrut_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Optional".to_string())) && ((crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string())) || (crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Absent".to_string())))); + let optional_coproduct_subject = + ((scrut_name.clone().as_str() + == "Optional".to_string().as_str()) + && ((variant_name.clone().as_str() + == "Present".to_string().as_str()) + || (variant_name.clone().as_str() + == "Absent".to_string().as_str()))); let direct_match = find_child_named( scrut_node.clone(), variant_name.clone(), source_indices.clone(), ); - let record_destructure = (((field_binding_count > 0) && (scrut_node.connective.clone() == Connective::Conj)) && (crate::v2_std_text::host_string_text_to_rust_host(scrut_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()))); + let record_destructure = (((field_binding_count > 0) + && (scrut_node.connective.clone() + == Connective::Conj)) + && (scrut_name.clone().as_str() + == variant_name.clone().as_str())); let fallback = if record_destructure { node_lookup_resolved(scrut_node.clone()) } else { - if (optional_coproduct_subject.clone() && (crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Present".to_string()))) { - node_lookup_resolved(synthesize_optional_present_variant(scrut_node.clone())) - } else { - if (optional_coproduct_subject.clone() && (crate::v2_std_text::host_string_text_to_rust_host(variant_name.clone()) == crate::v2_std_text::host_string_text_to_rust_host("Absent".to_string()))) { - node_lookup_resolved(none_type()) + if (optional_coproduct_subject.clone() + && (variant_name.clone().as_str() + == "Present".to_string().as_str())) + { + node_lookup_resolved( + synthesize_optional_present_variant( + scrut_node.clone(), + ), + ) } else { - variant_not_found_result(scrut_node.clone(), variant_name.clone(), module_name, source_indices.clone()) + if (optional_coproduct_subject.clone() + && (variant_name.clone().as_str() + == "Absent".to_string().as_str())) + { + node_lookup_resolved(none_type()) + } else { + variant_not_found_result( + scrut_node.clone(), + variant_name.clone(), + module_name, + source_indices.clone(), + ) + } } - } }; match direct_match { Some(v) => node_lookup_resolved(v.clone()), @@ -452,8 +456,8 @@ pub fn lookup_variant_in_type( pub fn lookup_field_in_variant( variant: Rc, - field_name: Rc>, - module_name: Rc>, + field_name: String, + module_name: String, source_indices: Rc>>, ) -> Rc { match (*variant).clone() { @@ -496,7 +500,7 @@ pub fn check_match_exhaustiveness( arms: Rc>>, env: Rc, span: Rc, - module_name: Rc>, + module_name: String, ) -> Rc>> { { let scrut_is_optional = @@ -562,7 +566,7 @@ pub fn check_match_exhaustiveness( } else { { let covered_set = arms.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), + v1_rt::rc_empty_map::(), |acc: Rc>, arm: Rc| match (*arm_pattern( arm.clone(), )) diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index a7aaeba8f74..c6f8c18b5e4 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -62,7 +62,7 @@ pub fn is_unit_variant_node(variant: Rc) -> bool { pub fn unit_variant_in_coproduct( env: Rc, ty: Rc, - variant_name: Rc>, + variant_name: String, ) -> Option> { match ty.connective.clone() { Connective::Disj => { @@ -74,12 +74,9 @@ pub fn unit_variant_in_coproduct( if (acc.clone() != None) { acc.clone() } else { - if ((crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - env.source_indices.clone(), - v.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - variant_name.clone(), - )) && is_unit_variant_node(v.clone())) + if ((authored_name_at(env.source_indices.clone(), v.clone()).as_str() + == variant_name.clone().as_str()) + && is_unit_variant_node(v.clone())) { Some(v.clone()) } else { @@ -105,7 +102,7 @@ pub fn structural_type_for_variant_lookup(env: Rc, ty: Rc) -> Rc< pub fn lookup_unit_variant_phantom_type( env: Rc, - variant_name: Rc>, + variant_name: String, ) -> Option> { { let matches = collect_unit_variant_phantom_matches(env, variant_name); @@ -122,7 +119,7 @@ pub fn lookup_unit_variant_phantom_type( pub fn collect_unit_variant_phantom_matches( env: Rc, - variant_name: Rc>, + variant_name: String, ) -> Rc>> { Rc::new(v1_rt::map_keys(&env.bindings.clone())) .iter() @@ -188,16 +185,12 @@ pub fn with_authored_identity(identity: Rc, structural: Rc) -> Rc, structural: Rc, - brand_name: Rc>, + brand_name: String, source_indices: Rc>>, ) -> Rc { - if (((crate::v2_std_text::host_string_text_to_rust_host(brand_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - && (crate::v2_std_text::host_string_text_to_rust_host(brand_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices, - structural.clone(), - )))) + if (((brand_name.clone().as_str() != "".to_string().as_str()) + && (brand_name.clone().as_str() + != authored_name_at(source_indices, structural.clone()).as_str())) && !is_declared_container_alias_spelling(brand_name.clone())) { with_authored_identity(identity, structural.clone()) @@ -206,11 +199,7 @@ pub fn preserve_nominal_brand_on_resolve( } } -pub fn peel_nominal_alias_identity( - n: Rc, - env: Rc, - module_name: Rc>, -) -> Rc { +pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: String) -> Rc { { let source_indices = env.source_indices.clone(); let brand = authored_name_at(source_indices.clone(), n.clone()); @@ -243,13 +232,9 @@ pub fn peel_nominal_alias_identity( .resolved .clone() }; - if (((crate::v2_std_text::host_string_text_to_rust_host(brand.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - && (crate::v2_std_text::host_string_text_to_rust_host(brand.clone()) - != crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - structural.clone(), - )))) + if (((brand.clone().as_str() != "".to_string().as_str()) + && (brand.clone().as_str() + != authored_name_at(source_indices.clone(), structural.clone()).as_str())) && !is_declared_container_alias_spelling(brand.clone())) { with_authored_identity(n.clone(), structural.clone()) @@ -348,11 +333,7 @@ pub struct ResourceUseResult { pub diagnostics: Rc>>, } -pub fn resolve_node( - n: Rc, - env: Rc, - module_name: Rc>, -) -> Rc { +pub fn resolve_node(n: Rc, env: Rc, module_name: String) -> Rc { resolve_node_bounded(n, env, module_name, 0) } @@ -365,10 +346,8 @@ pub fn resolve_generic_use_decl(env: Rc, n: Rc) -> Rc { decl.clone() } else { if ((((n.children.clone().len() as i64) > 0) - && (crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) - && (crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host(brand))) + && (n.name.clone().as_str() != "".to_string().as_str())) + && (n.name.clone().as_str() != brand.as_str())) { match lookup_type_by_name(env.clone(), n.name.clone()) { Some(structural) => structural.clone(), @@ -416,7 +395,7 @@ pub fn is_user_generic_use_site(n: Rc, env: Rc) -> bool { pub fn substitute_type_slots( n: Rc, slot_bindings: Rc>>, - decl_name: Rc>, + decl_name: String, source_indices: Rc>>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -438,11 +417,9 @@ pub fn substitute_type_slots( let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { __result.push( - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(source_indices.clone(), child.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - decl_name.clone(), - )) { + if (authored_name_at(source_indices.clone(), child.clone()).as_str() + == decl_name.clone().as_str()) + { { let substituted_args = Rc::new({ let mut __result = Vec::new(); @@ -559,7 +536,7 @@ pub fn classify_alias(target: Rc) -> AliasKind { pub fn resolve_alias_target( target: Rc, env: Rc, - module_name: Rc>, + module_name: String, depth: i64, ) -> Rc { match classify_alias(target.clone()) { @@ -590,7 +567,7 @@ pub fn is_parametric_type_alias_decl(item: Rc) -> bool { pub fn resolve_nominal_alias_rhs( n: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if ((n.connective.clone() == Connective::NoConnective) @@ -656,7 +633,7 @@ pub fn resolve_nominal_alias_rhs( pub fn resolve_node_bounded( n: Rc, env: Rc, - module_name: Rc>, + module_name: String, depth: i64, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { @@ -846,26 +823,60 @@ pub fn resolve_node_bounded( let mut __result = Vec::new(); for variant_child in n.children.clone().iter().cloned() { __result.push({ - let field_results = Rc::new({ let mut __result = Vec::new(); for field_child in variant_child.children.clone().iter().cloned() { __result.push(if (field_child.inferred.clone() == None) { - Rc::new(NodeResolveResult { - resolved: field_child.clone(), - diagnostics: Rc::new(vec![]), -}) - } else { - { - let field_rt = resolved_type(field_child.clone()); -let is_self_ref = ((crate::v2_std_text::host_string_text_to_rust_host(authored_name(env.clone(), field_rt.clone())) == crate::v2_std_text::host_string_text_to_rust_host(authored_name(env.clone(), n.clone()))) && ((field_rt.children.clone().len() as i64) > 0)); -let rt_result = if is_self_ref.clone() { - Rc::new(NodeResolveResult { - resolved: field_rt.clone(), - diagnostics: Rc::new(vec![]), -}) - } else { - resolve_node_bounded(field_rt.clone(), env.clone(), module_name.clone(), (depth.clone() + 1)) - }; -let rt_resolved = rt_result.resolved.clone(); -let rt_diags = rt_result.diagnostics.clone(); -Rc::new(NodeResolveResult { + let field_results = Rc::new({ + let mut __result = Vec::new(); + for field_child in + variant_child.children.clone().iter().cloned() + { + __result.push( + if (field_child.inferred.clone() == None) { + Rc::new(NodeResolveResult { + resolved: field_child.clone(), + diagnostics: Rc::new(vec![]), + }) + } else { + { + let field_rt = resolved_type( + field_child.clone(), + ); + let is_self_ref = ((authored_name( + env.clone(), + field_rt.clone(), + ) + .as_str() + == authored_name( + env.clone(), + n.clone(), + ) + .as_str()) + && ((field_rt + .children + .clone() + .len() + as i64) + > 0)); + let rt_result = if is_self_ref + .clone() + { + Rc::new(NodeResolveResult { + resolved: field_rt.clone(), + diagnostics: Rc::new( + vec![], + ), + }) + } else { + resolve_node_bounded( + field_rt.clone(), + env.clone(), + module_name.clone(), + (depth.clone() + 1), + ) + }; + let rt_resolved = + rt_result.resolved.clone(); + let rt_diags = + rt_result.diagnostics.clone(); + Rc::new(NodeResolveResult { resolved: Rc::new(Node { name: field_child.name.clone(), span: field_child.span.clone(), @@ -890,34 +901,56 @@ Rc::new(NodeResolveResult { }), diagnostics: rt_diags.clone(), }) -} - }); } __result }); -let resolved_fields = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { __result.push(fr.resolved.clone()); } __result }); -let field_diags = Rc::new({ let mut __result = Vec::new(); for fr in field_results.clone().iter().cloned() { __result.extend((*fr.diagnostics.clone()).iter().cloned()); } __result }); -Rc::new(NodeResolveResult { - resolved: Rc::new(Node { - name: variant_child.name.clone(), - span: variant_child.span.clone(), - ident_span: variant_child.ident_span.clone(), - children: resolved_fields.clone(), - connective: variant_child.connective.clone(), - params: variant_child.params.clone(), - inferred: variant_child.inferred.clone(), - return_cardinality: variant_child.return_cardinality.clone(), - uses: variant_child.uses.clone(), - body: variant_child.body.clone(), - transport: variant_child.transport.clone(), - properties: variant_child.properties.clone(), - type_annotation: variant_child.type_annotation.clone(), - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, -}), - diagnostics: field_diags.clone(), -}) -}); + } + }, + ); + } + __result + }); + let resolved_fields = Rc::new({ + let mut __result = Vec::new(); + for fr in field_results.clone().iter().cloned() { + __result.push(fr.resolved.clone()); + } + __result + }); + let field_diags = Rc::new({ + let mut __result = Vec::new(); + for fr in field_results.clone().iter().cloned() { + __result.extend( + (*fr.diagnostics.clone()).iter().cloned(), + ); + } + __result + }); + Rc::new(NodeResolveResult { + resolved: Rc::new(Node { + name: variant_child.name.clone(), + span: variant_child.span.clone(), + ident_span: variant_child.ident_span.clone(), + children: resolved_fields.clone(), + connective: variant_child.connective.clone(), + params: variant_child.params.clone(), + inferred: variant_child.inferred.clone(), + return_cardinality: variant_child + .return_cardinality + .clone(), + uses: variant_child.uses.clone(), + body: variant_child.body.clone(), + transport: variant_child.transport.clone(), + properties: variant_child.properties.clone(), + type_annotation: variant_child + .type_annotation + .clone(), + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, + }), + diagnostics: field_diags.clone(), + }) + }); } __result }); @@ -1023,7 +1056,7 @@ Rc::new(NodeResolveResult { .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let slot_name = @@ -1507,7 +1540,7 @@ Rc::new(NodeResolveResult { pub fn missing_generic_args_diagnostics( n: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc>> { if ((((n.children.clone().len() as i64) == 0) && ((n.params.clone().len() as i64) == 0)) && is_user_generic_use_site(n.clone(), env.clone())) @@ -1536,7 +1569,7 @@ pub fn missing_generic_args_diagnostics( pub fn resolve_optional_node( n: Option>, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { if (n.clone() == None) { Rc::new(NodeResolveResult { @@ -1593,11 +1626,7 @@ pub fn resolve_optional_node( } } -pub fn resolve_field( - field: Rc, - env: Rc, - module_name: Rc>, -) -> Rc { +pub fn resolve_field(field: Rc, env: Rc, module_name: String) -> Rc { { let authored_type = field_node_type_expr(field.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); @@ -1640,11 +1669,7 @@ pub fn resolve_field( } } -pub fn resolve_param( - param: Rc, - env: Rc, - module_name: Rc>, -) -> Rc { +pub fn resolve_param(param: Rc, env: Rc, module_name: String) -> Rc { { let authored_type = param_node_type_expr(param.clone()); let type_result = resolve_node(authored_type.clone(), env.clone(), module_name.clone()); @@ -1716,7 +1741,7 @@ pub fn resolve_param( pub fn resolve_resource_use( ru: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { { let type_result = resolve_node(resource_use_resource(ru.clone()), env.clone(), module_name); @@ -1737,7 +1762,7 @@ pub fn resolve_resource_use( pub fn resolve_named_arg( arg: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { { let value_result = resolve_expr_types(arg_value(arg.clone()), env.clone(), module_name); @@ -1758,7 +1783,7 @@ pub fn resolve_named_arg( pub fn resolve_field_init( field_init: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { { let value_result = resolve_expr_types( @@ -1783,7 +1808,7 @@ pub fn resolve_field_init( pub fn resolve_match_arm( arm: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { { let arm_g = arm_guard(arm.clone()); @@ -1821,7 +1846,7 @@ pub fn resolve_match_arm( pub fn resolve_string_part( part: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { match (*part).clone() { StringPart::Text { value: value, .. } => Rc::new(StringPartResolveResult { @@ -1847,7 +1872,7 @@ pub fn resolve_string_part( pub fn resolve_transport_binding( transport: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { if is_local_transport(transport.clone(), env.source_indices.clone()) { Rc::new(TransportResolveResult { @@ -1946,7 +1971,7 @@ pub fn resolve_transport_binding( pub fn resolve_expr_types( texpr: Rc, env: Rc, - module_name: Rc>, + module_name: String, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*texpr.expr_data.clone()).clone() { @@ -1990,6 +2015,9 @@ pub fn resolve_expr_types( descent_evidence: de, .. } => { + // bind-once: resolve each arg child a SINGLE time, then split + // into resolved children + diagnostics. Resolving twice made a + // nested constructor literal O(2^depth). let arg_results = Rc::new({ let mut __result = Vec::new(); for arg_node in texpr.children.clone().iter().cloned() { @@ -2019,14 +2047,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.clone().iter().cloned() { + for r in arg_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in arg_results.clone().iter().cloned() { + for r in arg_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2050,6 +2078,7 @@ pub fn resolve_expr_types( method_semantics: ms, .. } => { + // bind-once: resolve each child a SINGLE time (see ExprCall). let mc_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2115,14 +2144,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.clone().iter().cloned() { + for r in mc_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in mc_results.clone().iter().cloned() { + for r in mc_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2142,6 +2171,7 @@ pub fn resolve_expr_types( }) } ExprData::ExprMatch => { + // bind-once: resolve each scrutinee/arm a SINGLE time (see ExprCall). let match_results = Rc::new({ let mut __result = Vec::new(); for pair in Rc::new( @@ -2252,14 +2282,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in match_results.clone().iter().cloned() { + for r in match_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in match_results.clone().iter().cloned() { + for r in match_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2360,6 +2390,9 @@ pub fn resolve_expr_types( ExprData::ExprRecordLit { parent_enum: pe, .. } => { + // bind-once: resolve each field-init value a SINGLE time. This is + // the arm hit by deep nested constructor literals (Cons/record + // chains) — resolving twice per field was O(2^depth). let fi_results = Rc::new({ let mut __result = Vec::new(); for fi_node in texpr.children.clone().iter().cloned() { @@ -2385,14 +2418,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.clone().iter().cloned() { + for r in fi_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in fi_results.clone().iter().cloned() { + for r in fi_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2526,6 +2559,7 @@ pub fn resolve_expr_types( }) } ExprData::ExprStringInterp => { + // bind-once: resolve each interpolation part a SINGLE time (see ExprCall). let part_results = Rc::new({ let mut __result = Vec::new(); for part_node in texpr.children.clone().iter().cloned() { @@ -2560,14 +2594,14 @@ pub fn resolve_expr_types( }); let resolved_children = Rc::new({ let mut __result = Vec::new(); - for r in part_results.clone().iter().cloned() { + for r in part_results.iter().cloned() { __result.push(r.expr.clone()); } __result }); let all_diags = Rc::new({ let mut __result = Vec::new(); - for r in part_results.clone().iter().cloned() { + for r in part_results.iter().cloned() { __result.extend((*r.diagnostics.clone()).iter().cloned()); } __result @@ -2783,13 +2817,10 @@ pub fn fn_type_param_names( for p in Rc::new({ let mut __result = Vec::new(); for p in item.params.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(param_node_name_at( - p.clone(), - source_indices.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - param_node_type_expr(p.clone()), - ))) { + if (param_node_name_at(p.clone(), source_indices.clone()).as_str() + == authored_name_at(source_indices.clone(), param_node_type_expr(p.clone())) + .as_str()) + { __result.push(p); } } @@ -2835,9 +2866,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { .iter() .cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(other.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(s.clone())) - { + if (other.clone().as_str() == s.clone().as_str()) { __found = true; break; } @@ -2853,11 +2882,7 @@ pub fn has_duplicate_type_param_name(names: Rc>) -> bool { } } -pub fn resolve_item_types( - item: Rc, - env: Rc, - module_name: Rc>, -) -> Rc { +pub fn resolve_item_types(item: Rc, env: Rc, module_name: String) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tp_names = if ((item.connective.clone() != Connective::NoConnective) && (item.transport.clone() == None)) @@ -2882,7 +2907,7 @@ pub fn resolve_item_types( }; let env = tp_names.clone().iter().cloned().fold( env.clone(), - |e: Rc, tp_name: Rc>| { + |e: Rc, tp_name: String| { Rc::new(TypeEnv { bindings: v1_rt::rc_map_insert( e.bindings.clone(), @@ -3291,7 +3316,3 @@ pub fn resolve_item_types( }) }) } - -pub struct AliasParameterized; -pub struct AliasLeaf; -pub struct AliasPassthrough; diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index afe715f1d41..f4617b9f287 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -34,7 +34,7 @@ pub struct UniqueAccum { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OpEntry { - pub name: Rc>, + pub name: String, pub outputs: Rc>>, pub params: Rc>>, } @@ -73,7 +73,7 @@ pub fn is_typed_service_call_receiver( pub fn extract_typed_service_name( receiver: Rc, source_indices: Rc>>, -) -> Rc> { +) -> Option { match (*receiver.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: _, .. } => { let f = field_access_field_at(receiver.clone(), source_indices.clone()); @@ -100,7 +100,7 @@ pub fn collect_typed_service_calls( let result = collect_typed_service_calls_into( texpr, Rc::new(UniqueAccum { - seen: v1_rt::rc_empty_map::>, bool>(), + seen: v1_rt::rc_empty_map::(), result: Rc::new(vec![]), }), source_indices, @@ -196,7 +196,7 @@ pub fn collect_called_func_names( let result = collect_called_func_names_into( texpr, Rc::new(UniqueAccum { - seen: v1_rt::rc_empty_map::>, bool>(), + seen: v1_rt::rc_empty_map::(), result: Rc::new(vec![]), }), source_indices, @@ -223,7 +223,7 @@ let extra = Rc::new({ let mut __result = Vec::new(); for callee_name in called.c Some(callee_info) => callee_info.service_names.clone(), None => Rc::new(vec![]), }).iter().cloned()); } __result }); -let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: Rc>| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (crate::v2_std_text::host_string_text_to_rust_host(s.clone()) == crate::v2_std_text::host_string_text_to_rust_host(svc.clone())) { __found = true; break; } } __found } { +let merged = extra.clone().iter().cloned().fold(info.service_names.clone(), |svc_list: Rc>, svc: String| if { let mut __found = false; for s in svc_list.clone().iter().cloned() { if (s.clone().as_str() == svc.clone().as_str()) { __found = true; break; } } __found } { svc_list.clone() } else { v1_rt::rc_list_push(svc_list.clone(), svc.clone()) @@ -289,7 +289,7 @@ pub fn expand_transitive_services( pub fn check_service_field_access_node( base_type: Rc, - field: Rc>, + field: String, service_registry: Rc>>>>, source_indices: Rc>>, ) -> Option> { @@ -316,7 +316,7 @@ pub fn check_service_field_access_node( pub fn check_service_method_call_node( receiver_type: Rc, - method: Rc>, + method: String, service_registry: Rc>>>>, source_indices: Rc>>, ) -> Option> { @@ -331,9 +331,7 @@ pub fn check_service_method_call_node( let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(op.name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(method.clone())) - { + if (op.name.clone().as_str() == method.clone().as_str()) { __result.push(op); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 9d990427a25..eb42df493d0 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -21,7 +21,7 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ResolvedFuncSig { - pub name: Rc>, + pub name: String, pub params: Rc>>, pub inferred: Rc, pub is_async: bool, @@ -49,8 +49,8 @@ pub struct SigsAccum { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CallEdge { - pub caller: Rc>, - pub callee: Rc>, + pub caller: String, + pub callee: String, } pub fn collect_func_call_edges( @@ -81,7 +81,7 @@ pub fn collect_func_call_edges( } pub fn collect_calls_in_expr( - caller: Rc>, + caller: String, texpr: Rc, local_func_set: Rc>, source_indices: Rc>>, @@ -123,8 +123,8 @@ pub fn collect_calls_in_expr( } pub fn func_reaches_self( - root: Rc>, - current: Rc>, + root: String, + current: String, call_edges: Rc>>, visited: Rc>, ) -> bool { @@ -139,11 +139,7 @@ pub fn func_reaches_self( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(e.caller.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - current.clone(), - )) - { + if (e.caller.clone().as_str() == current.clone().as_str()) { __result.push(e); } } @@ -159,9 +155,7 @@ pub fn func_reaches_self( { let mut __found = false; for c in callees.iter().cloned() { - if if (crate::v2_std_text::host_string_text_to_rust_host(c.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(root.clone())) - { + if if (c.clone().as_str() == root.clone().as_str()) { true } else { func_reaches_self( @@ -184,8 +178,8 @@ pub fn func_reaches_self( pub fn build_name_set(names: Rc>) -> Rc> { names.iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ) @@ -199,7 +193,7 @@ pub fn collect_parent_resolved_sigs( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, dsig: Rc| { if emit_map_has(local_func_set.clone(), dsig.name.clone()) { acc.clone() @@ -258,7 +252,7 @@ pub fn topo_resolve_loop( mut declared_sigs: Rc>>, mut call_edges: Rc>>, mut local_func_set: Rc>, - mut module_name: Rc>, + mut module_name: String, mut diagnostics: Rc>>, mut fuel: i64, ) -> Rc { @@ -302,11 +296,7 @@ pub fn topo_resolve_loop( for e in Rc::new({ let mut __result = Vec::new(); for e in call_edges.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - e.caller.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - fn_name.clone(), - )) { + if (e.caller.clone().as_str() == fn_name.clone().as_str()) { __result.push(e); } } @@ -351,7 +341,7 @@ pub fn topo_resolve_loop( signatures: resolved.clone(), diagnostics: Rc::new(vec![]), }), - |acc: Rc, fn_name: Rc>| match v1_rt::map_get( + |acc: Rc, fn_name: String| match v1_rt::map_get( &declared_sigs, fn_name.clone(), ) { @@ -419,7 +409,7 @@ pub fn topo_resolve_loop( signatures: resolved.clone(), diagnostics: diagnostics.clone(), }), - |acc: Rc, fn_name: Rc>| match v1_rt::map_get( + |acc: Rc, fn_name: String| match v1_rt::map_get( &declared_sigs, fn_name.clone(), ) { @@ -454,8 +444,8 @@ pub fn topo_resolve_loop( }, ); let ready_set = ready.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, fn_name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, fn_name: String| { v1_rt::rc_map_insert(acc, fn_name.clone(), true) }, ); @@ -485,7 +475,7 @@ pub fn topo_resolve_loop( pub fn resolve_func_sigs( declared_sigs: Rc>>, items: Rc>>, - module_name: Rc>, + module_name: String, source_indices: Rc>>, ) -> Rc { { diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index e297a53f711..8f708772956 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -59,7 +59,7 @@ pub fn is_type_variable(inferred: Rc) -> bool { } } -pub fn type_variable_node(id: Rc>) -> Rc { +pub fn type_variable_node(id: String) -> Rc { Rc::new(Node { name: "".to_string(), span: make_span(0, 0), @@ -132,16 +132,14 @@ pub fn node_is_set_collection( source_indices: Rc>>, ) -> bool { (node_is_element_collection(n.clone(), source_indices.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - n.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host("Set".to_string()))) + && (authored_name_at(source_indices.clone(), n.clone()).as_str() + == "Set".to_string().as_str())) } pub fn canonical_template_name( n: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { { let nm = authored_name_at(source_indices, n); match container_template_algebra(nm.clone()) { @@ -151,7 +149,7 @@ pub fn canonical_template_name( } } -pub fn is_declared_container_alias_spelling(name: Rc>) -> bool { +pub fn is_declared_container_alias_spelling(name: String) -> bool { match container_template_algebra(name) { Some(_) => true, None => false, @@ -161,10 +159,8 @@ pub fn is_declared_container_alias_spelling(name: Rc>) -> bool { pub fn structural_carrier_template_name( n: Rc, source_indices: Rc>>, -) -> Rc> { - if (crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { +) -> String { + if (n.name.clone().as_str() != "".to_string().as_str()) { canonical_template_name( Rc::new(Node { name: n.name.clone(), @@ -372,7 +368,7 @@ pub fn bare_set_node() -> Option> { } } -pub fn kernel_container_profile_miss_diagnostic(kind_name: Rc>) -> Rc { +pub fn kernel_container_profile_miss_diagnostic(kind_name: String) -> Rc { { let msg = v1_rt::concat("missing kernel container profile: ".to_string(), kind_name); make_error_node( @@ -385,7 +381,7 @@ pub fn kernel_container_profile_miss_diagnostic(kind_name: Rc>) } } -pub fn missing_kernel_container_profile_type(kind_name: Rc>) -> Rc { +pub fn missing_kernel_container_profile_type(kind_name: String) -> Rc { { let msg = v1_rt::concat("missing kernel container profile: ".to_string(), kind_name); Rc::new(Node { @@ -423,10 +419,7 @@ pub struct KernelTypeBuild { pub diagnostics: Rc>>, } -pub fn make_container_type( - kind_name: Rc>, - element: Rc, -) -> Rc { +pub fn make_container_type(kind_name: String, element: Rc) -> Rc { match container_param_name(kind_name.clone(), 0) { Some(param_name) => Rc::new(KernelTypeBuild { ty: Rc::new(Node { @@ -649,7 +642,7 @@ pub fn make_tuple_type(first: Rc, second: Rc) -> Rc { }) } -pub fn algebra_value_field(name: Rc>, type_node: Rc) -> Rc { +pub fn algebra_value_field(name: String, type_node: Rc) -> Rc { Rc::new(Node { name: name.clone(), span: kernel_span(name.clone()), @@ -673,7 +666,7 @@ pub fn algebra_value_field(name: Rc>, type_node: Rc) -> Rc } pub fn algebra_method_field( - name: Rc>, + name: String, param_types: Rc>>, return_type: Rc, ) -> Rc { @@ -716,7 +709,7 @@ pub fn algebra_method_field( } pub fn enrich_base_with_fields( - name: Rc>, + name: String, base: Rc, fields: Rc>>, ) -> Rc { @@ -742,18 +735,18 @@ pub fn enrich_base_with_fields( }) } -pub fn placeholder_type_node(name: Rc>) -> Rc { +pub fn placeholder_type_node(name: String) -> Rc { nominal_type_ref(name) } -pub fn nominal_type_ref(name: Rc>) -> Rc { +pub fn nominal_type_ref(name: String) -> Rc { leaf_node_with_span(name.clone(), kernel_span(name.clone())) } pub fn algebra_child_or_placeholder( base: Rc, child_index: i64, - placeholder: Rc>, + placeholder: String, ) -> Rc { match Rc::new({ let mut __result = Vec::new(); @@ -970,7 +963,7 @@ pub fn instantiate_algebra_field( } pub fn enrich_kernel_type( - name: Rc>, + name: String, base: Rc, source_indices: Rc>>, ) -> Rc { @@ -1103,10 +1096,8 @@ pub fn unify_template( } ContainerSource::Named { name: n, .. } => n.clone(), }; - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - concrete.clone(), - )) != crate::v2_std_text::host_string_text_to_rust_host(expected_name)) + if (authored_name_at(source_indices.clone(), concrete.clone()).as_str() + != expected_name.as_str()) { subst.clone() } else { @@ -1657,7 +1648,7 @@ pub fn normalize_access_type_node(mut n: Rc) -> Rc { pub fn node_type_shape( n: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let __is_leaf = (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) @@ -1670,11 +1661,8 @@ pub fn node_type_shape( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(source_indices.clone(), rt.clone()), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "None".to_string(), - ))) + && (authored_name_at(source_indices.clone(), rt.clone()).as_str() + != "None".to_string().as_str())) && (is_kernel_type(authored_name_at( source_indices.clone(), rt.clone(), @@ -1820,11 +1808,11 @@ pub fn node_type_compatible( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { - if (crate::v2_std_text::host_string_text_to_rust_host( - canonical_template_name(left.clone(), source_indices.clone()), - ) != crate::v2_std_text::host_string_text_to_rust_host( - canonical_template_name(right.clone(), source_indices.clone()), - )) { + if (canonical_template_name(left.clone(), source_indices.clone()) + .as_str() + != canonical_template_name(right.clone(), source_indices.clone()) + .as_str()) + { break false; } else { match left.children.clone().first().cloned() { @@ -1859,16 +1847,20 @@ pub fn node_type_compatible( } } } else { - if (((((crate::v2_std_text::host_string_text_to_rust_host( - canonical_template_name(left.clone(), source_indices.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - canonical_template_name(right.clone(), source_indices.clone()), - )) && (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(source_indices.clone(), left.clone()), + if (((((canonical_template_name( + left.clone(), + source_indices.clone(), ) - != crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(source_indices.clone(), right.clone()), - ))) + .as_str() + == canonical_template_name( + right.clone(), + source_indices.clone(), + ) + .as_str()) + && (authored_name_at(source_indices.clone(), left.clone()) + .as_str() + != authored_name_at(source_indices.clone(), right.clone()) + .as_str())) && ((left.children.clone().len() as i64) == 1)) && ((right.children.clone().len() as i64) == 1)) && (is_declared_container_alias_spelling(authored_name_at( @@ -1929,15 +1921,16 @@ pub fn node_type_compatible( if (left_opt.clone() || right_opt.clone()) { break false; } else { - break (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(source_indices.clone(), left.clone()), + break (authored_name_at( + source_indices.clone(), + left.clone(), ) - == crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at( - source_indices.clone(), - right.clone(), - ), - )); + .as_str() + == authored_name_at( + source_indices.clone(), + right.clone(), + ) + .as_str()); } } } @@ -1981,11 +1974,8 @@ pub fn prefer_specific_type( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); let right_is_optional = (right.return_cardinality.clone() == Cardinality::CardOptional); let same_kind = if (left_is_container.clone() && right_is_container) { - (crate::v2_std_text::host_string_text_to_rust_host(left_norm_name) - == crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - right.clone(), - ))) + (left_norm_name.as_str() + == authored_name_at(source_indices.clone(), right.clone()).as_str()) } else { if (left_is_optional.clone() && right_is_optional) { true @@ -2086,13 +2076,10 @@ pub fn node_type_equals_core( let left_name = authored_name_at(source_indices.clone(), left.clone()); let right_name = authored_name_at(source_indices.clone(), right.clone()); if (left_leaf.clone() && right_leaf.clone()) { - (crate::v2_std_text::host_string_text_to_rust_host(left_name) - == crate::v2_std_text::host_string_text_to_rust_host(right_name)) + (left_name.as_str() == right_name.as_str()) } else { if (left_struct.clone() && right_struct.clone()) { - if (crate::v2_std_text::host_string_text_to_rust_host(left_name) - != crate::v2_std_text::host_string_text_to_rust_host(right_name)) - { + if (left_name.as_str() != right_name.as_str()) { false } else { if ((left.connective.clone() == Connective::Conj) @@ -2143,12 +2130,10 @@ pub fn node_type_equals_core( } } else { if (left_leaf.clone() && right_struct.clone()) { - (crate::v2_std_text::host_string_text_to_rust_host(left_name) - == crate::v2_std_text::host_string_text_to_rust_host(right_name)) + (left_name.as_str() == right_name.as_str()) } else { if (left_struct.clone() && right_leaf.clone()) { - (crate::v2_std_text::host_string_text_to_rust_host(left_name) - == crate::v2_std_text::host_string_text_to_rust_host(right_name)) + (left_name.as_str() == right_name.as_str()) } else { { let left_is_container = @@ -2156,11 +2141,7 @@ pub fn node_type_equals_core( let right_is_container = node_is_element_collection(right.clone(), source_indices.clone()); if (left_is_container && right_is_container) { - if (crate::v2_std_text::host_string_text_to_rust_host(left_name) - != crate::v2_std_text::host_string_text_to_rust_host( - right_name, - )) - { + if (left_name.as_str() != right_name.as_str()) { false } else { match left.children.clone().first().cloned() { @@ -2357,12 +2338,8 @@ pub fn node_type_deps( (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) && (rt.ident_span.clone() != None)) - && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - rt.clone(), - )) != crate::v2_std_text::host_string_text_to_rust_host( - "None".to_string(), - ))) + && (authored_name_at(source_indices.clone(), rt.clone()).as_str() + != "None".to_string().as_str())) && (is_kernel_type(authored_name_at(source_indices.clone(), rt.clone())) == false)) } @@ -2434,10 +2411,7 @@ pub fn node_type_deps( } } else { if ((is_kernel_type(n_name.clone()) - || (crate::v2_std_text::host_string_text_to_rust_host(n_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "None".to_string(), - ))) + || (n_name.clone().as_str() == "None".to_string().as_str())) || (n.ident_span.clone() == None)) { Rc::new(vec![]) @@ -2498,8 +2472,7 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { if is_optional { with_required_cardinality(n.clone()) } else { - if ((crate::v2_std_text::host_string_text_to_rust_host(n.name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("Optional".to_string())) + if ((n.name.clone().as_str() == "Optional".to_string().as_str()) && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { @@ -2513,7 +2486,7 @@ pub fn extract_optional_inner_node(n: Rc) -> Rc { } } -pub fn algebra_field_kind_name(kind: AlgebraFieldKind) -> Rc> { +pub fn algebra_field_kind_name(kind: AlgebraFieldKind) -> String { match kind { AlgebraFieldKind::AlgAdd => "add".to_string(), AlgebraFieldKind::AlgMul => "mul".to_string(), @@ -2710,12 +2683,8 @@ pub fn for_each_element_type_node( if ((((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) == 0)) && ((normed.properties.clone().len() as i64) == 0)) - && (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices, - normed.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - "String".to_string(), - ))) + && (authored_name_at(source_indices, normed.clone()).as_str() + == "String".to_string().as_str())) { string_type() } else { @@ -2726,7 +2695,7 @@ pub fn for_each_element_type_node( } } -pub fn emit_map_has(m: Rc>, key: Rc>) -> bool { +pub fn emit_map_has(m: Rc>, key: String) -> bool { match v1_rt::map_get(&m, key) { Some(_) => true, None => false, diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index 06379572485..55bfc8d5028 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -85,8 +85,8 @@ use std::rc::Rc; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ReservedWordStrategy { - PrefixEscape { prefix: Rc> }, - SuffixEscape { suffix: Rc> }, + PrefixEscape { prefix: String }, + SuffixEscape { suffix: String }, NoEscape, } @@ -98,22 +98,22 @@ pub struct ReservedWords { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ProjectScaffold { - pub manifest_file: Rc>, - pub module_init_file: Rc>, - pub source_file_extension: Rc>, - pub source_dir: Rc>, + pub manifest_file: Option, + pub module_init_file: Option, + pub source_file_extension: String, + pub source_dir: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SerializationSpec { - pub struct_derives: Rc>, - pub struct_derives_copy: Rc>, - pub enum_derives: Rc>, - pub enum_derives_copy: Rc>, - pub tag_attribute: Rc>, - pub rename_attribute_template: Rc>, - pub derive_attribute: Rc>, - pub default_value: Rc>, + pub struct_derives: Option, + pub struct_derives_copy: Option, + pub enum_derives: Option, + pub enum_derives_copy: Option, + pub tag_attribute: Option, + pub rename_attribute_template: Option, + pub derive_attribute: Option, + pub default_value: Option, } #[derive( @@ -127,88 +127,88 @@ pub enum TestNameStyle { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TestConventions { - pub file_prefix: Rc>, - pub file_suffix: Rc>, - pub file_dir: Rc>, - pub function_prefix: Rc>, + pub file_prefix: String, + pub file_suffix: String, + pub file_dir: Option, + pub function_prefix: String, pub name_style: TestNameStyle, - pub async_decorator: Rc>, + pub async_decorator: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ImportTrigger { - TypeUsageTrigger { type_name: Rc> }, - TraitImplTrigger { trait_name: Rc> }, - DeriveMacroTrigger { macro_name: Rc> }, - ContainerUsageTrigger { container: Rc> }, + TypeUsageTrigger { type_name: String }, + TraitImplTrigger { trait_name: String }, + DeriveMacroTrigger { macro_name: String }, + ContainerUsageTrigger { container: String }, AsyncUsageTrigger, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ImportRule { pub trigger: Rc, - pub import_path: Rc>, + pub import_path: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SharingStrategy { pub needs_sharing: bool, - pub wrap_template: Rc>, - pub clone_value: Rc>, - pub deref_clone: Rc>, - pub field_clone: Rc>, - pub iter_owned: Rc>, - pub clone_suffix: Rc>, - pub borrow_param_template: Rc>, - pub borrow_arg_template: Rc>, + pub wrap_template: String, + pub clone_value: String, + pub deref_clone: String, + pub field_clone: String, + pub iter_owned: String, + pub clone_suffix: String, + pub borrow_param_template: String, + pub borrow_arg_template: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct IndexingSemantics { - pub list_index: Rc>, - pub map_index: Rc>, - pub string_index: Rc>, - pub list_slice: Rc>, - pub string_slice: Rc>, + pub list_index: String, + pub map_index: String, + pub string_index: String, + pub list_slice: Option, + pub string_slice: Option, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct AnnotationRequirements { - pub let_binding_inferred: Rc>, - pub let_binding_annotated: Rc>, - pub lambda_param_typed: Rc>, - pub lambda_param_untyped: Rc>, + pub let_binding_inferred: String, + pub let_binding_annotated: String, + pub lambda_param_typed: String, + pub lambda_param_untyped: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ServiceFieldTemplates { - pub rest_decl: Rc>, - pub auth_decl: Rc>, - pub shell_decl: Rc>, - pub file_decl: Rc>, - pub rest_ctor: Rc>, - pub auth_ctor: Rc>, - pub shell_ctor: Rc>, - pub file_ctor: Rc>, + pub rest_decl: String, + pub auth_decl: String, + pub shell_decl: String, + pub file_decl: String, + pub rest_ctor: String, + pub auth_ctor: String, + pub shell_ctor: String, + pub file_ctor: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct BlockSyntax { - pub block_open: Rc>, - pub block_close: Rc>, - pub else_clause: Rc>, - pub match_keyword: Rc>, - pub case_keyword: Rc>, - pub arm_separator: Rc>, - pub stmt_terminator: Rc>, + pub block_open: String, + pub block_close: String, + pub else_clause: String, + pub match_keyword: String, + pub case_keyword: String, + pub arm_separator: String, + pub stmt_terminator: String, pub significant_whitespace: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ForEachSyntax { - pub prefix: Rc>, - pub separator: Rc>, + pub prefix: String, + pub separator: String, } #[derive( @@ -234,20 +234,20 @@ pub enum MatchValueForm { pub struct ExpressionSemantics { pub if_value_form: IfValueForm, pub match_value_form: MatchValueForm, - pub wildcard_case: Rc>, + pub wildcard_case: Option, pub variant_pattern: Option>, - pub guard_prefix: Rc>, - pub empty_return_value: Rc>, - pub return_suffix: Rc>, + pub guard_prefix: Option, + pub empty_return_value: String, + pub return_suffix: String, pub suppress_unit_return: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct VariantPatternSyntax { - pub open: Rc>, - pub close: Rc>, - pub binding_sep: Rc>, - pub empty_suffix: Rc>, + pub open: String, + pub close: String, + pub binding_sep: String, + pub empty_suffix: String, } #[derive( @@ -264,35 +264,35 @@ pub enum NamingCase { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum VisibilitySpec { - KeywordVisibility { prefix: Rc> }, + KeywordVisibility { prefix: String }, CaseVisibility { export_case: NamingCase }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TcoSyntax { - pub loop_keyword: Rc>, - pub break_return: Rc>, - pub continue_str: Rc>, - pub temp_var_prefix: Rc>, - pub temp_decl_prefix: Rc>, - pub temp_assign_op: Rc>, + pub loop_keyword: String, + pub break_return: String, + pub continue_str: String, + pub temp_var_prefix: String, + pub temp_decl_prefix: String, + pub temp_assign_op: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ServiceMethodStrategy { - SelfInParams { self_param: Rc> }, - ExternalReceiver { var_name: Rc> }, + SelfInParams { self_param: String }, + ExternalReceiver { var_name: String }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ServiceReturnStrategy { ArrowReturn, - ErrorTupleReturn { error_type: Rc> }, + ErrorTupleReturn { error_type: String }, } impl ServiceReturnStrategy { - pub fn error_type(&self) -> Rc> { + pub fn error_type(&self) -> String { match self { ServiceReturnStrategy::ArrowReturn => panic!("no error_type on unit variant"), ServiceReturnStrategy::ErrorTupleReturn { @@ -302,17 +302,14 @@ impl ServiceReturnStrategy { } } -pub fn service_self_param(spec: Rc) -> Rc> { +pub fn service_self_param(spec: Rc) -> String { match (*spec.service_method.clone()).clone() { ServiceMethodStrategy::SelfInParams { self_param: sp, .. } => sp.clone(), ServiceMethodStrategy::ExternalReceiver { var_name: _, .. } => "".to_string(), } } -pub fn service_receiver_str( - spec: Rc, - service_name: Rc>, -) -> Rc> { +pub fn service_receiver_str(spec: Rc, service_name: String) -> String { match (*spec.service_method.clone()).clone() { ServiceMethodStrategy::SelfInParams { self_param: _, .. } => "".to_string(), ServiceMethodStrategy::ExternalReceiver { var_name: v, .. } => v1_rt::concat( @@ -339,10 +336,7 @@ pub fn service_methods_inside_class(spec: Rc) -> bool { } } -pub fn service_return_str( - spec: Rc, - ret_type: Rc>, -) -> Rc> { +pub fn service_return_str(spec: Rc, ret_type: String) -> String { match (*spec.service_return.clone()).clone() { ServiceReturnStrategy::ArrowReturn => { v1_rt::concat(spec.items.clone().return_arrow.clone(), ret_type) @@ -359,23 +353,20 @@ pub fn service_return_str( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemKeywords { - pub func_keyword: Rc>, - pub async_prefix: Rc>, - pub struct_keyword: Rc>, - pub enum_keyword: Rc>, - pub type_alias_keyword: Rc>, - pub param_separator: Rc>, - pub return_arrow: Rc>, - pub param_type_sep: Rc>, - pub module_keyword: Rc>, - pub import_keyword: Rc>, - pub import_from_keyword: Rc>, + pub func_keyword: String, + pub async_prefix: String, + pub struct_keyword: String, + pub enum_keyword: String, + pub type_alias_keyword: String, + pub param_separator: String, + pub return_arrow: String, + pub param_type_sep: String, + pub module_keyword: String, + pub import_keyword: String, + pub import_from_keyword: String, } -pub fn item_keyword_for_kind( - forms: Rc>>, - kind: ItemFormKind, -) -> Rc> { +pub fn item_keyword_for_kind(forms: Rc>>, kind: ItemFormKind) -> String { { let matching = Rc::new({ let mut __result = Vec::new(); @@ -395,7 +386,7 @@ pub fn item_keyword_for_kind( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct LanguageSpec { - pub target_name: Rc>, + pub target_name: String, pub reserved_words: Rc, pub scaffold: Rc, pub serialization: Rc, @@ -410,21 +401,21 @@ pub struct LanguageSpec { pub tco: Rc, pub items: Rc, pub expression_semantics: Rc, - pub lambda_template: Rc>, - pub error_expr_template: Rc>, - pub list_literal_empty: Rc>, - pub list_literal_template: Rc>, - pub null_coalesce_template: Rc>, - pub error_type_template: Rc>, - pub type_arg_open: Rc>, - pub type_arg_close: Rc>, - pub void_type: Rc>, + pub lambda_template: String, + pub error_expr_template: String, + pub list_literal_empty: String, + pub list_literal_template: String, + pub null_coalesce_template: String, + pub error_type_template: String, + pub type_arg_open: String, + pub type_arg_close: String, + pub void_type: String, pub tuple_syntax: Rc, pub string_interp: Rc, - pub callable_type_template: Rc>, + pub callable_type_template: Option, pub naming_case: NamingCase, - pub async_call_prefix: Rc>, - pub bridge_method_prefix: Rc>, + pub async_call_prefix: String, + pub bridge_method_prefix: String, pub bridge_method_case: NamingCase, pub bridge_method_overrides: Rc>, pub record_lit: Rc, @@ -434,35 +425,35 @@ pub struct LanguageSpec { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TupleSyntax { - pub empty: Rc>, - pub pair_template: Rc>, - pub multi_template: Rc>, - pub separator: Rc>, - pub first_accessor: Rc>, - pub second_accessor: Rc>, + pub empty: String, + pub pair_template: String, + pub multi_template: String, + pub separator: String, + pub first_accessor: String, + pub second_accessor: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RecordLitSyntax { - pub named_open: Rc>, - pub named_close: Rc>, - pub named_empty: Rc>, - pub named_field_sep: Rc>, - pub named_field_join: Rc>, - pub anon_empty: Rc>, - pub anon_prefix: Rc>, - pub anon_suffix: Rc>, - pub anon_field_indent: Rc>, + pub named_open: String, + pub named_close: String, + pub named_empty: String, + pub named_field_sep: String, + pub named_field_join: String, + pub anon_empty: String, + pub anon_prefix: String, + pub anon_suffix: String, + pub anon_field_indent: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum InterpStyle { - FormatArgs { placeholder: Rc> }, + FormatArgs { placeholder: String }, InlineExpr, } impl InterpStyle { - pub fn placeholder(&self) -> Rc> { + pub fn placeholder(&self) -> String { match self { InterpStyle::FormatArgs { placeholder: __val, .. @@ -474,15 +465,15 @@ impl InterpStyle { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EscapePair { - pub from: Rc>, - pub to: Rc>, + pub from: String, + pub to: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StringInterpSyntax { pub style: Rc, - pub format_template: Rc>, - pub plain_template: Rc>, + pub format_template: String, + pub plain_template: String, pub escape_pairs: Rc>>, } @@ -648,7 +639,7 @@ pub fn rust_spec() -> Rc { async_call_prefix: "".to_string(), bridge_method_prefix: "".to_string(), bridge_method_case: NamingCase::SnakeCase, - bridge_method_overrides: v1_rt::rc_empty_map::>, Rc>>(), + bridge_method_overrides: v1_rt::rc_empty_map::(), record_lit: Rc::new(RecordLitSyntax { named_open: " {".to_string(), named_close: "}".to_string(), @@ -828,7 +819,7 @@ pub fn python_spec() -> Rc { bridge_method_prefix: "".to_string(), bridge_method_case: NamingCase::SnakeCase, bridge_method_overrides: v1_rt::rc_map_insert( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::(), "with".to_string(), "with_update".to_string(), ), @@ -998,7 +989,7 @@ pub fn go_spec() -> Rc { async_call_prefix: "".to_string(), bridge_method_prefix: "v2rt.".to_string(), bridge_method_case: NamingCase::PascalCase, - bridge_method_overrides: v1_rt::rc_empty_map::>, Rc>>(), + bridge_method_overrides: v1_rt::rc_empty_map::(), record_lit: Rc::new(RecordLitSyntax { named_open: "{".to_string(), named_close: "}".to_string(), @@ -1174,7 +1165,7 @@ pub fn dag_spec() -> Rc { async_call_prefix: "".to_string(), bridge_method_prefix: "".to_string(), bridge_method_case: NamingCase::SnakeCase, - bridge_method_overrides: v1_rt::rc_empty_map::>, Rc>>(), + bridge_method_overrides: v1_rt::rc_empty_map::(), record_lit: Rc::new(RecordLitSyntax { named_open: " {".to_string(), named_close: "}".to_string(), @@ -1202,7 +1193,7 @@ pub fn language_spec_for_target(target: RenderTarget) -> Rc { } } -pub fn target_keyword(target: RenderTarget, key: Rc>) -> Rc> { +pub fn target_keyword(target: RenderTarget, key: String) -> String { match target { RenderTarget::Rust => match v1_rt::lookup(&rust_keywords(), key.clone()) { v1_rt::Witness::Holds { value: kw, .. } => kw.clone(), @@ -1233,7 +1224,7 @@ pub fn binop_symbol( target: RenderTarget, op: BinOp, algebra_field: Option, -) -> Rc> { +) -> Option { { let ops = target_operators(target); let op_matching = Rc::new({ @@ -1286,14 +1277,12 @@ pub fn binop_symbol( } } -pub fn is_string_like(target: RenderTarget, name: Rc>) -> bool { +pub fn is_string_like(target: RenderTarget, name: String) -> bool { match target { RenderTarget::Rust => { let mut __found = false; for t in rust_string_types().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(t.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) - { + if (t.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1303,9 +1292,7 @@ pub fn is_string_like(target: RenderTarget, name: Rc>) -> bool { RenderTarget::Go => { let mut __found = false; for t in go_string_types().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(t.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) - { + if (t.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1315,9 +1302,7 @@ pub fn is_string_like(target: RenderTarget, name: Rc>) -> bool { RenderTarget::Python => { let mut __found = false; for t in python_string_types().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(t.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) - { + if (t.clone().as_str() == name.clone().as_str()) { __found = true; break; } @@ -1354,19 +1339,9 @@ pub fn expression_semantics_for_target(target: RenderTarget) -> Rc>) -> Rc> { +pub fn wrap_shared_type(target: RenderTarget, inner: String) -> String { { let tmpl = sharing_for_target(target).wrap_template.clone(); v1_rt::replace(tmpl, "{0}".to_string(), inner) } } - -pub struct SnakeCaseTestNames; -pub struct PascalCaseTestNames; -pub struct IfExpression; -pub struct ConditionalTernary; -pub struct IfStatement; -pub struct MatchExpression; -pub struct MatchStatementArmReturn; -pub struct PascalCase; -pub struct CamelCase; diff --git a/src/v1/stage0/src/v1_compiler_normalize.rs b/src/v1/stage0/src/v1_compiler_normalize.rs index 928b81029d0..0da15e2a8e5 100644 --- a/src/v1/stage0/src/v1_compiler_normalize.rs +++ b/src/v1/stage0/src/v1_compiler_normalize.rs @@ -28,7 +28,7 @@ pub struct NormalizeResult { pub fn check_bare_containers( n: Rc, - module_name: Rc>, + module_name: String, source_indices: Rc>>, ) -> Rc>> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index b98626e24fa..881d0355c8b 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -43,13 +43,13 @@ pub enum EdgeKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EdgeClassification { pub kind: EdgeKind, - pub site: Rc>, + pub site: String, pub span_start: i64, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct BindingUsage { - pub name: Rc>, + pub name: String, pub binding_kind: Option>, pub consumers: Rc>>, } @@ -90,21 +90,21 @@ pub fn binding_fan_out(usage: Rc) -> i64 { #[serde(tag = "_variant")] pub enum OwnershipDecision { SoleOwner { - binding: Rc>, - site: Rc>, + binding: String, + site: String, }, SharedError { - binding: Rc>, + binding: String, consumer_count: i64, sites: Rc>, }, Unclassified { - binding: Rc>, - reason: Rc>, + binding: String, + reason: String, }, } impl OwnershipDecision { - pub fn binding(&self) -> Rc> { + pub fn binding(&self) -> String { match self { OwnershipDecision::SoleOwner { binding: __val, .. } => __val.clone(), OwnershipDecision::SharedError { binding: __val, .. } => __val.clone(), @@ -115,9 +115,9 @@ impl OwnershipDecision { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FoldAccUnwrapProof { - pub site_key: Rc>, - pub acc_param_name: Rc>, - pub acc_type_name: Rc>, + pub site_key: String, + pub acc_param_name: String, + pub acc_type_name: String, pub body_constructs_acc: bool, pub whole_acc_single_use: bool, pub safe_field_moves: bool, @@ -133,7 +133,7 @@ pub struct FoldAccUseSummary { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct OwnershipProof { - pub func_name: Rc>, + pub func_name: String, pub bindings: Rc>>, pub decisions: Rc>>, pub fold_acc_unwrap: Rc>>, @@ -147,16 +147,16 @@ pub struct UsageAccum { pub fn empty_usage_accum() -> Rc { Rc::new(UsageAccum { - bindings: v1_rt::rc_empty_map::>, Rc>(), + bindings: v1_rt::rc_empty_map::>(), fold_call_nodes: Rc::new(vec![]), }) } pub fn record_use( accum: Rc, - name: Rc>, + name: String, kind: EdgeKind, - site: Rc>, + site: String, binding_kind: Option>, span_start: i64, ) -> Rc { @@ -201,7 +201,7 @@ pub fn max_usage_by_fan_out(a: Rc, b: Rc) -> Rc>>, - key: Rc>, + key: String, new_val: Rc, ) -> Rc>> { match v1_rt::map_get(&base, key.clone()) { @@ -314,18 +314,14 @@ pub fn walk_expr( } ExprData::ExprCall { .. } => { let fname = expr_call_func_at(texpr.clone(), si.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(fname) - == crate::v2_std_text::host_string_text_to_rust_host("fold".to_string())) - { + if (fname.as_str() == "fold".to_string().as_str()) { { let init_arg = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(si.clone(), a.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "init".to_string(), - )) { + if (authored_name_at(si.clone(), a.clone()).as_str() + == "init".to_string().as_str()) + { __result.push(a); } } @@ -358,11 +354,9 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in texpr.children.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(si.clone(), a.clone()), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "init".to_string(), - )) { + if (authored_name_at(si.clone(), a.clone()).as_str() + != "init".to_string().as_str()) + { __result.push(a); } } @@ -388,19 +382,15 @@ pub fn walk_expr( let recv = method_receiver(texpr.clone()); let mc_args = method_arg_nodes(texpr.clone()); let mname = expr_method_name_at(texpr.clone(), si.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(mname) - == crate::v2_std_text::host_string_text_to_rust_host("fold".to_string())) - { + if (mname.as_str() == "fold".to_string().as_str()) { { let recv_accum = walk_expr(accum, recv, false, si.clone()); let init_arg = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(si.clone(), a.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "init".to_string(), - )) { + if (authored_name_at(si.clone(), a.clone()).as_str() + == "init".to_string().as_str()) + { __result.push(a); } } @@ -433,11 +423,9 @@ pub fn walk_expr( let non_init = Rc::new({ let mut __result = Vec::new(); for a in mc_args.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(si.clone(), a.clone()), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "init".to_string(), - )) { + if (authored_name_at(si.clone(), a.clone()).as_str() + != "init".to_string().as_str()) + { __result.push(a); } } @@ -934,7 +922,7 @@ pub fn merge_fold_acc_use_summaries( pub fn summarize_fold_acc_uses( node: Rc, - acc_name: Rc>, + acc_name: String, si: Rc>>, inside_nested: bool, ) -> Rc { @@ -943,10 +931,8 @@ pub fn summarize_fold_acc_uses( ExprData::ExprVar { binding_kind: _, .. } => { - if (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( - node.clone(), - si.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(acc_name.clone())) + if (expr_var_name_at(node.clone(), si.clone()).as_str() + == acc_name.clone().as_str()) { if inside_nested.clone() { Rc::new(FoldAccUseSummary { @@ -971,10 +957,8 @@ pub fn summarize_fold_acc_uses( ExprData::ExprVar { binding_kind: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(expr_var_name_at( - base.clone(), - si.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(acc_name.clone())) + (expr_var_name_at(base.clone(), si.clone()).as_str() + == acc_name.clone().as_str()) } _ => false, }; @@ -1079,7 +1063,7 @@ pub fn summarize_fold_acc_uses( pub fn fold_lambda_acc_use_summary( lambda_node: Rc, - acc_name: Rc>, + acc_name: String, si: Rc>>, ) -> Rc { match (*lambda_node.expr_data.clone()).clone() { @@ -1092,7 +1076,7 @@ pub fn fold_lambda_acc_use_summary( pub fn fold_body_constructs_acc_struct( lambda_node: Rc, - acc_type_name: Rc>, + acc_type_name: String, si: Rc>>, ) -> bool { match (*lambda_node.expr_data.clone()).clone() { @@ -1101,10 +1085,7 @@ pub fn fold_body_constructs_acc_struct( let terminal = fold_terminal_expr(body); match (*terminal.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { - (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - si, - terminal.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host(acc_type_name)) + (authored_name_at(si, terminal.clone()).as_str() == acc_type_name.as_str()) } _ => false, } @@ -1115,14 +1096,14 @@ pub fn fold_body_constructs_acc_struct( pub fn fold_body_safe_field_moves( lambda_node: Rc, - acc_name: Rc>, + acc_name: String, si: Rc>>, ) -> bool { { let summary = fold_lambda_acc_use_summary(lambda_node, acc_name, si); let deduped = summary.field_moves.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |seen: Rc>, field: Rc>| { + v1_rt::rc_empty_map::(), + |seen: Rc>, field: String| { v1_rt::rc_map_insert(seen, field.clone(), true) }, ); @@ -1134,7 +1115,7 @@ pub fn fold_body_safe_field_moves( pub fn fold_body_consumes_acc_once( lambda_node: Rc, - acc_name: Rc>, + acc_name: String, si: Rc>>, ) -> bool { { @@ -1198,13 +1179,10 @@ pub fn analyze_single_fold( si.clone(), ); let eligible = ((cond_required - && (crate::v2_std_text::host_string_text_to_rust_host(acc_type_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + && (acc_type_name.clone().as_str() != "".to_string().as_str())) && ((cond_struct.clone() && cond_safe.clone()) || cond_whole_acc.clone())); Rc::new(FoldAccUnwrapProof { - site_key: crate::v2_std_text::host_string_text_from_rust_host( - (method_call.span.clone().start.clone()).to_string(), - ), + site_key: (method_call.span.clone().start.clone()).to_string(), acc_param_name: acc_param_name.clone(), acc_type_name: acc_type_name.clone(), body_constructs_acc: cond_struct.clone(), @@ -1216,7 +1194,7 @@ pub fn analyze_single_fold( } pub fn analyze_ownership( - func_name: Rc>, + func_name: String, params: Rc>>, body: Rc, si: Rc>>, @@ -1268,8 +1246,3 @@ pub fn analyze_ownership( }) } } - -pub struct Consumed; -pub struct Read; -pub struct Threaded; -pub struct Projected; diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 5580b6113ad..e5170bf42d7 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -140,7 +140,7 @@ pub struct TokenResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct NameResult { - pub name: Rc>, + pub name: String, pub span: Rc, pub tokens: Rc>>, pub err: Option>, @@ -284,7 +284,7 @@ pub struct ResUseResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ItemPrefixResult { - pub name: Rc>, + pub name: String, pub name_span: Rc, pub type_params: Rc>>, pub params: Rc>>, @@ -322,7 +322,7 @@ pub struct BindingPower { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum ExpectedToken { - ExpectKeyword { text: Rc> }, + ExpectKeyword { text: String }, ExpectLBrace, ExpectRBrace, ExpectLParen, @@ -341,7 +341,7 @@ pub enum ExpectedToken { ExpectPipe, } impl ExpectedToken { - pub fn text(&self) -> Rc> { + pub fn text(&self) -> String { match self { ExpectedToken::ExpectKeyword { text: __val, .. } => __val.clone(), ExpectedToken::ExpectLBrace => panic!("no text on unit variant"), @@ -484,7 +484,7 @@ pub struct BindingsResult { pub err: Option>, } -pub fn parse_recovery_expr(span: Rc, message: Rc>) -> Rc { +pub fn parse_recovery_expr(span: Rc, message: String) -> Rc { make_expr_error_node(ExprErrorKind::ParseRecoveryError, message, span) } @@ -510,7 +510,7 @@ pub struct GuardResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct FromKeyResult { - pub from_key: Rc>, + pub from_key: Option, pub tokens: Rc>>, pub ctx: Rc, pub err: Option>, @@ -527,7 +527,7 @@ pub struct PostfixResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ParserParam { - pub name: Rc>, + pub name: String, pub span: Rc, } @@ -560,7 +560,7 @@ pub struct RangeArgsResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct NamedIntResult { - pub arg_name: Rc>, + pub arg_name: String, pub arg_value: i64, pub tokens: Rc>>, pub ctx: Rc, @@ -657,7 +657,7 @@ pub struct UnitResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct StringLitResult { - pub value: Rc>, + pub value: String, pub tokens: Rc>>, pub err: Option>, } @@ -683,7 +683,7 @@ pub enum ParserHelperIdentity { #[serde(tag = "_variant")] pub enum ParserCallIdentity { ParserCallHelper { helper: ParserHelperIdentity }, - ParserCallFunction { name: Rc> }, + ParserCallFunction { name: String }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -709,7 +709,7 @@ impl ParserResultWitness { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DescResult { - pub desc: Rc>, + pub desc: Option, pub tokens: Rc>>, } @@ -737,7 +737,7 @@ pub fn advance(tokens: Rc>>) -> Rc { } } -pub fn parse_error(msg: Rc>, span: Rc) -> Rc { +pub fn parse_error(msg: String, span: Rc) -> Rc { make_error_node( Rc::new(CompilerDiagnostic::ParseError { message: msg, @@ -1144,18 +1144,14 @@ pub fn is_pipe_arrow_shape(shape: TokenShape) -> bool { } } -pub fn tok_is_keyword(tok: Option>, kw: Rc>) -> bool { +pub fn tok_is_keyword(tok: Option>, kw: String) -> bool { match tok { - Some(t) => { - (is_keyword_shape(t.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(kw))) - } + Some(t) => (is_keyword_shape(t.shape.clone()) && (t.text.clone().as_str() == kw.as_str())), None => false, } } -pub fn tok_keyword_text(tok: Option>) -> Rc> { +pub fn tok_keyword_text(tok: Option>) -> String { match tok { Some(t) => { if is_keyword_shape(t.shape.clone()) { @@ -1175,20 +1171,16 @@ pub fn tok_is_ident(tok: Option>) -> bool { } } -pub fn tok_is_ident_text(tok: Option>, text: Rc>) -> bool { +pub fn tok_is_ident_text(tok: Option>, text: String) -> bool { match tok { - Some(t) => { - (is_ident_shape(t.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(text))) - } + Some(t) => (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == text.as_str())), None => false, } } pub fn drop_leading_type_modifier( tokens: Rc>>, - modifier: Rc>, + modifier: String, ) -> Rc>> { if tok_is_ident_text(tokens.clone().first().cloned(), modifier) { skip_newlines(Rc::new( @@ -1206,9 +1198,8 @@ pub fn drop_leading_type_modifier( pub fn drop_leading_test_marker(tokens: Rc>>) -> Rc>> { if (tok_is_ident_text(tokens.clone().first().cloned(), "test".to_string()) - && (crate::v2_std_text::host_string_text_to_rust_host(tok_keyword_text( - tokens.clone().get(1 as usize).cloned(), - )) != crate::v2_std_text::host_string_text_to_rust_host("".to_string()))) + && (tok_keyword_text(tokens.clone().get(1 as usize).cloned()).as_str() + != "".to_string().as_str())) { Rc::new( tokens @@ -1381,7 +1372,7 @@ pub fn tok_span(tok: Option>) -> Rc { } } -pub fn tok_keyword_to_name(tok: Option>) -> Rc> { +pub fn tok_keyword_to_name(tok: Option>) -> Option { match tok { Some(t) => { if is_name_keyword(t.clone()) { @@ -1401,7 +1392,7 @@ pub fn tok_is_keyword_name(tok: Option>) -> bool { } } -pub fn shape_display_name(shape: TokenShape) -> Rc> { +pub fn shape_display_name(shape: TokenShape) -> String { match shape { TokenShape::ShKeyword => "keyword".to_string(), TokenShape::ShLBrace => "LBrace".to_string(), @@ -1449,7 +1440,7 @@ pub fn shape_display_name(shape: TokenShape) -> Rc> { } } -pub fn token_display_name(token: Rc) -> Rc> { +pub fn token_display_name(token: Rc) -> String { if is_keyword_shape(token.shape.clone()) { v1_rt::concat( "keyword '".to_string(), @@ -1460,7 +1451,7 @@ pub fn token_display_name(token: Rc) -> Rc> { } } -pub fn expected_token_name(expected: Rc) -> Rc> { +pub fn expected_token_name(expected: Rc) -> String { match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => v1_rt::concat( "keyword '".to_string(), @@ -1489,8 +1480,7 @@ pub fn token_matches_expected(token: Rc, expected: Rc) -> match (*expected).clone() { ExpectedToken::ExpectKeyword { text: kw, .. } => { (is_keyword_shape(token.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(token.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(kw.clone()))) + && (token.text.clone().as_str() == kw.clone().as_str())) } ExpectedToken::ExpectLBrace => is_lbrace_shape(token.shape.clone()), ExpectedToken::ExpectRBrace => is_rbrace_shape(token.shape.clone()), @@ -1546,10 +1536,7 @@ pub fn expect(tokens: Rc>>, expected: Rc) -> Rc>>, expected: Rc) -> Rc, source_indices: Rc>>, -) -> Rc> { +) -> Option { match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => match expr.children.clone().first().cloned() { Some(base) => match (*base.expr_data.clone()).clone() { @@ -1798,14 +1785,8 @@ pub fn parser_helper_state_arg_expr( let arg_node = pair.1.clone(); let matches_state = match arg_name_at(arg_node.clone(), source_indices.clone()) { Some(name) => { - ((crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "state".to_string(), - )) - || (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "tokens".to_string(), - ))) + ((name.clone().as_str() == "state".to_string().as_str()) + || (name.clone().as_str() == "tokens".to_string().as_str())) } None => (idx.clone() == 0), }; @@ -1822,14 +1803,12 @@ pub fn parser_helper_state_arg_expr( pub fn parser_progress_flag_var( expr: Rc, source_indices: Rc>>, -) -> Rc> { +) -> Option { match (*expr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { .. } => { let field = field_access_field_at(expr.clone(), source_indices.clone()); - if ((crate::v2_std_text::host_string_text_to_rust_host(field.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("consumed".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(field.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("changed".to_string()))) + if ((field.clone().as_str() == "consumed".to_string().as_str()) + || (field.clone().as_str() == "changed".to_string().as_str())) { parser_result_base_var(expr.clone(), source_indices.clone()) } else { @@ -1840,22 +1819,14 @@ pub fn parser_progress_flag_var( } } -pub fn parser_helper_identity(callee: Rc>) -> Option { - if (crate::v2_std_text::host_string_text_to_rust_host(callee.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("skip_newlines".to_string())) - { +pub fn parser_helper_identity(callee: String) -> Option { + if (callee.clone().as_str() == "skip_newlines".to_string().as_str()) { Some(ParserHelperIdentity::ParserHelperSkipNewlines) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(callee.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "skip_continuation_newlines".to_string(), - )) - { + if (callee.clone().as_str() == "skip_continuation_newlines".to_string().as_str()) { Some(ParserHelperIdentity::ParserHelperSkipContinuationNewlines) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(callee.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("with".to_string())) - { + if (callee.clone().as_str() == "with".to_string().as_str()) { Some(ParserHelperIdentity::ParserHelperWith) } else { None @@ -1916,13 +1887,11 @@ pub fn parser_result_witness( } } -pub fn leaf_type_node(name: Rc>, span: Rc) -> Rc { +pub fn leaf_type_node(name: String, span: Rc) -> Rc { Rc::new(Node { name: name.clone(), span: span.clone(), - ident_span: if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("".to_string())) - { + ident_span: if (name.clone().as_str() == "".to_string().as_str()) { None } else { Some(span.clone()) @@ -2078,7 +2047,7 @@ pub fn parse_dotted_ident(tokens: Rc>>) -> Rc { pub fn parse_dotted_ident_rest( mut tokens: Rc>>, - mut acc: Rc>, + mut acc: String, mut span: Rc, ) -> Rc { loop { @@ -2469,7 +2438,7 @@ pub fn parse_import_names(tokens: Rc>>, ctx: Rc) -> parse_import_names_acc(tokens, ctx, Rc::new(vec![])) } -pub fn parsed_name_leaf(name: Rc>, span: Rc) -> Rc { +pub fn parsed_name_leaf(name: String, span: Rc) -> Rc { leaf_node_with_span(name, span) } @@ -2513,17 +2482,12 @@ pub fn parse_import_names_acc( } } -pub fn find_item_form( - forms: Rc>>, - keyword: Rc>, -) -> Option> { +pub fn find_item_form(forms: Rc>>, keyword: String) -> Option> { { let matches = Rc::new({ let mut __result = Vec::new(); for f in forms.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(f.keyword.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(keyword.clone())) - { + if (f.keyword.clone().as_str() == keyword.clone().as_str()) { __result.push(f); } } @@ -2952,7 +2916,7 @@ pub fn outputs_to_inferred( } pub fn make_operation_node( - name: Rc>, + name: String, ident_span: Option>, inputs: Rc>>, outputs: Rc>>, @@ -3005,7 +2969,7 @@ pub fn make_operation_node( } pub fn make_capability_node( - name: Rc>, + name: String, ident_span: Option>, inputs: Rc>>, outputs: Rc>>, @@ -3393,7 +3357,7 @@ pub fn parse_type_body_from_prefix( pub fn parse_type_body_after_eq( tokens: Rc>>, ctx: Rc, - name: Rc>, + name: String, name_span: Rc, start_span: Rc, type_params: Rc>>, @@ -4211,34 +4175,24 @@ pub fn parse_named_int_args( err: r2.err.clone(), }); } - let min_val = - if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("min".to_string())) - { - Some(r.arg_value.clone()) + let min_val = if (r.arg_name.clone().as_str() == "min".to_string().as_str()) { + Some(r.arg_value.clone()) + } else { + if (r2.arg_name.clone().as_str() == "min".to_string().as_str()) { + Some(r2.arg_value.clone()) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(r2.arg_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("min".to_string())) - { - Some(r2.arg_value.clone()) - } else { - None - } - }; - let max_val = - if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("max".to_string())) - { - Some(r.arg_value.clone()) + None + } + }; + let max_val = if (r.arg_name.clone().as_str() == "max".to_string().as_str()) { + Some(r.arg_value.clone()) + } else { + if (r2.arg_name.clone().as_str() == "max".to_string().as_str()) { + Some(r2.arg_value.clone()) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(r2.arg_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("max".to_string())) - { - Some(r2.arg_value.clone()) - } else { - None - } - }; + None + } + }; Rc::new(RangeArgsResult { min_val: min_val, max_val: max_val, @@ -4248,22 +4202,16 @@ pub fn parse_named_int_args( }) } EatResult::EatUnchanged { tokens: __eu, .. } => { - let min_val = - if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("min".to_string())) - { - Some(r.arg_value.clone()) - } else { - None - }; - let max_val = - if (crate::v2_std_text::host_string_text_to_rust_host(r.arg_name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("max".to_string())) - { - Some(r.arg_value.clone()) - } else { - None - }; + let min_val = if (r.arg_name.clone().as_str() == "min".to_string().as_str()) { + Some(r.arg_value.clone()) + } else { + None + }; + let max_val = if (r.arg_name.clone().as_str() == "max".to_string().as_str()) { + Some(r.arg_value.clone()) + } else { + None + }; Rc::new(RangeArgsResult { min_val: min_val, max_val: max_val, @@ -4366,7 +4314,7 @@ pub fn parse_positional_variant_type_fields( pub fn parse_variant_fields( tokens: Rc>>, ctx: Rc, - vname: Rc>, + vname: String, vname_span: Rc, ) -> Rc { { @@ -4616,10 +4564,7 @@ pub fn parse_type_expr(tokens: Rc>>, ctx: Rc) -> Rc< }) } Some(TokenShape::ShKeyword) => { - if (crate::v2_std_text::host_string_text_to_rust_host( - tok.clone().unwrap().text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host("fn".to_string())) - { + if (tok.clone().unwrap().text.clone().as_str() == "fn".to_string().as_str()) { parse_callable_type_expr( Rc::new( tokens @@ -4818,7 +4763,7 @@ pub fn parse_callable_param_types( pub fn finish_type_expr_from_name( tokens: Rc>>, ctx: Rc, - type_name: Rc>, + type_name: String, start_span: Rc, ) -> Rc { { @@ -5228,10 +5173,7 @@ pub fn parse_optional_from_key( }; match sh { Some(TokenShape::ShIdent) => { - if (crate::v2_std_text::host_string_text_to_rust_host( - tok.clone().unwrap().text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host("from".to_string())) - { + if (tok.clone().unwrap().text.clone().as_str() == "from".to_string().as_str()) { { let tok2 = tokens.clone().get(1 as usize).cloned(); let sh2 = match tok2.clone() { @@ -5570,9 +5512,7 @@ pub fn parse_func_def(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> Rc>>, ctx: Rc) -> R let is_uses = match tok { Some(t) => { (is_ident_shape(t.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("uses".to_string()))) + && (t.text.clone().as_str() == "uses".to_string().as_str())) } None => false, }; @@ -6421,9 +6355,7 @@ pub fn parse_service_entries( match sh { Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("config".to_string())) - { + if (id.clone().as_str() == "config".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -6481,11 +6413,7 @@ pub fn parse_service_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "transport".to_string(), - )) - { + if (id.clone().as_str() == "transport".to_string().as_str()) { let r = parse_transport_binding( Rc::new( tokens @@ -6534,11 +6462,7 @@ pub fn parse_service_entries( } Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text) - == crate::v2_std_text::host_string_text_to_rust_host( - "operation".to_string(), - )) - { + if (kw_text.as_str() == "operation".to_string().as_str()) { let r = parse_operation_def(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ServiceBodyResult { @@ -6750,9 +6674,7 @@ pub fn parse_transport_binding( }; match sh { Some(TokenShape::ShIdent) => { - if (crate::v2_std_text::host_string_text_to_rust_host(tok_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("rest".to_string())) - { + if (tok_text.clone().as_str() == "rest".to_string().as_str()) { { let r = expect( Rc::new( @@ -6803,9 +6725,7 @@ pub fn parse_transport_binding( }) } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(tok_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("shell".to_string())) - { + if (tok_text.clone().as_str() == "shell".to_string().as_str()) { { let r = expect( Rc::new( @@ -6858,11 +6778,7 @@ pub fn parse_transport_binding( }) } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(tok_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "file".to_string(), - )) - { + if (tok_text.clone().as_str() == "file".to_string().as_str()) { { let r = expect( Rc::new( @@ -7034,73 +6950,52 @@ pub fn parse_rest_fields( EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; ctx = r3.ctx.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(transport_url_key())) - { + if (fname.clone().as_str() == transport_url_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); base_url = __tco_0; continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(transport_method_key())) - { + if (fname.clone().as_str() == transport_method_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); method = __tco_0; continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - transport_path_template_key(), - )) - { + if (fname.clone().as_str() == transport_path_template_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); path_template = __tco_0; continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - transport_query_key(), - )) - { + if (fname.clone().as_str() == transport_query_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); query = __tco_0; continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - transport_body_key(), - )) - { + if (fname.clone().as_str() == transport_body_key().as_str()) { { let __tco_0 = Some(r3.expr.clone()); request_body = __tco_0; continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - fname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - transport_response_format_key(), - )) { + if (fname.clone().as_str() + == transport_response_format_key().as_str()) + { { let __tco_0 = Some(r3.expr.clone()); response_format = __tco_0; continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - fname.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - transport_headers_key(), - )) { + if (fname.clone().as_str() == transport_headers_key().as_str()) + { let h = match (*r3.expr.clone().expr_data.clone()).clone() { ExprData::ExprRecordLit { .. } => r3.expr.clone().children.clone(), _ => return Rc::new(TransportResult { @@ -7179,9 +7074,7 @@ pub fn parse_shell_fields( err: r2.err.clone(), }); } - if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("argv".to_string())) - { + if (fname.clone().as_str() == "argv".to_string().as_str()) { let r3 = expect(r2.tokens.clone(), Rc::new(ExpectedToken::ExpectLBracket)); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7226,9 +7119,7 @@ pub fn parse_shell_fields( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(transport_stdin_key())) - { + if (fname.clone().as_str() == transport_stdin_key().as_str()) { let r3 = parse_expr(r2.tokens.clone(), ctx.clone()); if has_err(r3.err.clone()) { return Rc::new(TransportResult { @@ -7348,10 +7239,8 @@ pub fn parse_file_fields( EatResult::EatConsumed { tokens: __ec, .. } => __ec.clone(), EatResult::EatUnchanged { tokens: _, .. } => r3.tokens.clone(), }; - if ((crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("path".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(fname.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(transport_path_key()))) + if ((fname.clone().as_str() == "path".to_string().as_str()) + || (fname.clone().as_str() == transport_path_key().as_str())) { { let __tco_0 = r3.ctx.clone(); @@ -7436,7 +7325,7 @@ pub fn parse_operation_def(tokens: Rc>>, ctx: Rc) -> pub fn parse_operation_v2_inline( tokens: Rc>>, ctx: Rc, - name: Rc>, + name: String, name_span: Rc, start_span: Rc, ) -> Rc { @@ -7556,7 +7445,7 @@ pub fn parse_operation_v2_inline( pub fn parse_operation_v1_body( tokens: Rc>>, ctx: Rc, - name: Rc>, + name: String, name_span: Rc, start_span: Rc, ) -> Rc { @@ -7674,9 +7563,7 @@ pub fn parse_op_body_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok.clone().unwrap().text.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("input".to_string())) - { + if (kw_text.clone().as_str() == "input".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -7745,11 +7632,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "output".to_string(), - )) - { + if (kw_text.clone().as_str() == "output".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -7818,11 +7701,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "idempotent".to_string(), - )) - { + if (kw_text.clone().as_str() == "idempotent".to_string().as_str()) { let prop = modifier_to_prop("idempotent".to_string(), span); { let __tco_0 = Rc::new( @@ -7834,11 +7713,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - kw_text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "readonly".to_string(), - )) { + if (kw_text.clone().as_str() == "readonly".to_string().as_str()) { let prop = modifier_to_prop("readonly".to_string(), span); { let __tco_0 = Rc::new( @@ -7854,11 +7729,8 @@ pub fn parse_op_body_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - kw_text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "hermetic".to_string(), - )) { + if (kw_text.clone().as_str() == "hermetic".to_string().as_str()) + { let prop = modifier_to_prop("hermetic".to_string(), span); { let __tco_0 = Rc::new( @@ -7883,11 +7755,7 @@ pub fn parse_op_body_entries( } Some(TokenShape::ShIdent) => { let id = tok.clone().unwrap().text.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "transport".to_string(), - )) - { + if (id.clone().as_str() == "transport".to_string().as_str()) { let r = parse_transport_binding( Rc::new( tokens @@ -7923,11 +7791,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "exit".to_string(), - )) - { + if (id.clone().as_str() == "exit".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -7997,11 +7861,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "response".to_string(), - )) - { + if (id.clone().as_str() == "response".to_string().as_str()) { let r = parse_optional_response_block(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(OpBodyResult { @@ -8027,11 +7887,7 @@ pub fn parse_op_body_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(id.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "mock_response".to_string(), - )) - { + if (id.clone().as_str() == "mock_response".to_string().as_str()) { let r = parse_optional_mock_response_block( tokens.clone(), ctx.clone(), @@ -8128,11 +7984,9 @@ pub fn parse_op_body_entries( tokens: tokens.clone(), ctx: ctx.clone(), err: Some(parse_error( - crate::v2_std_text::host_string_text_from_rust_host( - format!( - "unexpected '{}' in operation body", - id.clone() - ), + format!( + "unexpected '{}' in operation body", + id.clone() ), span, )), @@ -8165,7 +8019,7 @@ pub fn parse_op_body_entries( } } -pub fn modifier_to_prop(name: Rc>, span: Rc) -> Rc { +pub fn modifier_to_prop(name: String, span: Rc) -> Rc { make_field_init_node( name, make_expr_node( @@ -8207,7 +8061,7 @@ pub fn modifiers_to_props( pub fn status_expr_to_str( expr: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: v, .. } => match (*v.clone()).clone() { LiteralValue::LitInt { value: n, .. } => int_to_string(n.clone()), @@ -8221,7 +8075,7 @@ pub fn status_expr_to_str( } } -pub fn int_to_string(value: i64) -> Rc> { +pub fn int_to_string(value: i64) -> String { if (value.clone() == 0) { "0".to_string() } else { @@ -8304,7 +8158,7 @@ pub fn last_child_or_self(n: Rc) -> Rc { pub fn node_to_name_str( n: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let is_optional = (n.return_cardinality.clone() == Cardinality::CardOptional); let effective_n = if is_optional.clone() { @@ -8487,9 +8341,7 @@ pub fn parse_operation_modifiers_acc( ) -> Rc { loop { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("idempotent".to_string())) - { + if (kw.clone().as_str() == "idempotent".to_string().as_str()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); let __tco_1 = v1_rt::rc_list_push(acc, OperationModifier::Idempotent); @@ -8498,9 +8350,7 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("readonly".to_string())) - { + if (kw.clone().as_str() == "readonly".to_string().as_str()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8510,9 +8360,7 @@ pub fn parse_operation_modifiers_acc( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("hermetic".to_string())) - { + if (kw.clone().as_str() == "hermetic".to_string().as_str()) { { let __tco_0 = Rc::new(tokens.iter().cloned().skip(1 as usize).collect::>()); @@ -8571,19 +8419,13 @@ pub fn parse_status_pattern(tokens: Rc>>, ctx: Rc) - match next_tok { Some(t) => { if (is_ident_shape(t.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "xx".to_string(), - ))) + && (t.text.clone().as_str() == "xx".to_string().as_str())) { Rc::new(ExprResult { expr: make_expr_node( Rc::new(ExprData::ExprLiteral { value: Rc::new(LiteralValue::LitStr { - value: - crate::v2_std_text::host_string_text_from_rust_host( - format!("{}xx", n), - ), + value: format!("{}xx", n), }), }), Rc::new(vec![]), @@ -8704,10 +8546,7 @@ pub fn parse_optional_response_block( let is_response = match tok { Some(t) => { (is_ident_shape(t.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "response".to_string(), - ))) + && (t.text.clone().as_str() == "response".to_string().as_str())) } None => false, }; @@ -8864,10 +8703,7 @@ pub fn parse_optional_mock_response_block( let is_mock = match tok { Some(t) => { (is_ident_shape(t.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "mock_response".to_string(), - ))) + && (t.text.clone().as_str() == "mock_response".to_string().as_str())) } None => false, }; @@ -9207,11 +9043,7 @@ pub fn parse_resource_entries( match sh { Some(TokenShape::ShKeyword) => { let kw_text = tok_keyword_text(tok.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "capability".to_string(), - )) - { + if (kw_text.clone().as_str() == "capability".to_string().as_str()) { let r = parse_capability(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(ResPropResult { @@ -9232,11 +9064,7 @@ pub fn parse_resource_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "acquire".to_string(), - )) - { + if (kw_text.clone().as_str() == "acquire".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -9275,11 +9103,7 @@ pub fn parse_resource_entries( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "release".to_string(), - )) - { + if (kw_text.clone().as_str() == "release".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -9657,9 +9481,7 @@ pub fn parse_io_blocks_acc( }); } else { let kw = tok_keyword_text(tokens.clone().first().cloned()); - if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("input".to_string())) - { + if (kw.clone().as_str() == "input".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -9713,9 +9535,7 @@ pub fn parse_io_blocks_acc( continue; } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("output".to_string())) - { + if (kw.clone().as_str() == "output".to_string().as_str()) { let r = expect( Rc::new( tokens @@ -10253,14 +10073,10 @@ pub fn parse_stmt(tokens: Rc>>, ctx: Rc) -> Rc { let kw_text = tok_keyword_text(tok.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("let".to_string())) - { + if (kw_text.clone().as_str() == "let".to_string().as_str()) { parse_let(tokens.clone(), ctx) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("return".to_string())) - { + if (kw_text.clone().as_str() == "return".to_string().as_str()) { parse_return(tokens.clone(), ctx) } else { if peek_is_eq_after_ident(tokens.clone()) { @@ -10413,12 +10229,10 @@ pub fn parse_constrained_assignment( } } -pub fn peek_text_is(tokens: Rc>>, expected: Rc>) -> bool { +pub fn peek_text_is(tokens: Rc>>, expected: String) -> bool { match tokens.first().cloned() { Some(t) => { - (is_ident_shape(t.shape.clone()) - && (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(expected))) + (is_ident_shape(t.shape.clone()) && (t.text.clone().as_str() == expected.as_str())) } None => false, } @@ -10817,17 +10631,12 @@ pub fn parse_expr_loop( } } -pub fn find_operator_bp( - ops: Rc>>, - symbol: Rc>, -) -> Option { +pub fn find_operator_bp(ops: Rc>>, symbol: String) -> Option { { let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(op.symbol.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(symbol.clone())) - { + if (op.symbol.clone().as_str() == symbol.clone().as_str()) { __result.push(op); } } @@ -10854,17 +10663,12 @@ pub fn infix_bp(tokens: Rc>>) -> Option { } } -pub fn find_operator_binop( - ops: Rc>>, - symbol: Rc>, -) -> Option { +pub fn find_operator_binop(ops: Rc>>, symbol: String) -> Option { { let matching = Rc::new({ let mut __result = Vec::new(); for op in ops.iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(op.symbol.clone()) - == crate::v2_std_text::host_string_text_to_rust_host(symbol.clone())) - { + if (op.symbol.clone().as_str() == symbol.clone().as_str()) { __result.push(op); } } @@ -11155,18 +10959,18 @@ pub fn parse_caret_expr(tokens: Rc>>, ctx: Rc) -> Rc Rc::new(ExprResult { expr: parse_recovery_expr( span.clone(), - crate::v2_std_text::host_string_text_from_rust_host(format!( + format!( "expected identifier or `(` after `^`, found {}", found.clone() - )), + ), ), tokens: after_caret.clone(), ctx: ctx.clone(), err: Some(parse_error( - crate::v2_std_text::host_string_text_from_rust_host(format!( + format!( "expected identifier or `(` after `^`, found {}", found.clone() - )), + ), span.clone(), )), }) @@ -11208,57 +11012,41 @@ pub fn parse_primary(tokens: Rc>>, ctx: Rc) -> Rc { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "match".to_string(), - )) - { + if (kw_text.clone().as_str() == "match".to_string().as_str()) { parse_match(tokens.clone(), ctx.clone()) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "if".to_string(), - )) - { + if (kw_text.clone().as_str() == "if".to_string().as_str()) { parse_if(tokens.clone(), ctx.clone()) } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - kw_text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "for".to_string(), - )) { + if (kw_text.clone().as_str() == "for".to_string().as_str()) { parse_for(tokens.clone(), ctx.clone()) } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - kw_text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "let".to_string(), - )) { + if (kw_text.clone().as_str() == "let".to_string().as_str()) { parse_let(tokens.clone(), ctx.clone()) } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - kw_text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "return".to_string(), - )) { + if (kw_text.clone().as_str() + == "return".to_string().as_str()) + { parse_return(tokens.clone(), ctx.clone()) } else { - if (crate::v2_std_text::host_string_text_to_rust_host(kw_text.clone()) == crate::v2_std_text::host_string_text_to_rust_host("fn".to_string())) { - parse_fn_lambda(tokens.clone(), ctx.clone()) - } else { - { - let kw_name = tok_keyword_to_name(tok.clone()); -match kw_name { + if (kw_text.clone().as_str() + == "fn".to_string().as_str()) + { + parse_fn_lambda(tokens.clone(), ctx.clone()) + } else { + { + let kw_name = tok_keyword_to_name(tok.clone()); + match kw_name { Some(n) => parse_ident_expr(tokens.clone(), ctx.clone(), n.clone()), None => Rc::new(ExprResult { - expr: parse_recovery_expr(span.clone(), crate::v2_std_text::host_string_text_from_rust_host(format!("expected expression, found keyword '{}'", kw_text.clone()))), + expr: parse_recovery_expr(span.clone(), format!("expected expression, found keyword '{}'", kw_text.clone())), tokens: tokens.clone(), ctx: ctx.clone(), - err: Some(parse_error(crate::v2_std_text::host_string_text_from_rust_host(format!("expected expression, found keyword '{}'", kw_text.clone())), span.clone())), + err: Some(parse_error(format!("expected expression, found keyword '{}'", kw_text.clone()), span.clone())), }), } -} - } + } + } } } } @@ -11375,18 +11163,12 @@ match kw_name { Rc::new(ExprResult { expr: parse_recovery_expr( span.clone(), - crate::v2_std_text::host_string_text_from_rust_host(format!( - "expected expression, found {}", - tag.clone() - )), + format!("expected expression, found {}", tag.clone()), ), tokens: tokens.clone(), ctx: ctx.clone(), err: Some(parse_error( - crate::v2_std_text::host_string_text_from_rust_host(format!( - "expected expression, found {}", - tag.clone() - )), + format!("expected expression, found {}", tag.clone()), span.clone(), )), }) @@ -11481,7 +11263,7 @@ pub fn parse_lambda_stmts( pub fn parse_ident_expr( tokens: Rc>>, ctx: Rc, - name: Rc>, + name: String, ) -> Rc { { let span = token_span(tokens.clone().first().cloned()); @@ -11547,7 +11329,7 @@ pub fn parse_ident_expr( } } -pub fn is_uppercase_start(name: Rc>) -> bool { +pub fn is_uppercase_start(name: String) -> bool { { let ch = v1_rt::char_at(&name, 0); ((ch.clone() >= "A".to_string()) && (ch.clone() <= "Z".to_string())) @@ -11606,10 +11388,7 @@ pub fn try_postfix( } } Some(TokenShape::ShIdent) => { - if (crate::v2_std_text::host_string_text_to_rust_host( - tok.clone().unwrap().text.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host("as".to_string())) - { + if (tok.clone().unwrap().text.clone().as_str() == "as".to_string().as_str()) { if (13 < min_bp) { Rc::new(PostfixResult { expr: lhs.clone(), @@ -11783,10 +11562,8 @@ pub fn is_constraint_bracket(tokens: Rc>>) -> bool { match tokens.get(1 as usize).cloned() { Some(t) => { if is_ident_shape(t.shape.clone()) { - ((crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("after".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("when".to_string()))) + ((t.text.clone().as_str() == "after".to_string().as_str()) + || (t.text.clone().as_str() == "when".to_string().as_str())) } else { false } @@ -11849,12 +11626,8 @@ pub fn parse_constraint_list( let is_constraint_kw = match tok.clone() { Some(t) => { (is_ident_shape(t.shape.clone()) - && ((crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("after".to_string())) - || (crate::v2_std_text::host_string_text_to_rust_host(t.text.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "when".to_string(), - )))) + && ((t.text.clone().as_str() == "after".to_string().as_str()) + || (t.text.clone().as_str() == "when".to_string().as_str()))) } None => false, }; @@ -12817,9 +12590,7 @@ pub fn looks_like_arm_start(tokens: Rc>>) -> bool { match sh { Some(TokenShape::ShIdent) => { let n = tok.clone().unwrap().text.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("_".to_string())) - { + if (n.clone().as_str() == "_".to_string().as_str()) { peek_is_fat_arrow_at(tokens.clone(), 1) } else { if is_uppercase_start(n.clone()) { @@ -12990,9 +12761,7 @@ pub fn parse_pattern(tokens: Rc>>, ctx: Rc) -> Rc { let n = tok.clone().unwrap().text.clone(); - if (crate::v2_std_text::host_string_text_to_rust_host(n.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("_".to_string())) - { + if (n.clone().as_str() == "_".to_string().as_str()) { Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), tokens: Rc::new( @@ -13132,7 +12901,7 @@ pub fn parse_pattern(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc, - name: Rc>, + name: String, ) -> Rc { { let span = token_span(tokens.clone().first().cloned()); @@ -13626,7 +13395,7 @@ pub fn parse_for(tokens: Rc>>, ctx: Rc) -> Rc>>, ctx: Rc, - name: Rc>, + name: String, span: Rc, ) -> Rc { { @@ -14535,15 +14304,8 @@ pub fn parse_brace_expr(tokens: Rc>>, ctx: Rc) -> Rc match sh { Some(TokenShape::ShKeyword) => { let brace_kw = tok_keyword_text(tok.clone()); - if ((crate::v2_std_text::host_string_text_to_rust_host(brace_kw.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "let".to_string(), - )) - || (crate::v2_std_text::host_string_text_to_rust_host( - brace_kw.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "return".to_string(), - ))) + if ((brace_kw.clone().as_str() == "let".to_string().as_str()) + || (brace_kw.clone().as_str() == "return".to_string().as_str())) { { let r = parse_stmts(tokens.clone(), ctx); @@ -14796,7 +14558,3 @@ pub fn peek_is_colon_after_ident(tokens: Rc>>) -> bool { None => false, } } - -pub struct ParserHelperSkipNewlines; -pub struct ParserHelperSkipContinuationNewlines; -pub struct ParserHelperWith; diff --git a/src/v1/stage0/src/v1_compiler_resolve.rs b/src/v1/stage0/src/v1_compiler_resolve.rs index 25905d6c08b..1b987853c7b 100644 --- a/src/v1/stage0/src/v1_compiler_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_resolve.rs @@ -35,7 +35,7 @@ pub struct ResolvedModule { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ResolvedImport { - pub module_path: Rc>, + pub module_path: String, pub is_all: bool, pub specific_names: Rc>, pub target_module: Option>, @@ -43,8 +43,8 @@ pub struct ResolvedImport { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DepEdge { - pub from_module: Rc>, - pub to_module: Rc>, + pub from_module: String, + pub to_module: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -53,7 +53,7 @@ pub struct ResolveAccum { pub diagnostics: Rc>>, } -pub fn map_has(m: Rc>, key: Rc>) -> bool { +pub fn map_has(m: Rc>, key: String) -> bool { match v1_rt::map_get(&m, key) { Some(_) => true, None => false, @@ -67,7 +67,7 @@ pub fn resolve_modules( { let dup_diags = check_duplicate_modules(modules.clone(), source_indices.clone()); let module_index = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>(), + v1_rt::rc_empty_map::>(), |acc: Rc>>, m: Rc| { v1_rt::rc_map_insert( acc, @@ -77,12 +77,12 @@ pub fn resolve_modules( }, ); let export_sets = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::>>(), |acc: Rc>>>, m: Rc| { let exported = get_exported_names(m.clone(), source_indices.clone()); let exported_set = exported.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |inner_acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |inner_acc: Rc>, name: String| { v1_rt::rc_map_insert(inner_acc, name.clone(), true) }, ); @@ -95,10 +95,7 @@ pub fn resolve_modules( ); let resolve_accum = modules.clone().iter().cloned().fold( Rc::new(ResolveAccum { - imports_by_name: v1_rt::rc_empty_map::< - Rc>, - Rc>>, - >(), + imports_by_name: v1_rt::rc_empty_map::>>>(), diagnostics: Rc::new(vec![]), }), |acc: Rc, m: Rc| { @@ -140,7 +137,7 @@ pub fn resolve_modules( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, i64>(), + v1_rt::rc_empty_map::(), |acc: Rc>, pair: (i64, String)| { v1_rt::rc_map_insert(acc, pair.1.clone(), pair.0.clone()) }, @@ -188,10 +185,7 @@ pub fn resolve_modules( } } -pub fn find_module( - module_index: Rc>>, - path: Rc>, -) -> Option> { +pub fn find_module(module_index: Rc>>, path: String) -> Option> { v1_rt::map_get(&module_index, path) } @@ -264,7 +258,7 @@ pub struct ImportResolveResult { pub fn resolve_import( import: Rc, module_index: Rc>>, - importing_module: Rc>, + importing_module: String, export_sets: Rc>>>, source_indices: Rc>>, ) -> Rc { @@ -297,7 +291,7 @@ pub fn resolve_import( Some(target_mod) => { let exported_set = match v1_rt::map_get(&export_sets, import_path.clone()) { Some(set) => set.clone(), - None => v1_rt::rc_empty_map::>, bool>(), + None => v1_rt::rc_empty_map::(), }; let name_diags = if import_is_all(import.clone()) { Rc::new(vec![]) @@ -398,7 +392,7 @@ pub fn get_exported_names( pub fn get_item_name( item: Rc, source_indices: Rc>>, -) -> Rc> { +) -> String { authored_name_at(source_indices, item) } @@ -435,7 +429,7 @@ pub fn check_duplicate_modules( { let result = modules.iter().cloned().fold( Rc::new(DuplicateCheckState { - seen_names: v1_rt::rc_empty_map::>, bool>(), + seen_names: v1_rt::rc_empty_map::(), diagnostics: Rc::new(vec![]), }), |state: Rc, m: Rc| { @@ -479,8 +473,8 @@ pub struct TopoResult { pub fn adjacency_add_edge( adjacency: Rc>>>, - from_module: Rc>, - to_module: Rc>, + from_module: String, + to_module: String, ) -> Rc>>> { { let existing = match v1_rt::map_get(&adjacency, from_module.clone()) { @@ -495,10 +489,8 @@ pub fn adjacency_add_edge( } } -pub fn topo_sort_key(name: Rc>) -> Rc> { - if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) - { +pub fn topo_sort_key(name: String) -> String { + if (name.clone().as_str() == "std.types".to_string().as_str()) { "".to_string() } else { name.clone() @@ -520,9 +512,7 @@ pub fn topological_sort( let has_std_types = { let mut __found = false; for name in module_names.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(name.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("std.types".to_string())) - { + if (name.clone().as_str() == "std.types".to_string().as_str()) { __found = true; break; } @@ -559,30 +549,22 @@ pub fn topological_sort( let imports_std_types = { let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host( - authored_name_at(source_indices.clone(), imp.clone()), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "std.types".to_string(), - )) { + if (authored_name_at(source_indices.clone(), imp.clone()) + .as_str() + == "std.types".to_string().as_str()) + { __found = true; break; } } __found }; - if ((((crate::v2_std_text::host_string_text_to_rust_host( - m_name.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "std.types".to_string(), - )) && (crate::v2_std_text::host_string_text_to_rust_host( - m_name.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "std.algebra".to_string(), - ))) && (crate::v2_std_text::host_string_text_to_rust_host( - m_name.clone(), - ) != crate::v2_std_text::host_string_text_to_rust_host( - "std.error_primitives".to_string(), - ))) && (imports_std_types.clone() == false)) + if ((((m_name.clone().as_str() != "std.types".to_string().as_str()) + && (m_name.clone().as_str() + != "std.algebra".to_string().as_str())) + && (m_name.clone().as_str() + != "std.error_primitives".to_string().as_str())) + && (imports_std_types.clone() == false)) { Rc::new(vec![Rc::new(DepEdge { from_module: "std.types".to_string(), @@ -605,24 +587,21 @@ pub fn topological_sort( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, Rc>>(), + v1_rt::rc_empty_map::>>(), |acc: Rc>>>, edge: Rc| { adjacency_add_edge(acc, edge.from_module.clone(), edge.to_module.clone()) }, ); let in_degree_map = modules.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, i64>(), + v1_rt::rc_empty_map::(), |acc: Rc>, m: Rc| { let m_name = authored_name_at(source_indices.clone(), m.clone()); let imports_std_types = { let mut __found = false; for imp in module_imports(m.clone()).iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(authored_name_at( - source_indices.clone(), - imp.clone(), - )) == crate::v2_std_text::host_string_text_to_rust_host( - "std.types".to_string(), - )) { + if (authored_name_at(source_indices.clone(), imp.clone()).as_str() + == "std.types".to_string().as_str()) + { __found = true; break; } @@ -630,18 +609,9 @@ pub fn topological_sort( __found }; let implicit_std_types_in_degree = if ((((has_std_types.clone() - && (crate::v2_std_text::host_string_text_to_rust_host(m_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - "std.types".to_string(), - ))) - && (crate::v2_std_text::host_string_text_to_rust_host(m_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - "std.algebra".to_string(), - ))) - && (crate::v2_std_text::host_string_text_to_rust_host(m_name.clone()) - != crate::v2_std_text::host_string_text_to_rust_host( - "std.error_primitives".to_string(), - ))) + && (m_name.clone().as_str() != "std.types".to_string().as_str())) + && (m_name.clone().as_str() != "std.algebra".to_string().as_str())) + && (m_name.clone().as_str() != "std.error_primitives".to_string().as_str())) && (imports_std_types.clone() == false)) { 1 @@ -672,9 +642,9 @@ pub fn topological_sort( .iter() .cloned() .collect(); - __sorted.sort_by(|a: &Rc>, b: &Rc>| { - let __ka = (|name: Rc>| topo_sort_key(name.clone()))(a.clone()); - let __kb = (|name: Rc>| topo_sort_key(name.clone()))(b.clone()); + __sorted.sort_by(|a: &String, b: &String| { + let __ka = (|name: String| topo_sort_key(name.clone()))(a.clone()); + let __kb = (|name: String| topo_sort_key(name.clone()))(b.clone()); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted @@ -695,8 +665,8 @@ pub fn topological_sort( } else { { let sorted_set = result.sorted.clone().iter().cloned().fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -750,7 +720,7 @@ pub fn kahn_drain( sorted: sorted.clone(), in_degree_map: in_degree_map.clone(), }), - |state: Rc, node: Rc>| { + |state: Rc, node: String| { let state = Rc::try_unwrap(state).unwrap_or_else(|rc| (*rc).clone()); { let new_sorted = v1_rt::rc_list_push(state.sorted, node.clone()); @@ -760,7 +730,7 @@ pub fn kahn_drain( }; let new_degrees = neighbors.clone().iter().cloned().fold( state.in_degree_map, - |deg_map: Rc>, neighbor: Rc>| { + |deg_map: Rc>, neighbor: String| { let current = match v1_rt::map_get(°_map, neighbor.clone()) { Some(d) => d.clone(), None => 0, @@ -810,8 +780,8 @@ pub fn kahn_drain( .iter() .cloned() .fold( - v1_rt::rc_empty_map::>, bool>(), - |acc: Rc>, name: Rc>| { + v1_rt::rc_empty_map::(), + |acc: Rc>, name: String| { v1_rt::rc_map_insert(acc, name.clone(), true) }, ); @@ -820,9 +790,9 @@ pub fn kahn_drain( .iter() .cloned() .collect(); - __sorted.sort_by(|a: &Rc>, b: &Rc>| { - let __ka = (|name: Rc>| name.clone())(a.clone()); - let __kb = (|name: Rc>| name.clone())(b.clone()); + __sorted.sort_by(|a: &String, b: &String| { + let __ka = (|name: String| name.clone())(a.clone()); + let __kb = (|name: String| name.clone())(b.clone()); __ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal) }); __sorted diff --git a/src/v1/stage0/src/v1_compiler_runtime_go.rs b/src/v1/stage0/src/v1_compiler_runtime_go.rs index 7510b3b1428..f51dc3d24db 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_go.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_go.rs @@ -10,7 +10,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn go_rt_header() -> Rc> { +pub fn go_rt_header() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -36,7 +36,7 @@ pub fn go_rt_header() -> Rc> { ) } -pub fn go_rt_concat() -> Rc> { +pub fn go_rt_concat() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -67,15 +67,15 @@ pub fn go_rt_concat() -> Rc> { ) } -pub fn go_rt_slice_ops() -> Rc> { +pub fn go_rt_slice_ops() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("func Map(xs interface{}, fn interface{}) interface{} {\n".to_string(), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tout := make([]interface{}, len(items))\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor i, x := range items {\n".to_string()), "\t\t\tout[i] = call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Interface()\n".to_string()), "\t\t}\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Filter(xs interface{}, fn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tout := make([]interface{}, 0, len(items))\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tif call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Bool() {\n".to_string()), "\t\t\t\tout = append(out, x)\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Any(xs interface{}, fn interface{}) bool {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tif call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Bool() {\n".to_string()), "\t\t\t\treturn true\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn false\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn false\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func All(xs interface{}, fn interface{}) bool {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tif !call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Bool() {\n".to_string()), "\t\t\t\treturn false\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn true\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn true\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func FlatMap(xs interface{}, fn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tout := make([]interface{}, 0)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tchunk := call.Call([]reflect.Value{reflect.ValueOf(x)})[0].Interface()\n".to_string()), "\t\t\tif nested, ok := chunk.([]interface{}); ok {\n".to_string()), "\t\t\t\tout = append(out, nested...)\n".to_string()), "\t\t\t}\n".to_string()), "\t\t}\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Fold(xs interface{}, init interface{}, fn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tacc := init\n".to_string()), "\t\tcall := reflect.ValueOf(fn)\n".to_string()), "\t\tfor _, x := range items {\n".to_string()), "\t\t\tacc = call.Call([]reflect.Value{reflect.ValueOf(acc), reflect.ValueOf(x)})[0].Interface()\n".to_string()), "\t\t}\n".to_string()), "\t\treturn acc\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn init\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func SortBy(xs interface{}, keyFn interface{}) interface{} {\n".to_string()), "\tswitch items := xs.(type) {\n".to_string()), "\tcase []interface{}:\n".to_string()), "\t\tcall := reflect.ValueOf(keyFn)\n".to_string()), "\t\tout := append([]interface{}(nil), items...)\n".to_string()), "\t\tsort.SliceStable(out, func(i, j int) bool {\n".to_string()), "\t\t\tki := call.Call([]reflect.Value{reflect.ValueOf(out[i])})[0].Interface()\n".to_string()), "\t\t\tkj := call.Call([]reflect.Value{reflect.ValueOf(out[j])})[0].Interface()\n".to_string()), "\t\t\treturn fmt.Sprint(ki) < fmt.Sprint(kj)\n".to_string()), "\t\t})\n".to_string()), "\t\treturn out\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn xs\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()), "func Lookup(m interface{}, key interface{}) interface{} {\n".to_string()), "\tswitch table := m.(type) {\n".to_string()), "\tcase map[string]interface{}:\n".to_string()), "\t\treturn table[fmt.Sprint(key)]\n".to_string()), "\tdefault:\n".to_string()), "\t\treturn nil\n".to_string()), "\t}\n".to_string()), "}\n\n".to_string()) } -pub fn go_rt_algebra() -> Rc> { +pub fn go_rt_algebra() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("func Init(algebra interface{}, node interface{}) interface{} {\n".to_string(), "\tv := reflect.ValueOf(algebra)\n".to_string()), "\tinitFn := v.FieldByName(\"Init\")\n".to_string()), "\tif !initFn.IsValid() {\n".to_string()), "\t\treturn nil\n".to_string()), "\t}\n".to_string()), "\treturn initFn.Call([]reflect.Value{reflect.ValueOf(node)})[0].Interface()\n".to_string()), "}\n\n".to_string()), "func Step(algebra interface{}, acc interface{}, edge interface{}, sub interface{}) interface{} {\n".to_string()), "\tv := reflect.ValueOf(algebra)\n".to_string()), "\tstepFn := v.FieldByName(\"Step\")\n".to_string()), "\tif !stepFn.IsValid() {\n".to_string()), "\t\treturn acc\n".to_string()), "\t}\n".to_string()), "\treturn stepFn.Call([]reflect.Value{reflect.ValueOf(acc), reflect.ValueOf(edge), reflect.ValueOf(sub)})[0].Interface()\n".to_string()), "}\n\n".to_string()) } -pub fn go_runtime_source() -> Rc> { +pub fn go_runtime_source() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat(go_rt_header(), go_rt_concat()), diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index 757278006e8..3df8222f6a3 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -10,7 +10,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn rt_header() -> Rc> { +pub fn rt_header() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -29,27 +29,27 @@ pub fn rt_header() -> Rc> { ) } -pub fn rt_text_lookup_work_counter() -> Rc> { +pub fn rt_text_lookup_work_counter() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string(), "use std::cell::Cell;\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "thread_local! {\n".to_string()), " static TEXT_LOOKUP_CHARS_WALKED: Cell = Cell::new(0);\n".to_string()), "}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "pub fn reset_text_lookup_chars_walked() {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(0));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "pub fn reset_text_lookup_chars_walked() {}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "pub fn take_text_lookup_chars_walked() -> u64 {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| {\n".to_string()), " let walked = c.get();\n".to_string()), " c.set(0);\n".to_string()), " walked\n".to_string()), " })\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "pub fn take_text_lookup_chars_walked() -> u64 { 0 }\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "fn record_substring_chars_walked(s: &str, start: usize, take_len: usize) {\n".to_string()), " let walked = if s.is_ascii() {\n".to_string()), " take_len as u64\n".to_string()), " } else {\n".to_string()), " (start + take_len) as u64\n".to_string()), " };\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(c.get() + walked));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "fn record_substring_chars_walked(_s: &str, _start: usize, _take_len: usize) {}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "fn record_source_chars_slice_walked(units: u64) {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(c.get() + units));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "fn record_source_chars_slice_walked(_units: u64) {}\n\n".to_string()), "#[cfg(feature = \"text_lookup_work_counter\")]\n".to_string()), "pub fn record_source_chars_index_lookup() {\n".to_string()), " TEXT_LOOKUP_CHARS_WALKED.with(|c| c.set(c.get() + 1));\n".to_string()), "}\n\n".to_string()), "#[cfg(not(feature = \"text_lookup_work_counter\"))]\n".to_string()), "pub fn record_source_chars_index_lookup() {}\n\n".to_string()) } -pub fn rt_concat_trait() -> Rc> { +pub fn rt_concat_trait() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub trait V2Concat {\n".to_string(), " fn v1_concat(self, other: Self) -> Self;\n".to_string()), "}\n\n".to_string()), "impl V2Concat for String {\n".to_string()), " fn v1_concat(mut self, other: String) -> String { self.push_str(&other); self }\n".to_string()), "}\n\n".to_string()), "impl V2Concat for Vec {\n".to_string()), " fn v1_concat(mut self, other: Vec) -> Vec { self.extend(other); self }\n".to_string()), "}\n\n".to_string()), "pub fn concat(a: T, b: T) -> T { a.v1_concat(b) }\n\n".to_string()) } -pub fn rt_string_ops() -> Rc> { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8.\n".to_string()), "pub fn utf8_decode_bytes(bytes: &[u8]) -> Result {\n".to_string()), " String::from_utf8(bytes.to_vec()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))\n".to_string()), "}\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) +pub fn rt_string_ops() -> String { + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn char_at(s: &str, pos: i64) -> String {\n".to_string(), " let pos = pos.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " return String::from(bytes[pos] as char);\n".to_string()), " }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " if s.is_ascii() {\n".to_string()), " let len = s.len();\n".to_string()), " if start >= len { return String::new(); }\n".to_string()), " let out_end = end.min(len);\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) } -pub fn rt_collection_ops() -> Rc> { +pub fn rt_collection_ops() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Clone, Debug, PartialEq)]\n".to_string(), "pub enum Witness {\n".to_string()), " Holds { value: V },\n".to_string()), " Violates { diagnostic: String },\n".to_string()), "}\n\n".to_string()), "pub fn lookup(table: &HashMap, key: String) -> Witness {\n".to_string()), " match table.get(&key).cloned() {\n".to_string()), " Some(value) => Witness::Holds { value },\n".to_string()), " None => Witness::Violates {\n".to_string()), " diagnostic: format!(\"lookup miss for key {}\", key),\n".to_string()), " },\n".to_string()), " }\n".to_string()), "}\n\n".to_string()), "pub fn index_by String>(list: Vec, key_fn: F) -> HashMap {\n".to_string()), " let mut map = HashMap::new();\n".to_string()), " for item in list { let key = key_fn(&item); map.insert(key, item); }\n".to_string()), " map\n".to_string()), "}\n\n".to_string()), "pub fn empty_map() -> HashMap { HashMap::new() }\n\n".to_string()), "pub fn map_insert(mut map: HashMap, key: K, value: V) -> HashMap {\n".to_string()), " map.insert(key, value); map\n".to_string()), "}\n\n".to_string()), "pub fn map_merge(mut base: HashMap, overlay: HashMap) -> HashMap {\n".to_string()), " base.extend(overlay); base\n".to_string()), "}\n\n".to_string()), "pub fn map_get(m: &HashMap, key: K) -> Option {\n".to_string()), " m.get(&key).cloned()\n".to_string()), "}\n\n".to_string()), "pub fn map_keys(m: &HashMap) -> Vec { m.keys().cloned().collect() }\n\n".to_string()), "pub fn map_is_empty(m: &HashMap) -> bool { m.is_empty() }\n\n".to_string()), "// Sound identity hint (see 04_infer.dag substitute_generics): returns true =>\n".to_string()), "// the two are structurally equal. The compiled realization answers with pointer\n".to_string()), "// identity (conservative: may say false when equal); never true-when-unequal, so\n".to_string()), "// callers that return the original on true preserve output structure. Owned Rc\n".to_string()), "// args (cheap refcount bump) keep the inner element pointers, so ptr_eq on the\n".to_string()), "// clones equals ptr_eq on the originals -- lets the .dag pass args by value and\n".to_string()), "// emit through the normal clone path (no all-args-by-ref emit rule needed).\n".to_string()), "pub fn rc_ptr_eq(a: Rc, b: Rc) -> bool { Rc::ptr_eq(&a, &b) }\n\n".to_string()), "pub fn rc_vec_ptr_eq(a: Rc>>, b: Rc>>) -> bool {\n".to_string()), " a.len() == b.len() && a.iter().zip(b.iter()).all(|(x, y)| Rc::ptr_eq(x, y))\n".to_string()), "}\n\n".to_string()), "pub fn map_values(m: &HashMap) -> Vec { m.values().cloned().collect() }\n\n".to_string()), "pub fn list_concat(mut a: Vec, b: Vec) -> Vec { a.extend(b); a }\n\n".to_string()), "pub fn list_push(mut list: Vec, item: T) -> Vec { list.push(item); list }\n\n".to_string()), "pub fn append(list: Rc>, item: T) -> Vec {\n".to_string()), " let mut v = (*list).clone();\n".to_string()), " v.push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn chars_to_string(chars: &Rc>, start: i64, end: i64) -> String {\n".to_string()), " let len = chars.len();\n".to_string()), " let start = (start.max(0) as usize).min(len);\n".to_string()), " let end = (end.max(0) as usize).min(len).max(start);\n".to_string()), " let units = (end.saturating_sub(start)) as u64;\n".to_string()), " record_source_chars_slice_walked(units);\n".to_string()), " chars[start..end]\n".to_string()), " .iter()\n".to_string()), " .filter_map(|&cp| char::from_u32(cp as u32))\n".to_string()), " .collect()\n".to_string()), "}\n\n".to_string()), "pub fn parse_int(s: String) -> Option { s.parse::().ok() }\n\n".to_string()), "pub fn map_contains_key(m: &HashMap, key: K) -> bool {\n".to_string()), " m.contains_key(&key)\n".to_string()), "}\n\n".to_string()), "pub fn map_has(m: &HashMap, key: K) -> bool {\n".to_string()), " m.contains_key(&key)\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_set() -> Rc> {\n".to_string()), " Rc::new(BTreeSet::new())\n".to_string()), "}\n\n".to_string()), "pub fn rc_set_insert(mut s: Rc>, x: T) -> Rc> {\n".to_string()), " Rc::make_mut(&mut s).insert(x);\n".to_string()), " s\n".to_string()), "}\n\n".to_string()), "pub fn rc_set_union(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut out = a;\n".to_string()), " for x in b.iter().cloned() {\n".to_string()), " Rc::make_mut(&mut out).insert(x);\n".to_string()), " }\n".to_string()), " out\n".to_string()), "}\n\n".to_string()), "pub fn set_contains>>(s: S, x: T) -> bool {\n".to_string()), " s.as_ref().contains(&x)\n".to_string()), "}\n\n".to_string()), "pub fn reverse(list: Rc>) -> Rc> {\n".to_string()), " let mut v = (*list).clone(); v.reverse(); Rc::new(v)\n".to_string()), "}\n\n".to_string()), "pub fn replace(s: String, from: String, to: String) -> String {\n".to_string()), " s.replace(&from, &to)\n".to_string()), "}\n\n".to_string()) } -pub fn rt_scanner_ops() -> Rc> { +pub fn rt_scanner_ops() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("pub fn scan_while(s: &str, start: i64, pred: impl Fn(String) -> bool) -> i64 {\n".to_string(), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let mut pos = start.min(bytes.len());\n".to_string()), " while pos < bytes.len() && pred(String::from(bytes[pos] as char)) { pos += 1; }\n".to_string()), " return pos as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if pred(ch.to_string()) { pos += 1; } else { break; }\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()), "pub fn skip_horizontal_ws(s: &str, start: i64) -> i64 {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let mut pos = start.min(bytes.len());\n".to_string()), " while pos < bytes.len() && (bytes[pos] == b' ' || bytes[pos] == b'\\t') { pos += 1; }\n".to_string()), " return pos as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if ch == ' ' || ch == '\\t' { pos += 1; } else { break; }\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()), "pub fn scan_to_eol(s: &str, start: i64) -> i64 {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let start = start.min(bytes.len());\n".to_string()), " for i in start..bytes.len() { if bytes[i] == b'\\n' { return i as i64; } }\n".to_string()), " return bytes.len() as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if ch == '\\n' { return pos as i64; }\n".to_string()), " pos += 1;\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()), "pub fn scan_string_end(s: &str, start: i64) -> i64 {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " if s.is_ascii() {\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " let mut pos = start.min(bytes.len());\n".to_string()), " while pos < bytes.len() {\n".to_string()), " if bytes[pos] == b'\\\\' { pos += 2; }\n".to_string()), " else if bytes[pos] == b'\\\"' { return (pos + 1) as i64; }\n".to_string()), " else { pos += 1; }\n".to_string()), " }\n".to_string()), " return bytes.len() as i64;\n".to_string()), " }\n".to_string()), " let char_len = s.chars().count();\n".to_string()), " let start = start.min(char_len);\n".to_string()), " let mut pos = start;\n".to_string()), " let mut escaped = false;\n".to_string()), " for ch in s.chars().skip(start) {\n".to_string()), " if escaped {\n".to_string()), " escaped = false;\n".to_string()), " pos += 1;\n".to_string()), " } else if ch == '\\\\' {\n".to_string()), " escaped = true;\n".to_string()), " pos += 1;\n".to_string()), " } else if ch == '\\\"' {\n".to_string()), " return (pos + 1) as i64;\n".to_string()), " } else {\n".to_string()), " pos += 1;\n".to_string()), " }\n".to_string()), " }\n".to_string()), " pos as i64\n".to_string()), "}\n\n".to_string()) } -pub fn rt_unicode_ops() -> Rc> { +pub fn rt_unicode_ops() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -69,11 +69,11 @@ pub fn rt_unicode_ops() -> Rc> { ) } -pub fn rt_rc_container_ops() -> Rc> { +pub fn rt_rc_container_ops() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// -- Rc-wrapped container operations (FF-8) ---------------------------------\n".to_string(), "// These mirror the bare Vec/HashMap functions above but operate on Rc-wrapped\n".to_string()), "// containers for O(1) clone cost. Generated code using Rc container templates\n".to_string()), "// will call these. Read-only functions (map_get, map_keys, map_values, lookup,\n".to_string()), "// map_contains_key, map_has) work with Rc via auto-deref.\n\n".to_string()), "pub fn rc_list_push(list: Rc>, item: T) -> Rc> {\n".to_string()), " let mut v = list;\n".to_string()), " Rc::make_mut(&mut v).push(item);\n".to_string()), " v\n".to_string()), "}\n\n".to_string()), "pub fn rc_list_concat(a: Rc>, b: Rc>) -> Rc> {\n".to_string()), " let mut result = a;\n".to_string()), " Rc::make_mut(&mut result).extend(b.iter().cloned());\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_insert(map: Rc>, key: K, value: V) -> Rc> {\n".to_string()), " let mut m = map;\n".to_string()), " Rc::make_mut(&mut m).insert(key, value);\n".to_string()), " m\n".to_string()), "}\n\n".to_string()), "pub fn rc_map_merge(base: Rc>, overlay: Rc>) -> Rc> {\n".to_string()), " let mut result = base;\n".to_string()), " let inner = Rc::make_mut(&mut result);\n".to_string()), " for (k, v) in overlay.iter() {\n".to_string()), " inner.insert(k.clone(), v.clone());\n".to_string()), " }\n".to_string()), " result\n".to_string()), "}\n\n".to_string()), "pub fn rc_index_by String>(list: Rc>, key_fn: F) -> Rc> {\n".to_string()), " Rc::new(list.iter().map(|v| (key_fn(v), v.clone())).collect())\n".to_string()), "}\n\n".to_string()), "pub fn rc_empty_map() -> Rc> { Rc::new(HashMap::new()) }\n\n".to_string()), "impl V2Concat for Rc> {\n".to_string()), " fn v1_concat(self, other: Rc>) -> Rc> { rc_list_concat(self, other) }\n".to_string()), "}\n\n".to_string()) } -pub fn rt_filesystem() -> Rc> { +pub fn rt_filesystem() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -103,11 +103,11 @@ pub fn rt_filesystem() -> Rc> { ) } -pub fn rt_hash_ops() -> Rc> { +pub fn rt_hash_ops() -> String { v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("const FNV1A64_OFFSET: u64 = 0xcbf29ce484222325;\n".to_string(), "const FNV1A64_PRIME: u64 = 0x100000001b3;\n\n".to_string()), "fn fnv1a64(bytes: &[u8]) -> u64 {\n".to_string()), " let mut hash = FNV1A64_OFFSET;\n".to_string()), " for b in bytes {\n".to_string()), " hash ^= *b as u64;\n".to_string()), " hash = hash.wrapping_mul(FNV1A64_PRIME);\n".to_string()), " }\n".to_string()), " hash\n".to_string()), "}\n\n".to_string()), "pub type Hash = String;\n\n".to_string()), "const HASH_DIGEST_LEN: usize = 16;\n\n".to_string()), "pub fn is_hash_digest(s: &str) -> bool {\n".to_string()), " s.len() == HASH_DIGEST_LEN && s.bytes().all(|b| b.is_ascii_hexdigit())\n".to_string()), "}\n\n".to_string()), "fn expect_hash_digest(s: &str, arg: &str) {\n".to_string()), " if !is_hash_digest(s) {\n".to_string()), " panic!(\"{} must be a 16-char hex Hash digest\", arg);\n".to_string()), " }\n".to_string()), "}\n\n".to_string()), "pub fn atom_identity_hash(s: String) -> Hash {\n".to_string()), " format!(\"{:016x}\", fnv1a64(s.as_bytes()))\n".to_string()), "}\n\n".to_string()), "pub fn hash_combine(a: Hash, b: Hash) -> Hash {\n".to_string()), " expect_hash_digest(&a, \"a\");\n".to_string()), " expect_hash_digest(&b, \"b\");\n".to_string()), " let mut bytes = a.into_bytes();\n".to_string()), " bytes.push(0);\n".to_string()), " bytes.extend_from_slice(b.as_bytes());\n".to_string()), " format!(\"{:016x}\", fnv1a64(&bytes))\n".to_string()), "}\n\n".to_string()) } -pub fn rust_runtime_source() -> Rc> { +pub fn rust_runtime_source() -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_stage0_crates.rs b/src/v1/stage0/src/v1_compiler_stage0_crates.rs index a9c5526f97e..baa2ce9dd3a 100644 --- a/src/v1/stage0/src/v1_compiler_stage0_crates.rs +++ b/src/v1/stage0/src/v1_compiler_stage0_crates.rs @@ -4,7 +4,6 @@ use self::Stage0CrateKind::*; use crate::extdeps_cargo::CargoDepSource::{LocalPathDep, RegistryDep}; pub use crate::extdeps_cargo::{CargoDepSource, CargoDependency, CargoFeature}; -pub use crate::extdeps_cargo_version::render_cargo_package_header_prefix; pub use crate::v1_compiler_emit_rust::{emit_cargo_dep, emit_non_empty_wrappers}; use crate::v1_rt; use crate::v1_rt::Witness; @@ -27,10 +26,10 @@ pub enum Stage0CrateKind { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Stage0CrateSpec { - pub package_name: Rc>, - pub crate_dir: Rc>, + pub package_name: String, + pub crate_dir: String, pub kind: Stage0CrateKind, - pub header_doc: Rc>, + pub header_doc: String, pub modules: Rc>, pub dependencies: Rc>>, pub features: Rc>>, @@ -42,7 +41,7 @@ pub struct Stage0CratePlan { pub crates: Rc>>, } -pub fn stage0_crate_allow_block() -> Rc> { +pub fn stage0_crate_allow_block() -> String { Rc::new(vec![ "#![allow(".to_string(), " unused_imports,".to_string(), @@ -59,7 +58,7 @@ pub fn stage0_crate_allow_block() -> Rc> { .join(&"\n".to_string()) } -pub fn stage0_core_header_doc() -> Rc> { +pub fn stage0_core_header_doc() -> String { Rc::new(vec![ "//! Generated by regen_stage0 -- do not edit.".to_string(), "//!".to_string(), @@ -76,7 +75,7 @@ pub fn stage0_core_header_doc() -> Rc> { .join(&"\n".to_string()) } -pub fn stage0_emit_core_header_doc() -> Rc> { +pub fn stage0_emit_core_header_doc() -> String { Rc::new(vec![ "//! Generated by regen_stage0 -- do not edit.".to_string(), "//!".to_string(), @@ -90,7 +89,7 @@ pub fn stage0_emit_core_header_doc() -> Rc> { .join(&"\n".to_string()) } -pub fn render_stage0_crate_dep(dep: Rc) -> Rc> { +pub fn render_stage0_crate_dep(dep: Rc) -> String { match (*dep.source.clone()).clone() { CargoDepSource::RegistryDep { version, features, .. @@ -105,7 +104,7 @@ pub fn render_stage0_crate_dep(dep: Rc) -> Rc> } } -pub fn render_stage0_crate_feature(feature: Rc) -> Rc> { +pub fn render_stage0_crate_feature(feature: Rc) -> String { if ((feature.dependencies.clone().len() as i64) == 0) { v1_rt::concat(feature.name.clone(), " = []\n".to_string()) } else { @@ -132,9 +131,7 @@ pub fn render_stage0_crate_feature(feature: Rc) -> Rc>>, -) -> Rc> { +pub fn render_stage0_crate_features_section(features: Rc>>) -> String { if ((features.clone().len() as i64) == 0) { "".to_string() } else { @@ -168,8 +165,11 @@ pub fn emit_stage0_crate_manifest(spec: Rc) -> Rc { v1_rt::concat( v1_rt::concat( v1_rt::concat( - render_cargo_package_header_prefix(spec.package_name.clone()), - "\nedition = \"2021\"".to_string(), + v1_rt::concat( + "[package]\nname = \"".to_string(), + spec.package_name.clone(), + ), + "\"\nversion = \"0.1.0\"\nedition = \"2021\"".to_string(), ), render_stage0_crate_features_section(spec.features.clone()), ), @@ -184,7 +184,7 @@ pub fn emit_stage0_crate_manifest(spec: Rc) -> Rc { } } -pub fn render_stage0_core_lib(spec: Rc) -> Rc> { +pub fn render_stage0_core_lib(spec: Rc) -> String { { let includes = Rc::new({ let mut __result = Vec::new(); @@ -227,7 +227,7 @@ pub fn render_stage0_core_lib(spec: Rc) -> Rc> } } -pub fn render_stage0_emit_core_lib(spec: Rc) -> Rc> { +pub fn render_stage0_emit_core_lib(spec: Rc) -> String { { let reexports = Rc::new({ let mut __result = Vec::new(); @@ -401,6 +401,3 @@ pub fn emit_stage0_crate_boundary_files(plan: Rc) -> Rc Rc>> { emit_stage0_crate_boundary_files(stage0_crate_plan()) } - -pub struct CoreCrate; -pub struct EmitCoreCrate; diff --git a/src/v1/stage0/src/v1_compiler_tokenize.rs b/src/v1/stage0/src/v1_compiler_tokenize.rs index 9bbb2f59fba..3ffce56192f 100644 --- a/src/v1/stage0/src/v1_compiler_tokenize.rs +++ b/src/v1/stage0/src/v1_compiler_tokenize.rs @@ -22,7 +22,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn is_keyword_text(text: Rc>) -> bool { +pub fn is_keyword_text(text: String) -> bool { match v1_rt::lookup(&dag_keyword_set(), text) { v1_rt::Witness::Holds { value: _, .. } => true, v1_rt::Witness::Violates { diagnostic: _, .. } => false, @@ -33,18 +33,18 @@ pub fn single_punct() -> Rc> { thread_local! { static CACHED: Rc> = { let mut __m = HashMap::new(); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("("), TokenShape::ShLParen); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host(")"), TokenShape::ShRParen); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("["), TokenShape::ShLBracket); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("]"), TokenShape::ShRBracket); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host(":"), TokenShape::ShColon); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host(","), TokenShape::ShComma); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("."), TokenShape::ShDot); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("+"), TokenShape::ShPlus); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("*"), TokenShape::ShStar); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("%"), TokenShape::ShPercent); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("/"), TokenShape::ShSlash); - __m.insert(crate::v2_std_text::host_string_text_from_rust_host("^"), TokenShape::ShCaret); + __m.insert("(".to_string(), TokenShape::ShLParen); + __m.insert(")".to_string(), TokenShape::ShRParen); + __m.insert("[".to_string(), TokenShape::ShLBracket); + __m.insert("]".to_string(), TokenShape::ShRBracket); + __m.insert(":".to_string(), TokenShape::ShColon); + __m.insert(",".to_string(), TokenShape::ShComma); + __m.insert(".".to_string(), TokenShape::ShDot); + __m.insert("+".to_string(), TokenShape::ShPlus); + __m.insert("*".to_string(), TokenShape::ShStar); + __m.insert("%".to_string(), TokenShape::ShPercent); + __m.insert("/".to_string(), TokenShape::ShSlash); + __m.insert("^".to_string(), TokenShape::ShCaret); Rc::new(__m) }; } @@ -73,12 +73,12 @@ pub struct ScanResult { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SourceRef { - pub file: Rc>, - pub text: Rc>, + pub file: String, + pub text: String, pub source_chars: Rc>, } -pub fn make_token(text: Rc>, span: Rc, shape: TokenShape) -> Rc { +pub fn make_token(text: String, span: Rc, shape: TokenShape) -> Rc { Rc::new(Token { text: text, span: span, @@ -86,7 +86,7 @@ pub fn make_token(text: Rc>, span: Rc, shape: TokenS }) } -pub fn source_char(source: Rc, pos: i64) -> Rc> { +pub fn source_char(source: Rc, pos: i64) -> String { v1_rt::from_code_point(source.source_chars.clone()[(pos) as usize].clone()) } @@ -101,7 +101,7 @@ pub fn source_len(source: Rc) -> i64 { (source.source_chars.clone().len() as i64) } -pub fn source_substring(source: Rc, start: i64, end: i64) -> Rc> { +pub fn source_substring(source: Rc, start: i64, end: i64) -> String { v1_rt::chars_to_string(&source.source_chars.clone(), start, end) } @@ -164,7 +164,7 @@ pub fn source_scan_to_eol(mut source: Rc, mut start: i64) -> i64 { } } -pub fn tokenize(source: Rc>, file: Rc>) -> Rc>> { +pub fn tokenize(source: String, file: String) -> Rc>> { { let c = Rc::new(source.clone().chars().map(|c| c as i64).collect::>()); let src = Rc::new(SourceRef { @@ -509,9 +509,9 @@ pub fn scan_token(source: Rc, pos: Rc, ch: i64) -> Rc, shape: TokenShape, - text: Rc>, + text: String, len: i64, - file: Rc>, + file: String, ) -> Rc { { let token = make_token( @@ -593,21 +593,12 @@ pub fn scan_number(source: Rc, pos: Rc) -> Rc { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum StringScanResult { - ClosedString { - content: Rc>, - end_pos: i64, - }, - InterpolationStart { - content: Rc>, - end_pos: i64, - }, - UnterminatedString { - content: Rc>, - end_pos: i64, - }, + ClosedString { content: String, end_pos: i64 }, + InterpolationStart { content: String, end_pos: i64 }, + UnterminatedString { content: String, end_pos: i64 }, } impl StringScanResult { - pub fn content(&self) -> Rc> { + pub fn content(&self) -> String { match self { StringScanResult::ClosedString { content: __val, .. } => __val.clone(), StringScanResult::InterpolationStart { content: __val, .. } => __val.clone(), @@ -744,17 +735,13 @@ pub fn scan_string_body( }); } else { let ch = source_char(source.clone(), pos.clone()); - if (crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("\"".to_string())) - { + if (ch.clone().as_str() == "\"".to_string().as_str()) { break Rc::new(StringScanResult::ClosedString { content: acc.join(&"".to_string()), end_pos: pos.clone(), }); } else { - if (crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("\\".to_string())) - { + if (ch.clone().as_str() == "\\".to_string().as_str()) { if ((pos.clone() + 1) < source_len(source.clone())) { let escaped = source_char(source.clone(), (pos.clone() + 1)); { @@ -775,9 +762,7 @@ pub fn scan_string_body( }); } } else { - if (crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("{".to_string())) - { + if (ch.clone().as_str() == "{".to_string().as_str()) { if should_start_interpolation(source.clone(), pos.clone()) { break Rc::new(StringScanResult::InterpolationStart { content: acc.join(&"".to_string()), @@ -819,59 +804,36 @@ pub fn should_start_interpolation(source: Rc, pos: i64) -> bool { } } -pub fn process_escapes(raw: Rc>) -> Rc> { +pub fn process_escapes(raw: String) -> String { process_escapes_loop(raw, 0, Rc::new(vec![])) } -pub fn process_escapes_loop( - mut source: Rc>, - mut pos: i64, - mut acc: Rc>, -) -> Rc> { +pub fn process_escapes_loop(mut source: String, mut pos: i64, mut acc: Rc>) -> String { loop { if (pos.clone() >= v1_rt::string_length(&source)) { break acc.join(&"".to_string()); } else { let ch = v1_rt::char_at(&source, pos.clone()); - if ((crate::v2_std_text::host_string_text_to_rust_host(ch.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("\\".to_string())) + if ((ch.clone().as_str() == "\\".to_string().as_str()) && ((pos.clone() + 1) < v1_rt::string_length(&source))) { let next = v1_rt::char_at(&source, (pos.clone() + 1)); - let resolved = if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("\"".to_string())) - { + let resolved = if (next.clone().as_str() == "\"".to_string().as_str()) { "\"".to_string() } else { - if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("\\".to_string())) - { + if (next.clone().as_str() == "\\".to_string().as_str()) { "\\".to_string() } else { - if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) - == crate::v2_std_text::host_string_text_to_rust_host("n".to_string())) - { + if (next.clone().as_str() == "n".to_string().as_str()) { "\n".to_string() } else { - if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "t".to_string(), - )) - { + if (next.clone().as_str() == "t".to_string().as_str()) { "\t".to_string() } else { - if (crate::v2_std_text::host_string_text_to_rust_host(next.clone()) - == crate::v2_std_text::host_string_text_to_rust_host( - "{".to_string(), - )) - { + if (next.clone().as_str() == "{".to_string().as_str()) { "{".to_string() } else { - if (crate::v2_std_text::host_string_text_to_rust_host( - next.clone(), - ) == crate::v2_std_text::host_string_text_to_rust_host( - "}".to_string(), - )) { + if (next.clone().as_str() == "}".to_string().as_str()) { "}".to_string() } else { v1_rt::concat("\\".to_string(), next.clone()) diff --git a/src/v1/stage0/src/v1_compiler_trace.rs b/src/v1/stage0/src/v1_compiler_trace.rs index 05c7fc54cec..d1063b6e923 100644 --- a/src/v1/stage0/src/v1_compiler_trace.rs +++ b/src/v1/stage0/src/v1_compiler_trace.rs @@ -23,23 +23,23 @@ pub struct SpanMapping { #[serde(tag = "_variant")] pub enum TraceEvent { TraceEnter { - node_id: Rc>, + node_id: String, span: Rc, inputs: Rc>, }, TraceExit { - node_id: Rc>, + node_id: String, span: Rc, - output: Rc>, + output: String, }, TraceError { - node_id: Rc>, + node_id: String, span: Rc, - message: Rc>, + message: String, }, } impl TraceEvent { - pub fn node_id(&self) -> Rc> { + pub fn node_id(&self) -> String { match self { TraceEvent::TraceEnter { node_id: __val, .. } => __val.clone(), TraceEvent::TraceExit { node_id: __val, .. } => __val.clone(), @@ -57,7 +57,7 @@ impl TraceEvent { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct TraceFrame { - pub func_name: Rc>, + pub func_name: String, pub span: Rc, pub bindings: Rc>, } @@ -122,7 +122,7 @@ pub fn event_span(event: Rc) -> Rc { } } -pub fn event_node_id(event: Rc) -> Rc> { +pub fn event_node_id(event: Rc) -> String { match (*event).clone() { TraceEvent::TraceEnter { node_id: id, .. } => id.clone(), TraceEvent::TraceExit { node_id: id, .. } => id.clone(), @@ -133,7 +133,7 @@ pub fn event_node_id(event: Rc) -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum TraceFilter { - FilterByFunc { func_name: Rc> }, + FilterByFunc { func_name: String }, FilterBySpan { start: i64, end: i64 }, FilterErrors, } @@ -152,9 +152,7 @@ pub fn replay_trace(trace: Rc, filter: Rc) -> Rc Rc::new({ let mut __result = Vec::new(); for e in trace.events.clone().iter().cloned() { - if (crate::v2_std_text::host_string_text_to_rust_host(event_node_id(e.clone())) - == crate::v2_std_text::host_string_text_to_rust_host(name.clone())) - { + if (event_node_id(e.clone()).as_str() == name.clone().as_str()) { __result.push(e); } } @@ -186,25 +184,20 @@ pub fn replay_trace(trace: Rc, filter: Rc) -> Rc) -> Rc> { +pub fn format_span(sp: Rc) -> String { v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - "[".to_string(), - crate::v2_std_text::host_string_text_from_rust_host( - (sp.start.clone()).to_string(), - ), - ), + v1_rt::concat("[".to_string(), (sp.start.clone()).to_string()), "..".to_string(), ), - crate::v2_std_text::host_string_text_from_rust_host((sp.end.clone()).to_string()), + (sp.end.clone()).to_string(), ), ")".to_string(), ) } -pub fn format_trace_event(event: Rc) -> Rc> { +pub fn format_trace_event(event: Rc) -> String { match (*event).clone() { TraceEvent::TraceEnter { node_id: id, @@ -268,14 +261,14 @@ pub fn format_trace(trace: Rc) -> Rc> { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct ReproCase { - pub func_name: Rc>, + pub func_name: String, pub inputs: Rc>, - pub expected_output: Rc>, + pub expected_output: Option, pub trace: Option>, } pub fn capture_repro( - func_name: Rc>, + func_name: String, inputs: Rc>, trace: Rc, ) -> Rc { @@ -289,7 +282,7 @@ pub fn capture_repro( #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct SourceMap { - pub generated_file: Rc>, + pub generated_file: String, pub mappings: Rc>>, } diff --git a/src/v1/stage0/src/v1_compiler_workspace_members.rs b/src/v1/stage0/src/v1_compiler_workspace_members.rs index 8e5f763ce3c..58d96300af0 100644 --- a/src/v1/stage0/src/v1_compiler_workspace_members.rs +++ b/src/v1/stage0/src/v1_compiler_workspace_members.rs @@ -12,22 +12,22 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; -pub fn workspace_members_region_begin_marker() -> Rc> { +pub fn workspace_members_region_begin_marker() -> String { " # BEGIN generated stage0 crate members -- regen_stage0 writes this region (authority: v1.compiler.workspace_members)".to_string() } -pub fn workspace_members_region_end_marker() -> Rc> { +pub fn workspace_members_region_end_marker() -> String { " # END generated stage0 crate members".to_string() } -pub fn stage0_member_entry(spec: Rc) -> Rc> { +pub fn stage0_member_entry(spec: Rc) -> String { v1_rt::concat( v1_rt::concat(" \"".to_string(), spec.crate_dir.clone()), "\",".to_string(), ) } -pub fn stage0_workspace_member_region() -> Rc> { +pub fn stage0_workspace_member_region() -> String { Rc::new( stage0_crate_plan() .crates diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 8462a365c03..7858d655b57 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -152,6 +152,11 @@ pub fn to_string(value: i64) -> String { value.to_string() } +/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8. +pub fn utf8_decode_bytes(bytes: &[u8]) -> Result { + String::from_utf8(bytes.to_vec()).map_err(|e| format!("invalid UTF-8 in access payload: {e}")) +} + pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 { val.clamp(min_val, max_val) } From 3b62e68203f6fd781228d8fb536ec8a3aa0def22 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Sat, 20 Jun 2026 15:46:44 +0000 Subject: [PATCH 15/15] Stage0 #5325: de-enroll Stage0LockstepGate until seed-green (keep B/C injection) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Stage0LockstepGate ran regen_stage0 --verify in the CI floor and correctly FAILED: the committed seed is main-green but not yet a regen fixpoint (pending the A-lane carrier-completeness work). Per the thin-co-land plan, the gate must enroll LAST, atomically with the green regenerated seed — enrolling it now reds CI on every push during the emitter grind. De-enroll for now (revert ci_spec/ci_gates/floor_effect_gate_witness/ci_floor_plan to main, remove the two gate .dag files — preserved in history at 62413385fc and re-landed compile-verified at co-land). Keep the B/C regen_stage0.rs languages_consumer_census lib.rs mod-decl injection (harmless: affects regen output only, not the committed seed or the build). #5325 now: main + regen tooling injection. CI green. The enforcing gate + green seed co-land at the end once the A-lane drives a fresh regen to build green and regen --verify byte-identical. Co-Authored-By: Claude Opus 4.8 --- dsl/gunbc/ci_spec.dag | 4 +- dsl/tools/ci_gates.dag | 7 +- dsl/tools/floor_effect_gate_witness.dag | 7 +- dsl/tools/stage0_lockstep_gate.dag | 55 --------- dsl/tools/stage0_lockstep_transport.dag | 155 ------------------------ src/v2/workflow/ci_floor_plan.dag | 4 +- 6 files changed, 5 insertions(+), 227 deletions(-) delete mode 100644 dsl/tools/stage0_lockstep_gate.dag delete mode 100644 dsl/tools/stage0_lockstep_transport.dag diff --git a/dsl/gunbc/ci_spec.dag b/dsl/gunbc/ci_spec.dag index 348412331aa..4c161b5e567 100644 --- a/dsl/gunbc/ci_spec.dag +++ b/dsl/gunbc/ci_spec.dag @@ -15,7 +15,6 @@ type Gate | DslCompileCleanGate | CiYamlGate | SourceRootIngestGate - | Stage0LockstepGate type DiffMode = DiffMergeBase | DiffTwoDot @@ -41,8 +40,7 @@ data gunbc_ci_gates: List = [ ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, - SourceRootIngestGate, - Stage0LockstepGate + SourceRootIngestGate ] data gunbc_ci_spec: CiSpec = { diff --git a/dsl/tools/ci_gates.dag b/dsl/tools/ci_gates.dag index 7831d86781c..c6059b85769 100644 --- a/dsl/tools/ci_gates.dag +++ b/dsl/tools/ci_gates.dag @@ -14,7 +14,7 @@ import std.process { ProcessExit, ExitSuccess, exit_failure } import gunbc.ci_spec { gunbc_ci_spec, CiSpec, Gate, RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, - SourceRootIngestGate, Stage0LockstepGate + SourceRootIngestGate } import tools.rust_gates_ci { run_rust_monolith_gate } import tools.emit_host_gate { run_emit_host_ci_gate } @@ -22,7 +22,6 @@ import tools.layering_imports_gate { run_layering_imports_ci_gate } import tools.resolved_imports_gate { run_resolved_imports_ci_gate } import tools.dsl_compile_clean_gate { run_dsl_compile_clean_gate } import tools.ci_yaml_gate { run_ci_yaml_gate } -import tools.stage0_lockstep_gate { run_stage0_lockstep_gate } fn exit_ok(e: ProcessExit) -> Bool { match e { ExitSuccess => true _ => false } @@ -39,7 +38,6 @@ fn run_spec_gate(g: Gate) -> ProcessExit { SourceRootIngestGate => exit_failure( reason: "SourceRootIngestGate: run via ci_floor_plan v2.workflow.source_root_ingest_gate (slice 3)" ) - Stage0LockstepGate => run_stage0_lockstep_gate() } } @@ -51,8 +49,7 @@ func run_ci_gates_sequential(spec: CiSpec) -> ProcessExit { let g3 = if exit_ok(g2) { run_spec_gate(g: ResolvedImportsGate) } else { g2 } let g4 = if exit_ok(g3) { run_spec_gate(g: DslCompileCleanGate) } else { g3 } let g5 = if exit_ok(g4) { run_spec_gate(g: CiYamlGate) } else { g4 } - let g6 = if exit_ok(g5) { run_spec_gate(g: SourceRootIngestGate) } else { g5 } - if exit_ok(g6) { run_spec_gate(g: Stage0LockstepGate) } else { g6 } + if exit_ok(g5) { run_spec_gate(g: SourceRootIngestGate) } else { g5 } } func main() -> ProcessExit { diff --git a/dsl/tools/floor_effect_gate_witness.dag b/dsl/tools/floor_effect_gate_witness.dag index b3a86b67ca6..f2ae81efd74 100644 --- a/dsl/tools/floor_effect_gate_witness.dag +++ b/dsl/tools/floor_effect_gate_witness.dag @@ -11,8 +11,7 @@ module tools.floor_effect_gate_witness import gunbc.ci_spec { - RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, - Stage0LockstepGate + RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate } import tools.ci_gates { exit_ok, run_spec_gate } @@ -39,7 +38,3 @@ func dsl_compile_clean_gate_passes() -> Bool { func ci_yaml_gate_passes() -> Bool { exit_ok(e: run_spec_gate(g: CiYamlGate)) } - -func stage0_lockstep_gate_passes() -> Bool { - exit_ok(e: run_spec_gate(g: Stage0LockstepGate)) -} diff --git a/dsl/tools/stage0_lockstep_gate.dag b/dsl/tools/stage0_lockstep_gate.dag deleted file mode 100644 index ffea2ef6c86..00000000000 --- a/dsl/tools/stage0_lockstep_gate.dag +++ /dev/null @@ -1,55 +0,0 @@ -// tools/stage0_lockstep_gate.dag — stage0 regen-lockstep gate, run by the CI floor. -// -// Closes the §6 hole: nothing in CI gated on the stage0 seed being a clean -// function of the `.dag`, so the seed silently drifted. This gate runs -// `regen_stage0 --verify` (the lockstep oracle) over the live tree (GREEN) plus -// a planted-drift RED receipt (the +/- teeth), mirroring tools.dsl_compile_clean_gate. -// -// Catches drift the existing floor MISSES — two observed data points: (1) a -// hand-patched seed fn with no `.dag` source (the policy accessors that lived -// seed-only) regen-drops on a fresh self-compile, which `regen_stage0 --verify` -// flags but a typecheck of the committed seed does not; (2) a parse error in the -// emitter `.dag` that surfaces ONLY in regen's self-compile of the v1 tree — a PR -// whose `DslCompileCleanGate` was GREEN still failed `regen_stage0 --verify` (a -// parser-strictness divergence / compile-clean blind spot). Both are seed↔.dag -// lockstep failures the regen oracle detects and the rest of the floor does not. -// -// Run standalone: -// cargo run -p v1-compiler --release --bin gunbc -- run \ -// --source-root dsl --entry dsl/tools/stage0_lockstep_gate.dag --function main -// -// §2 DEDUP MARKER (dissolution trigger — prompt follow-up, not someday): this gate's -// `regen_stage0 --verify` self-compiles the .dag tree, and DslCompileCleanGate ALSO -// self-compiles the whole tree in the same floor run — TWO full self-compiles per CI -// pass (real §1-time redundancy). Dissolve by having the lockstep verify REUSE the -// DslCompileCleanGate whole-tree compile artifact (content-addressed) rather than -// recompiling. Landed as always-run (option A) now; this is the named optimization to -// reclaim the second compile once the artifact-reuse seam exists. - -module tools.stage0_lockstep_gate - -import std.process { ProcessExit, ExitSuccess, exit_failure } -import tools.stage0_lockstep_transport { - run_stage0_lockstep_verify, - run_stage0_lockstep_perturb_red_receipt -} - -func run_stage0_lockstep_gate_body() -> ProcessExit { - let clean = run_stage0_lockstep_verify() - let perturb = run_stage0_lockstep_perturb_red_receipt() - return if clean && perturb { - ExitSuccess - } else { - exit_failure( - reason: "stage0 regen-lockstep gate failed: regen_stage0 --verify and/or planted-drift red receipt" - ) - } -} - -func run_stage0_lockstep_gate() -> ProcessExit { - run_stage0_lockstep_gate_body() -} - -func main() -> ProcessExit { - run_stage0_lockstep_gate_body() -} diff --git a/dsl/tools/stage0_lockstep_transport.dag b/dsl/tools/stage0_lockstep_transport.dag deleted file mode 100644 index 9bd9c364416..00000000000 --- a/dsl/tools/stage0_lockstep_transport.dag +++ /dev/null @@ -1,155 +0,0 @@ -// tools/stage0_lockstep_transport.dag — shell transport for the stage0 regen-lockstep gate. -// -// The §6 enforcement the CI floor was MISSING: the committed v1 stage0 seed -// (`src/v1/stage0/src/*.rs`) must be a clean function of the `.dag` authorities. -// `regen_stage0 --verify` is the lockstep oracle — it self-compiles the `.dag` -// tree, then byte-compares every GENERATED_STAGE0_FILES entry, the split-crate -// boundary files, and the workspace-members region against the committed seed, -// failing (exit 1) on any drift. -// -// GREEN: `regen_stage0 --verify` over the live tree exits 0. -// RED receipt: clobber one committed generated seed file, run `--verify` -// (MUST fail), restore via `git checkout`. The +/- teeth: a drifted seed -// is caught. (Proven by execution at authoring time; this encodes it for CI.) -// -// Both transports are structured `ShellProgram`s rendered by `serialize_bash` -// (extdeps.languages.bash.program), mirroring tools.dsl_compile_clean_transport. -// The RED receipt overwrites a tracked file then restores it with `git checkout` -// (verify must read the on-disk committed seed, so — unlike the compile-clean -// perturb — it cannot stay in a TMP dir); the CI checkout is ephemeral. - -module tools.stage0_lockstep_transport - -import extdeps.shell -import extdeps.languages.bash.program { - ShellProgram, ShellStmt, ShellWord, - Command, Assign, If, Subshell, AndOr, WithRedir, Heredoc, Exit, - Lit, VarRef, Concat, CmdSubst, - AndThen, OrElse, StderrToNull, StdoutAndStderrToNull, - lit, var_ref, command, assign, serialize_bash -} - -// ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) -// REGEN="$ROOT"/target/release/regen_stage0 -// if [ ! -x "$REGEN" ]; then (cd "$ROOT" && cargo build -p v1-compiler --release --bin regen_stage0) || exit 1; fi -fn ensure_regen_stage0_built() -> List { - let root = var_ref(name: "ROOT") - let regen = var_ref(name: "REGEN") - [ - assign(name: "ROOT", value: CmdSubst { body: AndOr { - left: WithRedir { - stmt: command(words: [lit(text: "git"), lit(text: "rev-parse"), lit(text: "--show-toplevel")]), - redir: StderrToNull - }, - op: OrElse, - right: command(words: [lit(text: "pwd")]) - } }), - assign(name: "REGEN", value: Concat { parts: [root, lit(text: "/target/release/regen_stage0")] }), - If { - cond: command(words: [lit(text: "["), lit(text: "!"), lit(text: "-x"), regen, lit(text: "]")]), - then: [ - AndOr { - left: Subshell { body: [ - AndOr { - left: command(words: [lit(text: "cd"), root]), - op: AndThen, - right: command(words: [ - lit(text: "cargo"), lit(text: "build"), lit(text: "-p"), lit(text: "v1-compiler"), - lit(text: "--release"), lit(text: "--bin"), lit(text: "regen_stage0") - ]) - } - ] }, - op: OrElse, - right: Exit { code: 1 } - } - ] - } - ] -} - -// GREEN: ; "$REGEN" --verify -fn stage0_lockstep_verify_program() -> ShellProgram { - let regen = var_ref(name: "REGEN") - ShellProgram { - set_e: true, - statements: concat(ensure_regen_stage0_built(), [ - command(words: [regen, lit(text: "--verify")]) - ]) - } -} - -fn run_stage0_lockstep_verify() -> Bool { - let result = shell.Exec.Run(script: serialize_bash(p: stage0_lockstep_verify_program())) - result.success -} - -// The committed generated seed file the RED receipt clobbers. Any GENERATED -// entry works; std_node is a small, stable generated module. -data perturb_seed_relpath: String = "src/v1/stage0/src/std_node.rs" - -// Drift sentinel written over the seed file — content that a fresh self-compile -// will never reproduce, so `--verify` must report the byte mismatch. -data perturb_seed_drift_body: String = "// __stage0_lockstep_perturb_red__ planted drift sentinel — not a fixpoint of the .dag" - -// RED receipt: clobber one committed generated seed file, run `--verify` (MUST -// fail), restore via `git checkout` on both branches. If `--verify` SUCCEEDS on -// the drifted seed the gate is toothless → exit 1. -// -// CRASH-SAFETY: this mutates a TRACKED seed file in place (verify must read the -// on-disk committed seed, so — unlike the compile-clean perturb — it cannot stay -// in a TMP dir). Two guards: (1) the floor gate is CI-EPHEMERAL — it runs in a -// fresh per-run checkout, so a crash cannot corrupt a persistent tree; (2) a -// fail-closed PRE-CHECK refuses to run if the seed is already dirty (`git diff -// --quiet`), so it never clobbers a dev's uncommitted seed and surfaces a prior -// crash's residue instead of compounding it. The bash program model has no -// `trap`, and `RawLine` is the banned transport-position escape hatch, so the -// pre-check + ephemeral-checkout posture is the model-expressible safety net. -// set -e; -// git -C "$ROOT" diff --quiet -- || exit 1 # refuse to clobber a dirty seed -// cat > "$ROOT"/ <<'PERTURB' ... PERTURB -// if "$REGEN" --verify >/dev/null 2>&1; then git -C "$ROOT" checkout -- ; exit 1; fi -// git -C "$ROOT" checkout -- ; exit 0 -fn stage0_lockstep_perturb_program() -> ShellProgram { - let root = var_ref(name: "ROOT") - let regen = var_ref(name: "REGEN") - let seed_abs = Concat { parts: [root, lit(text: "/"), lit(text: perturb_seed_relpath)] } - let restore = command(words: [ - lit(text: "git"), lit(text: "-C"), root, lit(text: "checkout"), - lit(text: "--"), lit(text: perturb_seed_relpath) - ]) - ShellProgram { - set_e: true, - statements: concat(ensure_regen_stage0_built(), [ - AndOr { - left: command(words: [ - lit(text: "git"), lit(text: "-C"), root, lit(text: "diff"), lit(text: "--quiet"), - lit(text: "--"), lit(text: perturb_seed_relpath) - ]), - op: OrElse, - right: Exit { code: 1 } - }, - Heredoc { - path: seed_abs, - delimiter: "PERTURB", - body: perturb_seed_drift_body - }, - If { - cond: WithRedir { - stmt: command(words: [regen, lit(text: "--verify")]), - redir: StdoutAndStderrToNull - }, - then: [ - restore, - Exit { code: 1 } - ] - }, - restore, - Exit { code: 0 } - ]) - } -} - -fn run_stage0_lockstep_perturb_red_receipt() -> Bool { - let result = shell.Exec.Run(script: serialize_bash(p: stage0_lockstep_perturb_program())) - result.success -} diff --git a/src/v2/workflow/ci_floor_plan.dag b/src/v2/workflow/ci_floor_plan.dag index bf8e9d9dd69..c9d9924ee85 100644 --- a/src/v2/workflow/ci_floor_plan.dag +++ b/src/v2/workflow/ci_floor_plan.dag @@ -30,7 +30,7 @@ import gunbc.ci_layer_roots { witness_layer_roots, witness_discovery_scan_dirs } import gunbc.ci_spec { gunbc_ci_spec, CiSpec, Gate, RustMonolithGate, EmitHostGate, LayeringImportsGate, ResolvedImportsGate, DslCompileCleanGate, CiYamlGate, - SourceRootIngestGate, Stage0LockstepGate + SourceRootIngestGate } import v2.std.algebra { length, list_snoc_item } import v2.std.collection { List } @@ -83,7 +83,6 @@ fn gate_node(g: Gate) -> Node { DslCompileCleanGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_compile } }, children: [] } CiYamlGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_ciyaml } }, children: [] } SourceRootIngestGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_sourceingest } }, children: [] } - Stage0LockstepGate => Node { kind: TypeNode { connective: Atom { identity: ^gunbc_floor_gate_stage0_lockstep } }, children: [] } } } @@ -101,7 +100,6 @@ fn gate_runnable(g: Gate) -> Runnable { entry: floor_source_root_ingest_gate_entry, function: "source_root_ingest_gate_passes" } - Stage0LockstepGate => RunnableSingleClaim { entry: floor_gate_witness_entry, function: "stage0_lockstep_gate_passes" } } }