feat: test 24 passes
fixed issue with is_tuple in types minor monomorphize change
This commit is contained in:
parent
17603e8cca
commit
9177267570
|
@ -825,6 +825,7 @@ pub fn get_generics_and_type(tipo: &Type, param: &Type) -> Vec<(u64, Arc<Type>)>
|
||||||
|
|
||||||
if let Some(id) = tipo.get_generic() {
|
if let Some(id) = tipo.get_generic() {
|
||||||
generics_ids.push((id, param.clone().into()));
|
generics_ids.push((id, param.clone().into()));
|
||||||
|
return generics_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tipo, param_type) in tipo
|
for (tipo, param_type) in tipo
|
||||||
|
|
|
@ -162,7 +162,11 @@ impl Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_tuple(&self) -> bool {
|
pub fn is_tuple(&self) -> bool {
|
||||||
matches!(self, Self::Tuple { .. })
|
match self {
|
||||||
|
Type::Var { tipo } => tipo.borrow().is_tuple(),
|
||||||
|
Type::Tuple { .. } => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_generic(&self) -> bool {
|
pub fn is_generic(&self) -> bool {
|
||||||
|
@ -218,6 +222,7 @@ impl Type {
|
||||||
} else if self.is_tuple() {
|
} else if self.is_tuple() {
|
||||||
match self {
|
match self {
|
||||||
Self::Tuple { elems } => elems.to_vec(),
|
Self::Tuple { elems } => elems.to_vec(),
|
||||||
|
Self::Var { tipo } => tipo.borrow().get_inner_type(),
|
||||||
_ => vec![],
|
_ => vec![],
|
||||||
}
|
}
|
||||||
} else if matches!(self.get_uplc_type(), UplcType::Data) {
|
} else if matches!(self.get_uplc_type(), UplcType::Data) {
|
||||||
|
@ -258,6 +263,7 @@ impl Type {
|
||||||
UplcType::List(UplcType::Data.into())
|
UplcType::List(UplcType::Data.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Self::Var { tipo } => tipo.borrow().get_uplc_type().unwrap(),
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -450,6 +456,13 @@ impl TypeVar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_tuple(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
Self::Link { tipo } => tipo.is_tuple(),
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_generic(&self) -> bool {
|
pub fn is_generic(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
TypeVar::Generic { .. } => true,
|
TypeVar::Generic { .. } => true,
|
||||||
|
|
|
@ -1598,17 +1598,18 @@ impl<'a> CodeGenerator<'a> {
|
||||||
ir_stack: &mut [Air],
|
ir_stack: &mut [Air],
|
||||||
func_components: &mut IndexMap<FunctionAccessKey, FuncComponents>,
|
func_components: &mut IndexMap<FunctionAccessKey, FuncComponents>,
|
||||||
func_index_map: &mut IndexMap<FunctionAccessKey, Vec<u64>>,
|
func_index_map: &mut IndexMap<FunctionAccessKey, Vec<u64>>,
|
||||||
recursion_func_map: IndexMap<FunctionAccessKey, ()>,
|
mut recursion_func_map: IndexMap<FunctionAccessKey, ()>,
|
||||||
) {
|
) {
|
||||||
self.process_define_ir(ir_stack, func_components, func_index_map);
|
self.process_define_ir(ir_stack, func_components, func_index_map);
|
||||||
|
|
||||||
let mut recursion_func_map = recursion_func_map;
|
let mut recursion_func_map_to_add = recursion_func_map.clone();
|
||||||
|
|
||||||
for func_index in func_index_map.clone().iter() {
|
for func_index in func_index_map.clone().iter() {
|
||||||
let func = func_index.0;
|
let func = func_index.0;
|
||||||
|
|
||||||
let function_components = func_components.get(func).unwrap();
|
let function_components = func_components.get(func).unwrap();
|
||||||
let mut function_ir = function_components.ir.clone();
|
let mut function_ir = function_components.ir.clone();
|
||||||
|
let mut skip = false;
|
||||||
|
|
||||||
for ir in function_ir.clone() {
|
for ir in function_ir.clone() {
|
||||||
if let Air::Var {
|
if let Air::Var {
|
||||||
|
@ -1630,10 +1631,16 @@ impl<'a> CodeGenerator<'a> {
|
||||||
module_name: module.clone(),
|
module_name: module.clone(),
|
||||||
function_name: func_name.clone(),
|
function_name: func_name.clone(),
|
||||||
variant_name: variant_name.clone(),
|
variant_name: variant_name.clone(),
|
||||||
}) {
|
}) && func.clone()
|
||||||
return;
|
== (FunctionAccessKey {
|
||||||
|
module_name: module.clone(),
|
||||||
|
function_name: func_name.clone(),
|
||||||
|
variant_name: variant_name.clone(),
|
||||||
|
})
|
||||||
|
{
|
||||||
|
skip = true;
|
||||||
} else {
|
} else {
|
||||||
recursion_func_map.insert(
|
recursion_func_map_to_add.insert(
|
||||||
FunctionAccessKey {
|
FunctionAccessKey {
|
||||||
module_name: module.clone(),
|
module_name: module.clone(),
|
||||||
function_name: func_name.clone(),
|
function_name: func_name.clone(),
|
||||||
|
@ -1645,6 +1652,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recursion_func_map = recursion_func_map_to_add.clone();
|
||||||
|
if !skip {
|
||||||
let mut inner_func_components = IndexMap::new();
|
let mut inner_func_components = IndexMap::new();
|
||||||
|
|
||||||
let mut inner_func_index_map = IndexMap::new();
|
let mut inner_func_index_map = IndexMap::new();
|
||||||
|
@ -1672,6 +1681,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn process_define_ir(
|
fn process_define_ir(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -1996,17 +2006,14 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
let tipo = constructor.tipo;
|
let tipo = constructor.tipo;
|
||||||
|
|
||||||
let args_type = match tipo.as_ref() {
|
let args_type = tipo.arg_types().unwrap();
|
||||||
Type::Fn { args, .. } | Type::App { args, .. } => args,
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(field_map) = field_map.clone() {
|
if let Some(field_map) = field_map.clone() {
|
||||||
for field in field_map
|
for field in field_map
|
||||||
.fields
|
.fields
|
||||||
.iter()
|
.iter()
|
||||||
.sorted_by(|item1, item2| item1.1.cmp(item2.1))
|
.sorted_by(|item1, item2| item1.1.cmp(item2.1))
|
||||||
.zip(args_type)
|
.zip(&args_type)
|
||||||
.rev()
|
.rev()
|
||||||
{
|
{
|
||||||
// TODO revisit
|
// TODO revisit
|
||||||
|
|
Loading…
Reference in New Issue