web engine - experimental web browser
at x25519 32 lines 1.1 kB view raw
1//! JavaScript engine — lexer, parser, bytecode, register VM, GC, JIT (AArch64). 2 3use std::fmt; 4 5/// An error produced by the JavaScript engine. 6#[derive(Debug)] 7pub enum JsError { 8 /// The engine does not yet support this feature or syntax. 9 NotImplemented, 10 /// A parse/syntax error in the source. 11 SyntaxError(String), 12 /// A runtime error during execution. 13 RuntimeError(String), 14} 15 16impl fmt::Display for JsError { 17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 18 match self { 19 JsError::NotImplemented => write!(f, "not implemented"), 20 JsError::SyntaxError(msg) => write!(f, "SyntaxError: {}", msg), 21 JsError::RuntimeError(msg) => write!(f, "RuntimeError: {}", msg), 22 } 23 } 24} 25 26/// Evaluate a JavaScript source string and return the completion value. 27/// 28/// This is a stub that always returns `NotImplemented`. The real 29/// implementation will lex, parse, compile to bytecode, and execute. 30pub fn evaluate(_source: &str) -> Result<(), JsError> { 31 Err(JsError::NotImplemented) 32}