Use Engine's interner.

This commit is contained in:
Stephen Chung
2022-11-24 15:10:17 +08:00
parent 6791ef64da
commit d1913edf3c
8 changed files with 136 additions and 107 deletions

View File

@@ -1,7 +1,6 @@
//! Module that defines the public compilation API of [`Engine`].
use crate::parser::{ParseResult, ParseState};
use crate::types::StringsInterner;
use crate::{Engine, OptimizationLevel, Scope, AST};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
@@ -222,7 +221,8 @@ impl Engine {
scripts.as_ref(),
self.token_mapper.as_ref().map(<_>::as_ref),
);
let mut state = ParseState::new(self, scope, StringsInterner::default(), tokenizer_control);
let interned_strings = &mut *self.interned_strings.borrow_mut();
let mut state = ParseState::new(self, scope, interned_strings, tokenizer_control);
let mut _ast = self.parse(&mut stream.peekable(), &mut state, optimization_level)?;
#[cfg(feature = "metadata")]
_ast.set_doc(state.tokenizer_control.borrow().global_comments.join("\n"));
@@ -295,7 +295,8 @@ impl Engine {
self.lex_raw(&scripts, self.token_mapper.as_ref().map(<_>::as_ref));
let mut peekable = stream.peekable();
let mut state = ParseState::new(self, scope, StringsInterner::default(), tokenizer_control);
let interned_strings = &mut *self.interned_strings.borrow_mut();
let mut state = ParseState::new(self, scope, interned_strings, tokenizer_control);
self.parse_global_expr(&mut peekable, &mut state, |_| {}, self.optimization_level)
}
}