mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(semantic): remove serialize (#8015)
This commit is contained in:
parent
0a38eea95c
commit
e7476a1a28
10 changed files with 262 additions and 225 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
|
@ -1929,10 +1929,7 @@ dependencies = [
|
|||
"oxc_syntax",
|
||||
"phf",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tsify",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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<SymbolId>,
|
||||
/// 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<SymbolId> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
@ -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<I, T> = Array<T>;
|
||||
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<RedeclarationId>` (4 bytes).
|
||||
/// That ID indexes into `redeclarations` where the actual `Vec<Span>` is stored.
|
||||
#[derive(Debug, Default)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify), serde(rename_all = "camelCase"))]
|
||||
pub struct SymbolTable {
|
||||
pub(crate) spans: IndexVec<SymbolId, Span>,
|
||||
pub(crate) names: IndexVec<SymbolId, CompactStr>,
|
||||
|
|
|
|||
|
|
@ -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<SymbolId>,
|
||||
/// 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<SymbolId> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<JsValue, serde_wasm_bindgen::Error> {
|
||||
#[derive(Serialize)]
|
||||
struct Data {
|
||||
span: Span,
|
||||
name: String,
|
||||
flags: SymbolFlags,
|
||||
scope_id: ScopeId,
|
||||
resolved_references: Vec<ReferenceId>,
|
||||
references: Vec<Reference>,
|
||||
}
|
||||
|
||||
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::<Vec<_>>(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
data.serialize(&self.serializer)
|
||||
}
|
||||
|
||||
fn save_diagnostics(&self, diagnostics: Vec<oxc::diagnostics::OxcDiagnostic>) {
|
||||
self.diagnostics.borrow_mut().extend(diagnostics);
|
||||
}
|
||||
|
|
|
|||
45
npm/oxc-wasm/oxc_wasm.d.ts
vendored
45
npm/oxc-wasm/oxc_wasm.d.ts
vendored
|
|
@ -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<I, T> = Array<T>;
|
||||
export type CompactStr = string;
|
||||
|
||||
|
||||
export interface SymbolTable {
|
||||
spans: IndexVec<SymbolId, Span>;
|
||||
names: IndexVec<SymbolId, CompactStr>;
|
||||
flags: IndexVec<SymbolId, SymbolFlags>;
|
||||
scopeIds: IndexVec<SymbolId, ScopeId>;
|
||||
declarations: IndexVec<SymbolId, NodeId>;
|
||||
resolvedReferences: IndexVec<SymbolId, ReferenceId[]>;
|
||||
redeclarations: IndexVec<SymbolId, RedeclarationId | null>;
|
||||
redeclarationSpans: IndexVec<RedeclarationId, Span[]>;
|
||||
references: IndexVec<ReferenceId, Reference>;
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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 "<failed to stringify thrown value>";
|
||||
}
|
||||
}());
|
||||
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);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue