Source Code Cross Referenced for ScriptOrFnNode.java in  » Scripting » rhino » org » mozilla » javascript » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » rhino » org.mozilla.javascript 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
002:         *
003:         * ***** BEGIN LICENSE BLOCK *****
004:         * Version: MPL 1.1/GPL 2.0
005:         *
006:         * The contents of this file are subject to the Mozilla Public License Version
007:         * 1.1 (the "License"); you may not use this file except in compliance with
008:         * the License. You may obtain a copy of the License at
009:         * http://www.mozilla.org/MPL/
010:         *
011:         * Software distributed under the License is distributed on an "AS IS" basis,
012:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013:         * for the specific language governing rights and limitations under the
014:         * License.
015:         *
016:         * The Original Code is Rhino code, released
017:         * May 6, 1999.
018:         *
019:         * The Initial Developer of the Original Code is
020:         * Netscape Communications Corporation.
021:         * Portions created by the Initial Developer are Copyright (C) 1997-1999
022:         * the Initial Developer. All Rights Reserved.
023:         *
024:         * Contributor(s):
025:         *   Igor Bukanov
026:         *   Bob Jervis
027:         *   Norris Boyd
028:         *
029:         * Alternatively, the contents of this file may be used under the terms of
030:         * the GNU General Public License Version 2 or later (the "GPL"), in which
031:         * case the provisions of the GPL are applicable instead of those above. If
032:         * you wish to allow use of your version of this file only under the terms of
033:         * the GPL and not to allow others to use your version of this file under the
034:         * MPL, indicate your decision by deleting the provisions above and replacing
035:         * them with the notice and other provisions required by the GPL. If you do
036:         * not delete the provisions above, a recipient may use your version of this
037:         * file under either the MPL or the GPL.
038:         *
039:         * ***** END LICENSE BLOCK ***** */
040:
041:        package org.mozilla.javascript;
042:
043:        import java.util.ArrayList;
044:
045:        public class ScriptOrFnNode extends Node.Scope {
046:
047:            public ScriptOrFnNode(int nodeType) {
048:                super (nodeType);
049:                symbols = new ArrayList(4);
050:                setParent(null);
051:            }
052:
053:            public final String getSourceName() {
054:                return sourceName;
055:            }
056:
057:            public final void setSourceName(String sourceName) {
058:                this .sourceName = sourceName;
059:            }
060:
061:            public final int getEncodedSourceStart() {
062:                return encodedSourceStart;
063:            }
064:
065:            public final int getEncodedSourceEnd() {
066:                return encodedSourceEnd;
067:            }
068:
069:            public final void setEncodedSourceBounds(int start, int end) {
070:                this .encodedSourceStart = start;
071:                this .encodedSourceEnd = end;
072:            }
073:
074:            public final int getBaseLineno() {
075:                return this .lineno;
076:            }
077:
078:            public final void setBaseLineno(int lineno) {
079:                // One time action
080:                if (lineno < 0 || this .lineno >= 0)
081:                    Kit.codeBug();
082:                this .lineno = lineno;
083:            }
084:
085:            public final int getEndLineno() {
086:                return endLineno;
087:            }
088:
089:            public final void setEndLineno(int lineno) {
090:                // One time action
091:                if (lineno < 0 || endLineno >= 0)
092:                    Kit.codeBug();
093:                endLineno = lineno;
094:            }
095:
096:            public final int getFunctionCount() {
097:                if (functions == null) {
098:                    return 0;
099:                }
100:                return functions.size();
101:            }
102:
103:            public final FunctionNode getFunctionNode(int i) {
104:                return (FunctionNode) functions.get(i);
105:            }
106:
107:            public final int addFunction(FunctionNode fnNode) {
108:                if (fnNode == null)
109:                    Kit.codeBug();
110:                if (functions == null) {
111:                    functions = new ObjArray();
112:                }
113:                functions.add(fnNode);
114:                return functions.size() - 1;
115:            }
116:
117:            public final int getRegexpCount() {
118:                if (regexps == null) {
119:                    return 0;
120:                }
121:                return regexps.size() / 2;
122:            }
123:
124:            public final String getRegexpString(int index) {
125:                return (String) regexps.get(index * 2);
126:            }
127:
128:            public final String getRegexpFlags(int index) {
129:                return (String) regexps.get(index * 2 + 1);
130:            }
131:
132:            public final int addRegexp(String string, String flags) {
133:                if (string == null)
134:                    Kit.codeBug();
135:                if (regexps == null) {
136:                    regexps = new ObjArray();
137:                }
138:                regexps.add(string);
139:                regexps.add(flags);
140:                return regexps.size() / 2 - 1;
141:            }
142:
143:            public int getIndexForNameNode(Node nameNode) {
144:                if (variableNames == null)
145:                    throw Kit.codeBug();
146:                Node.Scope node = nameNode.getScope();
147:                Symbol symbol = node == null ? null : node.getSymbol(nameNode
148:                        .getString());
149:                if (symbol == null)
150:                    return -1;
151:                return symbol.index;
152:            }
153:
154:            public final String getParamOrVarName(int index) {
155:                if (variableNames == null)
156:                    throw Kit.codeBug();
157:                return variableNames[index];
158:            }
159:
160:            public final int getParamCount() {
161:                return paramCount;
162:            }
163:
164:            public final int getParamAndVarCount() {
165:                if (variableNames == null)
166:                    throw Kit.codeBug();
167:                return symbols.size();
168:            }
169:
170:            public final String[] getParamAndVarNames() {
171:                if (variableNames == null)
172:                    throw Kit.codeBug();
173:                return variableNames;
174:            }
175:
176:            public final boolean[] getParamAndVarConst() {
177:                if (variableNames == null)
178:                    throw Kit.codeBug();
179:                return isConsts;
180:            }
181:
182:            void addSymbol(Symbol symbol) {
183:                if (variableNames != null)
184:                    throw Kit.codeBug();
185:                if (symbol.declType == Token.LP) {
186:                    paramCount++;
187:                }
188:                symbols.add(symbol);
189:            }
190:
191:            /**
192:             * Assign every symbol a unique integer index. Generate arrays of variable 
193:             * names and constness that can be indexed by those indices.
194:             * 
195:             * @param flattenAllTables if true, flatten all symbol tables, included
196:             * nested block scope symbol tables. If false, just flatten the script's
197:             * or function's symbol table.
198:             */
199:            void flattenSymbolTable(boolean flattenAllTables) {
200:                if (!flattenAllTables) {
201:                    ArrayList newSymbols = new ArrayList();
202:                    if (this .symbolTable != null) {
203:                        // Just replace "symbols" with the symbols in this object's
204:                        // symbol table. Can't just work from symbolTable map since
205:                        // we need to retain duplicate parameters.
206:                        for (int i = 0; i < symbols.size(); i++) {
207:                            Symbol symbol = (Symbol) symbols.get(i);
208:                            if (symbol.containingTable == this ) {
209:                                newSymbols.add(symbol);
210:                            }
211:                        }
212:                    }
213:                    symbols = newSymbols;
214:                }
215:                variableNames = new String[symbols.size()];
216:                isConsts = new boolean[symbols.size()];
217:                for (int i = 0; i < symbols.size(); i++) {
218:                    Symbol symbol = (Symbol) symbols.get(i);
219:                    variableNames[i] = symbol.name;
220:                    isConsts[i] = symbol.declType == Token.CONST;
221:                    symbol.index = i;
222:                }
223:            }
224:
225:            public final Object getCompilerData() {
226:                return compilerData;
227:            }
228:
229:            public final void setCompilerData(Object data) {
230:                if (data == null)
231:                    throw new IllegalArgumentException();
232:                // Can only call once
233:                if (compilerData != null)
234:                    throw new IllegalStateException();
235:                compilerData = data;
236:            }
237:
238:            public String getNextTempName() {
239:                return "$" + tempNumber++;
240:            }
241:
242:            private int encodedSourceStart;
243:            private int encodedSourceEnd;
244:            private String sourceName;
245:            private int endLineno = -1;
246:
247:            private ObjArray functions;
248:            private ObjArray regexps;
249:
250:            private ArrayList symbols;
251:            private int paramCount = 0;
252:            private String[] variableNames;
253:            private boolean[] isConsts;
254:
255:            private Object compilerData;
256:            private int tempNumber = 0;
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.