mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
LibJS: Use Identifier to represent FunctionParameter name
Using identifier instead of string allows to store supplemental information about whether it can be represented as local variable.
This commit is contained in:
parent
2f1d6c0b9a
commit
2e81cc4cf7
5 changed files with 50 additions and 31 deletions
|
@ -308,6 +308,7 @@ public:
|
|||
|
||||
ThrowCompletionOr<void> for_each_lexically_scoped_declaration(ThrowCompletionOrVoidCallback<Declaration const&>&& callback) const;
|
||||
ThrowCompletionOr<void> for_each_lexically_declared_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const;
|
||||
ThrowCompletionOr<void> for_each_lexically_declared_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const;
|
||||
|
||||
ThrowCompletionOr<void> for_each_var_declared_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const;
|
||||
ThrowCompletionOr<void> for_each_var_declared_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const;
|
||||
|
@ -665,12 +666,6 @@ struct BindingPattern : RefCounted<BindingPattern> {
|
|||
Kind kind { Kind::Object };
|
||||
};
|
||||
|
||||
struct FunctionParameter {
|
||||
Variant<DeprecatedFlyString, NonnullRefPtr<BindingPattern const>> binding;
|
||||
RefPtr<Expression const> default_value;
|
||||
bool is_rest { false };
|
||||
};
|
||||
|
||||
class Identifier final : public Expression {
|
||||
public:
|
||||
explicit Identifier(SourceRange source_range, DeprecatedFlyString string)
|
||||
|
@ -703,6 +698,12 @@ private:
|
|||
Optional<size_t> m_local_variable_index;
|
||||
};
|
||||
|
||||
struct FunctionParameter {
|
||||
Variant<NonnullRefPtr<Identifier const>, NonnullRefPtr<BindingPattern const>> binding;
|
||||
RefPtr<Expression const> default_value;
|
||||
bool is_rest { false };
|
||||
};
|
||||
|
||||
class FunctionNode {
|
||||
public:
|
||||
StringView name() const { return m_name ? m_name->string().view() : ""sv; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue