From e7476a1a28f7872b7771b48600bcce8e8b1d9e54 Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Thu, 19 Dec 2024 09:51:12 +0000 Subject: [PATCH] refactor(semantic): remove `serialize` (#8015) --- Cargo.lock | 3 - crates/oxc_semantic/Cargo.toml | 6 +- crates/oxc_semantic/src/builder.rs | 3 +- crates/oxc_semantic/src/lib.rs | 4 +- crates/oxc_semantic/src/reference.rs | 119 ---------------------- crates/oxc_semantic/src/symbol.rs | 17 +--- crates/oxc_syntax/src/reference.rs | 106 ++++++++++++++++++++ crates/oxc_wasm/src/lib.rs | 42 +++++++- npm/oxc-wasm/oxc_wasm.d.ts | 45 +++------ npm/oxc-wasm/oxc_wasm.js | 142 +++++++++++++++++++-------- 10 files changed, 262 insertions(+), 225 deletions(-) delete mode 100644 crates/oxc_semantic/src/reference.rs diff --git a/Cargo.lock b/Cargo.lock index 3b32c9a4b2a44..680ae0ab7fcf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1929,10 +1929,7 @@ dependencies = [ "oxc_syntax", "phf", "rustc-hash", - "serde", "serde_json", - "tsify", - "wasm-bindgen", ] [[package]] diff --git a/crates/oxc_semantic/Cargo.toml b/crates/oxc_semantic/Cargo.toml index facd8e08fcfa6..1b915140ac4f6 100644 --- a/crates/oxc_semantic/Cargo.toml +++ b/crates/oxc_semantic/Cargo.toml @@ -35,10 +35,6 @@ itertools = { workspace = true } phf = { workspace = true, features = ["macros"] } rustc-hash = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } -tsify = { workspace = true, optional = true } -wasm-bindgen = { workspace = true, optional = true } - [dev-dependencies] oxc_parser = { workspace = true } @@ -50,4 +46,4 @@ serde_json = { workspace = true } [features] default = [] -serialize = ["dep:serde", "dep:tsify", "dep:wasm-bindgen", "oxc_span/serialize", "oxc_syntax/serialize"] +serialize = ["oxc_span/serialize", "oxc_syntax/serialize"] diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 0c236d678ce93..93aeac2148f07 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -17,7 +17,7 @@ use oxc_diagnostics::OxcDiagnostic; use oxc_span::{Atom, CompactStr, SourceType, Span}; use oxc_syntax::{ node::{NodeFlags, NodeId}, - reference::{ReferenceFlags, ReferenceId}, + reference::{Reference, ReferenceFlags, ReferenceId}, scope::{ScopeFlags, ScopeId}, symbol::{SymbolFlags, SymbolId}, }; @@ -30,7 +30,6 @@ use crate::{ jsdoc::JSDocBuilder, label::UnusedLabels, node::AstNodes, - reference::Reference, scope::{Bindings, ScopeTree}, stats::Stats, symbol::SymbolTable, diff --git a/crates/oxc_semantic/src/lib.rs b/crates/oxc_semantic/src/lib.rs index d7e3328f50e37..158f93611d728 100644 --- a/crates/oxc_semantic/src/lib.rs +++ b/crates/oxc_semantic/src/lib.rs @@ -15,7 +15,7 @@ use oxc_span::{GetSpan, SourceType, Span}; // Re-export flags and ID types pub use oxc_syntax::{ node::{NodeFlags, NodeId}, - reference::{ReferenceFlags, ReferenceId}, + reference::{Reference, ReferenceFlags, ReferenceId}, scope::{ScopeFlags, ScopeId}, symbol::{SymbolFlags, SymbolId}, }; @@ -30,7 +30,6 @@ mod diagnostics; mod jsdoc; mod label; mod node; -mod reference; mod scope; mod stats; mod symbol; @@ -39,7 +38,6 @@ mod unresolved_stack; pub use builder::{SemanticBuilder, SemanticBuilderReturn}; pub use jsdoc::{JSDoc, JSDocFinder, JSDocTag}; pub use node::{AstNode, AstNodes}; -pub use reference::Reference; pub use scope::ScopeTree; pub use stats::Stats; pub use symbol::{IsGlobalReference, SymbolTable}; diff --git a/crates/oxc_semantic/src/reference.rs b/crates/oxc_semantic/src/reference.rs deleted file mode 100644 index 81fe53c3e94ca..0000000000000 --- a/crates/oxc_semantic/src/reference.rs +++ /dev/null @@ -1,119 +0,0 @@ -#[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] -use tsify::Tsify; - -use oxc_syntax::{node::NodeId, reference::ReferenceFlags, symbol::SymbolId}; - -/// Describes where and how a Symbol is used in the AST. -/// -/// References indicate how they are being used using [`ReferenceFlags`]. Refer -/// to the documentation for [`ReferenceFlags`] for more information. -/// -/// ## Resolution -/// References to symbols that could be resolved have their `symbol_id` field -/// populated. [`None`] indicates that either a global variable or a -/// non-existent symbol is being referenced. -/// -/// The node identified by `node_id` will be an [`IdentifierReference`]. -/// Note that declarations do not count as references, even if the declaration -/// is being used in an expression. -/// -/// ```ts -/// const arr = [1, 2, 3].map(function mapper(x) { return x + 1; }); -/// // Not considered a reference ^^^^^^ -/// ``` -/// -/// [`IdentifierReference`]: oxc_ast::ast::IdentifierReference -#[derive(Debug, Clone)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))] -pub struct Reference { - /// The AST node making the reference. - node_id: NodeId, - /// The symbol being referenced. - /// - /// This will be [`None`] if no symbol could be found within - /// the reference's scope tree. Usually this indicates a global variable or - /// a reference to a non-existent symbol. - symbol_id: Option, - /// Describes how this referenced is used by other AST nodes. References can - /// be reads, writes, or both. - flags: ReferenceFlags, -} - -impl Reference { - /// Create a new unresolved reference. - #[inline] - pub fn new(node_id: NodeId, flags: ReferenceFlags) -> Self { - Self { node_id, symbol_id: None, flags } - } - - /// Create a new resolved reference on a symbol. - #[inline] - pub fn new_with_symbol_id(node_id: NodeId, symbol_id: SymbolId, flags: ReferenceFlags) -> Self { - Self { node_id, symbol_id: Some(symbol_id), flags } - } - - /// Get the id of the node that is referencing the symbol. - /// - /// This will usually point to an [`IdentifierReference`] node, but it could - /// be some specialized reference type like a [`JSXIdentifier`]. - /// - /// [`IdentifierReference`]: oxc_ast::ast::IdentifierReference - /// [`JSXIdentifier`]: oxc_ast::ast::JSXIdentifier - #[inline] - pub fn node_id(&self) -> NodeId { - self.node_id - } - - /// Get the id of the symbol being referenced. - /// - /// Will return [`None`] if the symbol could not be resolved. - #[inline] - pub fn symbol_id(&self) -> Option { - self.symbol_id - } - - #[inline] - pub fn set_symbol_id(&mut self, symbol_id: SymbolId) { - self.symbol_id = Some(symbol_id); - } - - #[inline] - pub fn flags(&self) -> ReferenceFlags { - self.flags - } - - #[inline] - pub fn flags_mut(&mut self) -> &mut ReferenceFlags { - &mut self.flags - } - - /// Returns `true` if the identifier value was read. - /// - /// This is not mutually exclusive with [`Reference::is_write`]. - #[inline] - pub fn is_read(&self) -> bool { - self.flags.is_read() - } - - /// Returns `true` if the identifier was written to. - /// - /// This is not mutually exclusive with [`Reference::is_read`]. - #[inline] - pub fn is_write(&self) -> bool { - self.flags.is_write() - } - - /// Returns `true` if this reference is used in a value context. - pub fn is_value(&self) -> bool { - self.flags.is_value() - } - - /// Returns `true` if this reference is used in a type context. - #[inline] - pub fn is_type(&self) -> bool { - self.flags.is_type() - } -} diff --git a/crates/oxc_semantic/src/symbol.rs b/crates/oxc_semantic/src/symbol.rs index 01fdc45b71443..79740717e4a50 100644 --- a/crates/oxc_semantic/src/symbol.rs +++ b/crates/oxc_semantic/src/symbol.rs @@ -1,29 +1,15 @@ use std::mem; -#[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] -use tsify::Tsify; - use oxc_ast::ast::{Expression, IdentifierReference}; use oxc_index::IndexVec; use oxc_span::{CompactStr, Span}; use oxc_syntax::{ node::NodeId, - reference::ReferenceId, + reference::{Reference, ReferenceId}, scope::ScopeId, symbol::{RedeclarationId, SymbolFlags, SymbolId}, }; -use crate::reference::Reference; - -#[cfg(feature = "serialize")] -#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = r#" -export type IndexVec = Array; -export type CompactStr = string; -"#; - /// Symbol Table /// /// `SoA` (Struct of Arrays) for memory efficiency. @@ -32,7 +18,6 @@ export type CompactStr = string; /// `redeclare_variables` (32 bytes per symbol), store `Option` (4 bytes). /// That ID indexes into `redeclarations` where the actual `Vec` is stored. #[derive(Debug, Default)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify), serde(rename_all = "camelCase"))] pub struct SymbolTable { pub(crate) spans: IndexVec, pub(crate) names: IndexVec, diff --git a/crates/oxc_syntax/src/reference.rs b/crates/oxc_syntax/src/reference.rs index 6ddd21637c6da..61aaadfd52fa0 100644 --- a/crates/oxc_syntax/src/reference.rs +++ b/crates/oxc_syntax/src/reference.rs @@ -6,6 +6,8 @@ use oxc_index::Idx; #[cfg(feature = "serialize")] use serde::{Serialize, Serializer}; +use crate::{node::NodeId, symbol::SymbolId}; + #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct ReferenceId(NonMaxU32); @@ -208,3 +210,107 @@ impl<'alloc> CloneIn<'alloc> for ReferenceFlags { *self } } + +/// Describes where and how a Symbol is used in the AST. +/// +/// References indicate how they are being used using [`ReferenceFlags`]. Refer +/// to the documentation for [`ReferenceFlags`] for more information. +/// +/// ## Resolution +/// References to symbols that could be resolved have their `symbol_id` field +/// populated. [`None`] indicates that either a global variable or a +/// non-existent symbol is being referenced. +/// +/// The node identified by `node_id` will be an `IdentifierReference`. +/// Note that declarations do not count as references, even if the declaration +/// is being used in an expression. +/// +/// ```ts +/// const arr = [1, 2, 3].map(function mapper(x) { return x + 1; }); +/// // Not considered a reference ^^^^^^ +/// ``` +#[cfg_attr(feature = "serialize", derive(Serialize), serde(rename_all = "camelCase"))] +#[derive(Debug, Clone)] +pub struct Reference { + /// The AST node making the reference. + node_id: NodeId, + /// The symbol being referenced. + /// + /// This will be [`None`] if no symbol could be found within + /// the reference's scope tree. Usually this indicates a global variable or + /// a reference to a non-existent symbol. + symbol_id: Option, + /// Describes how this referenced is used by other AST nodes. References can + /// be reads, writes, or both. + flags: ReferenceFlags, +} + +impl Reference { + /// Create a new unresolved reference. + #[inline] + pub fn new(node_id: NodeId, flags: ReferenceFlags) -> Self { + Self { node_id, symbol_id: None, flags } + } + + /// Create a new resolved reference on a symbol. + #[inline] + pub fn new_with_symbol_id(node_id: NodeId, symbol_id: SymbolId, flags: ReferenceFlags) -> Self { + Self { node_id, symbol_id: Some(symbol_id), flags } + } + + /// Get the id of the node that is referencing the symbol. + #[inline] + pub fn node_id(&self) -> NodeId { + self.node_id + } + + /// Get the id of the symbol being referenced. + /// + /// Will return [`None`] if the symbol could not be resolved. + #[inline] + pub fn symbol_id(&self) -> Option { + self.symbol_id + } + + #[inline] + pub fn set_symbol_id(&mut self, symbol_id: SymbolId) { + self.symbol_id = Some(symbol_id); + } + + #[inline] + pub fn flags(&self) -> ReferenceFlags { + self.flags + } + + #[inline] + pub fn flags_mut(&mut self) -> &mut ReferenceFlags { + &mut self.flags + } + + /// Returns `true` if the identifier value was read. + /// + /// This is not mutually exclusive with [`Reference::is_write`]. + #[inline] + pub fn is_read(&self) -> bool { + self.flags.is_read() + } + + /// Returns `true` if the identifier was written to. + /// + /// This is not mutually exclusive with [`Reference::is_read`]. + #[inline] + pub fn is_write(&self) -> bool { + self.flags.is_write() + } + + /// Returns `true` if this reference is used in a value context. + pub fn is_value(&self) -> bool { + self.flags.is_value() + } + + /// Returns `true` if this reference is used in a type context. + #[inline] + pub fn is_type(&self) -> bool { + self.flags.is_type() + } +} diff --git a/crates/oxc_wasm/src/lib.rs b/crates/oxc_wasm/src/lib.rs index 518f4fbe948a4..fe6cf2c7015eb 100644 --- a/crates/oxc_wasm/src/lib.rs +++ b/crates/oxc_wasm/src/lib.rs @@ -17,9 +17,10 @@ use oxc::{ parser::{ParseOptions, Parser, ParserReturn}, semantic::{ dot::{DebugDot, DebugDotContext}, - ScopeFlags, ScopeId, ScopeTree, SemanticBuilder, SymbolTable, + ReferenceId, ScopeFlags, ScopeId, ScopeTree, SemanticBuilder, SymbolFlags, SymbolTable, }, - span::SourceType, + span::{SourceType, Span}, + syntax::reference::Reference, transformer::{TransformOptions, Transformer}, }; use oxc_index::Idx; @@ -51,7 +52,7 @@ pub struct Oxc { pub control_flow_graph: String, #[wasm_bindgen(readonly, skip_typescript)] - #[tsify(type = "SymbolTable")] + #[tsify(type = "any")] pub symbols: JsValue, #[wasm_bindgen(readonly, skip_typescript, js_name = "scopeText")] @@ -239,7 +240,7 @@ impl Oxc { self.scope_text = Self::get_scope_text(&program, &symbols, &scopes); } if run_options.symbol.unwrap_or_default() { - self.symbols = symbols.serialize(&self.serializer)?; + self.symbols = self.get_symbols_text(&symbols)?; } } @@ -405,6 +406,39 @@ impl Oxc { writer.scope_text } + fn get_symbols_text( + &self, + symbols: &SymbolTable, + ) -> Result { + #[derive(Serialize)] + struct Data { + span: Span, + name: String, + flags: SymbolFlags, + scope_id: ScopeId, + resolved_references: Vec, + references: Vec, + } + + let data = symbols + .symbol_ids() + .map(|symbol_id| Data { + span: symbols.get_span(symbol_id), + name: symbols.get_name(symbol_id).into(), + flags: symbols.get_flags(symbol_id), + scope_id: symbols.get_scope_id(symbol_id), + resolved_references: symbols.get_resolved_reference_ids(symbol_id).clone(), + references: symbols + .get_resolved_reference_ids(symbol_id) + .iter() + .map(|reference_id| symbols.get_reference(*reference_id).clone()) + .collect::>(), + }) + .collect::>(); + + data.serialize(&self.serializer) + } + fn save_diagnostics(&self, diagnostics: Vec) { self.diagnostics.borrow_mut().extend(diagnostics); } diff --git a/npm/oxc-wasm/oxc_wasm.d.ts b/npm/oxc-wasm/oxc_wasm.d.ts index 9922a877dc1ff..cf4e2099d9f4d 100644 --- a/npm/oxc-wasm/oxc_wasm.d.ts +++ b/npm/oxc-wasm/oxc_wasm.d.ts @@ -71,7 +71,7 @@ export interface Oxc { ast: Program; ir: string; controlFlowGraph: string; - symbols: SymbolTable; + symbols: any; scopeText: string; codegenText: string; formattedText: string; @@ -89,29 +89,6 @@ export interface Comment { export type CommentType = "Line" | "Block"; -export type IndexVec = Array; -export type CompactStr = string; - - -export interface SymbolTable { - spans: IndexVec; - names: IndexVec; - flags: IndexVec; - scopeIds: IndexVec; - declarations: IndexVec; - resolvedReferences: IndexVec; - redeclarations: IndexVec; - redeclarationSpans: IndexVec; - references: IndexVec; -} - -export interface Reference { - nodeId: NodeId; - symbolId: SymbolId | null; - flags: ReferenceFlags; -} - - export type NodeId = number; export type NodeFlags = { JSDoc: 1, @@ -122,6 +99,16 @@ export type NodeFlags = { +export type SymbolId = number; +export type SymbolFlags = unknown; +export type RedeclarationId = unknown; + + + +export type ScopeId = number; + + + export type ReferenceId = number; export type ReferenceFlags = { None: 0, @@ -132,16 +119,6 @@ export type ReferenceFlags = { } - -export type ScopeId = number; - - - -export type SymbolId = number; -export type SymbolFlags = unknown; -export type RedeclarationId = unknown; - - export class Oxc { free(): void; constructor(); diff --git a/npm/oxc-wasm/oxc_wasm.js b/npm/oxc-wasm/oxc_wasm.js index 47c93e69c0d03..5090d388f1c4e 100644 --- a/npm/oxc-wasm/oxc_wasm.js +++ b/npm/oxc-wasm/oxc_wasm.js @@ -1,5 +1,21 @@ let wasm; +function logError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + let error = (function () { + try { + return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); + } catch(_) { + return ""; + } + }()); + console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); + throw e; + } +} + function addToExternrefTable0(obj) { const idx = wasm.__externref_table_alloc(); wasm.__wbindgen_export_2.set(idx, obj); @@ -33,6 +49,16 @@ function getStringFromWasm0(ptr, len) { return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } +function _assertBoolean(n) { + if (typeof(n) !== 'boolean') { + throw new Error(`expected a boolean argument, found ${typeof(n)}`); + } +} + +function _assertNum(n) { + if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`); +} + let WASM_VECTOR_LEN = 0; const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); @@ -52,6 +78,8 @@ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' function passStringToWasm0(arg, malloc, realloc) { + if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`); + if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length, 1) >>> 0; @@ -80,7 +108,7 @@ function passStringToWasm0(arg, malloc, realloc) { ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); - + if (ret.read !== arg.length) throw new Error('failed to pass whole string'); offset += ret.written; ptr = realloc(ptr, len, offset, 1) >>> 0; } @@ -219,6 +247,8 @@ export class Oxc { * @returns {any} */ get ast() { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_ast(this.__wbg_ptr); return ret; } @@ -229,6 +259,8 @@ export class Oxc { let deferred1_0; let deferred1_1; try { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_ir(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; @@ -244,6 +276,8 @@ export class Oxc { let deferred1_0; let deferred1_1; try { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_controlFlowGraph(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; @@ -256,6 +290,8 @@ export class Oxc { * @returns {any} */ get symbols() { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_symbols(this.__wbg_ptr); return ret; } @@ -266,6 +302,8 @@ export class Oxc { let deferred1_0; let deferred1_1; try { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_scopeText(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; @@ -281,6 +319,8 @@ export class Oxc { let deferred1_0; let deferred1_1; try { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_codegenText(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; @@ -296,6 +336,8 @@ export class Oxc { let deferred1_0; let deferred1_1; try { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_formattedText(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; @@ -311,6 +353,8 @@ export class Oxc { let deferred1_0; let deferred1_1; try { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_prettierFormattedText(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; @@ -326,6 +370,8 @@ export class Oxc { let deferred1_0; let deferred1_1; try { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_prettierIrText(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; @@ -347,6 +393,8 @@ export class Oxc { * @returns {any[]} */ getDiagnostics() { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.oxc_getDiagnostics(this.__wbg_ptr); if (ret[3]) { throw takeFromExternrefTable0(ret[2]); @@ -361,6 +409,8 @@ export class Oxc { * @returns {any[]} */ getComments() { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ret = wasm.oxc_getComments(this.__wbg_ptr); if (ret[3]) { throw takeFromExternrefTable0(ret[2]); @@ -376,6 +426,8 @@ export class Oxc { * @param {OxcOptions} options */ run(source_text, options) { + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); const ptr0 = passStringToWasm0(source_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.oxc_run(this.__wbg_ptr, ptr0, len0, options); @@ -419,15 +471,15 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; - imports.wbg.__wbg_buffer_71667b1101df19da = function(arg0) { + imports.wbg.__wbg_buffer_71667b1101df19da = function() { return logError(function (arg0) { const ret = arg0.buffer; return ret; - }; + }, arguments) }; imports.wbg.__wbg_call_d68488931693e6ee = function() { return handleError(function (arg0, arg1) { const ret = arg0.call(arg1); return ret; }, arguments) }; - imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) { + imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function() { return logError(function (arg0, arg1) { let deferred0_0; let deferred0_1; try { @@ -437,19 +489,19 @@ function __wbg_get_imports() { } finally { wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); } - }; - imports.wbg.__wbg_getTime_55e0fe6b64674dc4 = function(arg0) { + }, arguments) }; + imports.wbg.__wbg_getTime_55e0fe6b64674dc4 = function() { return logError(function (arg0) { const ret = arg0.getTime(); return ret; - }; + }, arguments) }; imports.wbg.__wbg_get_ddd82e34e6366fb9 = function() { return handleError(function (arg0, arg1) { const ret = Reflect.get(arg0, arg1); return ret; }, arguments) }; - imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) { + imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function() { return logError(function (arg0, arg1) { const ret = arg0[arg1]; return ret; - }; + }, arguments) }; imports.wbg.__wbg_globalThis_59c7794d9413986f = function() { return handleError(function () { const ret = globalThis.globalThis; return ret; @@ -458,7 +510,7 @@ function __wbg_get_imports() { const ret = global.global; return ret; }, arguments) }; - imports.wbg.__wbg_instanceof_ArrayBuffer_36214dbc6ea8dd3d = function(arg0) { + imports.wbg.__wbg_instanceof_ArrayBuffer_36214dbc6ea8dd3d = function() { return logError(function (arg0) { let result; try { result = arg0 instanceof ArrayBuffer; @@ -466,9 +518,10 @@ function __wbg_get_imports() { result = false; } const ret = result; + _assertBoolean(ret); return ret; - }; - imports.wbg.__wbg_instanceof_Uint8Array_0d898f7981fe0a2d = function(arg0) { + }, arguments) }; + imports.wbg.__wbg_instanceof_Uint8Array_0d898f7981fe0a2d = function() { return logError(function (arg0) { let result; try { result = arg0 instanceof Uint8Array; @@ -476,64 +529,66 @@ function __wbg_get_imports() { result = false; } const ret = result; + _assertBoolean(ret); return ret; - }; - imports.wbg.__wbg_length_b52c3d528b88468e = function(arg0) { + }, arguments) }; + imports.wbg.__wbg_length_b52c3d528b88468e = function() { return logError(function (arg0) { const ret = arg0.length; + _assertNum(ret); return ret; - }; - imports.wbg.__wbg_new0_9e4a93c1026c7bae = function() { + }, arguments) }; + imports.wbg.__wbg_new0_9e4a93c1026c7bae = function() { return logError(function () { const ret = new Date(); return ret; - }; - imports.wbg.__wbg_new_8a6f238a6ece86ea = function() { + }, arguments) }; + imports.wbg.__wbg_new_8a6f238a6ece86ea = function() { return logError(function () { const ret = new Error(); return ret; - }; - imports.wbg.__wbg_new_9e6542cc3fe4b09e = function() { + }, arguments) }; + imports.wbg.__wbg_new_9e6542cc3fe4b09e = function() { return logError(function () { const ret = new Array(); return ret; - }; - imports.wbg.__wbg_new_9ed4506807911440 = function(arg0) { + }, arguments) }; + imports.wbg.__wbg_new_9ed4506807911440 = function() { return logError(function (arg0) { const ret = new Uint8Array(arg0); return ret; - }; - imports.wbg.__wbg_new_dbb4955149975b18 = function() { + }, arguments) }; + imports.wbg.__wbg_new_dbb4955149975b18 = function() { return logError(function () { const ret = new Object(); return ret; - }; - imports.wbg.__wbg_new_efea5718d1896ea2 = function() { + }, arguments) }; + imports.wbg.__wbg_new_efea5718d1896ea2 = function() { return logError(function () { const ret = new Map(); return ret; - }; - imports.wbg.__wbg_newnoargs_fe7e106c48aadd7e = function(arg0, arg1) { + }, arguments) }; + imports.wbg.__wbg_newnoargs_fe7e106c48aadd7e = function() { return logError(function (arg0, arg1) { const ret = new Function(getStringFromWasm0(arg0, arg1)); return ret; - }; + }, arguments) }; imports.wbg.__wbg_self_c9a63b952bd22cbd = function() { return handleError(function () { const ret = self.self; return ret; }, arguments) }; - imports.wbg.__wbg_set_0ccc5fa791d83f2d = function(arg0, arg1, arg2) { + imports.wbg.__wbg_set_0ccc5fa791d83f2d = function() { return logError(function (arg0, arg1, arg2) { arg0[arg1 >>> 0] = arg2; - }; - imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) { + }, arguments) }; + imports.wbg.__wbg_set_3f1d0b984ed272ed = function() { return logError(function (arg0, arg1, arg2) { arg0[arg1] = arg2; - }; - imports.wbg.__wbg_set_9b8ce78fa3e7ad0e = function(arg0, arg1, arg2) { + }, arguments) }; + imports.wbg.__wbg_set_9b8ce78fa3e7ad0e = function() { return logError(function (arg0, arg1, arg2) { const ret = arg0.set(arg1, arg2); return ret; - }; - imports.wbg.__wbg_set_e8d9380e866a1e41 = function(arg0, arg1, arg2) { + }, arguments) }; + imports.wbg.__wbg_set_e8d9380e866a1e41 = function() { return logError(function (arg0, arg1, arg2) { arg0.set(arg1, arg2 >>> 0); - }; - imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) { + }, arguments) }; + imports.wbg.__wbg_stack_0ed75d68575b0f3c = function() { return logError(function (arg0, arg1) { const ret = arg1.stack; const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); - }; + }, arguments) }; imports.wbg.__wbg_stringify_af61cb825a8f0ce6 = function() { return handleError(function (arg0) { const ret = JSON.stringify(arg0); return ret; @@ -553,6 +608,7 @@ function __wbg_get_imports() { imports.wbg.__wbindgen_boolean_get = function(arg0) { const v = arg0; const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + _assertNum(ret); return ret; }; imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { @@ -568,6 +624,7 @@ function __wbg_get_imports() { }; imports.wbg.__wbindgen_in = function(arg0, arg1) { const ret = arg0 in arg1; + _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_init_externref_table = function() { @@ -583,18 +640,22 @@ function __wbg_get_imports() { imports.wbg.__wbindgen_is_object = function(arg0) { const val = arg0; const ret = typeof(val) === 'object' && val !== null; + _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_is_string = function(arg0) { const ret = typeof(arg0) === 'string'; + _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_is_undefined = function(arg0) { const ret = arg0 === undefined; + _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) { const ret = arg0 == arg1; + _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_memory = function() { @@ -604,6 +665,9 @@ function __wbg_get_imports() { imports.wbg.__wbindgen_number_get = function(arg0, arg1) { const obj = arg1; const ret = typeof(obj) === 'number' ? obj : undefined; + if (!isLikeNone(ret)) { + _assertNum(ret); + } getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); };