comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStandardASTProber.java @ 19039:6f1afa58a9b8

Truffle/SL: clean up SL instrumentation code
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Thu, 29 Jan 2015 11:45:56 -0800
parents d1c1cd2530d7
children 894f82515e38
comparison
equal deleted inserted replaced
19038:c7e57dffc5ad 19039:6f1afa58a9b8
42 * Instruments and tags all relevant {@link SLStatementNode}s and {@link SLExpressionNode}s. 42 * Instruments and tags all relevant {@link SLStatementNode}s and {@link SLExpressionNode}s.
43 * Currently, only SLStatementNodes that are not SLExpressionNodes are tagged as statements. 43 * Currently, only SLStatementNodes that are not SLExpressionNodes are tagged as statements.
44 */ 44 */
45 public boolean visit(Node node) { 45 public boolean visit(Node node) {
46 46
47 if (node.isInstrumentable()) { 47 if (node instanceof SLStatementNode && node.getParent() != null && node.getSourceSection() != null) {
48 // All SL nodes are instrumentable, but treat expressions specially
48 49
49 if (node instanceof SLStatementNode) { 50 if (node instanceof SLExpressionNode) {
50 51 SLExpressionNode expressionNode = (SLExpressionNode) node;
51 // Distinguish between SLExpressionNode and SLStatementNode since some of the 52 Probe probe = expressionNode.probe();
52 // generated factory methods that require SLExpressionNodes as parameters. 53 if (node instanceof SLWriteLocalVariableNode) {
53 // Since 54 probe.tagAs(STATEMENT, null);
54 // SLExpressionNodes are a subclass of SLStatementNode, check if something is an 55 probe.tagAs(ASSIGNMENT, null);
55 // SLExpressionNode first. 56 }
56 if (node instanceof SLExpressionNode && node.getParent() != null) { 57 } else {
57 SLExpressionNode expressionNode = (SLExpressionNode) node; 58 SLStatementNode statementNode = (SLStatementNode) node;
58 if (expressionNode.getSourceSection() != null) { 59 Probe probe = statementNode.probe();
59 Probe probe = expressionNode.probe(); 60 probe.tagAs(STATEMENT, null);
60 61 if (node instanceof SLWhileNode) {
61 if (node instanceof SLWriteLocalVariableNode) { 62 probe.tagAs(START_LOOP, null);
62 probe.tagAs(STATEMENT, null);
63 probe.tagAs(ASSIGNMENT, null);
64 }
65 }
66 } else if (node instanceof SLStatementNode && node.getParent() != null) {
67
68 SLStatementNode statementNode = (SLStatementNode) node;
69 if (statementNode.getSourceSection() != null) {
70 Probe probe = statementNode.probe();
71 probe.tagAs(STATEMENT, null);
72
73 if (node instanceof SLWhileNode) {
74 probe.tagAs(START_LOOP, null);
75 }
76 }
77 } 63 }
78 } 64 }
79 } 65 }
80 return true; 66 return true;
81 } 67 }