Skip to content

Commit 9772126

Browse files
committedNov 14, 2024
WIP
1 parent fa47f57 commit 9772126

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed
 

‎crates/backend/src/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ pub enum OperationKind {
248248
/// A standard method, nothing special
249249
Regular,
250250
/// A method for getting the value of the provided Ident or String
251-
Getter(Option<String>),
251+
Getter,
252252
/// A method for setting the value of the provided Ident or String
253-
Setter(Option<String>),
253+
Setter,
254254
/// A dynamically intercepted getter
255255
IndexingGetter,
256256
/// A dynamically intercepted setter

‎crates/backend/src/encode.rs

+5-18
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn shared_export<'a>(
203203
intern: &'a Interner,
204204
) -> Result<Export<'a>, Diagnostic> {
205205
let consumed = matches!(export.method_self, Some(ast::MethodSelf::ByValue));
206-
let method_kind = from_ast_method_kind(&export.function, intern, &export.method_kind)?;
206+
let method_kind = from_ast_method_kind(&export.method_kind)?;
207207
Ok(Export {
208208
class: export.js_class.as_deref(),
209209
comments: export.comments.iter().map(|s| &**s).collect(),
@@ -321,7 +321,7 @@ fn shared_import_function<'a>(
321321
) -> Result<ImportFunction<'a>, Diagnostic> {
322322
let method = match &i.kind {
323323
ast::ImportFunctionKind::Method { class, kind, .. } => {
324-
let kind = from_ast_method_kind(&i.function, intern, kind)?;
324+
let kind = from_ast_method_kind(kind)?;
325325
Some(MethodData { class, kind })
326326
}
327327
ast::ImportFunctionKind::Normal => None,
@@ -584,28 +584,15 @@ macro_rules! encode_api {
584584
}
585585
wasm_bindgen_shared::shared_api!(encode_api);
586586

587-
fn from_ast_method_kind<'a>(
588-
function: &'a ast::Function,
589-
intern: &'a Interner,
590-
method_kind: &'a ast::MethodKind,
591-
) -> Result<MethodKind<'a>, Diagnostic> {
587+
fn from_ast_method_kind(method_kind: &ast::MethodKind) -> Result<MethodKind, Diagnostic> {
592588
Ok(match method_kind {
593589
ast::MethodKind::Constructor => MethodKind::Constructor,
594590
ast::MethodKind::Operation(ast::Operation { is_static, kind }) => {
595591
let is_static = *is_static;
596592
let kind = match kind {
597-
ast::OperationKind::Getter(g) => {
598-
let g = g.as_ref().map(|g| intern.intern_str(g));
599-
OperationKind::Getter(g.unwrap_or_else(|| function.infer_getter_property()))
600-
}
601593
ast::OperationKind::Regular => OperationKind::Regular,
602-
ast::OperationKind::Setter(s) => {
603-
let s = s.as_ref().map(|s| intern.intern_str(s));
604-
OperationKind::Setter(match s {
605-
Some(s) => s,
606-
None => intern.intern_str(&function.infer_setter_property()?),
607-
})
608-
}
594+
ast::OperationKind::Getter => OperationKind::Getter,
595+
ast::OperationKind::Setter => OperationKind::Setter,
609596
ast::OperationKind::IndexingGetter => OperationKind::IndexingGetter,
610597
ast::OperationKind::IndexingSetter => OperationKind::IndexingSetter,
611598
ast::OperationKind::IndexingDeleter => OperationKind::IndexingDeleter,

‎crates/shared/src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ macro_rules! shared_api {
6666

6767
struct MethodData<'a> {
6868
class: &'a str,
69-
kind: MethodKind<'a>,
69+
kind: MethodKind,
7070
}
7171

72-
enum MethodKind<'a> {
72+
enum MethodKind {
7373
Constructor,
74-
Operation(Operation<'a>),
74+
Operation(Operation),
7575
}
7676

77-
struct Operation<'a> {
77+
struct Operation {
7878
is_static: bool,
79-
kind: OperationKind<'a>,
79+
kind: OperationKind,
8080
}
8181

82-
enum OperationKind<'a> {
82+
enum OperationKind {
8383
Regular,
84-
Getter(&'a str),
85-
Setter(&'a str),
84+
Getter,
85+
Setter,
8686
IndexingGetter,
8787
IndexingSetter,
8888
IndexingDeleter,
@@ -116,7 +116,7 @@ macro_rules! shared_api {
116116
comments: Vec<&'a str>,
117117
consumed: bool,
118118
function: Function<'a>,
119-
method_kind: MethodKind<'a>,
119+
method_kind: MethodKind,
120120
start: bool,
121121
}
122122

0 commit comments

Comments
 (0)