Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/GuardsTest.java @ 9223:5f7f0d3e3638
Updated codegen tests to new codegen API.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sat, 20 Apr 2013 12:17:47 +0200 |
parents | 6ef9fc7375c7 |
children | e27f125147d6 |
comparison
equal
deleted
inserted
replaced
9222:aa9ffb3a715e | 9223:5f7f0d3e3638 |
---|---|
28 import org.junit.*; | 28 import org.junit.*; |
29 | 29 |
30 import com.oracle.truffle.api.codegen.*; | 30 import com.oracle.truffle.api.codegen.*; |
31 import com.oracle.truffle.api.codegen.test.GuardsTestFactory.GlobalFlagGuardFactory; | 31 import com.oracle.truffle.api.codegen.test.GuardsTestFactory.GlobalFlagGuardFactory; |
32 import com.oracle.truffle.api.codegen.test.GuardsTestFactory.InvocationGuardFactory; | 32 import com.oracle.truffle.api.codegen.test.GuardsTestFactory.InvocationGuardFactory; |
33 import com.oracle.truffle.api.codegen.test.TypeSystemTest.ChildrenNode; | |
34 import com.oracle.truffle.api.codegen.test.TypeSystemTest.TestRootNode; | 33 import com.oracle.truffle.api.codegen.test.TypeSystemTest.TestRootNode; |
35 import com.oracle.truffle.api.codegen.test.TypeSystemTest.ValueNode; | 34 import com.oracle.truffle.api.codegen.test.TypeSystemTest.ValueNode; |
36 | 35 |
37 @SuppressWarnings("unused") | 36 @SuppressWarnings("unused") |
38 public class GuardsTest { | 37 public class GuardsTest { |
50 assertEquals(42, executeWith(root, Integer.MAX_VALUE, 1)); | 49 assertEquals(42, executeWith(root, Integer.MAX_VALUE, 1)); |
51 assertEquals(1, InvocationGuard.specializedInvocations); | 50 assertEquals(1, InvocationGuard.specializedInvocations); |
52 assertEquals(1, InvocationGuard.genericInvocations); | 51 assertEquals(1, InvocationGuard.genericInvocations); |
53 } | 52 } |
54 | 53 |
55 public abstract static class InvocationGuard extends ChildrenNode { | 54 @NodeChildren({@NodeChild("value0"), @NodeChild("value1")}) |
55 public abstract static class InvocationGuard extends ValueNode { | |
56 | 56 |
57 static int specializedInvocations = 0; | 57 static int specializedInvocations = 0; |
58 static int genericInvocations = 0; | 58 static int genericInvocations = 0; |
59 | |
60 public InvocationGuard(ValueNode... children) { | |
61 super(children); | |
62 } | |
63 | |
64 public InvocationGuard(InvocationGuard node) { | |
65 super(node); | |
66 } | |
67 | 59 |
68 boolean guard(int value0, int value1) { | 60 boolean guard(int value0, int value1) { |
69 return value0 != Integer.MAX_VALUE; | 61 return value0 != Integer.MAX_VALUE; |
70 } | 62 } |
71 | 63 |
93 | 85 |
94 GlobalFlagGuard.globalFlag = false; | 86 GlobalFlagGuard.globalFlag = false; |
95 assertEquals(42, executeWith(root, NULL)); | 87 assertEquals(42, executeWith(root, NULL)); |
96 } | 88 } |
97 | 89 |
98 public abstract static class GlobalFlagGuard extends ChildrenNode { | 90 @NodeChild("expression") |
91 public abstract static class GlobalFlagGuard extends ValueNode { | |
99 | 92 |
100 static boolean globalFlag = false; | 93 static boolean globalFlag = false; |
101 | |
102 public GlobalFlagGuard(ValueNode... children) { | |
103 super(children); | |
104 } | |
105 | |
106 public GlobalFlagGuard(GlobalFlagGuard node) { | |
107 super(node); | |
108 } | |
109 | 94 |
110 static boolean globalFlagGuard() { | 95 static boolean globalFlagGuard() { |
111 return globalFlag; | 96 return globalFlag; |
112 } | 97 } |
113 | 98 |