From 6f0a0f5927f748b0e80ee988a18cbc392103df0d Mon Sep 17 00:00:00 2001 From: Michael Sippel <micha@fragmental.art> Date: Sat, 10 May 2025 16:28:58 +0200 Subject: [PATCH] when generating #defines for values of type variables, distinguish between variables of type 'Type' and others --- src/c_gen/morph/target_morph.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/c_gen/morph/target_morph.rs b/src/c_gen/morph/target_morph.rs index 161d6fa..2eb25b0 100644 --- a/src/c_gen/morph/target_morph.rs +++ b/src/c_gen/morph/target_morph.rs @@ -171,23 +171,21 @@ impl LdmcCTargetMorph { let mut c_source = String::new(); for (ty_id, kind) in morph.type_args.iter() { if let laddertypes::TypeID::Var(var_id) = ty_id { - //if morph_inst.get_type().strip_halo().src_type.contains_var(*var_id) || - //morph_inst.get_type().strip_halo().dst_type.contains_var(*var_id) { - if let Some(val) = σ.get(ty_id) { - let type_var_value = get_c_repr_type(dict, val); - c_source.push_str(&format!(" #define {} {}\n", dict.get_typename(&ty_id).unwrap(), type_var_value)); - } - //} + if let Some(val) = σ.get(ty_id) { + let type_var_value = + if kind == "Type" { + get_c_repr_type(dict, val) + } else { + encode_type_to_value(dict, val) + }; + c_source.push_str(&format!(" #define {} {}\n", dict.get_typename(&ty_id).unwrap(), type_var_value)); + } } } c_source.push_str(&morph.c_source); for (ty_id, kind) in morph.type_args.iter() { if let laddertypes::TypeID::Var(var_id) = ty_id { - //if morph_inst.get_type().strip_halo().src_type.contains_var(*var_id) || - //morph_inst.get_type().strip_halo().dst_type.contains_var(*var_id) { - - c_source.push_str(&format!("\n #undef {}", dict.get_typename(&ty_id).unwrap())); - //} + c_source.push_str(&format!("\n #undef {}", dict.get_typename(&ty_id).unwrap())); } }