Source Code Cross Referenced for Autoload.java in  » Rule-Engine » JLisa » org » armedbear » lisp » 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 » Rule Engine » JLisa » org.armedbear.lisp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Autoload.java
003:         *
004:         * Copyright (C) 2003 Peter Graves
005:         * $Id: Autoload.java,v 1.7 2003/11/15 11:03:34 beedlem Exp $
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:
022:        package org.armedbear.lisp;
023:
024:        public class Autoload extends Function {
025:            protected final Symbol symbol;
026:            protected final String fileName;
027:            protected final String className;
028:
029:            protected Autoload(Symbol symbol) {
030:                this .symbol = symbol;
031:                fileName = null;
032:                className = null;
033:            }
034:
035:            protected Autoload(Symbol symbol, String fileName, String className) {
036:                this .symbol = symbol;
037:                this .fileName = fileName;
038:                this .className = className;
039:            }
040:
041:            public static void autoload(String symbolName, String className) {
042:                autoload(PACKAGE_CL, symbolName, className);
043:            }
044:
045:            public static void autoload(Package pkg, String symbolName,
046:                    String className) {
047:                autoload(pkg, symbolName, className, false);
048:            }
049:
050:            public static void autoload(Package pkg, String symbolName,
051:                    String className, boolean exported) {
052:                Symbol symbol = intern(symbolName.toUpperCase(), pkg);
053:                if (pkg != PACKAGE_CL && exported) {
054:                    try {
055:                        pkg.export(symbol);
056:                    } catch (ConditionThrowable t) {
057:                        Debug.assertTrue(false);
058:                    }
059:                }
060:                symbol.setSymbolFunction(new Autoload(symbol, null,
061:                        "org.armedbear.lisp.".concat(className)));
062:            }
063:
064:            public void load() throws ConditionThrowable {
065:                if (className != null) {
066:                    final LispThread thread = LispThread.currentThread();
067:                    final Environment oldDynEnv = thread
068:                            .getDynamicEnvironment();
069:                    int loadDepth = Fixnum.getInt(_LOAD_DEPTH_.symbolValue());
070:                    thread.bindSpecial(_LOAD_DEPTH_, new Fixnum(++loadDepth));
071:                    try {
072:                        if (_AUTOLOAD_VERBOSE_.symbolValueNoThrow() != NIL) {
073:                            final String prefix = Load
074:                                    .getLoadVerbosePrefix(loadDepth);
075:                            CharacterOutputStream out = getStandardOutput();
076:                            out.writeString(prefix);
077:                            out.writeString(" Autoloading ");
078:                            out.writeString(className);
079:                            out.writeLine(" ...");
080:                            out.flushOutput();
081:                            long start = System.currentTimeMillis();
082:                            Class.forName(className);
083:                            long elapsed = System.currentTimeMillis() - start;
084:                            out.writeString(prefix);
085:                            out.writeString(" Autoloaded ");
086:                            out.writeString(className);
087:                            out.writeString(" (");
088:                            out.writeString(String
089:                                    .valueOf(((float) elapsed) / 1000));
090:                            out.writeLine(" seconds)");
091:                            out.flushOutput();
092:                        } else
093:                            Class.forName(className);
094:                    } catch (ClassNotFoundException e) {
095:                        e.printStackTrace();
096:                    } finally {
097:                        thread.setDynamicEnvironment(oldDynEnv);
098:                    }
099:                } else
100:                    Load._load(getFileName(), true);
101:            }
102:
103:            public final Symbol getSymbol() {
104:                return symbol;
105:            }
106:
107:            protected final String getFileName() {
108:                if (fileName != null)
109:                    return fileName;
110:                return symbol.getName().toLowerCase().concat(".lisp");
111:            }
112:
113:            public final int getFunctionalType() {
114:                return FTYPE_AUTOLOAD;
115:            }
116:
117:            public String toString() {
118:                StringBuffer sb = new StringBuffer("#<AUTOLOAD ");
119:                sb.append(symbol);
120:                sb.append(" \"");
121:                sb.append(getFileName());
122:                sb.append("\">");
123:                return sb.toString();
124:            }
125:
126:            private static final Primitive AUTOLOAD = new Primitive("autoload",
127:                    PACKAGE_EXT, true) {
128:                public LispObject execute(LispObject first)
129:                        throws ConditionThrowable {
130:                    if (first instanceof  Symbol) {
131:                        Symbol symbol = (Symbol) first;
132:                        symbol.setSymbolFunction(new Autoload(symbol));
133:                        return T;
134:                    }
135:                    if (first instanceof  Cons) {
136:                        for (LispObject list = first; list != NIL; list = list
137:                                .cdr()) {
138:                            Symbol symbol = checkSymbol(list.car());
139:                            symbol.setSymbolFunction(new Autoload(symbol));
140:                        }
141:                        return T;
142:                    }
143:                    throw new ConditionThrowable(new TypeError(first));
144:                }
145:
146:                public LispObject execute(LispObject first, LispObject second)
147:                        throws ConditionThrowable {
148:                    final String fileName = LispString.getValue(second);
149:                    if (first instanceof  Symbol) {
150:                        Symbol symbol = (Symbol) first;
151:                        symbol.setSymbolFunction(new Autoload(symbol, fileName,
152:                                null));
153:                        return T;
154:                    }
155:                    if (first instanceof  Cons) {
156:                        for (LispObject list = first; list != NIL; list = list
157:                                .cdr()) {
158:                            Symbol symbol = checkSymbol(list.car());
159:                            symbol.setSymbolFunction(new Autoload(symbol,
160:                                    fileName, null));
161:                        }
162:                        return T;
163:                    }
164:                    throw new ConditionThrowable(new TypeError(first));
165:                }
166:            };
167:
168:            // ### resolve
169:            // Force autoload to be resolved.
170:            private static final Primitive1 RESOLVE = new Primitive1("resolve",
171:                    PACKAGE_EXT, true) {
172:                public LispObject execute(LispObject arg)
173:                        throws ConditionThrowable {
174:                    Symbol symbol = checkSymbol(arg);
175:                    LispObject fun = symbol.getSymbolFunction();
176:                    if (fun instanceof  Autoload) {
177:                        Autoload autoload = (Autoload) fun;
178:                        autoload.load();
179:                        return autoload.getSymbol().getSymbolFunction();
180:                    }
181:                    return fun;
182:                }
183:            };
184:
185:            private static final Primitive1 AUTOLOADP = new Primitive1(
186:                    "autoloadp", PACKAGE_EXT, true) {
187:                public LispObject execute(LispObject arg)
188:                        throws ConditionThrowable {
189:                    if (arg instanceof  Symbol) {
190:                        if (arg.getSymbolFunction() instanceof  Autoload)
191:                            return T;
192:                    }
193:                    return NIL;
194:                }
195:            };
196:
197:            static {
198:                autoload("array-displacement", "DisplacedArray");
199:                autoload("ash", "ash");
200:                autoload("atan", "atan");
201:                autoload("cell-error-name", "cell_error_name");
202:                autoload("char-equal", "CharacterFunctions");
203:                autoload("char-greaterp", "CharacterFunctions");
204:                autoload("char-lessp", "CharacterFunctions");
205:                autoload("char-not-greaterp", "CharacterFunctions");
206:                autoload("char-not-lessp", "CharacterFunctions");
207:                autoload("char=", "CharacterFunctions");
208:                autoload("class-name", "LispClass");
209:                autoload("clrhash", "HashTable");
210:                autoload("coerce", "coerce");
211:                autoload("copy-structure", "StructureObject");
212:                autoload("delete-file", "delete_file");
213:                autoload("delete-package", "PackageFunctions");
214:                autoload("describe", "describe");
215:                autoload("directory-namestring", "Pathname");
216:                autoload("file-write-date", "Time");
217:                autoload("find-class", "LispClass");
218:                autoload("get-internal-real-time", "Time");
219:                autoload("get-internal-run-time", "Time");
220:                autoload("get-output-stream-string", "StringOutputStream");
221:                autoload("get-universal-time", "Time");
222:                autoload("gethash", "HashTable");
223:                autoload("hash-table-count", "HashTable");
224:                autoload("hash-table-p", "HashTable");
225:                autoload("import", "PackageFunctions");
226:                autoload("last", "last");
227:                autoload("lisp-implementation-type", "lisp_implementation_type");
228:                autoload("lisp-implementation-version",
229:                        "lisp_implementation_version");
230:                autoload("list-all-packages", "PackageFunctions");
231:                autoload("logand", "logand");
232:                autoload("logandc1", "logandc1");
233:                autoload("logandc2", "logandc2");
234:                autoload("logbitp", "logbitp");
235:                autoload("logcount", "logcount");
236:                autoload("logeqv", "logeqv");
237:                autoload("logior", "logior");
238:                autoload("lognand", "lognand");
239:                autoload("lognor", "lognor");
240:                autoload("lognot", "lognot");
241:                autoload("logorc1", "logorc1");
242:                autoload("logorc2", "logorc2");
243:                autoload("logtest", "logtest");
244:                autoload("logxor", "logxor");
245:                autoload("make-string-input-stream", "StringInputStream");
246:                autoload("make-string-output-stream", "StringOutputStream");
247:                autoload("namestring", "Pathname");
248:                autoload("package-name", "PackageFunctions");
249:                autoload("package-nicknames", "PackageFunctions");
250:                autoload("package-shadowing-symbols", "PackageFunctions");
251:                autoload("package-use-list", "PackageFunctions");
252:                autoload("package-used-by-list", "PackageFunctions");
253:                autoload("packagep", "PackageFunctions");
254:                autoload("pathname", "Pathname");
255:                autoload("pathnamep", "Pathname");
256:                autoload("probe-file", "probe_file");
257:                autoload("remhash", "HashTable");
258:                autoload("rename-package", "PackageFunctions");
259:                autoload("room", "room");
260:                autoload("shadow", "PackageFunctions");
261:                autoload("shadowing-import", "PackageFunctions");
262:                autoload("sxhash", "HashTable");
263:                autoload("unexport", "PackageFunctions");
264:                autoload("unuse-package", "PackageFunctions");
265:                autoload("user-homedir-pathname", "Pathname");
266:                autoload(PACKAGE_EXT, "add-class", "LispClass", true);
267:                autoload(PACKAGE_EXT, "assq", "assq", true);
268:                autoload(PACKAGE_EXT, "classp", "LispClass", true);
269:                autoload(PACKAGE_EXT, "file-directory-p", "probe_file", true);
270:                autoload(PACKAGE_EXT, "gc", "gc", true);
271:                autoload(PACKAGE_EXT, "probe-directory", "probe_file", true);
272:                autoload(PACKAGE_JAVA, "%jregister-handler", "JHandler");
273:                autoload(PACKAGE_PROF, "%start-profiler", "Profiler", true);
274:                autoload(PACKAGE_PROF, "stop-profiler", "Profiler", true);
275:                autoload(PACKAGE_SYS, "%define-condition", "define_condition");
276:                autoload(PACKAGE_SYS, "%defpackage", "PackageFunctions");
277:                autoload(PACKAGE_SYS, "%make-array", "make_array");
278:                autoload(PACKAGE_SYS, "%make-condition", "make_condition");
279:                autoload(PACKAGE_SYS, "%make-hash-table", "HashTable");
280:                autoload(PACKAGE_SYS, "%make-pathname", "Pathname");
281:                autoload(PACKAGE_SYS, "%make-structure", "StructureObject");
282:                autoload(PACKAGE_SYS, "%nstring-capitalize", "StringFunctions");
283:                autoload(PACKAGE_SYS, "%nstring-downcase", "StringFunctions");
284:                autoload(PACKAGE_SYS, "%nstring-upcase", "StringFunctions");
285:                autoload(PACKAGE_SYS, "%open-input-file", "open");
286:                autoload(PACKAGE_SYS, "%open-output-file", "open");
287:                autoload(PACKAGE_SYS, "%set-class-direct-methods", "LispClass");
288:                autoload(PACKAGE_SYS, "%set-class-direct-slots",
289:                        "StandardClass");
290:                autoload(PACKAGE_SYS, "%set-class-slots", "StandardClass");
291:                autoload(PACKAGE_SYS,
292:                        "%set-generic-function-discriminating-function",
293:                        "GenericFunction");
294:                autoload(PACKAGE_SYS, "%string-capitalize", "StringFunctions");
295:                autoload(PACKAGE_SYS, "%string-downcase", "StringFunctions");
296:                autoload(PACKAGE_SYS, "%string-equal", "StringFunctions");
297:                autoload(PACKAGE_SYS, "%string-greaterp", "StringFunctions");
298:                autoload(PACKAGE_SYS, "%string-lessp", "StringFunctions");
299:                autoload(PACKAGE_SYS, "%string-not-equal", "StringFunctions");
300:                autoload(PACKAGE_SYS, "%string-not-greaterp", "StringFunctions");
301:                autoload(PACKAGE_SYS, "%string-not-lessp", "StringFunctions");
302:                autoload(PACKAGE_SYS, "%string-upcase", "StringFunctions");
303:                autoload(PACKAGE_SYS, "%string/=", "StringFunctions");
304:                autoload(PACKAGE_SYS, "%string<", "StringFunctions");
305:                autoload(PACKAGE_SYS, "%string<=", "StringFunctions");
306:                autoload(PACKAGE_SYS, "%string=", "StringFunctions");
307:                autoload(PACKAGE_SYS, "%string>", "StringFunctions");
308:                autoload(PACKAGE_SYS, "%string>=", "StringFunctions");
309:                autoload(PACKAGE_SYS, "%structure-ref", "StructureObject");
310:                autoload(PACKAGE_SYS, "%structure-ref-0", "StructureObject");
311:                autoload(PACKAGE_SYS, "%structure-ref-1", "StructureObject");
312:                autoload(PACKAGE_SYS, "%structure-ref-2", "StructureObject");
313:                autoload(PACKAGE_SYS, "%structure-set", "StructureObject");
314:                autoload(PACKAGE_SYS, "%structure-set-0", "StructureObject");
315:                autoload(PACKAGE_SYS, "%structure-set-1", "StructureObject");
316:                autoload(PACKAGE_SYS, "%structure-set-2", "StructureObject");
317:                autoload(PACKAGE_SYS, "%time", "Time");
318:                autoload(PACKAGE_SYS, "allocate-std-instance", "StandardObject");
319:                autoload(PACKAGE_SYS, "class-direct-methods", "LispClass");
320:                autoload(PACKAGE_SYS, "class-direct-slots", "StandardClass");
321:                autoload(PACKAGE_SYS, "class-slots", "StandardClass");
322:                autoload(PACKAGE_SYS, "default-time-zone", "Time");
323:                autoload(PACKAGE_SYS,
324:                        "generic-function-discriminating-function",
325:                        "GenericFunction");
326:                autoload(PACKAGE_SYS, "hash-table-entries", "HashTable");
327:                autoload(PACKAGE_SYS, "make-fill-pointer-output-stream",
328:                        "FillPointerOutputStream");
329:                autoload(PACKAGE_SYS, "make-instance-standard-class",
330:                        "StandardClass");
331:                autoload(PACKAGE_SYS, "make-structure-class", "StructureClass");
332:                autoload(PACKAGE_SYS, "make-symbol-macro", "SymbolMacro");
333:                autoload(PACKAGE_SYS, "puthash", "HashTable");
334:                autoload(PACKAGE_SYS, "std-instance-slots", "StandardObject");
335:            }
336:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.