01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.js.ast;
17:
18: /**
19: * An abstract base class for named JavaScript objects.
20: */
21: public class JsName {
22:
23: private final JsScope enclosing;
24: private final String ident;
25: private boolean isObfuscatable;
26: private String shortIdent;
27:
28: /**
29: * A back-reference to the JsNode that the JsName refers to.
30: */
31: private JsNode staticRef;
32:
33: /**
34: * @param ident the unmangled ident to use for this name
35: */
36: JsName(JsScope enclosing, String ident, String shortIdent) {
37: this .enclosing = enclosing;
38: this .ident = ident;
39: this .shortIdent = shortIdent;
40: this .isObfuscatable = true;
41: }
42:
43: public JsScope getEnclosing() {
44: return enclosing;
45: }
46:
47: public String getIdent() {
48: return ident;
49: }
50:
51: public String getShortIdent() {
52: return shortIdent;
53: }
54:
55: public JsNode getStaticRef() {
56: return staticRef;
57: }
58:
59: public boolean isObfuscatable() {
60: return isObfuscatable;
61: }
62:
63: public JsNameRef makeRef() {
64: return new JsNameRef(this );
65: }
66:
67: public void setObfuscatable(boolean isObfuscatable) {
68: this .isObfuscatable = isObfuscatable;
69: }
70:
71: public void setShortIdent(String shortIdent) {
72: this .shortIdent = shortIdent;
73: }
74:
75: /**
76: * Should never be called except on immutable stuff.
77: */
78: public void setStaticRef(JsNode node) {
79: this .staticRef = node;
80: }
81:
82: @Override
83: public String toString() {
84: return ident;
85: }
86:
87: }
|