1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use super::{Context, Executable, InterpreterState};
use crate::{
    syntax::ast::node::{Break, Continue},
    Result, Value,
};

#[cfg(test)]
mod tests;

impl Executable for Break {
    fn run(&self, interpreter: &mut Context) -> Result<Value> {
        interpreter
            .executor()
            .set_current_state(InterpreterState::Break(self.label().map(Box::from)));

        Ok(Value::undefined())
    }
}

impl Executable for Continue {
    fn run(&self, interpreter: &mut Context) -> Result<Value> {
        interpreter
            .executor()
            .set_current_state(InterpreterState::Continue(self.label().map(Box::from)));

        Ok(Value::undefined())
    }
}