Cargo fmt + clippy, with latest rust
This commit is contained in:
parent
0d99afe5e2
commit
f464eb3702
|
@ -346,7 +346,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let type_info = self.module_types.get(module_name).unwrap();
|
let type_info = self.module_types.get(module_name).unwrap();
|
||||||
let value = type_info.values.get(name).unwrap();
|
let value = type_info.values.get(name).unwrap();
|
||||||
|
|
||||||
let ValueConstructorVariant::ModuleFn { builtin, .. } = &value.variant else {unreachable!("Missing module function definition")};
|
let ValueConstructorVariant::ModuleFn { builtin, .. } = &value.variant else {
|
||||||
|
unreachable!("Missing module function definition")
|
||||||
|
};
|
||||||
|
|
||||||
let fun_arg_types = fun
|
let fun_arg_types = fun
|
||||||
.tipo()
|
.tipo()
|
||||||
|
@ -589,8 +591,10 @@ impl<'a> CodeGenerator<'a> {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let ValueConstructorVariant::ModuleFn {
|
let ValueConstructorVariant::ModuleFn {
|
||||||
builtin: Some(builtin), ..
|
builtin: Some(builtin),
|
||||||
} = &value.variant else {
|
..
|
||||||
|
} = &value.variant
|
||||||
|
else {
|
||||||
unreachable!("Didn't find the function definition.")
|
unreachable!("Didn't find the function definition.")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1665,8 +1669,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
Pattern::List { .. } | Pattern::Var { .. } | Pattern::Discard { .. }
|
Pattern::List { .. } | Pattern::Var { .. } | Pattern::Discard { .. }
|
||||||
));
|
));
|
||||||
|
|
||||||
let Pattern::List { elements, tail, .. } = &clause.pattern
|
let Pattern::List { elements, tail, .. } = &clause.pattern else {
|
||||||
else {
|
|
||||||
let mut next_clause_props = ClauseProperties {
|
let mut next_clause_props = ClauseProperties {
|
||||||
clause_var_name: props.clause_var_name.clone(),
|
clause_var_name: props.clause_var_name.clone(),
|
||||||
complex_clause: false,
|
complex_clause: false,
|
||||||
|
@ -1811,7 +1814,13 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let (_, pattern_assigns) =
|
let (_, pattern_assigns) =
|
||||||
self.clause_pattern(&clause.pattern, subject_tipo, props);
|
self.clause_pattern(&clause.pattern, subject_tipo, props);
|
||||||
|
|
||||||
let ClauseProperties{ specific_clause: SpecificClause::TupleClause { defined_tuple_indices }, ..} = props
|
let ClauseProperties {
|
||||||
|
specific_clause:
|
||||||
|
SpecificClause::TupleClause {
|
||||||
|
defined_tuple_indices,
|
||||||
|
},
|
||||||
|
..
|
||||||
|
} = props
|
||||||
else {
|
else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
};
|
};
|
||||||
|
@ -1914,7 +1923,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
complex_clause,
|
complex_clause,
|
||||||
..
|
..
|
||||||
} = props
|
} = props
|
||||||
else { unreachable!() };
|
else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let list_elem_types = subject_tipo.get_inner_types();
|
let list_elem_types = subject_tipo.get_inner_types();
|
||||||
|
|
||||||
|
@ -2341,11 +2352,12 @@ impl<'a> CodeGenerator<'a> {
|
||||||
current_index,
|
current_index,
|
||||||
defined_tails,
|
defined_tails,
|
||||||
checked_index: _,
|
checked_index: _,
|
||||||
|
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} = props
|
} = props
|
||||||
else { unreachable!() };
|
else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
defined_tails.push(props.original_subject_name.clone());
|
defined_tails.push(props.original_subject_name.clone());
|
||||||
|
|
||||||
|
@ -2817,9 +2829,14 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
// In the case of zero args, we need to hoist the dependency function to the top of the zero arg function
|
// In the case of zero args, we need to hoist the dependency function to the top of the zero arg function
|
||||||
if &dep_path.common_ancestor(func_path) == func_path || params_empty {
|
if &dep_path.common_ancestor(func_path) == func_path || params_empty {
|
||||||
let UserFunction::Function { body: mut dep_air_tree, deps: dependency_deps, params: dependent_params } =
|
let UserFunction::Function {
|
||||||
dep_function.clone()
|
body: mut dep_air_tree,
|
||||||
else { unreachable!() };
|
deps: dependency_deps,
|
||||||
|
params: dependent_params,
|
||||||
|
} = dep_function.clone()
|
||||||
|
else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
if dependent_params.is_empty() {
|
if dependent_params.is_empty() {
|
||||||
// continue for zero arg functions. They are treated like global hoists.
|
// continue for zero arg functions. They are treated like global hoists.
|
||||||
|
@ -2869,8 +2886,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
current_function_deps: &mut Vec<(FunctionAccessKey, String)>,
|
current_function_deps: &mut Vec<(FunctionAccessKey, String)>,
|
||||||
validator_tree_path: &mut TreePath,
|
validator_tree_path: &mut TreePath,
|
||||||
) {
|
) {
|
||||||
let Some((depth, index)) = validator_tree_path.pop()
|
let Some((depth, index)) = validator_tree_path.pop() else {
|
||||||
else { return };
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
validator_tree_path.push(depth, index);
|
validator_tree_path.push(depth, index);
|
||||||
|
|
||||||
|
@ -2925,7 +2943,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
builtin: None,
|
builtin: None,
|
||||||
..
|
..
|
||||||
} = &constructor.variant
|
} = &constructor.variant
|
||||||
else { return };
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
let function_var_tipo = &constructor.tipo;
|
let function_var_tipo = &constructor.tipo;
|
||||||
|
|
||||||
|
@ -2936,8 +2956,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
let function_def = self.functions.get(&generic_function_key);
|
let function_def = self.functions.get(&generic_function_key);
|
||||||
|
|
||||||
let Some(function_def) = function_def
|
let Some(function_def) = function_def else {
|
||||||
else {
|
|
||||||
let code_gen_func = self
|
let code_gen_func = self
|
||||||
.code_gen_functions
|
.code_gen_functions
|
||||||
.get(&generic_function_key.function_name)
|
.get(&generic_function_key.function_name)
|
||||||
|
@ -2955,8 +2974,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let (path, _) = func_variants.get_mut("").unwrap();
|
let (path, _) = func_variants.get_mut("").unwrap();
|
||||||
*path = path.common_ancestor(tree_path);
|
*path = path.common_ancestor(tree_path);
|
||||||
} else {
|
} else {
|
||||||
let CodeGenFunction::Function{ body, params } = code_gen_func
|
let CodeGenFunction::Function { body, params } = code_gen_func else {
|
||||||
else { unreachable!() };
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let mut function_variant_path = IndexMap::new();
|
let mut function_variant_path = IndexMap::new();
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,6 @@ fn infer_definition(
|
||||||
.get_variable(&fun.name)
|
.get_variable(&fun.name)
|
||||||
.expect("Could not find preregistered type for function");
|
.expect("Could not find preregistered type for function");
|
||||||
|
|
||||||
|
|
||||||
let preregistered_type = preregistered_fn.tipo.clone();
|
let preregistered_type = preregistered_fn.tipo.clone();
|
||||||
|
|
||||||
let (args_types, _return_type) = preregistered_type
|
let (args_types, _return_type) = preregistered_type
|
||||||
|
@ -308,8 +307,11 @@ fn infer_definition(
|
||||||
environment,
|
environment,
|
||||||
tracing,
|
tracing,
|
||||||
kind,
|
kind,
|
||||||
)? else {
|
)?
|
||||||
unreachable!("validator definition inferred as something other than a function?")
|
else {
|
||||||
|
unreachable!(
|
||||||
|
"validator definition inferred as something other than a function?"
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
if !typed_fun.return_type.is_bool() {
|
if !typed_fun.return_type.is_bool() {
|
||||||
|
@ -319,7 +321,8 @@ fn infer_definition(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let typed_params = typed_fun.arguments
|
let typed_params = typed_fun
|
||||||
|
.arguments
|
||||||
.drain(0..params_length)
|
.drain(0..params_length)
|
||||||
.map(|mut arg| {
|
.map(|mut arg| {
|
||||||
if arg.tipo.is_unbound() {
|
if arg.tipo.is_unbound() {
|
||||||
|
@ -330,7 +333,6 @@ fn infer_definition(
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
||||||
if typed_fun.arguments.len() < 2 || typed_fun.arguments.len() > 3 {
|
if typed_fun.arguments.len() < 2 || typed_fun.arguments.len() > 3 {
|
||||||
return Err(Error::IncorrectValidatorArity {
|
return Err(Error::IncorrectValidatorArity {
|
||||||
count: typed_fun.arguments.len() as u32,
|
count: typed_fun.arguments.len() as u32,
|
||||||
|
@ -356,7 +358,8 @@ fn infer_definition(
|
||||||
environment,
|
environment,
|
||||||
tracing,
|
tracing,
|
||||||
kind,
|
kind,
|
||||||
)? else {
|
)?
|
||||||
|
else {
|
||||||
unreachable!(
|
unreachable!(
|
||||||
"validator definition inferred as something other than a function?"
|
"validator definition inferred as something other than a function?"
|
||||||
)
|
)
|
||||||
|
@ -398,8 +401,6 @@ fn infer_definition(
|
||||||
})
|
})
|
||||||
.transpose();
|
.transpose();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ok(Definition::Validator(Validator {
|
Ok(Definition::Validator(Validator {
|
||||||
doc,
|
doc,
|
||||||
end_position,
|
end_position,
|
||||||
|
|
|
@ -35,9 +35,8 @@ fn assert_uplc(source_code: &str, expected: Term<Name>, should_fail: bool) {
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
let Some(checked_module) = modules.values().next()
|
let Some(checked_module) = modules.values().next() else {
|
||||||
else {
|
unreachable!("There's got to be one right?")
|
||||||
unreachable!("There's got to be one right?")
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut scripts = vec![];
|
let mut scripts = vec![];
|
||||||
|
|
|
@ -712,8 +712,12 @@ impl DefaultFunction {
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
DefaultFunction::HeadList => {
|
DefaultFunction::HeadList => {
|
||||||
let c @ Value::Con(inner) = &args[0] else {unreachable!()};
|
let c @ Value::Con(inner) = &args[0] else {
|
||||||
let Constant::ProtoList(_, list) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::ProtoList(_, list) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
if list.is_empty() {
|
if list.is_empty() {
|
||||||
Err(Error::EmptyList(c.clone()))
|
Err(Error::EmptyList(c.clone()))
|
||||||
|
@ -724,8 +728,12 @@ impl DefaultFunction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DefaultFunction::TailList => {
|
DefaultFunction::TailList => {
|
||||||
let c @ Value::Con(inner) = &args[0] else {unreachable!()};
|
let c @ Value::Con(inner) = &args[0] else {
|
||||||
let Constant::ProtoList(r#type, list) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::ProtoList(r#type, list) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
if list.is_empty() {
|
if list.is_empty() {
|
||||||
Err(Error::EmptyList(c.clone()))
|
Err(Error::EmptyList(c.clone()))
|
||||||
|
@ -784,12 +792,9 @@ impl DefaultFunction {
|
||||||
let mut map = Vec::new();
|
let mut map = Vec::new();
|
||||||
|
|
||||||
for item in list {
|
for item in list {
|
||||||
let Constant::ProtoPair(
|
let Constant::ProtoPair(Type::Data, Type::Data, left, right) = item else {
|
||||||
Type::Data,
|
unreachable!()
|
||||||
Type::Data,
|
};
|
||||||
left,
|
|
||||||
right
|
|
||||||
) = item else {unreachable!()};
|
|
||||||
|
|
||||||
match (left.as_ref(), right.as_ref()) {
|
match (left.as_ref(), right.as_ref()) {
|
||||||
(Constant::Data(key), Constant::Data(value)) => {
|
(Constant::Data(key), Constant::Data(value)) => {
|
||||||
|
@ -838,7 +843,7 @@ impl DefaultFunction {
|
||||||
return Err(Error::DeserialisationError(
|
return Err(Error::DeserialisationError(
|
||||||
"UnConstrData".to_string(),
|
"UnConstrData".to_string(),
|
||||||
v.clone(),
|
v.clone(),
|
||||||
))
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let constant = Constant::ProtoPair(
|
let constant = Constant::ProtoPair(
|
||||||
|
@ -876,7 +881,7 @@ impl DefaultFunction {
|
||||||
return Err(Error::DeserialisationError(
|
return Err(Error::DeserialisationError(
|
||||||
"UnMapData".to_string(),
|
"UnMapData".to_string(),
|
||||||
v.clone(),
|
v.clone(),
|
||||||
))
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let constant = Constant::ProtoList(
|
let constant = Constant::ProtoList(
|
||||||
|
@ -909,7 +914,7 @@ impl DefaultFunction {
|
||||||
return Err(Error::DeserialisationError(
|
return Err(Error::DeserialisationError(
|
||||||
"UnListData".to_string(),
|
"UnListData".to_string(),
|
||||||
v.clone(),
|
v.clone(),
|
||||||
))
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let value = Value::list(
|
let value = Value::list(
|
||||||
|
@ -933,7 +938,7 @@ impl DefaultFunction {
|
||||||
return Err(Error::DeserialisationError(
|
return Err(Error::DeserialisationError(
|
||||||
"UnIData".to_string(),
|
"UnIData".to_string(),
|
||||||
v.clone(),
|
v.clone(),
|
||||||
))
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let value = Value::integer(from_pallas_bigint(b));
|
let value = Value::integer(from_pallas_bigint(b));
|
||||||
|
@ -951,7 +956,7 @@ impl DefaultFunction {
|
||||||
return Err(Error::DeserialisationError(
|
return Err(Error::DeserialisationError(
|
||||||
"UnBData".to_string(),
|
"UnBData".to_string(),
|
||||||
v.clone(),
|
v.clone(),
|
||||||
))
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let value = Value::byte_string(b.to_vec());
|
let value = Value::byte_string(b.to_vec());
|
||||||
|
@ -964,18 +969,28 @@ impl DefaultFunction {
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
DefaultFunction::EqualsData => {
|
DefaultFunction::EqualsData => {
|
||||||
let (Value::Con(inner1), Value::Con(inner2)) = (&args[0], &args[1]) else {unreachable!()};
|
let (Value::Con(inner1), Value::Con(inner2)) = (&args[0], &args[1]) else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let Constant::Data(d1) = inner1.as_ref() else {unreachable!()};
|
let Constant::Data(d1) = inner1.as_ref() else {
|
||||||
let Constant::Data(d2) = inner2.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::Data(d2) = inner2.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let value = Value::bool(d1.eq(d2));
|
let value = Value::bool(d1.eq(d2));
|
||||||
|
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
DefaultFunction::SerialiseData => {
|
DefaultFunction::SerialiseData => {
|
||||||
let Value::Con(inner) = &args[0] else {unreachable!()};
|
let Value::Con(inner) = &args[0] else {
|
||||||
let Constant::Data(d) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::Data(d) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let serialized_data = plutus_data_to_bytes(d).unwrap();
|
let serialized_data = plutus_data_to_bytes(d).unwrap();
|
||||||
|
|
||||||
|
@ -984,10 +999,16 @@ impl DefaultFunction {
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
DefaultFunction::MkPairData => {
|
DefaultFunction::MkPairData => {
|
||||||
let (Value::Con(inner1), Value::Con(inner2)) = (&args[0], &args[1]) else {unreachable!()};
|
let (Value::Con(inner1), Value::Con(inner2)) = (&args[0], &args[1]) else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let Constant::Data(d1) = inner1.as_ref() else {unreachable!()};
|
let Constant::Data(d1) = inner1.as_ref() else {
|
||||||
let Constant::Data(d2) = inner2.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::Data(d2) = inner2.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
let constant = Constant::ProtoPair(
|
let constant = Constant::ProtoPair(
|
||||||
Type::Data,
|
Type::Data,
|
||||||
|
|
|
@ -66,56 +66,86 @@ impl Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_integer(&self) -> &BigInt {
|
pub(super) fn unwrap_integer(&self) -> &BigInt {
|
||||||
let Value::Con(inner) = self else {unreachable!()};
|
let Value::Con(inner) = self else {
|
||||||
let Constant::Integer(integer) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::Integer(integer) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
integer
|
integer
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_byte_string(&self) -> &Vec<u8> {
|
pub(super) fn unwrap_byte_string(&self) -> &Vec<u8> {
|
||||||
let Value::Con(inner) = self else {unreachable!()};
|
let Value::Con(inner) = self else {
|
||||||
let Constant::ByteString(byte_string) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::ByteString(byte_string) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
byte_string
|
byte_string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_string(&self) -> &String {
|
pub(super) fn unwrap_string(&self) -> &String {
|
||||||
let Value::Con(inner) = self else {unreachable!()};
|
let Value::Con(inner) = self else {
|
||||||
let Constant::String(string) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::String(string) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
string
|
string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_bool(&self) -> &bool {
|
pub(super) fn unwrap_bool(&self) -> &bool {
|
||||||
let Value::Con(inner) = self else {unreachable!()};
|
let Value::Con(inner) = self else {
|
||||||
let Constant::Bool(condition) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::Bool(condition) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
condition
|
condition
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_pair(&self) -> (&Type, &Type, &Rc<Constant>, &Rc<Constant>) {
|
pub(super) fn unwrap_pair(&self) -> (&Type, &Type, &Rc<Constant>, &Rc<Constant>) {
|
||||||
let Value::Con(inner) = self else {unreachable!()};
|
let Value::Con(inner) = self else {
|
||||||
let Constant::ProtoPair(t1, t2, first, second) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::ProtoPair(t1, t2, first, second) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
(t1, t2, first, second)
|
(t1, t2, first, second)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_list(&self) -> (&Type, &Vec<Constant>) {
|
pub(super) fn unwrap_list(&self) -> (&Type, &Vec<Constant>) {
|
||||||
let Value::Con(inner) = self else {unreachable!()};
|
let Value::Con(inner) = self else {
|
||||||
let Constant::ProtoList(t, list) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::ProtoList(t, list) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
(t, list)
|
(t, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_constant(&self) -> &Constant {
|
pub(super) fn unwrap_constant(&self) -> &Constant {
|
||||||
let Value::Con(item) = self else {unreachable!()};
|
let Value::Con(item) = self else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
item.as_ref()
|
item.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unwrap_data_list(&self) -> &Vec<Constant> {
|
pub(super) fn unwrap_data_list(&self) -> &Vec<Constant> {
|
||||||
let Value::Con(inner) = self else {unreachable!()};
|
let Value::Con(inner) = self else {
|
||||||
let Constant::ProtoList(Type::Data, list) = inner.as_ref() else {unreachable!()};
|
unreachable!()
|
||||||
|
};
|
||||||
|
let Constant::ProtoList(Type::Data, list) = inner.as_ref() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,13 +181,15 @@ fn inline_direct_reduce(term: &mut Term<Name>) {
|
||||||
inline_direct_reduce(func);
|
inline_direct_reduce(func);
|
||||||
inline_direct_reduce(arg);
|
inline_direct_reduce(arg);
|
||||||
|
|
||||||
let Term::Lambda { parameter_name, body } = func
|
let Term::Lambda {
|
||||||
else{
|
parameter_name,
|
||||||
|
body,
|
||||||
|
} = func
|
||||||
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Term::Var(name) = body.as_ref()
|
let Term::Var(name) = body.as_ref() else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -220,18 +222,23 @@ fn inline_identity_reduce(term: &mut Term<Name>) {
|
||||||
inline_identity_reduce(func);
|
inline_identity_reduce(func);
|
||||||
inline_identity_reduce(arg);
|
inline_identity_reduce(arg);
|
||||||
|
|
||||||
let Term::Lambda { parameter_name, body } = func
|
let Term::Lambda {
|
||||||
|
parameter_name,
|
||||||
|
body,
|
||||||
|
} = func
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Term::Lambda { parameter_name: identity_name, body: identity_body } = arg
|
let Term::Lambda {
|
||||||
|
parameter_name: identity_name,
|
||||||
|
body: identity_body,
|
||||||
|
} = arg
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Term::Var(identity_var) = Rc::make_mut(identity_body)
|
let Term::Var(identity_var) = Rc::make_mut(identity_body) else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -316,10 +323,7 @@ fn wrap_data_reduce(term: &mut Term<Name>) {
|
||||||
wrap_data_reduce(Rc::make_mut(body));
|
wrap_data_reduce(Rc::make_mut(body));
|
||||||
}
|
}
|
||||||
Term::Apply { function, argument } => {
|
Term::Apply { function, argument } => {
|
||||||
let Term::Builtin(
|
let Term::Builtin(first_action) = function.as_ref() else {
|
||||||
first_action
|
|
||||||
) = function.as_ref()
|
|
||||||
else {
|
|
||||||
wrap_data_reduce(Rc::make_mut(function));
|
wrap_data_reduce(Rc::make_mut(function));
|
||||||
wrap_data_reduce(Rc::make_mut(argument));
|
wrap_data_reduce(Rc::make_mut(argument));
|
||||||
return;
|
return;
|
||||||
|
@ -330,8 +334,7 @@ fn wrap_data_reduce(term: &mut Term<Name>) {
|
||||||
argument: inner_arg,
|
argument: inner_arg,
|
||||||
} = Rc::make_mut(argument)
|
} = Rc::make_mut(argument)
|
||||||
{
|
{
|
||||||
let Term::Builtin(second_action) = inner_func.as_ref()
|
let Term::Builtin(second_action) = inner_func.as_ref() else {
|
||||||
else {
|
|
||||||
wrap_data_reduce(Rc::make_mut(argument));
|
wrap_data_reduce(Rc::make_mut(argument));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -564,9 +567,11 @@ fn replace_identity_usage(term: &Term<Name>, original: Rc<Name>) -> Term<Name> {
|
||||||
let func = replace_identity_usage(func, original.clone());
|
let func = replace_identity_usage(func, original.clone());
|
||||||
let arg = replace_identity_usage(arg, original.clone());
|
let arg = replace_identity_usage(arg, original.clone());
|
||||||
|
|
||||||
let Term::Var(f) = function.as_ref()
|
let Term::Var(f) = function.as_ref() else {
|
||||||
else {
|
return Term::Apply {
|
||||||
return Term::Apply { function: func.into(), argument: arg.into() }
|
function: func.into(),
|
||||||
|
argument: arg.into(),
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if f.as_ref() == original.as_ref() {
|
if f.as_ref() == original.as_ref() {
|
||||||
|
|
Loading…
Reference in New Issue