Fix to variant name creation for dependencies.
Last few changes to go Tuple Index, Assert, Check, not change test 35 to produce intended functionality
This commit is contained in:
parent
b0ea187151
commit
3514e66234
|
@ -992,8 +992,33 @@ pub fn get_variant_name(new_name: &mut String, t: &Arc<Type>) {
|
||||||
let list_type = &t.get_inner_types()[0];
|
let list_type = &t.get_inner_types()[0];
|
||||||
get_variant_name(&mut full_type, list_type);
|
get_variant_name(&mut full_type, list_type);
|
||||||
full_type
|
full_type
|
||||||
|
} else if t.is_tuple() {
|
||||||
|
let mut full_type = "tuple".to_string();
|
||||||
|
match &**t {
|
||||||
|
Type::App { .. } => {}
|
||||||
|
Type::Fn { .. } => {}
|
||||||
|
Type::Var { .. } => {}
|
||||||
|
Type::Tuple { elems } => {
|
||||||
|
for elem in elems {
|
||||||
|
get_variant_name(&mut full_type, elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
full_type
|
||||||
} else {
|
} else {
|
||||||
"data".to_string()
|
let mut full_type = "data".to_string();
|
||||||
|
match &**t {
|
||||||
|
Type::App { args, .. } => {
|
||||||
|
for arg in args {
|
||||||
|
get_variant_name(&mut full_type, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Type::Fn { .. } => {}
|
||||||
|
Type::Var { .. } => {}
|
||||||
|
Type::Tuple { .. } => {}
|
||||||
|
};
|
||||||
|
|
||||||
|
full_type
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,9 @@ use crate::{
|
||||||
},
|
},
|
||||||
builder::{
|
builder::{
|
||||||
check_when_pattern_needs, constants_ir, convert_constants_to_data, convert_data_to_type,
|
check_when_pattern_needs, constants_ir, convert_constants_to_data, convert_data_to_type,
|
||||||
convert_type_to_data, get_common_ancestor, get_generics_and_type, get_variant_name,
|
convert_type_to_data, get_common_ancestor, get_generics_and_type, handle_func_deps_ir,
|
||||||
handle_func_deps_ir, handle_recursion_ir, list_access_to_uplc, monomorphize,
|
handle_recursion_ir, list_access_to_uplc, monomorphize, rearrange_clauses,
|
||||||
rearrange_clauses, wrap_validator_args, ClauseProperties, DataTypeKey, FuncComponents,
|
wrap_validator_args, ClauseProperties, DataTypeKey, FuncComponents, FunctionAccessKey,
|
||||||
FunctionAccessKey,
|
|
||||||
},
|
},
|
||||||
expr::TypedExpr,
|
expr::TypedExpr,
|
||||||
tipo::{
|
tipo::{
|
||||||
|
@ -176,11 +175,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
self.build_ir(body, &mut func_body, func_scope);
|
self.build_ir(body, &mut func_body, func_scope);
|
||||||
let mut arg_names = vec![];
|
let mut arg_names = vec![];
|
||||||
for arg in args {
|
for arg in args {
|
||||||
let name = arg
|
let name = arg.arg_name.get_variable_name().unwrap_or("_").to_string();
|
||||||
.arg_name
|
|
||||||
.get_variable_name()
|
|
||||||
.unwrap_or_default()
|
|
||||||
.to_string();
|
|
||||||
arg_names.push(name);
|
arg_names.push(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2172,32 +2168,51 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let function = self.functions.get(¤t_func);
|
let function = self.functions.get(¤t_func);
|
||||||
if function_key.clone() == current_func_as_variant {
|
if function_key.clone() == current_func_as_variant {
|
||||||
func_calls.insert(current_func_as_variant, ());
|
func_calls.insert(current_func_as_variant, ());
|
||||||
} else if let (Some(function), Type::Fn { args, .. }) =
|
} else if let (Some(function), Type::Fn { .. }) =
|
||||||
(function, &*tipo)
|
(function, &*tipo)
|
||||||
{
|
{
|
||||||
if function
|
let mut generics_type_map: HashMap<u64, Arc<Type>> =
|
||||||
.arguments
|
HashMap::new();
|
||||||
.iter()
|
|
||||||
.any(|arg| arg.tipo.is_generic())
|
let param_types = tipo.arg_types().unwrap();
|
||||||
|
|
||||||
|
for (index, arg) in
|
||||||
|
function.arguments.iter().enumerate()
|
||||||
{
|
{
|
||||||
let mut new_name = String::new();
|
if arg.tipo.is_generic() {
|
||||||
for arg in args.iter() {
|
let mut map =
|
||||||
get_variant_name(&mut new_name, arg);
|
generics_type_map.into_iter().collect_vec();
|
||||||
|
map.append(&mut get_generics_and_type(
|
||||||
|
&arg.tipo,
|
||||||
|
¶m_types[index],
|
||||||
|
));
|
||||||
|
|
||||||
|
generics_type_map = map.into_iter().collect();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut func_ir = vec![];
|
||||||
|
|
||||||
|
self.build_ir(
|
||||||
|
&function.body,
|
||||||
|
&mut func_ir,
|
||||||
|
scope.to_vec(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let (variant_name, _) =
|
||||||
|
monomorphize(func_ir, generics_type_map, &tipo);
|
||||||
|
|
||||||
func_calls.insert(
|
func_calls.insert(
|
||||||
FunctionAccessKey {
|
FunctionAccessKey {
|
||||||
module_name: module,
|
module_name: current_func.module_name,
|
||||||
function_name: func_name,
|
function_name: current_func.function_name,
|
||||||
variant_name: new_name,
|
variant_name,
|
||||||
},
|
},
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
func_calls.insert(current_func, ());
|
func_calls.insert(current_func, ());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
func_calls.insert(current_func, ());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,10 @@ pub opaque type Dict<key, value> {
|
||||||
inner: List<#(ByteArray, value)>,
|
inner: List<#(ByteArray, value)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toList(self: Dict<ByteArray, value>){
|
||||||
|
self.inner
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a new map
|
/// Create a new map
|
||||||
pub fn new() -> Dict<key, value> {
|
pub fn new() -> Dict<key, value> {
|
||||||
Dict { inner: [] }
|
Dict { inner: [] }
|
||||||
|
|
|
@ -30,8 +30,7 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
|
||||||
v0,
|
v0,
|
||||||
v1,
|
v1,
|
||||||
fn(_, a0, a1) {
|
fn(_, a0, a1) {
|
||||||
Some(
|
let asset = dict.union_with(
|
||||||
dict.union_with(
|
|
||||||
a0,
|
a0,
|
||||||
a1,
|
a1,
|
||||||
fn(_, q0, q1) {
|
fn(_, q0, q1) {
|
||||||
|
@ -42,8 +41,12 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
|
||||||
Some(q)
|
Some(q)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
))
|
)
|
||||||
|
|
||||||
|
when dict.toList(asset) is {
|
||||||
|
[] -> None
|
||||||
|
_ -> Some(asset)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue