Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ArrayTest.java @ 19289:62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 03 Feb 2015 15:07:07 +0100 |
parents | 3ea386a1036f |
children | 18c0f02fa4d2 |
rev | line source |
---|---|
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import org.junit.*; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.*; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.dsl.*; |
18772
7fab6f106989
Truffle-DSL: avoid some checkstyle errors for generated code.
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
29 import com.oracle.truffle.api.dsl.internal.*; |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
30 import com.oracle.truffle.api.dsl.test.ArrayTestFactory.TestNode1NodeGen; |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.frame.*; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.nodes.*; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 public class ArrayTest { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 @Test |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 public void testNode1() { |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
38 final TestNode1 node = TestNode1NodeGen.create(null); |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 RootNode root = new RootNode() { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 @Child TestNode1 test = node; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 @Override |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 public Object execute(VirtualFrame frame) { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 return test.executeWith(frame, frame.getArguments()[0]); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 }; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 CallTarget target = Truffle.getRuntime().createCallTarget(root); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 Assert.assertEquals(1, (int) target.call(1)); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 Assert.assertArrayEquals(new double[0], (double[]) target.call(new int[0]), 0.0d); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 Assert.assertArrayEquals(new double[0], (double[]) target.call(new double[0]), 0.0d); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 Assert.assertArrayEquals(new String[0], (String[]) target.call((Object) new String[0])); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 @TypeSystemReference(ArrayTypeSystem.class) |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 abstract static class BaseNode extends Node { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 abstract Object execute(VirtualFrame frame); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 int executeInt(VirtualFrame frame) throws UnexpectedResultException { |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
61 return ArrayTypeSystemGen.expectInteger(execute(frame)); |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 int[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException { |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
65 return ArrayTypeSystemGen.expectIntArray(execute(frame)); |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 String[] executeStringArray(VirtualFrame frame) throws UnexpectedResultException { |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
69 return ArrayTypeSystemGen.expectStringArray(execute(frame)); |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 double[] executeDoubleArray(VirtualFrame frame) throws UnexpectedResultException { |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
73 return ArrayTypeSystemGen.expectDoubleArray(execute(frame)); |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 @NodeChild |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 abstract static class TestNode1 extends BaseNode { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 abstract Object executeWith(VirtualFrame frame, Object operand); |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 @Specialization |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 int doInt(int value) { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 return value; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 @Specialization |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 double[] doDoubleArray(double[] value) { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 return value; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 @Specialization |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 String[] doStringArray(String[] value) { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 return value; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 @TypeSystem({int.class, int[].class, double[].class, String[].class, Object[].class}) |
18772
7fab6f106989
Truffle-DSL: avoid some checkstyle errors for generated code.
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
100 @DSLOptions(useNewLayout = true) |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 public static class ArrayTypeSystem { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 @ImplicitCast |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
104 public static double[] castFromInt(int[] array) { |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 double[] newArray = new double[array.length]; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 for (int i = 0; i < array.length; i++) { |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 newArray[i] = array[i]; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 return newArray; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 |
18782
3ea386a1036f
Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18772
diff
changeset
|
112 @TypeCheck(int[].class) |
3ea386a1036f
Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18772
diff
changeset
|
113 public static boolean isIntArray2(Object array) { |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 return array instanceof int[]; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
115 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
116 |
18782
3ea386a1036f
Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18772
diff
changeset
|
117 @TypeCast(int[].class) |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18605
diff
changeset
|
118 public static int[] asIntArray(Object array) { |
18605
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 return (int[]) array; |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
120 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
122 } |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
123 |
58eb9bbb60c4
Truffle-DSL: fixed several bugs when using arrays as type. added arrays test.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 } |