-
-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(syntax_operations): add crate
oxc_syntax_operations
(#6202)
I intend to add constant folding and eval logic to this crate. There are downstream tools that require these functionalities alone. It's also reasonable to move these traits out of the `ast` crate.
- Loading branch information
Showing
30 changed files
with
118 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "oxc_syntax_operations" | ||
version = "0.30.5" | ||
authors.workspace = true | ||
categories.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
include = ["/src"] | ||
keywords.workspace = true | ||
license.workspace = true | ||
publish = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
description.workspace = true | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[lib] | ||
test = false | ||
doctest = false | ||
|
||
[dependencies] | ||
oxc_ast = { workspace = true } | ||
oxc_span = { workspace = true } |
7 changes: 6 additions & 1 deletion
7
...syntax_directed_operations/bound_names.rs → .../oxc_syntax_operations/src/bound_names.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use oxc_ast::ast::ObjectExpression; | ||
|
||
use crate::PropName; | ||
|
||
pub trait HasProto { | ||
/// Returns `true` if this object has a property named `__proto__` | ||
fn has_proto(&self) -> bool; | ||
} | ||
|
||
impl<'a> HasProto for ObjectExpression<'a> { | ||
fn has_proto(&self) -> bool { | ||
self.properties.iter().any(|p| p.prop_name().is_some_and(|name| name.0 == "__proto__")) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ed_operations/is_simple_parameter_list.rs → ...perations/src/is_simple_parameter_list.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! Traits for JavaScript syntax operations | ||
//! | ||
//! * BoundNames | ||
//! * IsSimpleParameterList | ||
//! * PrivateBoundIdentifiers | ||
//! * PropName | ||
//! * Constant Folding | ||
//! | ||
//! See [ECMA262 Syntax-Directed Operations](https://tc39.es/ecma262/#sec-syntax-directed-operations) | ||
mod bound_names; | ||
mod has_proto; | ||
mod is_simple_parameter_list; | ||
mod private_bound_identifiers; | ||
mod prop_name; | ||
|
||
pub use self::{ | ||
bound_names::BoundNames, has_proto::HasProto, is_simple_parameter_list::IsSimpleParameterList, | ||
private_bound_identifiers::PrivateBoundIdentifiers, prop_name::PropName, | ||
}; |
5 changes: 4 additions & 1 deletion
5
...d_operations/private_bound_identifiers.rs → ...erations/src/private_bound_identifiers.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...c/syntax_directed_operations/prop_name.rs → ...es/oxc_syntax_operations/src/prop_name.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.