Changeset - 390da0a44204
[Not reviewed]
0 4 0
mh - 3 years ago 2022-05-18 14:14:32
contact@maxhenger.nl
Update to tests
4 files changed with 33 insertions and 23 deletions:
0 comments (0 inline, 0 general)
src/protocol/ast.rs
Show inline comments
 
@@ -1170,30 +1170,35 @@ impl Statement {
 
        }
 
    }
 

	
 
    pub fn span(&self) -> InputSpan {
 
    pub fn maybe_span(&self) -> Option<InputSpan> {
 
        match self {
 
            Statement::Block(v) => v.span,
 
            Statement::Local(v) => v.span(),
 
            Statement::Labeled(v) => v.label.span,
 
            Statement::If(v) => v.span,
 
            Statement::While(v) => v.span,
 
            Statement::Break(v) => v.span,
 
            Statement::Continue(v) => v.span,
 
            Statement::Synchronous(v) => v.span,
 
            Statement::Fork(v) => v.span,
 
            Statement::Select(v) => v.span,
 
            Statement::Return(v) => v.span,
 
            Statement::Goto(v) => v.span,
 
            Statement::New(v) => v.span,
 
            Statement::Expression(v) => v.span,
 
            Statement::Block(v) => Some(v.span),
 
            Statement::Local(v) => Some(v.span()),
 
            Statement::Labeled(v) => Some(v.label.span),
 
            Statement::If(v) => Some(v.span),
 
            Statement::While(v) => Some(v.span),
 
            Statement::Break(v) => Some(v.span),
 
            Statement::Continue(v) => Some(v.span),
 
            Statement::Synchronous(v) => Some(v.span),
 
            Statement::Fork(v) => Some(v.span),
 
            Statement::Select(v) => Some(v.span),
 
            Statement::Return(v) => Some(v.span),
 
            Statement::Goto(v) => Some(v.span),
 
            Statement::New(v) => Some(v.span),
 
            Statement::Expression(v) => Some(v.span),
 
            Statement::EndBlock(_)
 
            | Statement::EndIf(_)
 
            | Statement::EndWhile(_)
 
            | Statement::EndSynchronous(_)
 
            | Statement::EndFork(_)
 
            | Statement::EndSelect(_) => unreachable!(),
 
            | Statement::EndSelect(_) => None,
 
        }
 
    }
 

	
 
    pub fn span(&self) -> InputSpan {
 
        return self.maybe_span().unwrap();
 
    }
 

	
 
    pub fn link_next(&mut self, next: StatementId) {
 
        match self {
 
            Statement::Block(stmt) => stmt.next = next,
src/protocol/eval/error.rs
Show inline comments
 
@@ -10,7 +10,7 @@ use super::executor::*;
 
/// Represents a stack frame recorded in an error
 
#[derive(Debug)]
 
pub struct EvalFrame {
 
    pub line: u32,
 
    pub line: Option<u32>,
 
    pub module_name: String,
 
    pub procedure: String, // function or component
 
    pub is_func: bool,
 
@@ -24,10 +24,15 @@ impl fmt::Display for EvalFrame {
 
            "component"
 
        };
 

	
 
        let line_str = match self.line {
 
            Some(line_number) => line_number.to_string(),
 
            None => String::from("??"),
 
        };
 

	
 
        if self.module_name.is_empty() {
 
            write!(f, "{} {}:{}", func_or_comp, &self.procedure, self.line)
 
            write!(f, "{} {}:{}", func_or_comp, &self.procedure, line_str)
 
        } else {
 
            write!(f, "{} {}:{}:{}", func_or_comp, &self.module_name, &self.procedure, self.line)
 
            write!(f, "{} {}:{}:{}", func_or_comp, &self.module_name, &self.procedure, line_str)
 
        }
 
    }
 
}
 
@@ -50,7 +55,7 @@ impl EvalError {
 
        for frame in prompt.frames.iter() {
 
            let definition = &heap[frame.definition];
 
            let statement = &heap[frame.position];
 
            let statement_span = statement.span();
 
            let statement_span = statement.maybe_span();
 

	
 
            // Lookup module name, if it has one
 
            let module = modules.iter().find(|m| m.root_id == definition.defined_in).unwrap();
 
@@ -62,7 +67,7 @@ impl EvalError {
 

	
 
            last_module_source = &module.source;
 
            frames.push(EvalFrame{
 
                line: statement_span.begin.line,
 
                line: statement_span.map(|v| v.begin.line),
 
                module_name,
 
                procedure: definition.identifier.value.as_str().to_string(),
 
                is_func: definition.kind == ProcedureKind::Function,
src/runtime2/component/consensus.rs
Show inline comments
 
@@ -331,7 +331,7 @@ impl Consensus {
 
    /// we've failed and wait until all the participants have been notified of
 
    /// the error.
 
    pub(crate) fn notify_sync_end_failure(&mut self, sched_ctx: &SchedulerCtx, comp_ctx: &CompCtx) -> SyncRoundDecision {
 
        debug_assert_eq!(self.mode, Mode::SyncBusy);
 
        // debug_assert_eq!(self.mode, Mode::SyncBusy);
 
        self.mode = Mode::SyncAwaitingSolution;
 

	
 
        let local_solution = self.generate_local_solution(comp_ctx, true);
src/runtime2/tests/mod.rs
Show inline comments
 
@@ -14,7 +14,7 @@ const NUM_THREADS: u32 = 1;
 
pub(crate) fn compile_and_create_component(source: &str, routine_name: &str, args: ValueGroup) {
 
    let protocol = ProtocolDescription::parse(source.as_bytes())
 
        .expect("successful compilation");
 
    let runtime = Runtime::new(NUM_THREADS, LogLevel::None, protocol)
 
    let runtime = Runtime::new(NUM_THREADS, LOG_LEVEL, protocol)
 
        .expect("successful runtime startup");
 
    create_component(&runtime, "", routine_name, args);
 
}
0 comments (0 inline, 0 general)