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

Unified Diff: src/preparser.h

Issue 898983002: Add strong mode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code review + fixes Created 5 years, 10 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/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index be27be75f75a66ad6b21590808467e91b081d210..5be009d66a39c5227795067b53e183cf3dd268aa 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -90,7 +90,8 @@ class ParserBase : public Traits {
allow_harmony_object_literals_(false),
allow_harmony_sloppy_(false),
allow_harmony_computed_property_names_(false),
- allow_harmony_rest_params_(false) {}
+ allow_harmony_rest_params_(false),
+ allow_strong_mode_(false) {}
// Getters that indicate whether certain syntactical constructs are
// allowed to be parsed by this instance of the parser.
@@ -118,6 +119,8 @@ class ParserBase : public Traits {
return allow_harmony_rest_params_;
}
+ bool allow_strong_mode() const { return allow_strong_mode_; }
+
// Setters that determine whether certain syntactical constructs are
// allowed to be parsed by this instance of the parser.
void set_allow_lazy(bool allow) { allow_lazy_ = allow; }
@@ -155,6 +158,7 @@ class ParserBase : public Traits {
void set_allow_harmony_rest_params(bool allow) {
allow_harmony_rest_params_ = allow;
}
+ void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; }
protected:
enum AllowEvalOrArgumentsAsIdentifier {
@@ -634,6 +638,7 @@ class ParserBase : public Traits {
bool allow_harmony_sloppy_;
bool allow_harmony_computed_property_names_;
bool allow_harmony_rest_params_;
+ bool allow_strong_mode_;
};
@@ -754,8 +759,7 @@ class PreParserExpression {
}
static PreParserExpression StringLiteral() {
- return PreParserExpression(TypeField::encode(kStringLiteralExpression) |
- IsUseStrictField::encode(false));
+ return PreParserExpression(TypeField::encode(kStringLiteralExpression));
}
static PreParserExpression UseStrictStringLiteral() {
@@ -763,6 +767,11 @@ class PreParserExpression {
IsUseStrictField::encode(true));
}
+ static PreParserExpression UseStrongStringLiteral() {
+ return PreParserExpression(TypeField::encode(kStringLiteralExpression) |
+ IsUseStrongField::encode(true));
+ }
+
static PreParserExpression This() {
return PreParserExpression(TypeField::encode(kExpression) |
ExpressionTypeField::encode(kThisExpression));
@@ -814,6 +823,11 @@ class PreParserExpression {
IsUseStrictField::decode(code_);
}
+ bool IsUseStrongLiteral() const {
+ return TypeField::decode(code_) == kStringLiteralExpression &&
+ IsUseStrongField::decode(code_);
+ }
+
bool IsThis() const {
return TypeField::decode(code_) == kExpression &&
ExpressionTypeField::decode(code_) == kThisExpression;
@@ -922,6 +936,7 @@ class PreParserExpression {
typedef BitField<ExpressionType, ParenthesizationField::kNext, 3>
ExpressionTypeField;
typedef BitField<bool, ParenthesizationField::kNext, 1> IsUseStrictField;
+ typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField;
typedef BitField<bool, ParenthesizationField::kNext, 1>
IsValidArrowParamListField;
typedef BitField<PreParserIdentifier::Type, ParenthesizationField::kNext, 10>
@@ -963,6 +978,9 @@ class PreParserStatement {
if (expression.IsUseStrictLiteral()) {
return PreParserStatement(kUseStrictExpressionStatement);
}
+ if (expression.IsUseStrongLiteral()) {
+ return PreParserStatement(kUseStrongExpressionStatement);
+ }
if (expression.IsStringLiteral()) {
return PreParserStatement(kStringLiteralExpressionStatement);
}
@@ -977,6 +995,8 @@ class PreParserStatement {
return code_ == kUseStrictExpressionStatement;
}
+ bool IsUseStrongLiteral() { return code_ == kUseStrongExpressionStatement; }
+
bool IsFunctionDeclaration() {
return code_ == kFunctionDeclaration;
}
@@ -986,6 +1006,7 @@ class PreParserStatement {
kUnknownStatement,
kStringLiteralExpressionStatement,
kUseStrictExpressionStatement,
+ kUseStrongExpressionStatement,
kFunctionDeclaration
};
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698