Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: src/variables.h

Issue 1053773006: [es6] implement default/optional parameters (WIP / comments) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Experimental not-quite-TDZ support Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopes.cc ('k') | src/variables.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/variables.h
diff --git a/src/variables.h b/src/variables.h
index 545c3bd1f5bfae92e9adbe9c013e4dd65f2331fa..8ff38b0fadd655135c0c8ec92a8f36067cf5c576 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -11,6 +11,13 @@
namespace v8 {
namespace internal {
+enum ParameterKind {
+ NotAParameter = -1,
+ NormalParameter,
+ RestParameter,
+ OptionalParameter
+};
+
// 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 +154,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 != NotAParameter && !isParameter());
+ parameter_kind_ = kind;
+ }
+
+ inline const ParameterKind& parameter_kind() const {
+ // Only access for function parameters
+ DCHECK(isParameter());
+ return parameter_kind_;
+ }
+
+ bool isParameter() const { return parameter_kind_ != NotAParameter; }
+ bool isRestParameter() const { return parameter_kind_ == RestParameter; }
+ bool isOptionalParameter() const {
+ return parameter_kind_ == OptionalParameter;
+ }
+
private:
Scope* scope_;
const AstRawString* name_;
@@ -172,6 +197,7 @@ class Variable: public ZoneObject {
bool is_used_;
InitializationFlag initialization_flag_;
MaybeAssignedFlag maybe_assigned_;
+ ParameterKind parameter_kind_;
};
« no previous file with comments | « src/scopes.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698