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: * The root scope is the parent of every scope. All identifiers in this scope
20: * are not obfuscatable.
21: */
22: public final class JsRootScope extends JsScope {
23:
24: private final JsProgram program;
25:
26: public JsRootScope(JsProgram program) {
27: super ("Root");
28: this .program = program;
29: ctorAddKnownGlobalSymbols();
30: }
31:
32: @Override
33: public JsProgram getProgram() {
34: return program;
35: }
36:
37: @Override
38: protected JsName doCreateName(String ident, String shortIdent) {
39: JsName name = super .doCreateName(ident, shortIdent);
40: name.setObfuscatable(false);
41: return name;
42: }
43:
44: private void ctorAddKnownGlobalSymbols() {
45: String[] commonBuiltins = new String[] { "ActiveXObject",
46: "Array", "Boolean", "Date", "Debug", "Enumerator",
47: "Error", "Function", "Global", "Image", "Math",
48: "Number", "Object", "RegExp", "String", "VBArray",
49: "window", "document", "event", "arguments", "call",
50: "toString", "$wnd", "$doc", "$moduleName",
51: "$moduleBase", "undefined", "getClass", "$gwt_version" };
52:
53: for (int i = 0; i < commonBuiltins.length; i++) {
54: String ident = commonBuiltins[i];
55: this.doCreateName(ident, ident);
56: }
57: }
58:
59: }
|