Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/SerializerConstantPool.java @ 12388:96c1d057a5ed
Truffle: Added experimental serialization API.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 02 Oct 2013 15:33:08 +0200 |
parents | |
children | 1cde96b96673 |
comparison
equal
deleted
inserted
replaced
12387:aff825fef0fd | 12388:96c1d057a5ed |
---|---|
1 /* | |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. Oracle designates this | |
8 * particular file as subject to the "Classpath" exception as provided | |
9 * by Oracle in the LICENSE file that accompanied this code. | |
10 * | |
11 * This code is distributed in the hope that it will be useful, but WITHOUT | |
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 * version 2 for more details (a copy is included in the LICENSE file that | |
15 * accompanied this code). | |
16 * | |
17 * You should have received a copy of the GNU General Public License version | |
18 * 2 along with this work; if not, write to the Free Software Foundation, | |
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 * | |
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
22 * or visit www.oracle.com if you need additional information or have any | |
23 * questions. | |
24 */ | |
25 package com.oracle.truffle.api.nodes.serial; | |
26 | |
27 /** | |
28 * Experimental API. May change without notice. This interface is used as bridge between the | |
29 * {@link PostOrderDeserializer}, {@link PostOrderSerializer} and underlying constant pool | |
30 * implementation. A constant pool stores a value and returns an identifying index, with which the | |
31 * object can later be returned from the pool again. All methods of this class are optional and may | |
32 * throw a {@link UnsupportedOperationException}. | |
33 */ | |
34 public interface SerializerConstantPool { | |
35 | |
36 /** | |
37 * Returns the constant pool index of a value that is not a java native type, a java | |
38 * native-wrapper class or a {@link Class} instance. The implementor should support all | |
39 * additional types that are necessary to serialize a truffle AST for a specific truffle | |
40 * implementation. If a type is not supported by this constant pool implementation a | |
41 * {@link UnsupportedConstantPoolTypeException} should be thrown. | |
42 * | |
43 * @param clazz the {@link Class} of the value | |
44 * @param value the value to be stored. Must be at least a subclass of the given clazz. | |
45 * @return the constant pool index | |
46 * @throws UnsupportedConstantPoolTypeException if a type is not supported for persistence in | |
47 * the constant pool. | |
48 */ | |
49 int putObject(Class<?> clazz, Object value) throws UnsupportedConstantPoolTypeException; | |
50 | |
51 /** | |
52 * Stores a value in the constant pool that is not a java native type, a java native-wrapper | |
53 * class or a {@link Class} instance. The implementor should support all additional types that | |
54 * are necessary to serialize a truffle AST for a specific truffle implementation. If a type is | |
55 * not supported by this constant pool implementation a | |
56 * {@link UnsupportedConstantPoolTypeException} should be thrown. | |
57 * | |
58 * @param clazz the {@link Class} of the value in the constant pool. | |
59 * @param cpi the previously returned index | |
60 * @return the value stored inside the constant pool | |
61 * @throws UnsupportedConstantPoolTypeException if a type is not supported for persistence in | |
62 * the constant pool. | |
63 * @throws IllegalArgumentException if the provided cpi is not a valid constant pool index. | |
64 */ | |
65 Object getObject(Class<?> clazz, int cpi) throws UnsupportedConstantPoolTypeException; | |
66 | |
67 /** | |
68 * Stores a Class instance in the constant pool and returns the constant pool index. | |
69 * | |
70 * @param value the class to store | |
71 * @return the new or existing constant pool index of the Class | |
72 */ | |
73 int putClass(Class<?> value); | |
74 | |
75 /** | |
76 * Returns the {@link Class} instance to the given constant pool index. | |
77 * | |
78 * @param cpi the constant pool index | |
79 * @return stored value | |
80 * @throws IllegalArgumentException if the constant pool indes is invalid. | |
81 */ | |
82 Class<?> getClass(int cpi); | |
83 | |
84 /** | |
85 * Stores an int value in the constant pool and returns the constant pool index. | |
86 * | |
87 * @param value the value to store | |
88 * @return the new or existing constant pool index of the value | |
89 */ | |
90 int putInt(int value); | |
91 | |
92 /** | |
93 * Returns the stored int value to the given constant pool index from the constant pool. | |
94 * | |
95 * @param cpi the constant pool index | |
96 * @return stored value | |
97 * @throws IllegalArgumentException if the constant pool index is invalid. | |
98 */ | |
99 int getInt(int cpi); | |
100 | |
101 /** | |
102 * Stores a long value in the constant pool and returns the constant pool index. | |
103 * | |
104 * @param value the value to store | |
105 * @return the new or existing constant pool index of the value | |
106 */ | |
107 int putLong(long value); | |
108 | |
109 /** | |
110 * Returns the stored long value to the given constant pool index from the constant pool. | |
111 * | |
112 * @param cpi the constant pool index | |
113 * @return the stored value | |
114 * @throws IllegalArgumentException if the constant pool index is invalid. | |
115 */ | |
116 long getLong(int cpi); | |
117 | |
118 /** | |
119 * Stores a double value in the constant pool and returns the constant pool index. | |
120 * | |
121 * @param value the value to store | |
122 * @return the new or existing constant pool index of the value | |
123 */ | |
124 int putDouble(double value); | |
125 | |
126 /** | |
127 * Returns the stored double value to the given constant pool index from the constant pool. | |
128 * | |
129 * @param cpi the constant pool index | |
130 * @return the stored value | |
131 * @throws IllegalArgumentException if the constant pool index is invalid. | |
132 */ | |
133 double getDouble(int cpi); | |
134 | |
135 /** | |
136 * Stores a float value in the constant pool and returns the constant pool index. | |
137 * | |
138 * @param value the value to store | |
139 * @return the new or existing constant pool index of the value | |
140 */ | |
141 int putFloat(float value); | |
142 | |
143 /** | |
144 * Returns the stored float value to the given constant pool index from the constant pool. | |
145 * | |
146 * @param cpi the constant pool index | |
147 * @return the stored value | |
148 * @throws IllegalArgumentException if the constant pool index is invalid. | |
149 */ | |
150 float getFloat(int cpi); | |
151 | |
152 } |