Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java @ 16051:da9b9b625818
Truffle FrameDescriptor: add compiler asserts
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Fri, 06 Jun 2014 09:40:22 +0200 |
parents | 0046afcda972 |
children | 1cde96b96673 |
rev | line source |
---|---|
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
11279
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9321
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9321
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9321
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 * questions. |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 */ |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.frame; |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 public final class FrameUtil { |
12645
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
28 /** |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
29 * Read a frame slot that is guaranteed to be of the desired kind (either previously checked by |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
30 * a guard or statically known). |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
31 * |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
32 * @param frameSlot the slot of the variable |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
33 * @throws IllegalStateException if the slot kind does not match |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
34 * @see Frame#getObject(FrameSlot) |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
35 */ |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
36 public static Object getObjectSafe(Frame frame, FrameSlot frameSlot) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
37 try { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
38 return frame.getObject(frameSlot); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
39 } catch (FrameSlotTypeException e) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
40 throw new IllegalStateException(); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
41 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
42 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
43 |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
44 /** |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
45 * Read a frame slot that is guaranteed to be of the desired kind (either previously checked by |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
46 * a guard or statically known). |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
47 * |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
48 * @param frameSlot the slot of the variable |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
49 * @throws IllegalStateException if the slot kind does not match |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
50 * @see Frame#getByte(FrameSlot) |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
51 */ |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
52 public static byte getByteSafe(Frame frame, FrameSlot frameSlot) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
53 try { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
54 return frame.getByte(frameSlot); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
55 } catch (FrameSlotTypeException e) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
56 throw new IllegalStateException(); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
57 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
58 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
59 |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
60 /** |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
61 * Read a frame slot that is guaranteed to be of the desired kind (either previously checked by |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
62 * a guard or statically known). |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
63 * |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
64 * @param frameSlot the slot of the variable |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
65 * @throws IllegalStateException if the slot kind does not match |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
66 * @see Frame#getBoolean(FrameSlot) |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
67 */ |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
68 public static boolean getBooleanSafe(Frame frame, FrameSlot frameSlot) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
69 try { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
70 return frame.getBoolean(frameSlot); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
71 } catch (FrameSlotTypeException e) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
72 throw new IllegalStateException(); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
73 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
74 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
75 |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
76 /** |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
77 * Read a frame slot that is guaranteed to be of the desired kind (either previously checked by |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
78 * a guard or statically known). |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
79 * |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
80 * @param frameSlot the slot of the variable |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
81 * @throws IllegalStateException if the slot kind does not match |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
82 * @see Frame#getInt(FrameSlot) |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
83 */ |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
84 public static int getIntSafe(Frame frame, FrameSlot frameSlot) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
85 try { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
86 return frame.getInt(frameSlot); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
87 } catch (FrameSlotTypeException e) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
88 throw new IllegalStateException(); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
89 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
90 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
91 |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
92 /** |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
93 * Read a frame slot that is guaranteed to be of the desired kind (either previously checked by |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
94 * a guard or statically known). |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
95 * |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
96 * @param frameSlot the slot of the variable |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
97 * @throws IllegalStateException if the slot kind does not match |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
98 * @see Frame#getLong(FrameSlot) |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
99 */ |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
100 public static long getLongSafe(Frame frame, FrameSlot frameSlot) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
101 try { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
102 return frame.getLong(frameSlot); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
103 } catch (FrameSlotTypeException e) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
104 throw new IllegalStateException(); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
105 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
106 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
107 |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
108 /** |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
109 * Read a frame slot that is guaranteed to be of the desired kind (either previously checked by |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
110 * a guard or statically known). |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
111 * |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
112 * @param frameSlot the slot of the variable |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
113 * @throws IllegalStateException if the slot kind does not match |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
114 * @see Frame#getDouble(FrameSlot) |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
115 */ |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
116 public static double getDoubleSafe(Frame frame, FrameSlot frameSlot) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
117 try { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
118 return frame.getDouble(frameSlot); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
119 } catch (FrameSlotTypeException e) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
120 throw new IllegalStateException(); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
121 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
122 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
123 |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
124 /** |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
125 * Read a frame slot that is guaranteed to be of the desired kind (either previously checked by |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
126 * a guard or statically known). |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
127 * |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
128 * @param frameSlot the slot of the variable |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
129 * @throws IllegalStateException if the slot kind does not match |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
130 * @see Frame#getFloat(FrameSlot) |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
131 */ |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
132 public static float getFloatSafe(Frame frame, FrameSlot frameSlot) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
133 try { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
134 return frame.getFloat(frameSlot); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
135 } catch (FrameSlotTypeException e) { |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
136 throw new IllegalStateException(); |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
137 } |
60c32ab6eb39
add FrameUtil.get<Type>Safe methods that do not throw checked exceptions.
Andreas Woess <andreas.woess@jku.at>
parents:
12405
diff
changeset
|
138 } |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 } |