StringConstants.java revision 6:5a1b0714df0e
1/*
2 * Copyright (c) 2010, 2013, 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
26package jdk.nashorn.internal.tools.nasgen;
27
28import java.lang.invoke.MethodHandle;
29import java.lang.reflect.Method;
30import jdk.internal.org.objectweb.asm.Type;
31import jdk.nashorn.internal.objects.PrototypeObject;
32import jdk.nashorn.internal.objects.ScriptFunctionImpl;
33import jdk.nashorn.internal.runtime.PropertyMap;
34import jdk.nashorn.internal.runtime.ScriptFunction;
35import jdk.nashorn.internal.runtime.ScriptObject;
36import jdk.nashorn.internal.runtime.linker.Lookup;
37
38/**
39 * String constants used for code generation/instrumentation.
40 */
41@SuppressWarnings("javadoc")
42public interface StringConstants {
43    static final Type TYPE_METHOD             = Type.getType(Method.class);
44    static final Type TYPE_METHODHANDLE       = Type.getType(MethodHandle.class);
45    static final Type TYPE_METHODHANDLE_ARRAY = Type.getType(MethodHandle[].class);
46    static final Type TYPE_OBJECT             = Type.getType(Object.class);
47    static final Type TYPE_CLASS              = Type.getType(Class.class);
48    static final Type TYPE_STRING             = Type.getType(String.class);
49
50    // Nashorn types
51    static final Type TYPE_LOOKUP             = Type.getType(Lookup.class);
52    static final Type TYPE_PROPERTYMAP        = Type.getType(PropertyMap.class);
53    static final Type TYPE_PROTOTYPEOBJECT    = Type.getType(PrototypeObject.class);
54    static final Type TYPE_SCRIPTFUNCTION     = Type.getType(ScriptFunction.class);
55    static final Type TYPE_SCRIPTFUNCTIONIMPL = Type.getType(ScriptFunctionImpl.class);
56    static final Type TYPE_SCRIPTOBJECT       = Type.getType(ScriptObject.class);
57
58    static final String PROTOTYPE = "prototype";
59    static final String PROTOTYPE_SUFFIX = "$Prototype";
60    static final String CONSTRUCTOR_SUFFIX = "$Constructor";
61    // This field name is known to Nashorn runtime (Context).
62    // Synchronize the name change, if needed at all.
63    static final String MAP_FIELD_NAME = "$nasgenmap$";
64    static final String $CLINIT$ = "$clinit$";
65    static final String CLINIT = "<clinit>";
66    static final String INIT = "<init>";
67    static final String DEFAULT_INIT_DESC = Type.getMethodDescriptor(Type.VOID_TYPE);
68
69    static final String SCRIPTOBJECT_INIT_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_PROPERTYMAP);
70
71    static final String METHODHANDLE_TYPE = TYPE_METHODHANDLE.getInternalName();
72
73    static final String OBJECT_TYPE = TYPE_OBJECT.getInternalName();
74    static final String OBJECT_DESC = TYPE_OBJECT.getDescriptor();
75    static final String OBJECT_ARRAY_DESC = Type.getDescriptor(Object[].class);
76
77    static final String SCRIPTFUNCTION_TYPE = TYPE_SCRIPTFUNCTION.getInternalName();
78    static final String SCRIPTFUNCTIONIMPL_TYPE = TYPE_SCRIPTFUNCTIONIMPL.getInternalName();
79    static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION = "makeFunction";
80    static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION_DESC =
81        Type.getMethodDescriptor(TYPE_SCRIPTFUNCTION, TYPE_STRING, TYPE_METHODHANDLE);
82    static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION_SPECS_DESC =
83        Type.getMethodDescriptor(TYPE_SCRIPTFUNCTION, TYPE_STRING, TYPE_METHODHANDLE, TYPE_METHODHANDLE_ARRAY);
84
85    static final String SCRIPTFUNCTIONIMPL_INIT_DESC3 =
86        Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING, TYPE_METHODHANDLE, TYPE_METHODHANDLE_ARRAY);
87    static final String SCRIPTFUNCTIONIMPL_INIT_DESC4 =
88        Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING, TYPE_METHODHANDLE, TYPE_PROPERTYMAP, TYPE_METHODHANDLE_ARRAY);
89    static final String SCRIPTFUNCTION_SETARITY = "setArity";
90    static final String SCRIPTFUNCTION_SETARITY_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE);
91    static final String PROTOTYPEOBJECT_TYPE = TYPE_PROTOTYPEOBJECT.getInternalName();
92    static final String PROTOTYPEOBJECT_SETCONSTRUCTOR = "setConstructor";
93    static final String PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_OBJECT, TYPE_OBJECT);
94    static final String SCRIPTOBJECT_TYPE = TYPE_SCRIPTOBJECT.getInternalName();
95    static final String MAP_TYPE = TYPE_PROPERTYMAP.getInternalName();
96    static final String MAP_DESC = TYPE_PROPERTYMAP.getDescriptor();
97    static final String MAP_NEWMAP = "newMap";
98    static final String MAP_NEWMAP_DESC = Type.getMethodDescriptor(TYPE_PROPERTYMAP, TYPE_CLASS);
99    static final String MAP_DUPLICATE = "duplicate";
100    static final String MAP_DUPLICATE_DESC = Type.getMethodDescriptor(TYPE_PROPERTYMAP);
101    static final String MAP_SETFLAGS = "setFlags";
102    static final String LOOKUP_TYPE = TYPE_LOOKUP.getInternalName();
103    static final String LOOKUP_GETMETHOD = "getMethod";
104    static final String LOOKUP_NEWPROPERTY = "newProperty";
105    static final String LOOKUP_NEWPROPERTY_DESC =
106        Type.getMethodDescriptor(TYPE_PROPERTYMAP, TYPE_PROPERTYMAP, TYPE_STRING, Type.INT_TYPE, TYPE_METHODHANDLE, TYPE_METHODHANDLE);
107    static final String GETTER_PREFIX = "G$";
108    static final String SETTER_PREFIX = "S$";
109
110    // ScriptObject.getClassName() method.
111    static final String GET_CLASS_NAME = "getClassName";
112    static final String GET_CLASS_NAME_DESC = Type.getMethodDescriptor(TYPE_STRING);
113}
114