Chromium Code Reviews| Index: src/variables.h |
| diff --git a/src/variables.h b/src/variables.h |
| index 545c3bd1f5bfae92e9adbe9c013e4dd65f2331fa..cf88c5ed47e627fdd5587703ea9be81a09d9f3bc 100644 |
| --- a/src/variables.h |
| +++ b/src/variables.h |
| @@ -11,6 +11,42 @@ |
| namespace v8 { |
| namespace internal { |
| +class ParameterKind { |
|
arv (Not doing code reviews)
2015/04/10 15:08:48
Not sure we need a class for this. Why isn't an en
caitp (gmail)
2015/04/10 15:28:00
I find it more readable, and it should end up bein
caitp (gmail)
2015/04/10 15:56:49
Actually, clang-format isn't keen on this, and it
|
| + public: |
| + enum Kind { |
| + NonParameter = -1, |
| + Normal, |
| + Rest, |
| + Optional |
| + }; |
| + |
| + ParameterKind() : kind_(Normal) {} |
| + ParameterKind(Kind k) : kind_(k) {} |
| + ParameterKind(const ParameterKind& other) : kind_(other.kind_) {} |
| + |
| + bool operator==(const ParameterKind& other) const { |
| + return other.kind_ == kind_; |
| + } |
| + bool operator==(Kind k) const { return k == kind_; } |
| + |
| + ParameterKind& operator=(const ParameterKind& other) { |
| + kind_ = other.kind_; |
| + return *this; |
| + } |
| + ParameterKind& operator=(Kind k) { |
| + kind_ = k; |
| + return *this; |
| + } |
| + |
| + bool isParameter() const { return kind_ != NonParameter; } |
| + bool isNormalParameter() const { return kind_ == Normal; } |
| + bool isRestParameter() const { return kind_ == Rest; } |
| + bool isOptionalParameter() const { return kind_ == Optional; } |
| + |
| + private: |
| + Kind kind_; |
| +}; |
| + |
| // The AST refers to variables via VariableProxies - placeholders for the actual |
| // variables. Variables themselves are never directly referred to from the AST, |
| // they are maintained by scopes, and referred to from VariableProxies and Slots |
| @@ -147,6 +183,24 @@ class Variable: public ZoneObject { |
| return strong_mode_reference_end_position_; |
| } |
| + inline void set_parameter_kind(ParameterKind& kind) { |
| + // Don't specify ParameterKind multiple times |
| + DCHECK(kind.isParameter() && !parameter_kind_.isParameter()); |
| + parameter_kind_ = kind; |
| + } |
| + |
| + inline const ParameterKind& parameter_kind() const { |
| + // Only access for function parameters |
| + DCHECK(parameter_kind_.isParameter()); |
| + return parameter_kind_; |
| + } |
| + |
| + bool isParameter() const { return parameter_kind_.isParameter(); } |
| + bool isRestParameter() const { return parameter_kind_.isRestParameter(); } |
| + bool isOptionalParameter() const { |
| + return parameter_kind_.isOptionalParameter(); |
| + } |
| + |
| private: |
| Scope* scope_; |
| const AstRawString* name_; |
| @@ -172,6 +226,7 @@ class Variable: public ZoneObject { |
| bool is_used_; |
| InitializationFlag initialization_flag_; |
| MaybeAssignedFlag maybe_assigned_; |
| + ParameterKind parameter_kind_; |
| }; |