author | hannesw |
Fri, 25 Nov 2016 14:20:24 +0100 | |
changeset 42376 | 8604f1a50c30 |
parent 41422 | 97eda72f53b6 |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 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 jdk.nashorn.internal.tools.nasgen; |
|
26 |
||
27 |
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_ARRAY_DESC; |
|
28 |
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC; |
|
36517 | 29 |
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJ_PKG; |
30 |
import static jdk.nashorn.internal.tools.nasgen.StringConstants.RUNTIME_PKG; |
|
31 |
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTS_PKG; |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
32 |
import static jdk.nashorn.internal.tools.nasgen.StringConstants.STRING_DESC; |
36023 | 33 |
import static jdk.nashorn.internal.tools.nasgen.StringConstants.TYPE_SYMBOL; |
34 |
||
16147 | 35 |
import jdk.internal.org.objectweb.asm.Opcodes; |
36 |
import jdk.internal.org.objectweb.asm.Type; |
|
37 |
||
38 |
/** |
|
39 |
* Details about a Java method or field annotated with any of the field/method |
|
40 |
* annotations from the jdk.nashorn.internal.objects.annotations package. |
|
41 |
*/ |
|
42 |
public final class MemberInfo implements Cloneable { |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
43 |
// class loader of this class |
31549
b627094c5649
8130734: Apply transformations found by netbeans Refactor->Inspect and transform menu
sundar
parents:
26768
diff
changeset
|
44 |
private static final ClassLoader MY_LOADER = MemberInfo.class.getClassLoader(); |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
45 |
|
16147 | 46 |
/** |
47 |
* The different kinds of available class annotations |
|
48 |
*/ |
|
49 |
public static enum Kind { |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
50 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
51 |
/** |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
52 |
* This is a script class |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
53 |
*/ |
16147 | 54 |
SCRIPT_CLASS, |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
55 |
/** |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
56 |
* This is a constructor |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
57 |
*/ |
16147 | 58 |
CONSTRUCTOR, |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
59 |
/** |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
60 |
* This is a function |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
61 |
*/ |
16147 | 62 |
FUNCTION, |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
63 |
/** |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
64 |
* This is a getter |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
65 |
*/ |
16147 | 66 |
GETTER, |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
67 |
/** |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
68 |
* This is a setter |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
69 |
*/ |
16147 | 70 |
SETTER, |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
71 |
/** |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
72 |
* This is a property |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
73 |
*/ |
16147 | 74 |
PROPERTY, |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
75 |
/** |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
76 |
* This is a specialized version of a function |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
77 |
*/ |
16147 | 78 |
SPECIALIZED_FUNCTION, |
79 |
} |
|
80 |
||
81 |
// keep in sync with jdk.nashorn.internal.objects.annotations.Attribute |
|
82 |
static final int DEFAULT_ATTRIBUTES = 0x0; |
|
83 |
||
84 |
static final int DEFAULT_ARITY = -2; |
|
85 |
||
86 |
// the kind of the script annotation - one of the above constants |
|
87 |
private MemberInfo.Kind kind; |
|
88 |
// script property name |
|
89 |
private String name; |
|
90 |
// script property attributes |
|
91 |
private int attributes; |
|
92 |
// name of the java member |
|
93 |
private String javaName; |
|
94 |
// type descriptor of the java member |
|
95 |
private String javaDesc; |
|
96 |
// access bits of the Java field or method |
|
97 |
private int javaAccess; |
|
98 |
// initial value for static @Property fields |
|
99 |
private Object value; |
|
100 |
// class whose object is created to fill property value |
|
101 |
private String initClass; |
|
102 |
// arity of the Function or Constructor |
|
103 |
private int arity; |
|
104 |
||
105 |
private Where where; |
|
106 |
||
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
107 |
private Type linkLogicClass; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
108 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
109 |
private boolean isSpecializedConstructor; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
110 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
111 |
private boolean isOptimistic; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
112 |
|
42376
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
113 |
private boolean convertsNumericArgs; |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
114 |
|
16147 | 115 |
/** |
116 |
* @return the kind |
|
117 |
*/ |
|
118 |
public Kind getKind() { |
|
119 |
return kind; |
|
120 |
} |
|
121 |
||
122 |
/** |
|
123 |
* @param kind the kind to set |
|
124 |
*/ |
|
125 |
public void setKind(final Kind kind) { |
|
126 |
this.kind = kind; |
|
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* @return the name |
|
131 |
*/ |
|
132 |
public String getName() { |
|
133 |
return name; |
|
134 |
} |
|
135 |
||
136 |
/** |
|
137 |
* @param name the name to set |
|
138 |
*/ |
|
139 |
public void setName(final String name) { |
|
140 |
this.name = name; |
|
141 |
} |
|
142 |
||
143 |
/** |
|
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
144 |
* Tag something as specialized constructor or not |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
145 |
* @param isSpecializedConstructor boolean, true if specialized constructor |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
146 |
*/ |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
147 |
public void setIsSpecializedConstructor(final boolean isSpecializedConstructor) { |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
148 |
this.isSpecializedConstructor = isSpecializedConstructor; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
149 |
} |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
150 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
151 |
/** |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
152 |
* Check if something is a specialized constructor |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
153 |
* @return true if specialized constructor |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
154 |
*/ |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
155 |
public boolean isSpecializedConstructor() { |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
156 |
return isSpecializedConstructor; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
157 |
} |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
158 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
159 |
/** |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
160 |
* Check if this is an optimistic builtin function |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
161 |
* @return true if optimistic builtin |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
162 |
*/ |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
163 |
public boolean isOptimistic() { |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
164 |
return isOptimistic; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
165 |
} |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
166 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
167 |
/** |
31738 | 168 |
* Tag something as optimistic builtin or not |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
169 |
* @param isOptimistic boolean, true if builtin constructor |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
170 |
*/ |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
171 |
public void setIsOptimistic(final boolean isOptimistic) { |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
172 |
this.isOptimistic = isOptimistic; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
173 |
} |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
174 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
175 |
/** |
42376
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
176 |
* Check if this function converts arguments for numeric parameters to numbers |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
177 |
* so it's safe to pass booleans as 0 and 1 |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
178 |
* @return true if it is safe to convert arguments to numbers |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
179 |
*/ |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
180 |
public boolean convertsNumericArgs() { |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
181 |
return convertsNumericArgs; |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
182 |
} |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
183 |
|
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
184 |
/** |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
185 |
* Tag this as a function that converts arguments for numeric params to numbers |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
186 |
* @param convertsNumericArgs if true args can be safely converted to numbers |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
187 |
*/ |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
188 |
public void setConvertsNumericArgs(final boolean convertsNumericArgs) { |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
189 |
this.convertsNumericArgs = convertsNumericArgs; |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
190 |
} |
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
191 |
|
8604f1a50c30
8170322: Specialized functions convert booleans to numbers
hannesw
parents:
41422
diff
changeset
|
192 |
/** |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
193 |
* Get the SpecializedFunction guard for specializations, i.e. optimistic |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
194 |
* builtins |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
195 |
* @return specialization, null if none |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
196 |
*/ |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
197 |
public Type getLinkLogicClass() { |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
198 |
return linkLogicClass; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
199 |
} |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
200 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
201 |
/** |
31738 | 202 |
* Set the SpecializedFunction link logic class for specializations, i.e. optimistic |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
203 |
* builtins |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
204 |
* @param linkLogicClass link logic class |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
205 |
*/ |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
206 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
207 |
public void setLinkLogicClass(final Type linkLogicClass) { |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
208 |
this.linkLogicClass = linkLogicClass; |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
209 |
} |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
210 |
|
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
211 |
/** |
16147 | 212 |
* @return the attributes |
213 |
*/ |
|
214 |
public int getAttributes() { |
|
215 |
return attributes; |
|
216 |
} |
|
217 |
||
218 |
/** |
|
219 |
* @param attributes the attributes to set |
|
220 |
*/ |
|
221 |
public void setAttributes(final int attributes) { |
|
222 |
this.attributes = attributes; |
|
223 |
} |
|
224 |
||
225 |
/** |
|
226 |
* @return the javaName |
|
227 |
*/ |
|
228 |
public String getJavaName() { |
|
229 |
return javaName; |
|
230 |
} |
|
231 |
||
232 |
/** |
|
233 |
* @param javaName the javaName to set |
|
234 |
*/ |
|
235 |
public void setJavaName(final String javaName) { |
|
236 |
this.javaName = javaName; |
|
237 |
} |
|
238 |
||
239 |
/** |
|
240 |
* @return the javaDesc |
|
241 |
*/ |
|
242 |
public String getJavaDesc() { |
|
243 |
return javaDesc; |
|
244 |
} |
|
245 |
||
246 |
void setJavaDesc(final String javaDesc) { |
|
247 |
this.javaDesc = javaDesc; |
|
248 |
} |
|
249 |
||
250 |
int getJavaAccess() { |
|
251 |
return javaAccess; |
|
252 |
} |
|
253 |
||
254 |
void setJavaAccess(final int access) { |
|
255 |
this.javaAccess = access; |
|
256 |
} |
|
257 |
||
258 |
Object getValue() { |
|
259 |
return value; |
|
260 |
} |
|
261 |
||
262 |
void setValue(final Object value) { |
|
263 |
this.value = value; |
|
264 |
} |
|
265 |
||
266 |
Where getWhere() { |
|
267 |
return where; |
|
268 |
} |
|
269 |
||
270 |
void setWhere(final Where where) { |
|
271 |
this.where = where; |
|
272 |
} |
|
273 |
||
274 |
boolean isFinal() { |
|
275 |
return (javaAccess & Opcodes.ACC_FINAL) != 0; |
|
276 |
} |
|
277 |
||
278 |
boolean isStatic() { |
|
279 |
return (javaAccess & Opcodes.ACC_STATIC) != 0; |
|
280 |
} |
|
281 |
||
282 |
boolean isStaticFinal() { |
|
283 |
return isStatic() && isFinal(); |
|
284 |
} |
|
285 |
||
286 |
boolean isInstanceGetter() { |
|
287 |
return kind == Kind.GETTER && where == Where.INSTANCE; |
|
288 |
} |
|
289 |
||
290 |
/** |
|
291 |
* Check whether this MemberInfo is a getter that resides in the instance |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
292 |
* |
16147 | 293 |
* @return true if instance setter |
294 |
*/ |
|
295 |
boolean isInstanceSetter() { |
|
296 |
return kind == Kind.SETTER && where == Where.INSTANCE; |
|
297 |
} |
|
298 |
||
299 |
boolean isInstanceProperty() { |
|
300 |
return kind == Kind.PROPERTY && where == Where.INSTANCE; |
|
301 |
} |
|
302 |
||
303 |
boolean isInstanceFunction() { |
|
304 |
return kind == Kind.FUNCTION && where == Where.INSTANCE; |
|
305 |
} |
|
306 |
||
307 |
boolean isPrototypeGetter() { |
|
308 |
return kind == Kind.GETTER && where == Where.PROTOTYPE; |
|
309 |
} |
|
310 |
||
311 |
boolean isPrototypeSetter() { |
|
312 |
return kind == Kind.SETTER && where == Where.PROTOTYPE; |
|
313 |
} |
|
314 |
||
315 |
boolean isPrototypeProperty() { |
|
316 |
return kind == Kind.PROPERTY && where == Where.PROTOTYPE; |
|
317 |
} |
|
318 |
||
319 |
boolean isPrototypeFunction() { |
|
320 |
return kind == Kind.FUNCTION && where == Where.PROTOTYPE; |
|
321 |
} |
|
322 |
||
323 |
boolean isConstructorGetter() { |
|
324 |
return kind == Kind.GETTER && where == Where.CONSTRUCTOR; |
|
325 |
} |
|
326 |
||
327 |
boolean isConstructorSetter() { |
|
328 |
return kind == Kind.SETTER && where == Where.CONSTRUCTOR; |
|
329 |
} |
|
330 |
||
331 |
boolean isConstructorProperty() { |
|
332 |
return kind == Kind.PROPERTY && where == Where.CONSTRUCTOR; |
|
333 |
} |
|
334 |
||
335 |
boolean isConstructorFunction() { |
|
336 |
return kind == Kind.FUNCTION && where == Where.CONSTRUCTOR; |
|
337 |
} |
|
338 |
||
339 |
boolean isConstructor() { |
|
340 |
return kind == Kind.CONSTRUCTOR; |
|
341 |
} |
|
342 |
||
343 |
void verify() { |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
344 |
switch (kind) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
345 |
case CONSTRUCTOR: { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
346 |
final Type returnType = Type.getReturnType(javaDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
347 |
if (!isJSObjectType(returnType)) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
348 |
error("return value of a @Constructor method should be of Object type, found " + returnType); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
349 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
350 |
final Type[] argTypes = Type.getArgumentTypes(javaDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
351 |
if (argTypes.length < 2) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
352 |
error("@Constructor methods should have at least 2 args"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
353 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
354 |
if (!argTypes[0].equals(Type.BOOLEAN_TYPE)) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
355 |
error("first argument of a @Constructor method should be of boolean type, found " + argTypes[0]); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
356 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
357 |
if (!isJavaLangObject(argTypes[1])) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
358 |
error("second argument of a @Constructor method should be of Object type, found " + argTypes[0]); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
359 |
} |
16147 | 360 |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
361 |
if (argTypes.length > 2) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
362 |
for (int i = 2; i < argTypes.length - 1; i++) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
363 |
if (!isJavaLangObject(argTypes[i])) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
364 |
error(i + "'th argument of a @Constructor method should be of Object type, found " + argTypes[i]); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
365 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
366 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
367 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
368 |
final String lastArgTypeDesc = argTypes[argTypes.length - 1].getDescriptor(); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
369 |
final boolean isVarArg = lastArgTypeDesc.equals(OBJECT_ARRAY_DESC); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
370 |
if (!lastArgTypeDesc.equals(OBJECT_DESC) && !isVarArg) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
371 |
error("last argument of a @Constructor method is neither Object nor Object[] type: " + lastArgTypeDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
372 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
373 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
374 |
if (isVarArg && argTypes.length > 3) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
375 |
error("vararg of a @Constructor method has more than 3 arguments"); |
16147 | 376 |
} |
377 |
} |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
378 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
379 |
break; |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
380 |
case FUNCTION: { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
381 |
final Type returnType = Type.getReturnType(javaDesc); |
24769 | 382 |
if (!(isValidJSType(returnType) || Type.VOID_TYPE == returnType)) { |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
383 |
error("return value of a @Function method should be a valid JS type, found " + returnType); |
16147 | 384 |
} |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
385 |
final Type[] argTypes = Type.getArgumentTypes(javaDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
386 |
if (argTypes.length < 1) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
387 |
error("@Function methods should have at least 1 arg"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
388 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
389 |
if (!isJavaLangObject(argTypes[0])) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
390 |
error("first argument of a @Function method should be of Object type, found " + argTypes[0]); |
16147 | 391 |
} |
392 |
||
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
393 |
if (argTypes.length > 1) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
394 |
for (int i = 1; i < argTypes.length - 1; i++) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
395 |
if (!isJavaLangObject(argTypes[i])) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
396 |
error(i + "'th argument of a @Function method should be of Object type, found " + argTypes[i]); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
397 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
398 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
399 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
400 |
final String lastArgTypeDesc = argTypes[argTypes.length - 1].getDescriptor(); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
401 |
final boolean isVarArg = lastArgTypeDesc.equals(OBJECT_ARRAY_DESC); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
402 |
if (!lastArgTypeDesc.equals(OBJECT_DESC) && !isVarArg) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
403 |
error("last argument of a @Function method is neither Object nor Object[] type: " + lastArgTypeDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
404 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
405 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
406 |
if (isVarArg && argTypes.length > 2) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
407 |
error("vararg @Function method has more than 2 arguments"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
408 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
409 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
410 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
411 |
break; |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
412 |
case SPECIALIZED_FUNCTION: { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
413 |
final Type returnType = Type.getReturnType(javaDesc); |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
24993
diff
changeset
|
414 |
if (!(isValidJSType(returnType) || (isSpecializedConstructor() && Type.VOID_TYPE == returnType))) { |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
415 |
error("return value of a @SpecializedFunction method should be a valid JS type, found " + returnType); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
416 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
417 |
final Type[] argTypes = Type.getArgumentTypes(javaDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
418 |
for (int i = 0; i < argTypes.length; i++) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
419 |
if (!isValidJSType(argTypes[i])) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
420 |
error(i + "'th argument of a @SpecializedFunction method is not valid JS type, found " + argTypes[i]); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
421 |
} |
16147 | 422 |
} |
423 |
} |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
424 |
break; |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
425 |
case GETTER: { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
426 |
final Type[] argTypes = Type.getArgumentTypes(javaDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
427 |
if (argTypes.length != 1) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
428 |
error("@Getter methods should have one argument"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
429 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
430 |
if (!isJavaLangObject(argTypes[0])) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
431 |
error("first argument of a @Getter method should be of Object type, found: " + argTypes[0]); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
432 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
433 |
|
24769 | 434 |
if (Type.getReturnType(javaDesc).equals(Type.VOID_TYPE)) { |
435 |
error("return type of getter should not be void"); |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
436 |
} |
16147 | 437 |
} |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
438 |
break; |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
439 |
case SETTER: { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
440 |
final Type[] argTypes = Type.getArgumentTypes(javaDesc); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
441 |
if (argTypes.length != 2) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
442 |
error("@Setter methods should have two arguments"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
443 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
444 |
if (!isJavaLangObject(argTypes[0])) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
445 |
error("first argument of a @Setter method should be of Object type, found: " + argTypes[0]); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
446 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
447 |
if (!Type.getReturnType(javaDesc).toString().equals("V")) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
448 |
error("return type of of a @Setter method should be void, found: " + Type.getReturnType(javaDesc)); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
449 |
} |
16147 | 450 |
} |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
451 |
break; |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
452 |
case PROPERTY: { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
453 |
if (where == Where.CONSTRUCTOR) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
454 |
if (isStatic()) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
455 |
if (!isFinal()) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
456 |
error("static Where.CONSTRUCTOR @Property should be final"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
457 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
458 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
459 |
if (!isJSPrimitiveType(Type.getType(javaDesc))) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
460 |
error("static Where.CONSTRUCTOR @Property should be a JS primitive"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
461 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
462 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
463 |
} else if (where == Where.PROTOTYPE) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
464 |
if (isStatic()) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
465 |
if (!isFinal()) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
466 |
error("static Where.PROTOTYPE @Property should be final"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
467 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
468 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
469 |
if (!isJSPrimitiveType(Type.getType(javaDesc))) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
470 |
error("static Where.PROTOTYPE @Property should be a JS primitive"); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
471 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
472 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
473 |
} |
16147 | 474 |
} |
24993
b707d46bae40
8046898: Make sure that lazy compilation is the default, remove redundant "enable lazy compilation" flags, added warning message if compile logging is enabled and lazy is switched off. Verified existing test suite code coverage equivalence between lazy and eager.
lagergren
parents:
24769
diff
changeset
|
475 |
break; |
b707d46bae40
8046898: Make sure that lazy compilation is the default, remove redundant "enable lazy compilation" flags, added warning message if compile logging is enabled and lazy is switched off. Verified existing test suite code coverage equivalence between lazy and eager.
lagergren
parents:
24769
diff
changeset
|
476 |
|
b707d46bae40
8046898: Make sure that lazy compilation is the default, remove redundant "enable lazy compilation" flags, added warning message if compile logging is enabled and lazy is switched off. Verified existing test suite code coverage equivalence between lazy and eager.
lagergren
parents:
24769
diff
changeset
|
477 |
default: |
b707d46bae40
8046898: Make sure that lazy compilation is the default, remove redundant "enable lazy compilation" flags, added warning message if compile logging is enabled and lazy is switched off. Verified existing test suite code coverage equivalence between lazy and eager.
lagergren
parents:
24769
diff
changeset
|
478 |
break; |
16147 | 479 |
} |
480 |
} |
|
481 |
||
36517 | 482 |
/** |
483 |
* Returns if the given (internal) name of a class represents a ScriptObject subtype. |
|
484 |
*/ |
|
485 |
public static boolean isScriptObject(final String name) { |
|
486 |
// very crude check for ScriptObject subtype! |
|
487 |
if (name.startsWith(OBJ_PKG + "Native") || |
|
488 |
name.equals(OBJ_PKG + "Global") || |
|
489 |
name.equals(OBJ_PKG + "ArrayBufferView")) { |
|
490 |
return true; |
|
491 |
} |
|
492 |
||
493 |
if (name.startsWith(RUNTIME_PKG)) { |
|
494 |
final String simpleName = name.substring(name.lastIndexOf('/') + 1); |
|
495 |
switch (simpleName) { |
|
496 |
case "ScriptObject": |
|
497 |
case "ScriptFunction": |
|
498 |
case "NativeJavaPackage": |
|
499 |
case "Scope": |
|
500 |
return true; |
|
501 |
} |
|
502 |
} |
|
503 |
||
504 |
if (name.startsWith(SCRIPTS_PKG)) { |
|
505 |
final String simpleName = name.substring(name.lastIndexOf('/') + 1); |
|
506 |
switch (simpleName) { |
|
507 |
case "JD": |
|
508 |
case "JO": |
|
509 |
return true; |
|
510 |
} |
|
511 |
} |
|
512 |
||
513 |
return false; |
|
514 |
} |
|
515 |
||
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
516 |
private static boolean isValidJSType(final Type type) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
517 |
return isJSPrimitiveType(type) || isJSObjectType(type); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
518 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
519 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
520 |
private static boolean isJSPrimitiveType(final Type type) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
521 |
switch (type.getSort()) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
522 |
case Type.BOOLEAN: |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
523 |
case Type.INT: |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
524 |
case Type.DOUBLE: |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
525 |
return true; |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
526 |
default: |
36023 | 527 |
return type != TYPE_SYMBOL; |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
528 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
529 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
530 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
531 |
private static boolean isJSObjectType(final Type type) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
532 |
return isJavaLangObject(type) || isJavaLangString(type) || isScriptObject(type); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
533 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
534 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
535 |
private static boolean isJavaLangObject(final Type type) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
536 |
return type.getDescriptor().equals(OBJECT_DESC); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
537 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
538 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
539 |
private static boolean isJavaLangString(final Type type) { |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
540 |
return type.getDescriptor().equals(STRING_DESC); |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
541 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
542 |
|
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
543 |
private static boolean isScriptObject(final Type type) { |
36517 | 544 |
if (type.getSort() != Type.OBJECT) { |
545 |
return false; |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
546 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
547 |
|
36517 | 548 |
return isScriptObject(type.getInternalName()); |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
549 |
} |
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
550 |
|
16147 | 551 |
private void error(final String msg) { |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
22380
diff
changeset
|
552 |
throw new RuntimeException(javaName + " of type " + javaDesc + " : " + msg); |
16147 | 553 |
} |
554 |
||
555 |
/** |
|
556 |
* @return the initClass |
|
557 |
*/ |
|
558 |
String getInitClass() { |
|
559 |
return initClass; |
|
560 |
} |
|
561 |
||
562 |
/** |
|
563 |
* @param initClass the initClass to set |
|
564 |
*/ |
|
565 |
void setInitClass(final String initClass) { |
|
566 |
this.initClass = initClass; |
|
567 |
} |
|
568 |
||
569 |
@Override |
|
570 |
protected Object clone() { |
|
571 |
try { |
|
572 |
return super.clone(); |
|
573 |
} catch (final CloneNotSupportedException e) { |
|
574 |
assert false : "clone not supported " + e; |
|
575 |
return null; |
|
576 |
} |
|
577 |
} |
|
578 |
||
579 |
/** |
|
580 |
* @return the arity |
|
581 |
*/ |
|
582 |
int getArity() { |
|
583 |
return arity; |
|
584 |
} |
|
585 |
||
586 |
/** |
|
587 |
* @param arity the arity to set |
|
588 |
*/ |
|
589 |
void setArity(final int arity) { |
|
590 |
this.arity = arity; |
|
591 |
} |
|
34844
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
592 |
|
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
593 |
String getDocumentationKey(final String objName) { |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
594 |
if (kind == Kind.FUNCTION) { |
41422 | 595 |
final StringBuilder buf = new StringBuilder(objName); |
34844
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
596 |
switch (where) { |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
597 |
case CONSTRUCTOR: |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
598 |
break; |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
599 |
case PROTOTYPE: |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
600 |
buf.append(".prototype"); |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
601 |
break; |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
602 |
case INSTANCE: |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
603 |
buf.append(".this"); |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
604 |
break; |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
605 |
} |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
606 |
buf.append('.'); |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
607 |
buf.append(name); |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
608 |
return buf.toString(); |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
609 |
} |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
610 |
|
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
611 |
return null; |
31c026e00569
8146251: Avoid annotation to specify documentation for JS builtin functions
sundar
parents:
34735
diff
changeset
|
612 |
} |
16147 | 613 |
} |