cli/commands/
eval.rs

1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6
7use ion::Context;
8use modules::Modules;
9use mozjs::rust::{JSEngine, Runtime};
10use runtime::RuntimeBuilder;
11
12use crate::evaluate::eval_inline;
13
14pub(crate) async fn eval_source(source: &str) {
15	let engine = JSEngine::init().unwrap();
16	let rt = Runtime::new(engine.handle());
17
18	let cx = &mut Context::from_runtime(&rt);
19	let rt = RuntimeBuilder::<(), _>::new()
20		.microtask_queue()
21		.macrotask_queue()
22		.standard_modules(Modules)
23		.build(cx);
24	eval_inline(&rt, source).await;
25}