comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TernaryNode.java @ 7848:698cd036a1ca

Added a ternary operator to simple language to test short circuit specialization.
author Christian Humer <christian.humer@gmail.com>
date Tue, 19 Feb 2013 17:27:02 +0100
parents 0110e781b6fa
children aa9ffb3a715e
comparison
equal deleted inserted replaced
7847:06a7cd6aaf00 7848:698cd036a1ca
54 @ShortCircuit("elsePartNode") 54 @ShortCircuit("elsePartNode")
55 public boolean needsElsePart(boolean condition, boolean hasIfPart, Object ifPart) { 55 public boolean needsElsePart(boolean condition, boolean hasIfPart, Object ifPart) {
56 return !hasIfPart; 56 return !hasIfPart;
57 } 57 }
58 58
59 @GuardCheck
60 public boolean demoIntegerGuard(boolean condition, boolean hasIfPart, int ifPart, boolean hasElsePart, int elsePart) {
61 return true;
62 }
63
64 @Specialization 59 @Specialization
65 @SpecializationGuard(methodName = "demoIntegerGuard")
66 @SpecializationThrows(javaClass = RuntimeException.class, transitionTo = "doBigInteger")
67 public int doInteger(boolean condition, boolean hasIfPart, int ifPart, boolean hasElsePart, int elsePart) { 60 public int doInteger(boolean condition, boolean hasIfPart, int ifPart, boolean hasElsePart, int elsePart) {
68 return hasIfPart ? ifPart : elsePart; 61 return hasIfPart ? ifPart : elsePart;
69 } 62 }
70 63
71 @Specialization 64 @Specialization