chore: clean up warnings
This commit is contained in:
parent
3787cce275
commit
4db0c93061
|
@ -189,7 +189,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
TypedExpr::Int { .. } => {}
|
TypedExpr::Int { .. } => {}
|
||||||
TypedExpr::String { .. } => {}
|
TypedExpr::String { .. } => {}
|
||||||
TypedExpr::ByteArray { .. } => {}
|
TypedExpr::ByteArray { .. } => {}
|
||||||
TypedExpr::Sequence { expressions, .. } => {
|
TypedExpr::Sequence { expressions, .. } | TypedExpr::Pipeline { expressions, .. } => {
|
||||||
// let mut terms = Vec::new();
|
// let mut terms = Vec::new();
|
||||||
for (i, exp) in expressions.iter().enumerate().rev() {
|
for (i, exp) in expressions.iter().enumerate().rev() {
|
||||||
self.recurse_scope_level(
|
self.recurse_scope_level(
|
||||||
|
@ -198,10 +198,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TypedExpr::Pipeline {
|
|
||||||
location,
|
|
||||||
expressions,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::Var {
|
TypedExpr::Var {
|
||||||
constructor, name, ..
|
constructor, name, ..
|
||||||
} => match (constructor.variant.clone(), (*constructor.tipo).clone()) {
|
} => match (constructor.variant.clone(), (*constructor.tipo).clone()) {
|
||||||
|
@ -219,20 +216,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
(ValueConstructorVariant::Record { .. }, Type::App { .. }) => {}
|
(ValueConstructorVariant::Record { .. }, Type::App { .. }) => {}
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
},
|
},
|
||||||
TypedExpr::Fn {
|
TypedExpr::Fn { .. } => todo!(),
|
||||||
location,
|
TypedExpr::List { .. } => todo!(),
|
||||||
tipo,
|
|
||||||
is_capture,
|
|
||||||
args,
|
|
||||||
body,
|
|
||||||
return_annotation,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::List {
|
|
||||||
location,
|
|
||||||
tipo,
|
|
||||||
elements,
|
|
||||||
tail,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::Call { fun, args, .. } => {
|
TypedExpr::Call { fun, args, .. } => {
|
||||||
self.recurse_scope_level(fun, scope_level.scope_increment(args.len() as i32 + 1));
|
self.recurse_scope_level(fun, scope_level.scope_increment(args.len() as i32 + 1));
|
||||||
|
|
||||||
|
@ -247,13 +232,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
TypedExpr::Assignment { value, pattern, .. } => {
|
TypedExpr::Assignment { value, pattern, .. } => {
|
||||||
self.recurse_scope_level_pattern(pattern, value, scope_level)
|
self.recurse_scope_level_pattern(pattern, value, scope_level)
|
||||||
}
|
}
|
||||||
TypedExpr::Try {
|
TypedExpr::Try { .. } => todo!(),
|
||||||
location,
|
|
||||||
tipo,
|
|
||||||
value,
|
|
||||||
then,
|
|
||||||
pattern,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::When {
|
TypedExpr::When {
|
||||||
subjects, clauses, ..
|
subjects, clauses, ..
|
||||||
} => {
|
} => {
|
||||||
|
@ -270,7 +249,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
self.recurse_scope_level(subject, scope_level.clone());
|
self.recurse_scope_level(subject, scope_level.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//if statements increase scope due to branching.
|
// if statements increase scope due to branching.
|
||||||
TypedExpr::If {
|
TypedExpr::If {
|
||||||
branches,
|
branches,
|
||||||
final_else,
|
final_else,
|
||||||
|
@ -365,13 +344,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a @ TypedExpr::ModuleSelect { constructor, .. } => match constructor {
|
a @ TypedExpr::ModuleSelect { constructor, .. } => match constructor {
|
||||||
ModuleValueConstructor::Record {
|
ModuleValueConstructor::Record { .. } => todo!(),
|
||||||
name,
|
|
||||||
arity,
|
|
||||||
tipo,
|
|
||||||
field_map,
|
|
||||||
location,
|
|
||||||
} => todo!(),
|
|
||||||
ModuleValueConstructor::Fn { module, name, .. } => {
|
ModuleValueConstructor::Fn { module, name, .. } => {
|
||||||
if self
|
if self
|
||||||
.uplc_function_holder_lookup
|
.uplc_function_holder_lookup
|
||||||
|
@ -408,18 +381,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
ModuleValueConstructor::Constant { .. } => todo!(),
|
ModuleValueConstructor::Constant { .. } => todo!(),
|
||||||
},
|
},
|
||||||
TypedExpr::Todo {
|
TypedExpr::Todo { .. } => todo!(),
|
||||||
location,
|
TypedExpr::RecordUpdate { .. } => todo!(),
|
||||||
label,
|
TypedExpr::Negate { .. } => todo!(),
|
||||||
tipo,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::RecordUpdate {
|
|
||||||
location,
|
|
||||||
tipo,
|
|
||||||
spread,
|
|
||||||
args,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::Negate { location, value } => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,25 +395,13 @@ impl<'a> CodeGenerator<'a> {
|
||||||
) {
|
) {
|
||||||
match dbg!(pattern) {
|
match dbg!(pattern) {
|
||||||
Pattern::Int { .. } | Pattern::String { .. } | Pattern::Var { .. } => {
|
Pattern::Int { .. } | Pattern::String { .. } | Pattern::Var { .. } => {
|
||||||
self.recurse_scope_level(value, scope_level.clone());
|
self.recurse_scope_level(value, scope_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pattern::VarUsage {
|
Pattern::VarUsage { .. } => todo!(),
|
||||||
location,
|
Pattern::Assign { .. } => todo!(),
|
||||||
name,
|
Pattern::Discard { .. } => todo!(),
|
||||||
tipo,
|
Pattern::List { .. } => todo!(),
|
||||||
} => todo!(),
|
|
||||||
Pattern::Assign {
|
|
||||||
name,
|
|
||||||
location,
|
|
||||||
pattern,
|
|
||||||
} => todo!(),
|
|
||||||
Pattern::Discard { name, location } => todo!(),
|
|
||||||
Pattern::List {
|
|
||||||
location,
|
|
||||||
elements,
|
|
||||||
tail,
|
|
||||||
} => todo!(),
|
|
||||||
Pattern::Constructor {
|
Pattern::Constructor {
|
||||||
name: constructor_name,
|
name: constructor_name,
|
||||||
tipo,
|
tipo,
|
||||||
|
@ -536,7 +488,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
TypedExpr::ByteArray { bytes, .. } => {
|
TypedExpr::ByteArray { bytes, .. } => {
|
||||||
Term::Constant(Constant::ByteString(bytes.clone()))
|
Term::Constant(Constant::ByteString(bytes.clone()))
|
||||||
}
|
}
|
||||||
TypedExpr::Sequence { expressions, .. } => {
|
TypedExpr::Sequence { expressions, .. } | TypedExpr::Pipeline { expressions, .. } => {
|
||||||
for (i, exp) in expressions.iter().enumerate().rev() {
|
for (i, exp) in expressions.iter().enumerate().rev() {
|
||||||
let mut term = self
|
let mut term = self
|
||||||
.recurse_code_gen(exp, scope_level.scope_increment_sequence(i as i32 + 1));
|
.recurse_code_gen(exp, scope_level.scope_increment_sequence(i as i32 + 1));
|
||||||
|
@ -550,10 +502,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
self.uplc_function_holder.pop().unwrap().1
|
self.uplc_function_holder.pop().unwrap().1
|
||||||
}
|
}
|
||||||
TypedExpr::Pipeline {
|
|
||||||
expressions: _expressions,
|
|
||||||
..
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::Var {
|
TypedExpr::Var {
|
||||||
constructor, name, ..
|
constructor, name, ..
|
||||||
} => {
|
} => {
|
||||||
|
@ -565,44 +513,14 @@ impl<'a> CodeGenerator<'a> {
|
||||||
text: name.to_string(),
|
text: name.to_string(),
|
||||||
unique: 0.into(),
|
unique: 0.into(),
|
||||||
}),
|
}),
|
||||||
ValueConstructorVariant::ModuleConstant {
|
ValueConstructorVariant::ModuleConstant { .. } => todo!(),
|
||||||
location,
|
ValueConstructorVariant::ModuleFn { .. } => todo!(),
|
||||||
module,
|
ValueConstructorVariant::Record { .. } => todo!(),
|
||||||
literal,
|
|
||||||
} => todo!(),
|
|
||||||
ValueConstructorVariant::ModuleFn {
|
|
||||||
name,
|
|
||||||
field_map,
|
|
||||||
module,
|
|
||||||
arity,
|
|
||||||
location,
|
|
||||||
builtin,
|
|
||||||
} => todo!(),
|
|
||||||
ValueConstructorVariant::Record {
|
|
||||||
name,
|
|
||||||
arity,
|
|
||||||
field_map,
|
|
||||||
location,
|
|
||||||
module,
|
|
||||||
constructors_count,
|
|
||||||
} => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TypedExpr::Fn {
|
TypedExpr::Fn { .. } => todo!(),
|
||||||
location,
|
TypedExpr::List { .. } => todo!(),
|
||||||
tipo,
|
|
||||||
is_capture,
|
|
||||||
args,
|
|
||||||
body,
|
|
||||||
return_annotation,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::List {
|
|
||||||
location,
|
|
||||||
tipo,
|
|
||||||
elements,
|
|
||||||
tail,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::Call { fun, args, .. } => {
|
TypedExpr::Call { fun, args, .. } => {
|
||||||
let mut term =
|
let mut term =
|
||||||
self.recurse_code_gen(fun, scope_level.scope_increment(args.len() as i32 + 1));
|
self.recurse_code_gen(fun, scope_level.scope_increment(args.len() as i32 + 1));
|
||||||
|
@ -624,6 +542,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let left_term = self.recurse_code_gen(left, scope_level.clone());
|
let left_term = self.recurse_code_gen(left, scope_level.clone());
|
||||||
|
|
||||||
let right_term = self.recurse_code_gen(right, scope_level);
|
let right_term = self.recurse_code_gen(right, scope_level);
|
||||||
|
|
||||||
match name {
|
match name {
|
||||||
BinOp::Eq => match &*left.tipo() {
|
BinOp::Eq => match &*left.tipo() {
|
||||||
Type::App { name, .. } => match name.as_str() {
|
Type::App { name, .. } => match name.as_str() {
|
||||||
|
@ -645,10 +564,20 @@ impl<'a> CodeGenerator<'a> {
|
||||||
argument: right_term.into(),
|
argument: right_term.into(),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"ByteArray" => Term::Apply {
|
||||||
|
function: Term::Apply {
|
||||||
|
function: Term::Builtin(DefaultFunction::EqualsByteString)
|
||||||
|
.into(),
|
||||||
|
argument: left_term.into(),
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
argument: right_term.into(),
|
||||||
|
},
|
||||||
|
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
},
|
},
|
||||||
Type::Fn { args, ret } => todo!(),
|
Type::Fn { .. } => todo!(),
|
||||||
Type::Var { tipo } => todo!(),
|
Type::Var { .. } => todo!(),
|
||||||
},
|
},
|
||||||
BinOp::And => todo!(),
|
BinOp::And => todo!(),
|
||||||
BinOp::Or => todo!(),
|
BinOp::Or => todo!(),
|
||||||
|
@ -681,46 +610,24 @@ impl<'a> CodeGenerator<'a> {
|
||||||
.into(),
|
.into(),
|
||||||
},
|
},
|
||||||
|
|
||||||
Pattern::VarUsage {
|
Pattern::VarUsage { .. } => todo!(),
|
||||||
location,
|
Pattern::Assign { .. } => todo!(),
|
||||||
name,
|
|
||||||
tipo,
|
|
||||||
} => todo!(),
|
|
||||||
Pattern::Assign {
|
|
||||||
name,
|
|
||||||
location,
|
|
||||||
pattern,
|
|
||||||
} => todo!(),
|
|
||||||
Pattern::Discard { .. } => todo!(),
|
Pattern::Discard { .. } => todo!(),
|
||||||
Pattern::List {
|
Pattern::List { .. } => todo!(),
|
||||||
location,
|
Pattern::Constructor { .. } => todo!(),
|
||||||
elements,
|
|
||||||
tail,
|
|
||||||
} => todo!(),
|
|
||||||
Pattern::Constructor {
|
|
||||||
location,
|
|
||||||
name,
|
|
||||||
arguments,
|
|
||||||
module,
|
|
||||||
constructor,
|
|
||||||
with_spread,
|
|
||||||
tipo,
|
|
||||||
} => todo!(),
|
|
||||||
},
|
},
|
||||||
TypedExpr::Try {
|
TypedExpr::Try { .. } => todo!(),
|
||||||
location,
|
|
||||||
tipo,
|
|
||||||
value,
|
|
||||||
then,
|
|
||||||
pattern,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::When {
|
TypedExpr::When {
|
||||||
subjects, clauses, ..
|
subjects, clauses, ..
|
||||||
} => {
|
} => {
|
||||||
let current_clauses = clauses.clone();
|
let current_clauses = clauses.clone();
|
||||||
|
|
||||||
let mut data_type = "".to_string();
|
let mut data_type = "".to_string();
|
||||||
|
|
||||||
let mut current_module = "".to_string();
|
let mut current_module = "".to_string();
|
||||||
|
|
||||||
let mut total_constr_length = 0;
|
let mut total_constr_length = 0;
|
||||||
|
|
||||||
let mut new_current_clauses: Vec<(usize, TypedExpr)> = current_clauses
|
let mut new_current_clauses: Vec<(usize, TypedExpr)> = current_clauses
|
||||||
.iter()
|
.iter()
|
||||||
.map(|clause| {
|
.map(|clause| {
|
||||||
|
@ -756,8 +663,11 @@ impl<'a> CodeGenerator<'a> {
|
||||||
new_current_clauses.sort_by(|a, b| a.0.cmp(&b.0));
|
new_current_clauses.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
|
|
||||||
let subject = &subjects[0];
|
let subject = &subjects[0];
|
||||||
|
|
||||||
let mut is_var = false;
|
let mut is_var = false;
|
||||||
|
|
||||||
let mut current_var_name = "".to_string();
|
let mut current_var_name = "".to_string();
|
||||||
|
|
||||||
let mut current_subject = subject.clone();
|
let mut current_subject = subject.clone();
|
||||||
|
|
||||||
while !is_var {
|
while !is_var {
|
||||||
|
@ -873,7 +783,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
term
|
term
|
||||||
}
|
}
|
||||||
//if statements increase scope due to branching.
|
// if statements increase scope due to branching.
|
||||||
TypedExpr::If {
|
TypedExpr::If {
|
||||||
branches,
|
branches,
|
||||||
final_else,
|
final_else,
|
||||||
|
@ -932,7 +842,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//TODO: for multi branch if statements we can insert function definitions between branches
|
// TODO: for multi branch if statements we can insert function definitions between branches
|
||||||
for branch in branches {
|
for branch in branches {
|
||||||
let condition_term = self.recurse_code_gen(
|
let condition_term = self.recurse_code_gen(
|
||||||
&branch.condition,
|
&branch.condition,
|
||||||
|
@ -961,6 +871,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.maybe_insert_def(final_if_term, scope_level)
|
self.maybe_insert_def(final_if_term, scope_level)
|
||||||
}
|
}
|
||||||
TypedExpr::RecordAccess { label, record, .. } => {
|
TypedExpr::RecordAccess { label, record, .. } => {
|
||||||
|
@ -1001,43 +912,17 @@ impl<'a> CodeGenerator<'a> {
|
||||||
unique: 0.into(),
|
unique: 0.into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
TypedExpr::ModuleSelect {
|
TypedExpr::ModuleSelect { constructor, .. } => match constructor {
|
||||||
location,
|
ModuleValueConstructor::Record { .. } => todo!(),
|
||||||
tipo,
|
ModuleValueConstructor::Fn { module, name, .. } => Term::Var(Name {
|
||||||
label,
|
|
||||||
module_name,
|
|
||||||
module_alias,
|
|
||||||
constructor,
|
|
||||||
} => match constructor {
|
|
||||||
ModuleValueConstructor::Record {
|
|
||||||
name,
|
|
||||||
arity,
|
|
||||||
tipo,
|
|
||||||
field_map,
|
|
||||||
location,
|
|
||||||
} => todo!(),
|
|
||||||
ModuleValueConstructor::Fn {
|
|
||||||
location,
|
|
||||||
module,
|
|
||||||
name,
|
|
||||||
} => Term::Var(Name {
|
|
||||||
text: format!("{module}_{name}"),
|
text: format!("{module}_{name}"),
|
||||||
unique: 0.into(),
|
unique: 0.into(),
|
||||||
}),
|
}),
|
||||||
ModuleValueConstructor::Constant { literal, location } => todo!(),
|
ModuleValueConstructor::Constant { .. } => todo!(),
|
||||||
},
|
},
|
||||||
TypedExpr::Todo {
|
TypedExpr::Todo { .. } => todo!(),
|
||||||
location,
|
TypedExpr::RecordUpdate { .. } => todo!(),
|
||||||
label,
|
TypedExpr::Negate { .. } => todo!(),
|
||||||
tipo,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::RecordUpdate {
|
|
||||||
location,
|
|
||||||
tipo,
|
|
||||||
spread,
|
|
||||||
args,
|
|
||||||
} => todo!(),
|
|
||||||
TypedExpr::Negate { location, value } => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,8 +1197,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_arg_getter(&self, term: Term<Name>) -> Term<Name> {
|
fn add_arg_getter(&self, term: Term<Name>) -> Term<Name> {
|
||||||
//Apply constr arg getter to top level.
|
// Apply constr arg getter to top level.
|
||||||
|
|
||||||
Term::Apply {
|
Term::Apply {
|
||||||
function: Term::Lambda {
|
function: Term::Lambda {
|
||||||
parameter_name: Name {
|
parameter_name: Name {
|
||||||
|
|
Loading…
Reference in New Issue