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

Unified Diff: src/parser.cc

Issue 952243002: Implement experimental exponentiation operator via desugaring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/ic/ic-state.h ('k') | src/preparser.h » ('j') | src/scanner.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index b1d427e2529f4ec23a4ac702094ba4f874657443..d0d61e276d22adf2e81bffd8219ff2a8f2377401 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -511,9 +511,25 @@ bool ParserTraits::ShortcutNumericLiteralBinaryExpression(
*x = factory->NewNumberLiteral(value, pos);
return true;
}
+ case Token::EXP: {
+ double value = power_helper(x_val, y_val);
+ *x = factory->NewNumberLiteral(value, pos);
+ return true;
+ }
default:
break;
}
+ } else if (op == Token::EXP) {
+ Zone* zone = parser_->zone();
+ AstValueFactory* ast_value_factory = parser_->ast_value_factory();
arv (Not doing code reviews) 2015/02/25 16:58:25 just inline this
caitp (gmail) 2015/02/25 20:52:59 Acknowledged.
+
+ // Desugar exponentiation to runtime call
+ ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone);
+ args->Add(*x, zone);
+ args->Add(y, zone);
+ *x = factory->NewCallRuntime(ast_value_factory->math_pow_string(), NULL,
+ args, pos);
+ return true;
}
return false;
}
@@ -815,6 +831,7 @@ Parser::Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
set_allow_harmony_computed_property_names(
FLAG_harmony_computed_property_names);
set_allow_harmony_rest_params(FLAG_harmony_rest_parameters);
+ set_allow_harmony_exponentiation(FLAG_harmony_exponentiation);
set_allow_strong_mode(FLAG_strong_mode);
for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
++feature) {
@@ -4059,6 +4076,8 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
allow_harmony_computed_property_names());
reusable_preparser_->set_allow_harmony_rest_params(
allow_harmony_rest_params());
+ reusable_preparser_->set_allow_harmony_exponentiation(
+ allow_harmony_exponentiation());
reusable_preparser_->set_allow_strong_mode(allow_strong_mode());
}
PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
« no previous file with comments | « src/ic/ic-state.h ('k') | src/preparser.h » ('j') | src/scanner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698