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

Unified Diff: lib/compiler/implementation/compiler.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: Created 8 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index f505318bc1f14eb64acbae531a0c4ec521a7aca4..e2f16eca9759a098abcece8096f2a3448f8eee1e 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -73,8 +73,97 @@ class JavaScriptBackend extends Backend {
void assembleProgram() => emitter.assembleProgram();
}
+class ReachabilityVisitor implements Visitor {
Anton Muhin 2012/05/23 16:58:13 I am planning to move this stuff into a separate f
Roman 2012/05/24 09:45:48 Any comments (dartdocs should I call them?) about
ahe 2012/05/24 10:07:05 Please do so.
Anton Muhin 2012/05/24 14:23:21 Done.
+ 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 {
- DartBackend(Compiler compiler) : super(compiler);
+ final ReachabilityVisitor reachabilityVisitor;
+ 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(libraries) {}
+ void assembleProgram() {
+ compiler.assembledCode = '';
+ }
}
class Compiler implements DiagnosticListener {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698