StringConstants.java revision 229:c62144b08c65
1219732Sume/*
2282746Sgjb * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3219732Sume * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4219732Sume *
5219732Sume * This code is free software; you can redistribute it and/or modify it
6219732Sume * under the terms of the GNU General Public License version 2 only, as
7219732Sume * published by the Free Software Foundation.  Oracle designates this
8219732Sume * particular file as subject to the "Classpath" exception as provided
9219732Sume * by Oracle in the LICENSE file that accompanied this code.
10219732Sume *
11219732Sume * This code is distributed in the hope that it will be useful, but WITHOUT
12219732Sume * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13219732Sume * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14219732Sume * version 2 for more details (a copy is included in the LICENSE file that
15219732Sume * accompanied this code).
16219732Sume *
17219732Sume * You should have received a copy of the GNU General Public License version
18219732Sume * 2 along with this work; if not, write to the Free Software Foundation,
19219732Sume * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20219732Sume *
21219732Sume * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22219732Sume * or visit www.oracle.com if you need additional information or have any
23219732Sume * questions.
24219732Sume */
25219732Sume
26219732Sumepackage jdk.nashorn.internal.tools.nasgen;
27219732Sume
28219732Sumeimport java.lang.invoke.MethodHandle;
29219732Sumeimport java.lang.reflect.Method;
30219732Sumeimport jdk.internal.org.objectweb.asm.Type;
31219732Sumeimport jdk.nashorn.internal.lookup.Lookup;
32282746Sgjbimport jdk.nashorn.internal.objects.PrototypeObject;
33282746Sgjbimport jdk.nashorn.internal.objects.ScriptFunctionImpl;
34282746Sgjbimport jdk.nashorn.internal.runtime.PropertyMap;
35219732Sumeimport jdk.nashorn.internal.runtime.ScriptFunction;
36219732Sumeimport jdk.nashorn.internal.runtime.ScriptObject;
37219732Sume
38219732Sume/**
39219732Sume * String constants used for code generation/instrumentation.
40219732Sume */
41219732Sume@SuppressWarnings("javadoc")
42219732Sumepublic interface StringConstants {
43219732Sume    static final Type TYPE_METHOD             = Type.getType(Method.class);
44219732Sume    static final Type TYPE_METHODHANDLE       = Type.getType(MethodHandle.class);
45219732Sume    static final Type TYPE_METHODHANDLE_ARRAY = Type.getType(MethodHandle[].class);
46219732Sume    static final Type TYPE_OBJECT             = Type.getType(Object.class);
47219732Sume    static final Type TYPE_CLASS              = Type.getType(Class.class);
48219732Sume    static final Type TYPE_STRING             = Type.getType(String.class);
49219732Sume
50219732Sume    // Nashorn types
51282746Sgjb    static final Type TYPE_LOOKUP             = Type.getType(Lookup.class);
52219732Sume    static final Type TYPE_PROPERTYMAP        = Type.getType(PropertyMap.class);
53219732Sume    static final Type TYPE_PROTOTYPEOBJECT    = Type.getType(PrototypeObject.class);
54219732Sume    static final Type TYPE_SCRIPTFUNCTION     = Type.getType(ScriptFunction.class);
55219732Sume    static final Type TYPE_SCRIPTFUNCTIONIMPL = Type.getType(ScriptFunctionImpl.class);
56219732Sume    static final Type TYPE_SCRIPTOBJECT       = Type.getType(ScriptObject.class);
57219732Sume
58219732Sume    static final String PROTOTYPE_SUFFIX = "$Prototype";
59219732Sume    static final String CONSTRUCTOR_SUFFIX = "$Constructor";
60219732Sume    // This field name is known to Nashorn runtime (Context).
61219732Sume    // Synchronize the name change, if needed at all.
62219732Sume    static final String MAP_FIELD_NAME = "$nasgenmap$";
63219732Sume    static final String $CLINIT$ = "$clinit$";
64219732Sume    static final String CLINIT = "<clinit>";
65219732Sume    static final String INIT = "<init>";
66219732Sume    static final String DEFAULT_INIT_DESC = Type.getMethodDescriptor(Type.VOID_TYPE);
67219732Sume
68219732Sume    static final String SCRIPTOBJECT_INIT_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_PROPERTYMAP);
69219732Sume
70219732Sume    static final String METHODHANDLE_TYPE = TYPE_METHODHANDLE.getInternalName();
71219732Sume
72219732Sume    static final String OBJECT_TYPE = TYPE_OBJECT.getInternalName();
73219732Sume    static final String OBJECT_DESC = TYPE_OBJECT.getDescriptor();
74219732Sume    static final String OBJECT_ARRAY_DESC = Type.getDescriptor(Object[].class);
75219732Sume
76219732Sume    static final String SCRIPTFUNCTION_TYPE = TYPE_SCRIPTFUNCTION.getInternalName();
77219732Sume    static final String SCRIPTFUNCTIONIMPL_TYPE = TYPE_SCRIPTFUNCTIONIMPL.getInternalName();
78219732Sume    static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION = "makeFunction";
79219732Sume    static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION_DESC =
80219732Sume        Type.getMethodDescriptor(TYPE_SCRIPTFUNCTION, TYPE_STRING, TYPE_METHODHANDLE);
81219732Sume    static final String SCRIPTFUNCTIONIMPL_MAKEFUNCTION_SPECS_DESC =
82219732Sume        Type.getMethodDescriptor(TYPE_SCRIPTFUNCTION, TYPE_STRING, TYPE_METHODHANDLE, TYPE_METHODHANDLE_ARRAY);
83219732Sume
84219732Sume    static final String SCRIPTFUNCTIONIMPL_INIT_DESC3 =
85282746Sgjb        Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING, TYPE_METHODHANDLE, TYPE_METHODHANDLE_ARRAY);
86219732Sume    static final String SCRIPTFUNCTIONIMPL_INIT_DESC4 =
87219732Sume        Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_STRING, TYPE_METHODHANDLE, TYPE_PROPERTYMAP, TYPE_METHODHANDLE_ARRAY);
88282746Sgjb    static final String SCRIPTFUNCTION_SETARITY = "setArity";
89282746Sgjb    static final String SCRIPTFUNCTION_SETARITY_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE);
90282746Sgjb    static final String SCRIPTFUNCTION_SETPROTOTYPE = "setPrototype";
91282746Sgjb    static final String SCRIPTFUNCTION_SETPROTOTYPE_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_OBJECT);
92282746Sgjb    static final String PROTOTYPEOBJECT_TYPE = TYPE_PROTOTYPEOBJECT.getInternalName();
93282746Sgjb    static final String PROTOTYPEOBJECT_SETCONSTRUCTOR = "setConstructor";
94282746Sgjb    static final String PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_OBJECT, TYPE_OBJECT);
95219732Sume    static final String SCRIPTOBJECT_TYPE = TYPE_SCRIPTOBJECT.getInternalName();
96219732Sume    static final String MAP_TYPE = TYPE_PROPERTYMAP.getInternalName();
97282746Sgjb    static final String MAP_DESC = TYPE_PROPERTYMAP.getDescriptor();
98219732Sume    static final String MAP_NEWMAP = "newMap";
99219732Sume    static final String MAP_NEWMAP_DESC = Type.getMethodDescriptor(TYPE_PROPERTYMAP, TYPE_CLASS);
100219732Sume    static final String MAP_DUPLICATE = "duplicate";
101282746Sgjb    static final String MAP_DUPLICATE_DESC = Type.getMethodDescriptor(TYPE_PROPERTYMAP);
102282746Sgjb    static final String MAP_SETFLAGS = "setFlags";
103219732Sume    static final String LOOKUP_TYPE = TYPE_LOOKUP.getInternalName();
104219732Sume    static final String LOOKUP_GETMETHOD = "getMethod";
105219732Sume    static final String LOOKUP_NEWPROPERTY = "newProperty";
106219732Sume    static final String LOOKUP_NEWPROPERTY_DESC =
107282746Sgjb        Type.getMethodDescriptor(TYPE_PROPERTYMAP, TYPE_PROPERTYMAP, TYPE_STRING, Type.INT_TYPE, TYPE_METHODHANDLE, TYPE_METHODHANDLE);
108282746Sgjb    static final String GETTER_PREFIX = "G$";
109219732Sume    static final String SETTER_PREFIX = "S$";
110282746Sgjb
111219732Sume    // ScriptObject.getClassName() method.
112219732Sume    static final String GET_CLASS_NAME = "getClassName";
113219732Sume    static final String GET_CLASS_NAME_DESC = Type.getMethodDescriptor(TYPE_STRING);
114219732Sume}
115219732Sume