OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
ahe
2012/06/01 13:55:51
Move this to a separate directory?
Anton Muhin
2012/06/01 15:09:04
I can easily do it, but maybe (again maybe) let's
ahe
2012/06/01 16:09:03
I think it would be best with a subdirectory now.
Anton Muhin
2012/06/01 16:31:38
Done.
| |
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'); | |
ahe
2012/06/01 13:55:51
I would prefer if you don't instantiate this excep
Anton Muhin
2012/06/01 15:09:04
Peter,
This unimplemented will disappear really s
ahe
2012/06/01 16:09:03
Sounds good.
On 2012/06/01 15:09:04, antonmuhin w
| |
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 DartBackend(Compiler compiler) | |
87 : reachabilityVisitor = new ReachabilityVisitor(), | |
88 super(compiler); | |
89 | |
90 String codegen(WorkItem work) { | |
91 // Traverse AST to populate sets of reachable classes and functions. | |
92 FunctionExpression function = work.element.parseNode(compiler); | |
93 function.body.accept(new TraversingVisitor(reachabilityVisitor)); | |
94 } | |
95 | |
96 void processNativeClasses(world, libraries) {} | |
97 void assembleProgram() { | |
98 compiler.assembledCode = ''; | |
99 } | |
100 } | |
OLD | NEW |