tests 1 through 10 pass now, add negate
This commit is contained in:
parent
6e46e7562e
commit
eddd202253
|
@ -216,7 +216,6 @@ pub enum Air {
|
||||||
|
|
||||||
Negate {
|
Negate {
|
||||||
scope: Vec<u64>,
|
scope: Vec<u64>,
|
||||||
value: Box<Self>,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
TupleAccessor {
|
TupleAccessor {
|
||||||
|
|
|
@ -747,7 +747,8 @@ pub fn match_ir_for_recursion(
|
||||||
|
|
||||||
pub fn find_generics_to_replace(tipo: &mut Arc<Type>, generic_types: &HashMap<u64, Arc<Type>>) {
|
pub fn find_generics_to_replace(tipo: &mut Arc<Type>, generic_types: &HashMap<u64, Arc<Type>>) {
|
||||||
if let Some(id) = tipo.get_generic() {
|
if let Some(id) = tipo.get_generic() {
|
||||||
*tipo = generic_types.get(&id).unwrap().clone();
|
//If generic does not have a type we know of like a None in option then just use same type
|
||||||
|
*tipo = generic_types.get(&id).unwrap_or(tipo).clone();
|
||||||
} else if tipo.is_generic() {
|
} else if tipo.is_generic() {
|
||||||
match &**tipo {
|
match &**tipo {
|
||||||
Type::App {
|
Type::App {
|
||||||
|
|
|
@ -484,7 +484,13 @@ impl<'a> CodeGenerator<'a> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
TypedExpr::RecordUpdate { .. } => todo!(),
|
TypedExpr::RecordUpdate { .. } => todo!(),
|
||||||
TypedExpr::Negate { .. } => todo!(),
|
TypedExpr::Negate { value, .. } => {
|
||||||
|
ir_stack.push(Air::Negate {
|
||||||
|
scope: scope.clone(),
|
||||||
|
});
|
||||||
|
|
||||||
|
self.build_ir(value, ir_stack, scope);
|
||||||
|
}
|
||||||
TypedExpr::Tuple { elems, tipo, .. } => {
|
TypedExpr::Tuple { elems, tipo, .. } => {
|
||||||
ir_stack.push(Air::Tuple {
|
ir_stack.push(Air::Tuple {
|
||||||
scope: scope.clone(),
|
scope: scope.clone(),
|
||||||
|
@ -3638,7 +3644,25 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
Air::Record { .. } => todo!(),
|
Air::Record { .. } => todo!(),
|
||||||
Air::RecordUpdate { .. } => todo!(),
|
Air::RecordUpdate { .. } => todo!(),
|
||||||
Air::Negate { .. } => todo!(),
|
Air::Negate { .. } => {
|
||||||
|
let value = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
let term = Term::Apply {
|
||||||
|
function: Term::Apply {
|
||||||
|
function: Term::Apply {
|
||||||
|
function: Term::Builtin(DefaultFunction::IfThenElse)
|
||||||
|
.force_wrap()
|
||||||
|
.into(),
|
||||||
|
argument: value.into(),
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
argument: Term::Constant(UplcConstant::Bool(false)).into(),
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
argument: Term::Constant(UplcConstant::Bool(true)).into(),
|
||||||
|
};
|
||||||
|
arg_stack.push(term);
|
||||||
|
}
|
||||||
Air::TupleAccessor { tipo, names, .. } => {
|
Air::TupleAccessor { tipo, names, .. } => {
|
||||||
let value = arg_stack.pop().unwrap();
|
let value = arg_stack.pop().unwrap();
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
Loading…
Reference in New Issue