move 'EvalInfo' to project::script & define a new 'EvalHint'

This commit is contained in:
KtorZ 2022-12-14 22:00:09 +01:00
parent 921e7abbb6
commit 7b22b63ad8
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 21 additions and 10 deletions

View File

@ -1,3 +1,5 @@
use crate::{ExBudget, Term};
use aiken_lang::ast::BinOp;
use std::path::PathBuf; use std::path::PathBuf;
use uplc::ast::{NamedDeBruijn, Program}; use uplc::ast::{NamedDeBruijn, Program};
@ -7,6 +9,7 @@ pub struct Script {
pub module: String, pub module: String,
pub name: String, pub name: String,
pub program: Program<NamedDeBruijn>, pub program: Program<NamedDeBruijn>,
pub evaluation_hint: Option<EvalHint>,
} }
impl Script { impl Script {
@ -15,12 +18,29 @@ impl Script {
module: String, module: String,
name: String, name: String,
program: Program<NamedDeBruijn>, program: Program<NamedDeBruijn>,
evaluation_hint: Option<EvalHint>,
) -> Script { ) -> Script {
Script { Script {
input_path, input_path,
module, module,
name, name,
program, program,
evaluation_hint,
} }
} }
} }
#[derive(Debug, Clone)]
pub struct EvalHint {
pub bin_op: BinOp,
pub left: Program<NamedDeBruijn>,
pub right: Program<NamedDeBruijn>,
}
#[derive(Debug)]
pub struct EvalInfo {
pub success: bool,
pub script: Script,
pub spent_budget: ExBudget,
pub output: Option<Term<NamedDeBruijn>>,
}

View File

@ -1,7 +1,5 @@
use crate::script::Script; use crate::script::EvalInfo;
use std::path::PathBuf; use std::path::PathBuf;
use uplc::ast::{NamedDeBruijn, Term};
use uplc::machine::cost_model::ExBudget;
pub trait EventListener: std::fmt::Debug { pub trait EventListener: std::fmt::Debug {
fn handle_event(&self, event: Event); fn handle_event(&self, event: Event);
@ -26,10 +24,3 @@ pub enum Event {
tests: Vec<EvalInfo>, tests: Vec<EvalInfo>,
}, },
} }
pub struct EvalInfo {
pub success: bool,
pub script: Script,
pub spent_budget: ExBudget,
pub output: Option<Term<NamedDeBruijn>>,
}