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

Unified Diff: test/cctest/expression-type-collector.cc

Issue 1288773007: Adding visitors to regurgitate expression types or reset them. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix asan Created 5 years, 4 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
Index: test/cctest/expression-type-collector.cc
diff --git a/test/cctest/expression-type-collector.cc b/test/cctest/expression-type-collector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6fe15d87dc4ee2de8389ff85b182588281348d61
--- /dev/null
+++ b/test/cctest/expression-type-collector.cc
@@ -0,0 +1,63 @@
+// Copyright 2015 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/v8.h"
+
+#include "test/cctest/expression-type-collector.h"
+
+#include "src/ast.h"
+#include "src/codegen.h"
+#include "src/scopes.h"
+
+namespace v8 {
+namespace internal {
+namespace {
+
+struct {
+ AstNode::NodeType type;
+ const char* name;
+} NodeTypeNameList[] = {
+#define DECLARE_VISIT(type) \
+ { AstNode::k##type, #type } \
+ ,
+ AST_NODE_LIST(DECLARE_VISIT)
+#undef DECLARE_VISIT
+};
+}
+
+
+void ExpressionTypeCollector::Run(CompilationInfo* info,
+ ZoneVector<ExpressionTypeEntry>* dst) {
+ ExpressionTypeCollector* visitor =
rossberg 2015/08/20 16:34:26 Same here, no reason for heap allocation.
bradn 2015/08/20 21:35:47 Done.
+ new (info->zone()) ExpressionTypeCollector(info);
+ dst->clear();
+ visitor->result_ = dst;
+ visitor->VisitAll();
+}
+
+
+void ExpressionTypeCollector::VisitExpression(Expression* expression) {
+ ExpressionTypeEntry e;
+ e.depth = depth();
+ VariableProxy* proxy = expression->AsVariableProxy();
+ if (proxy) {
+ e.name = proxy->raw_name();
+ }
+ e.bounds = expression->bounds();
+ AstNode::NodeType type = expression->node_type();
+ e.kind = "unknown";
+ for (size_t i = 0; i < arraysize(NodeTypeNameList); ++i) {
+ if (NodeTypeNameList[i].type == type) {
+ e.kind = NodeTypeNameList[i].name;
+ break;
+ }
+ }
+ result_->push_back(e);
+}
+
+
+ExpressionTypeCollector::ExpressionTypeCollector(CompilationInfo* info)
+ : AstExpressionVisitor(info) {}
+}
+}

Powered by Google App Engine
This is Rietveld 408576698