chore: update changelog
expecting a type on List<Data> from data now only checks that type is a list and not each element
This commit is contained in:
parent
eda388fb29
commit
2f7784f31e
|
@ -11,8 +11,10 @@
|
||||||
tree abstraction.
|
tree abstraction.
|
||||||
- **aiken-lang**: Zero argument anonymous functions now are implemted as a
|
- **aiken-lang**: Zero argument anonymous functions now are implemted as a
|
||||||
delayed function body and calling them simply does force
|
delayed function body and calling them simply does force
|
||||||
- **aiken-lang**: Matching on int in expect and when cases is now implemented.
|
- **aiken-lang**: Matching on int in expect and when cases is now implemented
|
||||||
- **aiken-lang**: Using assign in nested pattern matches is now implemented.
|
- **aiken-lang**: Using assign in nested pattern matches is now implemented
|
||||||
|
- **aiken-lang**: Using List<Data> as a validator params only checks the type is
|
||||||
|
a list and does not attempt to check each item
|
||||||
|
|
||||||
### Optimization
|
### Optimization
|
||||||
|
|
||||||
|
|
|
@ -1212,65 +1212,69 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
let inner_list_type = &tipo.get_inner_types()[0];
|
let inner_list_type = &tipo.get_inner_types()[0];
|
||||||
|
|
||||||
let list_name = format!("__list_span_{}_{}", location.start, location.end);
|
if inner_list_type.is_data() {
|
||||||
let item_name = format!("__item_span_{}_{}", location.start, location.end);
|
value
|
||||||
|
|
||||||
let assign = AirTree::let_assignment(&list_name, value);
|
|
||||||
|
|
||||||
let expect_item = self.expect_type_assign(
|
|
||||||
inner_list_type,
|
|
||||||
AirTree::cast_from_data(
|
|
||||||
AirTree::local_var(&item_name, data()),
|
|
||||||
inner_list_type.clone(),
|
|
||||||
),
|
|
||||||
defined_data_types,
|
|
||||||
location,
|
|
||||||
);
|
|
||||||
|
|
||||||
let anon_func_body = expect_item;
|
|
||||||
|
|
||||||
let unwrap_function = AirTree::anon_func(vec![item_name], anon_func_body);
|
|
||||||
|
|
||||||
let function = self.code_gen_functions.get(EXPECT_ON_LIST);
|
|
||||||
|
|
||||||
if function.is_none() {
|
|
||||||
let expect_list_func = AirTree::expect_on_list();
|
|
||||||
self.code_gen_functions.insert(
|
|
||||||
EXPECT_ON_LIST.to_string(),
|
|
||||||
CodeGenFunction::Function {
|
|
||||||
body: expect_list_func,
|
|
||||||
params: vec!["__list_to_check".to_string(), "__check_with".to_string()],
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(counter) = defined_data_types.get_mut(EXPECT_ON_LIST) {
|
|
||||||
*counter += 1
|
|
||||||
} else {
|
} else {
|
||||||
defined_data_types.insert(EXPECT_ON_LIST.to_string(), 1);
|
let list_name = format!("__list_span_{}_{}", location.start, location.end);
|
||||||
}
|
let item_name = format!("__item_span_{}_{}", location.start, location.end);
|
||||||
|
|
||||||
let func_call = AirTree::call(
|
let assign = AirTree::let_assignment(&list_name, value);
|
||||||
AirTree::var(
|
|
||||||
ValueConstructor::public(
|
let expect_item = self.expect_type_assign(
|
||||||
void(),
|
inner_list_type,
|
||||||
ValueConstructorVariant::ModuleFn {
|
AirTree::cast_from_data(
|
||||||
name: EXPECT_ON_LIST.to_string(),
|
AirTree::local_var(&item_name, data()),
|
||||||
field_map: None,
|
inner_list_type.clone(),
|
||||||
module: "".to_string(),
|
|
||||||
arity: 1,
|
|
||||||
location,
|
|
||||||
builtin: None,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
EXPECT_ON_LIST,
|
defined_data_types,
|
||||||
"",
|
location,
|
||||||
),
|
);
|
||||||
void(),
|
|
||||||
vec![AirTree::local_var(list_name, tipo.clone()), unwrap_function],
|
|
||||||
);
|
|
||||||
|
|
||||||
assign.hoist_over(func_call)
|
let anon_func_body = expect_item;
|
||||||
|
|
||||||
|
let unwrap_function = AirTree::anon_func(vec![item_name], anon_func_body);
|
||||||
|
|
||||||
|
let function = self.code_gen_functions.get(EXPECT_ON_LIST);
|
||||||
|
|
||||||
|
if function.is_none() {
|
||||||
|
let expect_list_func = AirTree::expect_on_list();
|
||||||
|
self.code_gen_functions.insert(
|
||||||
|
EXPECT_ON_LIST.to_string(),
|
||||||
|
CodeGenFunction::Function {
|
||||||
|
body: expect_list_func,
|
||||||
|
params: vec!["__list_to_check".to_string(), "__check_with".to_string()],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(counter) = defined_data_types.get_mut(EXPECT_ON_LIST) {
|
||||||
|
*counter += 1
|
||||||
|
} else {
|
||||||
|
defined_data_types.insert(EXPECT_ON_LIST.to_string(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let func_call = AirTree::call(
|
||||||
|
AirTree::var(
|
||||||
|
ValueConstructor::public(
|
||||||
|
void(),
|
||||||
|
ValueConstructorVariant::ModuleFn {
|
||||||
|
name: EXPECT_ON_LIST.to_string(),
|
||||||
|
field_map: None,
|
||||||
|
module: "".to_string(),
|
||||||
|
arity: 1,
|
||||||
|
location,
|
||||||
|
builtin: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
EXPECT_ON_LIST,
|
||||||
|
"",
|
||||||
|
),
|
||||||
|
void(),
|
||||||
|
vec![AirTree::local_var(list_name, tipo.clone()), unwrap_function],
|
||||||
|
);
|
||||||
|
|
||||||
|
assign.hoist_over(func_call)
|
||||||
|
}
|
||||||
} else if tipo.is_2_tuple() {
|
} else if tipo.is_2_tuple() {
|
||||||
let tuple_inner_types = tipo.get_inner_types();
|
let tuple_inner_types = tipo.get_inner_types();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue