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

Unified Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10332315: Add a draft of traversing visitor which will analyse function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Next iteration Created 8 years, 6 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: lib/compiler/implementation/dart_backend/backend.dart
diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a7beccf9b31163e01aa369a16265ca5726af570a
--- /dev/null
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -0,0 +1,102 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * Visitor to gather conservative estimate of functions which
+ * can be invoked and classes which can be instantiated.
+ */
+class ReachabilityVisitor implements Visitor {
+ visitBlock(Block node) {}
+ visitBreakStatement(BreakStatement node) {}
+ visitCascade(Cascade node) {}
+ visitCascadeReceiver(CascadeReceiver node) {}
+ visitCaseMatch(CaseMatch node) {}
+ visitCatchBlock(CatchBlock node) {}
+ visitClassNode(ClassNode node) {
+ internalError('should not reach ClassNode');
+ }
+ visitConditional(Conditional node) {}
+ visitContinueStatement(ContinueStatement node) {}
+ visitDoWhile(DoWhile node) {}
+ visitEmptyStatement(EmptyStatement node) {}
+ visitExpressionStatement(ExpressionStatement node) {}
+ visitFor(For node) {}
+ visitForIn(ForIn node) {}
+ visitFunctionDeclaration(FunctionDeclaration node) {}
+ visitFunctionExpression(FunctionExpression node) {
+ // TODO(antonm): add a closure to working queue.
+ unimplemented('FunctionExpression is not supported');
+ }
+ visitIdentifier(Identifier node) {}
+ visitIf(If node) {}
+ visitLabel(Label node) {}
+ visitLabeledStatement(LabeledStatement node) {}
+ visitLiteralBool(LiteralBool node) {}
+ visitLiteralDouble(LiteralDouble node) {}
+ visitLiteralInt(LiteralInt node) {}
+ visitLiteralList(LiteralList node) {}
+ visitLiteralMap(LiteralMap node) {}
+ visitLiteralMapEntry(LiteralMapEntry node) {}
+ visitLiteralNull(LiteralNull node) {}
+ visitLiteralString(LiteralString node) {}
+ visitModifiers(Modifiers node) {}
+ visitNamedArgument(NamedArgument node) {}
+ visitNewExpression(NewExpression node) {
+ // TODO(antonm): update set of instantiated classes.
+ unimplemented('NewExpression is not supported');
+ }
+ visitNodeList(NodeList node) {}
+ visitOperator(Operator node) {}
+ visitParenthesizedExpression(ParenthesizedExpression node) {}
+ visitReturn(Return node) {}
+ visitScriptTag(ScriptTag node) {}
+ visitSend(Send node) {
+ // TODO(antonm): update working queue.
+ unimplemented('Send is not supported');
+ }
+ visitSendSet(SendSet node) {
+ // TODO(antonm): update working queue.
+ unimplemented('SendSet is not supported');
+ }
+ visitStringInterpolation(StringInterpolation node) {}
+ visitStringInterpolationPart(StringInterpolationPart node) {}
+ visitStringJuxtaposition(StringJuxtaposition node) {}
+ visitSwitchCase(SwitchCase node) {}
+ visitSwitchStatement(SwitchStatement node) {}
+ visitThrow(Throw node) {}
+ visitTryStatement(TryStatement node) {}
+ visitTypeAnnotation(TypeAnnotation node) {}
+ visitTypedef(Typedef node) {}
+ visitTypeVariable(TypeVariable node) {}
+ visitVariableDefinitions(VariableDefinitions node) {}
+ visitWhile(While node) {}
+
+ unimplemented(String reason) {
+ throw new CompilerCancelledException('not implemented: $reason');
+ }
+
+ internalError(String reason) {
+ throw new CompilerCancelledException('internal error: $reason');
+ }
+}
+
+class DartBackend extends Backend {
+ final ReachabilityVisitor reachabilityVisitor;
+ final List<CompilerTask> tasks = const <CompilerTask>[];
+
+ DartBackend(Compiler compiler)
+ : reachabilityVisitor = new ReachabilityVisitor(),
+ super(compiler);
+
+ String codegen(WorkItem work) {
+ // Traverse AST to populate sets of reachable classes and functions.
+ FunctionExpression function = work.element.parseNode(compiler);
+ function.body.accept(new TraversingVisitor(reachabilityVisitor));
+ }
+
+ void processNativeClasses(world, libraries) {}
+ void assembleProgram() {
+ compiler.assembledCode = '';
+ }
+}
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/dart_backend/dart_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698