OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, 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 part of native; | |
6 | |
7 class SideEffectsVisitor extends js.BaseVisitor { | |
8 final SideEffects sideEffects; | |
9 SideEffectsVisitor(this.sideEffects); | |
10 | |
11 void visit(js.Node node) { | |
12 node.accept(this); | |
13 } | |
14 | |
15 void visitLiteralExpression(js.LiteralExpression node) { | |
16 sideEffects.setAllSideEffects(); | |
17 sideEffects.setDependsOnSomething(); | |
18 node.visitChildren(this); | |
19 } | |
20 | |
21 void visitLiteralStatement(js.LiteralStatement node) { | |
22 sideEffects.setAllSideEffects(); | |
23 sideEffects.setDependsOnSomething(); | |
24 node.visitChildren(this); | |
25 } | |
26 | |
27 void visitAssignment(js.Assignment node) { | |
28 sideEffects.setChangesStaticProperty(); | |
29 sideEffects.setChangesInstanceProperty(); | |
30 sideEffects.setChangesIndex(); | |
31 node.visitChildren(this); | |
32 } | |
33 | |
34 void visitVariableInitialization(js.VariableInitialization node) { | |
35 node.visitChildren(this); | |
36 } | |
37 | |
38 void visitCall(js.Call node) { | |
39 sideEffects.setAllSideEffects(); | |
40 sideEffects.setDependsOnSomething(); | |
41 node.visitChildren(this); | |
42 } | |
43 | |
44 void visitBinary(js.Binary node) { | |
45 node.visitChildren(this); | |
46 } | |
47 | |
48 void visitThrow(js.Throw node) { | |
49 // TODO(ngeoffray): Incorporate a mayThrow flag in the | |
50 // [SideEffects] class. | |
51 sideEffects.setAllSideEffects(); | |
52 } | |
53 | |
54 void visitNew(js.New node) { | |
55 sideEffects.setAllSideEffects(); | |
56 sideEffects.setDependsOnSomething(); | |
57 node.visitChildren(this); | |
58 } | |
59 | |
60 void visitPrefix(js.Prefix node) { | |
61 if (node.op == 'delete') { | |
62 sideEffects.setChangesStaticProperty(); | |
63 sideEffects.setChangesInstanceProperty(); | |
64 sideEffects.setChangesIndex(); | |
65 } | |
66 node.visitChildren(this); | |
67 } | |
68 | |
69 void visitVariableUse(js.VariableUse node) { | |
70 sideEffects.setDependsOnStaticPropertyStore(); | |
71 } | |
72 | |
73 void visitPostfix(js.Postfix node) { | |
74 node.visitChildren(this); | |
75 } | |
76 | |
77 void visitAccess(js.PropertyAccess node) { | |
78 sideEffects.setDependsOnIndexStore(); | |
79 sideEffects.setDependsOnInstancePropertyStore(); | |
80 sideEffects.setDependsOnStaticPropertyStore(); | |
81 node.visitChildren(this); | |
82 } | |
83 } | |
OLD | NEW |