Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/Translator.java @ 13732:fbf448929260
Ruby: remove some prototyping code no longer needed
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Sat, 18 Jan 2014 22:12:42 -0800 |
parents | d7af2296cebb |
children | 2c1c805153e6 |
comparison
equal
deleted
inserted
replaced
13684:72f85504e79e | 13732:fbf448929260 |
---|---|
14 import java.util.regex.*; | 14 import java.util.regex.*; |
15 | 15 |
16 import com.oracle.truffle.api.*; | 16 import com.oracle.truffle.api.*; |
17 import com.oracle.truffle.api.frame.*; | 17 import com.oracle.truffle.api.frame.*; |
18 import com.oracle.truffle.api.impl.*; | 18 import com.oracle.truffle.api.impl.*; |
19 import com.oracle.truffle.api.nodes.instrument.*; | |
20 import com.oracle.truffle.api.nodes.instrument.InstrumentationProbeNode.ProbeChain; | |
21 import com.oracle.truffle.ruby.nodes.*; | 19 import com.oracle.truffle.ruby.nodes.*; |
22 import com.oracle.truffle.ruby.nodes.call.*; | 20 import com.oracle.truffle.ruby.nodes.call.*; |
23 import com.oracle.truffle.ruby.nodes.cast.*; | 21 import com.oracle.truffle.ruby.nodes.cast.*; |
24 import com.oracle.truffle.ruby.nodes.constants.*; | 22 import com.oracle.truffle.ruby.nodes.constants.*; |
25 import com.oracle.truffle.ruby.nodes.control.*; | 23 import com.oracle.truffle.ruby.nodes.control.*; |
87 nodeDefinedNames.put(org.jrubyparser.ast.OrNode.class, "expression"); | 85 nodeDefinedNames.put(org.jrubyparser.ast.OrNode.class, "expression"); |
88 nodeDefinedNames.put(org.jrubyparser.ast.LocalVarNode.class, "local-variable"); | 86 nodeDefinedNames.put(org.jrubyparser.ast.LocalVarNode.class, "local-variable"); |
89 nodeDefinedNames.put(org.jrubyparser.ast.DVarNode.class, "local-variable"); | 87 nodeDefinedNames.put(org.jrubyparser.ast.DVarNode.class, "local-variable"); |
90 } | 88 } |
91 | 89 |
92 private static final Set<String> debugIgnoredCalls = new HashSet<>(); | |
93 | |
94 static { | |
95 debugIgnoredCalls.add("downto"); | |
96 debugIgnoredCalls.add("each"); | |
97 debugIgnoredCalls.add("times"); | |
98 debugIgnoredCalls.add("upto"); | |
99 } | |
100 | |
101 /** | 90 /** |
102 * Global variables which in common usage have frame local semantics. | 91 * Global variables which in common usage have frame local semantics. |
103 */ | 92 */ |
104 public static final Set<String> FRAME_LOCAL_GLOBAL_VARIABLES = new HashSet<>(Arrays.asList("$_")); | 93 public static final Set<String> FRAME_LOCAL_GLOBAL_VARIABLES = new HashSet<>(Arrays.asList("$_")); |
105 | 94 |
299 } | 288 } |
300 | 289 |
301 final ArgumentsAndBlockTranslation argumentsAndBlock = translateArgumentsAndBlock(sourceSection, block, args, extraArgument); | 290 final ArgumentsAndBlockTranslation argumentsAndBlock = translateArgumentsAndBlock(sourceSection, block, args, extraArgument); |
302 | 291 |
303 RubyNode translated = new CallNode(context, sourceSection, node.getName(), receiverTranslated, argumentsAndBlock.getBlock(), argumentsAndBlock.isSplatted(), argumentsAndBlock.getArguments()); | 292 RubyNode translated = new CallNode(context, sourceSection, node.getName(), receiverTranslated, argumentsAndBlock.getBlock(), argumentsAndBlock.isSplatted(), argumentsAndBlock.getArguments()); |
304 | |
305 if (context.getConfiguration().getDebug()) { | |
306 final CallNode callNode = (CallNode) translated; | |
307 if (!debugIgnoredCalls.contains(callNode.getName())) { | |
308 | |
309 final RubyProxyNode proxy = new RubyProxyNode(context, translated); | |
310 proxy.markAs(NodePhylum.CALL); | |
311 proxy.getProbeChain().appendProbe(new RubyCallProbe(context, node.getName())); | |
312 translated = proxy; | |
313 } | |
314 } | |
315 | 293 |
316 return translated; | 294 return translated; |
317 } | 295 } |
318 | 296 |
319 protected class ArgumentsAndBlockTranslation { | 297 protected class ArgumentsAndBlockTranslation { |
1160 rhs = (RubyNode) node.getValue().accept(this); | 1138 rhs = (RubyNode) node.getValue().accept(this); |
1161 } | 1139 } |
1162 | 1140 |
1163 RubyNode translated = ((ReadNode) lhs).makeWriteNode(rhs); | 1141 RubyNode translated = ((ReadNode) lhs).makeWriteNode(rhs); |
1164 | 1142 |
1165 if (context.getConfiguration().getDebug()) { | |
1166 final UniqueMethodIdentifier methodIdentifier = environment.findMethodForLocalVar(node.getName()); | |
1167 | |
1168 RubyProxyNode proxy; | |
1169 if (translated instanceof RubyProxyNode) { | |
1170 proxy = (RubyProxyNode) translated; | |
1171 } else { | |
1172 proxy = new RubyProxyNode(context, translated); | |
1173 } | |
1174 proxy.markAs(NodePhylum.ASSIGNMENT); | |
1175 context.getDebugManager().registerLocalDebugProxy(methodIdentifier, node.getName(), proxy.getProbeChain()); | |
1176 | |
1177 translated = proxy; | |
1178 } | |
1179 | |
1180 return translated; | 1143 return translated; |
1181 } | 1144 } |
1182 | 1145 |
1183 @Override | 1146 @Override |
1184 public Object visitLocalVarNode(org.jrubyparser.ast.LocalVarNode node) { | 1147 public Object visitLocalVarNode(org.jrubyparser.ast.LocalVarNode node) { |
1475 | 1438 |
1476 @Override | 1439 @Override |
1477 public Object visitNewlineNode(org.jrubyparser.ast.NewlineNode node) { | 1440 public Object visitNewlineNode(org.jrubyparser.ast.NewlineNode node) { |
1478 RubyNode translated = (RubyNode) node.getNextNode().accept(this); | 1441 RubyNode translated = (RubyNode) node.getNextNode().accept(this); |
1479 | 1442 |
1480 if (context.getConfiguration().getDebug()) { | |
1481 | |
1482 RubyProxyNode proxy; | |
1483 if (translated instanceof RubyProxyNode) { | |
1484 proxy = (RubyProxyNode) translated; | |
1485 if (proxy.getChild() instanceof CallNode) { | |
1486 // Special case; replace proxy with one registered by line, merge in information | |
1487 final CallNode callNode = (CallNode) proxy.getChild(); | |
1488 final ProbeChain probeChain = proxy.getProbeChain(); | |
1489 | |
1490 proxy = new RubyProxyNode(context, callNode, probeChain); | |
1491 } | |
1492 } else { | |
1493 proxy = new RubyProxyNode(context, translated); | |
1494 } | |
1495 proxy.markAs(NodePhylum.STATEMENT); | |
1496 translated = proxy; | |
1497 } | |
1498 | |
1499 if (context.getConfiguration().getTrace()) { | 1443 if (context.getConfiguration().getTrace()) { |
1500 RubyProxyNode proxy; | 1444 RubyProxyNode proxy; |
1501 if (translated instanceof RubyProxyNode) { | 1445 if (translated instanceof RubyProxyNode) { |
1502 proxy = (RubyProxyNode) translated; | 1446 proxy = (RubyProxyNode) translated; |
1503 } else { | 1447 } else { |