fix: expect void now checks for unit instead of expecting data

Args in validator are now fully expected on.
Add new air FieldsEmpty to make checking for empty constructors easier
This commit is contained in:
Kasey White
2023-04-03 14:28:38 -04:00
committed by Kasey
parent 23b72e18f3
commit ddf0fbfa0a
3 changed files with 118 additions and 12 deletions

View File

@@ -216,6 +216,9 @@ pub enum Air {
Noop {
scope: Scope,
},
FieldsEmpty {
scope: Scope,
},
}
impl Air {
@@ -253,6 +256,7 @@ impl Air {
| Air::RecordUpdate { scope, .. }
| Air::RecordAccess { scope, .. }
| Air::FieldsExpose { scope, .. }
| Air::FieldsEmpty { scope }
| Air::ListAccessor { scope, .. }
| Air::ListExpose { scope, .. }
| Air::TupleAccessor { scope, .. }
@@ -296,6 +300,7 @@ impl Air {
| Air::RecordUpdate { scope, .. }
| Air::RecordAccess { scope, .. }
| Air::FieldsExpose { scope, .. }
| Air::FieldsEmpty { scope }
| Air::ListAccessor { scope, .. }
| Air::ListExpose { scope, .. }
| Air::TupleAccessor { scope, .. }
@@ -392,6 +397,7 @@ impl Air {
| Air::AssertBool { .. }
| Air::Finally { .. }
| Air::FieldsExpose { .. }
| Air::FieldsEmpty { .. }
| Air::Noop { .. } => None,
Air::UnOp { op, .. } => match op {
UnOp::Not => Some(

View File

@@ -5,6 +5,7 @@ use uplc::{builder::EXPECT_ON_LIST, builtins::DefaultFunction};
use crate::{
ast::Span,
builtins::void,
tipo::{Type, ValueConstructor, ValueConstructorVariant},
IdGenerator,
};
@@ -337,6 +338,16 @@ impl AirStack {
self.merge_child(value);
}
pub fn fields_empty(&mut self, value: AirStack) {
self.new_scope();
self.air.push(Air::FieldsEmpty {
scope: self.scope.clone(),
});
self.merge_child(value);
}
pub fn clause(
&mut self,
tipo: Arc<Type>,
@@ -682,6 +693,19 @@ impl AirStack {
scope: self.scope.clone(),
});
}
pub fn choose_unit(&mut self, value_stack: AirStack) {
self.new_scope();
self.air.push(Air::Builtin {
scope: self.scope.clone(),
func: DefaultFunction::ChooseUnit,
tipo: void(),
count: DefaultFunction::ChooseUnit.arity(),
});
self.merge_child(value_stack);
}
}
#[cfg(test)]