diff --git a/crates/lang/src/tipo.rs b/crates/lang/src/tipo.rs index f450c399..ec09c20a 100644 --- a/crates/lang/src/tipo.rs +++ b/crates/lang/src/tipo.rs @@ -446,7 +446,7 @@ impl TypeVar { } pub fn get_uplc_type(&self) -> Option { - match dbg!(self) { + match self { Self::Link { tipo } => Some(tipo.get_uplc_type()), _ => None, } diff --git a/crates/lang/src/uplc.rs b/crates/lang/src/uplc.rs index 30d69653..130208ce 100644 --- a/crates/lang/src/uplc.rs +++ b/crates/lang/src/uplc.rs @@ -102,12 +102,8 @@ impl<'a> CodeGenerator<'a> { self.build_ir(&body, &mut ir_stack, scope); - print!("{ir_stack:#?}"); - self.define_ir(&mut ir_stack); - print!("{ir_stack:#?}"); - let mut term = self.uplc_code_gen(&mut ir_stack); if self.needs_field_access { @@ -134,8 +130,6 @@ impl<'a> CodeGenerator<'a> { term, }; - println!("{}", program.to_pretty()); - let mut interner = Interner::new(); interner.program(&mut program); @@ -1447,8 +1441,6 @@ impl<'a> CodeGenerator<'a> { } fn gen_uplc(&mut self, ir: Air, arg_stack: &mut Vec>) { - // println!("IR IS {ir:#?} AND ARG STACK IS {arg_stack:#?}"); - match ir { Air::Int { value, .. } => { let integer = value.parse().unwrap(); @@ -3809,11 +3801,85 @@ impl<'a> CodeGenerator<'a> { }; } } - Air::ListClause { .. } => todo!(), - Air::ClauseGuard { .. } => todo!(), - Air::RecordAccess { .. } => todo!(), - Air::FieldsExpose { .. } => todo!(), - Air::Tuple { .. } => todo!(), + Air::ListClause { + scope, + tipo, + tail_name, + complex_clause, + next_tail_name, + } => { + if tipo.is_generic() { + let mut tipo = tipo.clone(); + find_generics_to_replace(&mut tipo, &generic_types); + + new_air[index] = Air::ListClause { + scope, + tipo, + tail_name, + complex_clause, + next_tail_name, + }; + } + } + Air::ClauseGuard { + tipo, + scope, + subject_name, + } => { + if tipo.is_generic() { + let mut tipo = tipo.clone(); + find_generics_to_replace(&mut tipo, &generic_types); + + new_air[index] = Air::ClauseGuard { + scope, + subject_name, + tipo, + }; + } + } + Air::RecordAccess { + scope, + index: record_index, + tipo, + } => { + if tipo.is_generic() { + let mut tipo = tipo.clone(); + find_generics_to_replace(&mut tipo, &generic_types); + + new_air[index] = Air::RecordAccess { + scope, + index: record_index, + tipo, + }; + } + } + Air::FieldsExpose { + scope, + count, + indices, + } => { + let mut new_indices = vec![]; + for (ind, name, tipo) in indices { + if tipo.is_generic() { + let mut tipo = tipo.clone(); + find_generics_to_replace(&mut tipo, &generic_types); + } + new_indices.push((ind, name, tipo)); + } + new_air[index] = Air::FieldsExpose { + scope, + count, + indices: new_indices, + }; + } + Air::Tuple { scope, tipo, count } => { + if tipo.is_generic() { + let mut tipo = tipo.clone(); + find_generics_to_replace(&mut tipo, &generic_types); + + new_air[index] = Air::Tuple { scope, count, tipo }; + } + } Air::Todo { .. } => todo!(), Air::RecordUpdate { .. } => todo!(), Air::TupleAccessor { .. } => todo!(), diff --git a/examples/tests/b/lib/main.ak b/examples/tests/b/lib/main.ak index 4e80e58e..1b70e682 100644 --- a/examples/tests/b/lib/main.ak +++ b/examples/tests/b/lib/main.ak @@ -7,5 +7,5 @@ pub fn repeat(x: a, n: Int) -> List(a) { } test repeat_1() { - repeat("aiken", 1) == ["aiken"] + repeat("aiken", 2) == ["aiken", "aiken"] }