Code gen now handles expecting on validator args in the air stack.
Thus allowing us to use code gen created functions to expect on data types including recursive ones. Some minor tweaks to the air. Added a uplc optimization for later.
This commit is contained in:
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use uplc::builtins::DefaultFunction;
|
||||
|
||||
use crate::{
|
||||
ast::{Arg, BinOp, UnOp},
|
||||
ast::{BinOp, UnOp},
|
||||
tipo::{Type, ValueConstructor},
|
||||
};
|
||||
|
||||
@@ -213,9 +213,8 @@ pub enum Air {
|
||||
scope: Scope,
|
||||
tipo: Arc<Type>,
|
||||
},
|
||||
Validator {
|
||||
NoOp {
|
||||
scope: Scope,
|
||||
params: Vec<Arg<Arc<Type>>>,
|
||||
},
|
||||
FieldsEmpty {
|
||||
scope: Scope,
|
||||
@@ -264,7 +263,7 @@ impl Air {
|
||||
| Air::TupleIndex { scope, .. }
|
||||
| Air::ErrorTerm { scope, .. }
|
||||
| Air::Trace { scope, .. }
|
||||
| Air::Validator { scope, .. } => scope.clone(),
|
||||
| Air::NoOp { scope, .. } => scope.clone(),
|
||||
}
|
||||
}
|
||||
pub fn scope_mut(&mut self) -> &mut Scope {
|
||||
@@ -308,7 +307,7 @@ impl Air {
|
||||
| Air::TupleIndex { scope, .. }
|
||||
| Air::ErrorTerm { scope, .. }
|
||||
| Air::Trace { scope, .. }
|
||||
| Air::Validator { scope, .. } => scope,
|
||||
| Air::NoOp { scope, .. } => scope,
|
||||
}
|
||||
}
|
||||
pub fn tipo(&self) -> Option<Arc<Type>> {
|
||||
@@ -399,7 +398,7 @@ impl Air {
|
||||
| Air::Finally { .. }
|
||||
| Air::FieldsExpose { .. }
|
||||
| Air::FieldsEmpty { .. }
|
||||
| Air::Validator { .. } => None,
|
||||
| Air::NoOp { .. } => None,
|
||||
Air::UnOp { op, .. } => match op {
|
||||
UnOp::Not => Some(
|
||||
Type::App {
|
||||
|
||||
@@ -1492,14 +1492,18 @@ pub fn handle_func_dependencies(
|
||||
air: recursion_ir,
|
||||
};
|
||||
|
||||
temp_stack.define_func(
|
||||
dependency.function_name.clone(),
|
||||
dependency.module_name.clone(),
|
||||
dependency.variant_name.clone(),
|
||||
depend_comp.args.clone(),
|
||||
depend_comp.recursive,
|
||||
recursion_stack,
|
||||
);
|
||||
if depend_comp.is_code_gen_func {
|
||||
temp_stack = recursion_stack;
|
||||
} else {
|
||||
temp_stack.define_func(
|
||||
dependency.function_name.clone(),
|
||||
dependency.module_name.clone(),
|
||||
dependency.variant_name.clone(),
|
||||
depend_comp.args.clone(),
|
||||
depend_comp.recursive,
|
||||
recursion_stack,
|
||||
);
|
||||
}
|
||||
|
||||
let mut temp_ir = temp_stack.complete();
|
||||
|
||||
@@ -1550,7 +1554,7 @@ pub fn handle_recursion_ir(
|
||||
tipo,
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
_ => unreachable!("Will support not using call right away later."),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use indexmap::IndexSet;
|
||||
use uplc::{builder::EXPECT_ON_LIST, builtins::DefaultFunction};
|
||||
|
||||
use crate::{
|
||||
ast::{Arg, Span},
|
||||
ast::Span,
|
||||
builtins::{data, list, void},
|
||||
tipo::{Type, ValueConstructor, ValueConstructorVariant},
|
||||
IdGenerator,
|
||||
@@ -701,12 +701,11 @@ impl AirStack {
|
||||
self.merge_child(body_stack);
|
||||
}
|
||||
|
||||
pub fn validator(&mut self, params: Vec<Arg<Arc<Type>>>) {
|
||||
pub fn noop(&mut self) {
|
||||
self.new_scope();
|
||||
|
||||
self.air.push(Air::Validator {
|
||||
self.air.push(Air::NoOp {
|
||||
scope: self.scope.clone(),
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user