OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Visitor to gather conservative estimate of functions which |
| 7 * can be invoked and classes which can be instantiated. |
| 8 */ |
| 9 class ReachabilityVisitor implements Visitor { |
| 10 visitBlock(Block node) {} |
| 11 visitBreakStatement(BreakStatement node) {} |
| 12 visitCascade(Cascade node) {} |
| 13 visitCascadeReceiver(CascadeReceiver node) {} |
| 14 visitCaseMatch(CaseMatch node) {} |
| 15 visitCatchBlock(CatchBlock node) {} |
| 16 visitClassNode(ClassNode node) { |
| 17 internalError('should not reach ClassNode'); |
| 18 } |
| 19 visitConditional(Conditional node) {} |
| 20 visitContinueStatement(ContinueStatement node) {} |
| 21 visitDoWhile(DoWhile node) {} |
| 22 visitEmptyStatement(EmptyStatement node) {} |
| 23 visitExpressionStatement(ExpressionStatement node) {} |
| 24 visitFor(For node) {} |
| 25 visitForIn(ForIn node) {} |
| 26 visitFunctionDeclaration(FunctionDeclaration node) {} |
| 27 visitFunctionExpression(FunctionExpression node) { |
| 28 // TODO(antonm): add a closure to working queue. |
| 29 unimplemented('FunctionExpression is not supported'); |
| 30 } |
| 31 visitIdentifier(Identifier node) {} |
| 32 visitIf(If node) {} |
| 33 visitLabel(Label node) {} |
| 34 visitLabeledStatement(LabeledStatement node) {} |
| 35 visitLiteralBool(LiteralBool node) {} |
| 36 visitLiteralDouble(LiteralDouble node) {} |
| 37 visitLiteralInt(LiteralInt node) {} |
| 38 visitLiteralList(LiteralList node) {} |
| 39 visitLiteralMap(LiteralMap node) {} |
| 40 visitLiteralMapEntry(LiteralMapEntry node) {} |
| 41 visitLiteralNull(LiteralNull node) {} |
| 42 visitLiteralString(LiteralString node) {} |
| 43 visitModifiers(Modifiers node) {} |
| 44 visitNamedArgument(NamedArgument node) {} |
| 45 visitNewExpression(NewExpression node) { |
| 46 // TODO(antonm): update set of instantiated classes. |
| 47 unimplemented('NewExpression is not supported'); |
| 48 } |
| 49 visitNodeList(NodeList node) {} |
| 50 visitOperator(Operator node) {} |
| 51 visitParenthesizedExpression(ParenthesizedExpression node) {} |
| 52 visitReturn(Return node) {} |
| 53 visitScriptTag(ScriptTag node) {} |
| 54 visitSend(Send node) { |
| 55 // TODO(antonm): update working queue. |
| 56 unimplemented('Send is not supported'); |
| 57 } |
| 58 visitSendSet(SendSet node) { |
| 59 // TODO(antonm): update working queue. |
| 60 unimplemented('SendSet is not supported'); |
| 61 } |
| 62 visitStringInterpolation(StringInterpolation node) {} |
| 63 visitStringInterpolationPart(StringInterpolationPart node) {} |
| 64 visitStringJuxtaposition(StringJuxtaposition node) {} |
| 65 visitSwitchCase(SwitchCase node) {} |
| 66 visitSwitchStatement(SwitchStatement node) {} |
| 67 visitThrow(Throw node) {} |
| 68 visitTryStatement(TryStatement node) {} |
| 69 visitTypeAnnotation(TypeAnnotation node) {} |
| 70 visitTypedef(Typedef node) {} |
| 71 visitTypeVariable(TypeVariable node) {} |
| 72 visitVariableDefinitions(VariableDefinitions node) {} |
| 73 visitWhile(While node) {} |
| 74 |
| 75 unimplemented(String reason) { |
| 76 throw new CompilerCancelledException('not implemented: $reason'); |
| 77 } |
| 78 |
| 79 internalError(String reason) { |
| 80 throw new CompilerCancelledException('internal error: $reason'); |
| 81 } |
| 82 } |
| 83 |
| 84 class DartBackend extends Backend { |
| 85 final ReachabilityVisitor reachabilityVisitor; |
| 86 final List<CompilerTask> tasks = const <CompilerTask>[]; |
| 87 |
| 88 DartBackend(Compiler compiler) |
| 89 : reachabilityVisitor = new ReachabilityVisitor(), |
| 90 super(compiler); |
| 91 |
| 92 String codegen(WorkItem work) { |
| 93 // Traverse AST to populate sets of reachable classes and functions. |
| 94 FunctionExpression function = work.element.parseNode(compiler); |
| 95 function.body.accept(new TraversingVisitor(reachabilityVisitor)); |
| 96 } |
| 97 |
| 98 void processNativeClasses(world, libraries) {} |
| 99 void assembleProgram() { |
| 100 compiler.assembledCode = ''; |
| 101 } |
| 102 } |
OLD | NEW |