pub struct JsEngine {Show 36 fields
pub globals: BTreeMap<String, JsValue>,
pub root_scope: Rc<RefCell<Scope>>,
pub current_scope: Rc<RefCell<Scope>>,
pub document: Document,
pub console_logs: Vec<String>,
pub user_functions: HashMap<String, JsClosure>,
pub closures: HashMap<u64, JsClosure>,
pub next_closure_id: u64,
pub call_depth: usize,
pub live_nodes: RefCell<HashMap<u64, DomNode>>,
pub anon_counter: usize,
pub classes: HashMap<String, ClassDef>,
pub promises: HashMap<u64, JsPromise<JsValue>>,
pub promise_controllers: HashMap<u64, (ResolveFn<JsValue>, RejectFn)>,
pub next_promise_id: u64,
pub pending_throw: Option<JsValue>,
pub next_symbol_id: u64,
pub symbol_registry: HashMap<String, SymbolId>,
pub object_prototype: BTreeMap<String, JsValue>,
pub array_prototype: BTreeMap<String, JsValue>,
pub function_prototype: BTreeMap<String, JsValue>,
pub string_prototype: BTreeMap<String, JsValue>,
pub error_prototype: BTreeMap<String, JsValue>,
pub memory_limit_bytes: Option<usize>,
pub allocated_memory_bytes: usize,
pub freeze_prototypes: bool,
pub allow_prototype_mutation: bool,
pub eval_depth: usize,
pub is_strict: bool,
pub weak_maps: RefCell<HashMap<u64, HashMap<usize, JsValue>>>,
pub next_weak_id: u64,
pub weak_sets: RefCell<HashMap<u64, HashSet<usize>>>,
pub weak_refs: RefCell<WeakObjectMap>,
pub generators: RefCell<HashMap<u64, GeneratorInstance>>,
pub next_generator_id: u64,
pub pending_yield: Option<JsValue>,
}Fields§
§globals: BTreeMap<String, JsValue>§root_scope: Rc<RefCell<Scope>>§current_scope: Rc<RefCell<Scope>>§document: Document§console_logs: Vec<String>§user_functions: HashMap<String, JsClosure>§closures: HashMap<u64, JsClosure>§next_closure_id: u64§call_depth: usize§live_nodes: RefCell<HashMap<u64, DomNode>>§anon_counter: usize§classes: HashMap<String, ClassDef>§promises: HashMap<u64, JsPromise<JsValue>>§promise_controllers: HashMap<u64, (ResolveFn<JsValue>, RejectFn)>§next_promise_id: u64§pending_throw: Option<JsValue>§next_symbol_id: u64§symbol_registry: HashMap<String, SymbolId>§object_prototype: BTreeMap<String, JsValue>§array_prototype: BTreeMap<String, JsValue>§function_prototype: BTreeMap<String, JsValue>§string_prototype: BTreeMap<String, JsValue>§error_prototype: BTreeMap<String, JsValue>§memory_limit_bytes: Option<usize>§allocated_memory_bytes: usize§freeze_prototypes: bool§allow_prototype_mutation: bool§eval_depth: usize§is_strict: bool§weak_maps: RefCell<HashMap<u64, HashMap<usize, JsValue>>>§next_weak_id: u64§weak_sets: RefCell<HashMap<u64, HashSet<usize>>>§weak_refs: RefCell<WeakObjectMap>§generators: RefCell<HashMap<u64, GeneratorInstance>>§next_generator_id: u64§pending_yield: Option<JsValue>Implementations§
Source§impl JsEngine
impl JsEngine
pub fn execute_statement(&mut self, stmt: &Stmt) -> Result<JsValue, String>
pub fn execute_stmt_flow( &mut self, stmt: &Stmt, ) -> Result<StatementFlow, String>
pub fn call_value( &mut self, callee: &JsValue, args: Vec<JsValue>, ) -> Result<JsValue, String>
pub fn call_value_with_this( &mut self, callee: &JsValue, args: Vec<JsValue>, this_val: Option<JsValue>, ) -> Result<JsValue, String>
pub fn eval_expr(&mut self, expr: &Expr) -> Result<JsValue, String>
pub fn call_closure( &mut self, closure: &JsClosure, args: Vec<JsValue>, ) -> Result<JsValue, String>
pub fn call_closure_with_this( &mut self, closure: &JsClosure, args: Vec<JsValue>, this_val: Option<JsValue>, ) -> Result<JsValue, String>
pub fn step_generator( &mut self, gen_id: u64, _next_arg: Option<JsValue>, ) -> Result<JsValue, String>
pub fn to_bigint(&self, val: &JsValue) -> Result<JsValue, String>
pub fn call_function( &mut self, name: &str, args: Vec<JsValue>, ) -> Result<JsValue, String>
Source§impl JsEngine
impl JsEngine
pub fn new() -> Self
pub fn with_document(doc: Document) -> Self
Sourcepub fn with_memory_limit(self, limit_bytes: usize) -> Self
pub fn with_memory_limit(self, limit_bytes: usize) -> Self
Sets a strict memory allocation threshold in bytes (e.g. 64MB for sandbox).
Sourcepub fn set_freeze_prototypes(&mut self, freeze: bool)
pub fn set_freeze_prototypes(&mut self, freeze: bool)
Enables or disables prototype freezing to prevent prototype pollution.
Sourcepub fn with_allow_prototype_mutation(self, allow: bool) -> Self
pub fn with_allow_prototype_mutation(self, allow: bool) -> Self
Sets whether prototype mutation is allowed on root Object.prototype or via proto.
Sourcepub fn set_allow_prototype_mutation(&mut self, allow: bool)
pub fn set_allow_prototype_mutation(&mut self, allow: bool)
Toggles prototype mutation permissions on root prototypes and proto.
Sourcepub fn allocate_bytes(&mut self, bytes: usize) -> Result<(), String>
pub fn allocate_bytes(&mut self, bytes: usize) -> Result<(), String>
Tracks heap memory allocations and enforces memory limit quotas.
pub fn prune_dead_closures(&mut self)
pub fn maybe_prune_closures(&mut self)
pub fn compile_regex(&self, pattern: &str, flags: &str) -> Result<Regex, String>
pub fn create_regex_value( &self, pattern: &str, flags: &str, ) -> Result<JsValue, String>
pub fn create_promise_value(&mut self, promise: JsPromise<JsValue>) -> JsValue
pub fn tick_engine_timers(&mut self) -> usize
pub fn tick_timers(&mut self) -> usize
pub fn resolve_constructor( &self, class_name: &str, ) -> Option<(Vec<String>, Vec<Stmt>, Option<String>)>
pub fn resolve_method( &self, class_name: &str, method_name: &str, ) -> Option<(Vec<String>, Vec<Stmt>, Option<String>)>
pub fn is_instance_of(&self, instance: &JsValue, class_name: &str) -> bool
pub fn instantiate_class( &mut self, class_name: &str, args: Vec<JsValue>, ) -> Result<JsValue, String>
pub fn eval(&mut self, script: &str) -> Result<JsValue, String>
pub fn dom_node_to_js(&self, node: &DomNode) -> JsValue
pub fn create_error_from_string(&self, err_msg: &str) -> JsValue
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for JsEngine
impl !RefUnwindSafe for JsEngine
impl !Send for JsEngine
impl !Sync for JsEngine
impl !UnwindSafe for JsEngine
impl Forget for JsEngine
impl Move for JsEngine
impl Unpin for JsEngine
impl UnsafeUnpin for JsEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more