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

Side by Side Diff: src/preparser.h

Issue 953563002: Implement experimental exponentiation operator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add more tests and fix some bugs 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 bool allow_harmony_templates() const { return scanner()->HarmonyTemplates(); } 111 bool allow_harmony_templates() const { return scanner()->HarmonyTemplates(); }
112 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; } 112 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; }
113 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); } 113 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); }
114 bool allow_harmony_computed_property_names() const { 114 bool allow_harmony_computed_property_names() const {
115 return allow_harmony_computed_property_names_; 115 return allow_harmony_computed_property_names_;
116 } 116 }
117 bool allow_harmony_rest_params() const { 117 bool allow_harmony_rest_params() const {
118 return allow_harmony_rest_params_; 118 return allow_harmony_rest_params_;
119 } 119 }
120 120 bool allow_harmony_exponentiation() const {
121 return scanner()->HarmonyExponentiation();
122 }
121 bool allow_strong_mode() const { return allow_strong_mode_; } 123 bool allow_strong_mode() const { return allow_strong_mode_; }
122 124
123 // Setters that determine whether certain syntactical constructs are 125 // Setters that determine whether certain syntactical constructs are
124 // allowed to be parsed by this instance of the parser. 126 // allowed to be parsed by this instance of the parser.
125 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } 127 void set_allow_lazy(bool allow) { allow_lazy_ = allow; }
126 void set_allow_natives(bool allow) { allow_natives_ = allow; } 128 void set_allow_natives(bool allow) { allow_natives_ = allow; }
127 void set_allow_harmony_arrow_functions(bool allow) { 129 void set_allow_harmony_arrow_functions(bool allow) {
128 allow_harmony_arrow_functions_ = allow; 130 allow_harmony_arrow_functions_ = allow;
129 } 131 }
130 void set_allow_harmony_modules(bool allow) { 132 void set_allow_harmony_modules(bool allow) {
(...skipping 19 matching lines...) Expand all
150 } 152 }
151 void set_allow_harmony_unicode(bool allow) { 153 void set_allow_harmony_unicode(bool allow) {
152 scanner()->SetHarmonyUnicode(allow); 154 scanner()->SetHarmonyUnicode(allow);
153 } 155 }
154 void set_allow_harmony_computed_property_names(bool allow) { 156 void set_allow_harmony_computed_property_names(bool allow) {
155 allow_harmony_computed_property_names_ = allow; 157 allow_harmony_computed_property_names_ = allow;
156 } 158 }
157 void set_allow_harmony_rest_params(bool allow) { 159 void set_allow_harmony_rest_params(bool allow) {
158 allow_harmony_rest_params_ = allow; 160 allow_harmony_rest_params_ = allow;
159 } 161 }
162 void set_allow_harmony_exponentiation(bool allow) {
163 scanner()->SetHarmonyExponentiation(allow);
164 }
160 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } 165 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; }
161 166
162 protected: 167 protected:
163 enum AllowEvalOrArgumentsAsIdentifier { 168 enum AllowEvalOrArgumentsAsIdentifier {
164 kAllowEvalOrArguments, 169 kAllowEvalOrArguments,
165 kDontAllowEvalOrArguments 170 kDontAllowEvalOrArguments
166 }; 171 };
167 172
168 enum Mode { 173 enum Mode {
169 PARSE_LAZILY, 174 PARSE_LAZILY,
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 typename ParserBase<Traits>::ExpressionT 2458 typename ParserBase<Traits>::ExpressionT
2454 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) { 2459 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) {
2455 DCHECK(prec >= 4); 2460 DCHECK(prec >= 4);
2456 ExpressionT x = this->ParseUnaryExpression(CHECK_OK); 2461 ExpressionT x = this->ParseUnaryExpression(CHECK_OK);
2457 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { 2462 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
2458 // prec1 >= 4 2463 // prec1 >= 4
2459 while (Precedence(peek(), accept_IN) == prec1) { 2464 while (Precedence(peek(), accept_IN) == prec1) {
2460 Token::Value op = Next(); 2465 Token::Value op = Next();
2461 Scanner::Location op_location = scanner()->location(); 2466 Scanner::Location op_location = scanner()->location();
2462 int pos = position(); 2467 int pos = position();
2463 ExpressionT y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK); 2468 ExpressionT y = Traits::EmptyExpression();
2469
2470 if (op != Token::EXP) {
2471 // Left-to-right associativity
2472 y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
2473 } else {
2474 // Right-to-left associativity
2475 y = ParseBinaryExpression(prec1, accept_IN, CHECK_OK);
2476 }
2464 2477
2465 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos, 2478 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
2466 factory())) { 2479 factory())) {
2467 continue; 2480 continue;
2468 } 2481 }
2469 2482
2470 // For now we distinguish between comparisons and other binary 2483 // For now we distinguish between comparisons and other binary
2471 // operations. (We could combine the two and get rid of this 2484 // operations. (We could combine the two and get rid of this
2472 // code and AST node eventually.) 2485 // code and AST node eventually.)
2473 if (Token::IsCompareOp(op)) { 2486 if (Token::IsCompareOp(op)) {
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
3104 *ok = false; 3117 *ok = false;
3105 return; 3118 return;
3106 } 3119 }
3107 has_seen_constructor_ = true; 3120 has_seen_constructor_ = true;
3108 return; 3121 return;
3109 } 3122 }
3110 } 3123 }
3111 } } // v8::internal 3124 } } // v8::internal
3112 3125
3113 #endif // V8_PREPARSER_H 3126 #endif // V8_PREPARSER_H
OLDNEW
« src/compiler/typer.cc ('K') | « src/parser.cc ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698