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

Unified Diff: src/parsing/parsing.cc

Issue 2534393002: Split parsing of functions and top-level code into two separate methods (Closed)
Patch Set: updates Created 4 years 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/parsing/parsing.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parsing.cc
diff --git a/src/parsing/parsing.cc b/src/parsing/parsing.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7bae145a51cba6e27cf346986be619ceb6c750f1
--- /dev/null
+++ b/src/parsing/parsing.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/parsing/parsing.h"
+
+#include <memory>
+
+#include "src/ast/ast.h"
+#include "src/parsing/parse-info.h"
+#include "src/parsing/parser.h"
+
+namespace v8 {
+namespace internal {
+namespace parsing {
+
+bool ParseProgram(ParseInfo* info) {
+ DCHECK(info->is_toplevel());
+ DCHECK_NULL(info->literal());
+
+ Parser parser(info);
+
+ FunctionLiteral* result = nullptr;
+ // Ok to use Isolate here; this function is only called in the main thread.
+ DCHECK(parser.parsing_on_main_thread_);
+ Isolate* isolate = info->isolate();
+
+ parser.SetCachedData(info);
+ result = parser.ParseProgram(isolate, info);
+ info->set_literal(result);
+ parser.Internalize(isolate, info->script(), result == nullptr);
+ if (result != nullptr) {
+ info->set_language_mode(info->literal()->language_mode());
+ }
+ return (result != nullptr);
+}
+
+bool ParseFunction(ParseInfo* info) {
+ DCHECK(!info->is_toplevel());
+ DCHECK_NULL(info->literal());
+
+ Parser parser(info);
+
+ FunctionLiteral* result = nullptr;
+ // Ok to use Isolate here; this function is only called in the main thread.
+ DCHECK(parser.parsing_on_main_thread_);
+ Isolate* isolate = info->isolate();
+
+ result = parser.ParseFunction(isolate, info);
+ info->set_literal(result);
+ parser.Internalize(isolate, info->script(), result == nullptr);
+ return (result != nullptr);
+}
+
+bool ParseAny(ParseInfo* info) {
+ return info->is_toplevel() ? ParseProgram(info) : ParseFunction(info);
+}
+
+} // namespace parsing
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/parsing/parsing.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698