1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dasm;
18 
19 import java.util.Hashtable;
20 
21 import java_cup.runtime.token;
22 
23 class ReservedWords {
24     static Hashtable<String, token> reserved_words;
25 
get(String name)26     public static token get(String name) {
27         return (token) reserved_words.get(name);
28     }
29 
contains(String name)30     public static boolean contains(String name) {
31         return reserved_words.get(name) != null;
32     }
33 
34     static {
35         reserved_words = new Hashtable<String, token>();
36 
37         // Dasm directives
38         reserved_words.put(".annotation", new token(sym.DANNOTATION));
39         reserved_words.put(".attribute", new token(sym.DATTRIBUTE));
40         reserved_words.put(".bytecode", new token(sym.DBYTECODE));
41         reserved_words.put(".catch", new token(sym.DCATCH));
42         reserved_words.put(".class", new token(sym.DCLASS));
43         reserved_words.put(".deprecated", new token(sym.DDEPRECATED));
44         reserved_words.put(".end", new token(sym.DEND));
45         reserved_words.put(".field", new token(sym.DFIELD));
46         reserved_words.put(".implements", new token(sym.DIMPLEMENTS));
47         reserved_words.put(".inner", new token(sym.DINNER));
48         reserved_words.put(".interface", new token(sym.DINTERFACE));
49         reserved_words.put(".limit", new token(sym.DLIMIT));
50         reserved_words.put(".line", new token(sym.DLINE));
51         reserved_words.put(".method", new token(sym.DMETHOD));
52         reserved_words.put(".set", new token(sym.DSET));
53         reserved_words.put(".source", new token(sym.DSOURCE));
54         reserved_words.put(".super", new token(sym.DSUPER));
55         reserved_words.put(".throws", new token(sym.DTHROWS));
56         reserved_words.put(".var", new token(sym.DVAR));
57         reserved_words.put(".enclosing", new token(sym.DENCLOSING));
58         reserved_words.put(".signature", new token(sym.DSIGNATURE));
59 
60         // reserved_words used in Dasm directives
61         reserved_words.put("field", new token(sym.FIELD));
62         reserved_words.put("from", new token(sym.FROM));
63         reserved_words.put("method", new token(sym.METHOD));
64         reserved_words.put("to", new token(sym.TO));
65         reserved_words.put("is", new token(sym.IS));
66         reserved_words.put("using", new token(sym.USING));
67         reserved_words.put("signature", new token(sym.SIGNATURE));
68         reserved_words.put("regs", new token(sym.REGS));
69         reserved_words.put("inner", new token(sym.INNER));
70         reserved_words.put("outer", new token(sym.OUTER));
71         reserved_words.put("class", new token(sym.CLASS));
72         reserved_words.put("visible", new token(sym.VISIBLE));
73         reserved_words.put("invisible", new token(sym.INVISIBLE));
74         reserved_words.put("visibleparam", new token(sym.VISIBLEPARAM));
75         reserved_words.put("invisibleparam", new token(sym.INVISIBLEPARAM));
76 
77         // Special-case instructions
78         reserved_words.put("fill-array-data", new token(sym.FILL_ARRAY_DATA));
79         reserved_words.put("fill-array-data-end", new token(
80                 sym.FILL_ARRAY_DATA_END));
81         reserved_words.put("packed-switch", new token(sym.PACKED_SWITCH));
82         reserved_words.put("packed-switch-end",
83                 new token(sym.PACKED_SWITCH_END));
84         reserved_words.put("sparse-switch", new token(sym.SPARSE_SWITCH));
85         reserved_words.put("sparse-switch-end",
86                 new token(sym.SPARSE_SWITCH_END));
87         reserved_words.put("default", new token(sym.DEFAULT));
88 
89         // Access flags
90         reserved_words.put("public", new token(sym.PUBLIC));
91         reserved_words.put("private", new token(sym.PRIVATE));
92         reserved_words.put("protected", new token(sym.PROTECTED));
93         reserved_words.put("static", new token(sym.STATIC));
94         reserved_words.put("final", new token(sym.FINAL));
95         reserved_words.put("synchronized", new token(sym.SYNCHRONIZED));
96         reserved_words.put("declared_synchronized", new token(
97                 sym.DECLARED_SYNCHRONIZED));
98         reserved_words.put("volatile", new token(sym.VOLATILE));
99         reserved_words.put("transient", new token(sym.TRANSIENT));
100         reserved_words.put("native", new token(sym.NATIVE));
101         reserved_words.put("interface", new token(sym.INTERFACE));
102         reserved_words.put("abstract", new token(sym.ABSTRACT));
103 
104         reserved_words.put("annotation", new token(sym.ANNOTATION));
105         reserved_words.put("enum", new token(sym.ENUM));
106         reserved_words.put("bridge", new token(sym.BRIDGE));
107         reserved_words.put("varargs", new token(sym.VARARGS));
108         reserved_words.put("fpstrict", new token(sym.STRICT));
109         reserved_words.put("synthetic", new token(sym.SYNTHETIC));
110     }
111 }
112