Source Code Cross Referenced for ModuleWithContext.java in  » Scripting » Kawa » gnu » expr » 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 » Kawa » gnu.expr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package gnu.expr;
002:
003:        import gnu.mapping.*;
004:
005:        public abstract class ModuleWithContext extends ModuleBody {
006:            public int match0(ModuleMethod proc, CallContext ctx) {
007:                int num = proc.numArgs();
008:                int min = num & 0xFFF;
009:                if (min > 0)
010:                    return MethodProc.NO_MATCH_TOO_FEW_ARGS | min;
011:                ctx.count = 0;
012:                ctx.where = 0;
013:                if (num < 0)
014:                    return matchN(proc, ProcedureN.noArgs, ctx);
015:                ctx.next = 0;
016:                ctx.proc = this ;
017:                ctx.pc = proc.selector;
018:                return 0;
019:            }
020:
021:            public int match1(ModuleMethod proc, Object arg1, CallContext ctx) {
022:                int num = proc.numArgs();
023:                int min = num & 0xFFF;
024:                if (min > 1)
025:                    return MethodProc.NO_MATCH_TOO_FEW_ARGS | min;
026:                if (num >= 0) {
027:                    int max = num >> 12;
028:                    if (max < 1)
029:                        return MethodProc.NO_MATCH_TOO_MANY_ARGS | max;
030:                    ctx.value1 = arg1;
031:                    ctx.count = 1;
032:                    ctx.where = CallContext.ARG_IN_VALUE1;
033:                    ctx.next = 0;
034:                    ctx.proc = this ;
035:                    ctx.pc = proc.selector;
036:                    return 0;
037:                }
038:                ctx.where = 0;
039:                Object[] args = { arg1 };
040:                return matchN(proc, args, ctx);
041:            }
042:
043:            public int match2(ModuleMethod proc, Object arg1, Object arg2,
044:                    CallContext ctx) {
045:                int num = proc.numArgs();
046:                int min = num & 0xFFF;
047:                if (min > 2)
048:                    return MethodProc.NO_MATCH_TOO_FEW_ARGS | min;
049:                if (num >= 0) {
050:                    int max = num >> 12;
051:                    if (max < 2)
052:                        return MethodProc.NO_MATCH_TOO_MANY_ARGS | max;
053:                    ctx.value1 = arg1;
054:                    ctx.value2 = arg2;
055:                    ctx.count = 2;
056:                    ctx.where = CallContext.ARG_IN_VALUE1
057:                            | (CallContext.ARG_IN_VALUE2 << 4);
058:                    ctx.next = 0;
059:                    ctx.proc = this ;
060:                    ctx.pc = proc.selector;
061:                    return 0;
062:                }
063:                ctx.where = 0;
064:                Object[] args = { arg1, arg2 };
065:                return matchN(proc, args, ctx);
066:            }
067:
068:            public int match3(ModuleMethod proc, Object arg1, Object arg2,
069:                    Object arg3, CallContext ctx) {
070:                int num = proc.numArgs();
071:                int min = num & 0xFFF;
072:                if (min > 3)
073:                    return MethodProc.NO_MATCH_TOO_FEW_ARGS | min;
074:                if (num >= 0) {
075:                    int max = num >> 12;
076:                    if (max < 3)
077:                        return MethodProc.NO_MATCH_TOO_MANY_ARGS | max;
078:                    ctx.value1 = arg1;
079:                    ctx.value2 = arg2;
080:                    ctx.value3 = arg3;
081:                    ctx.count = 3;
082:                    ctx.where = CallContext.ARG_IN_VALUE1
083:                            | (CallContext.ARG_IN_VALUE2 << 4)
084:                            | (CallContext.ARG_IN_VALUE3 << 8);
085:                    ctx.next = 0;
086:                    ctx.proc = this ;
087:                    ctx.pc = proc.selector;
088:                    return 0;
089:                }
090:                ctx.where = 0;
091:                Object[] args = { arg1, arg2, arg3 };
092:                return matchN(proc, args, ctx);
093:            }
094:
095:            public int match4(ModuleMethod proc, Object arg1, Object arg2,
096:                    Object arg3, Object arg4, CallContext ctx) {
097:                int num = proc.numArgs();
098:                int min = num & 0xFFF;
099:                if (min > 4)
100:                    return MethodProc.NO_MATCH_TOO_FEW_ARGS | min;
101:                if (num >= 0) {
102:                    int max = num >> 12;
103:                    if (max < 4)
104:                        return MethodProc.NO_MATCH_TOO_MANY_ARGS | max;
105:                    ctx.value1 = arg1;
106:                    ctx.value2 = arg2;
107:                    ctx.value3 = arg3;
108:                    ctx.value4 = arg4;
109:                    ctx.count = 4;
110:                    ctx.where = (CallContext.ARG_IN_VALUE1
111:                            | (CallContext.ARG_IN_VALUE2 << 4)
112:                            | (CallContext.ARG_IN_VALUE3 << 8) | (CallContext.ARG_IN_VALUE4 << 12));
113:                    ctx.next = 0;
114:                    ctx.proc = this ;
115:                    ctx.pc = proc.selector;
116:                    return 0;
117:                }
118:                ctx.where = 0;
119:                Object[] args = { arg1, arg2, arg3, arg4 };
120:                return matchN(proc, args, ctx);
121:            }
122:
123:            public int matchN(ModuleMethod proc, Object[] args, CallContext ctx) {
124:                int num = proc.numArgs();
125:                int min = num & 0xFFF;
126:                if (args.length < min)
127:                    return MethodProc.NO_MATCH_TOO_FEW_ARGS | min;
128:                if (num >= 0) {
129:                    switch (args.length) {
130:                    case 0:
131:                        return match0(proc, ctx);
132:                    case 1:
133:                        return match1(proc, args[0], ctx);
134:                    case 2:
135:                        return match2(proc, args[0], args[1], ctx);
136:                    case 3:
137:                        return match3(proc, args[0], args[1], args[2], ctx);
138:                    case 4:
139:                        return match4(proc, args[0], args[1], args[2], args[3],
140:                                ctx);
141:                    default:
142:                        int max = num >> 12;
143:                        if (args.length > max)
144:                            return MethodProc.NO_MATCH_TOO_MANY_ARGS | max;
145:                    }
146:                }
147:                ctx.values = args;
148:                ctx.count = args.length;
149:                ctx.where = 0;
150:                ctx.next = 0;
151:                ctx.proc = this ;
152:                ctx.pc = proc.selector;
153:                return 0;
154:            }
155:
156:            public Object apply0(ModuleMethod method) throws Throwable {
157:                CallContext ctx = CallContext.getInstance();
158:                method.check0(ctx);
159:                return ctx.runUntilValue();
160:            }
161:
162:            public Object apply1(ModuleMethod method, Object arg1)
163:                    throws Throwable {
164:                CallContext ctx = CallContext.getInstance();
165:                method.check1(arg1, ctx);
166:                return ctx.runUntilValue();
167:            }
168:
169:            public Object apply2(ModuleMethod method, Object arg1, Object arg2)
170:                    throws Throwable {
171:                CallContext ctx = CallContext.getInstance();
172:                method.check2(arg1, arg2, ctx);
173:                return ctx.runUntilValue();
174:            }
175:
176:            public Object apply3(ModuleMethod method, Object arg1, Object arg2,
177:                    Object arg3) throws Throwable {
178:                CallContext ctx = CallContext.getInstance();
179:                method.check3(arg1, arg2, arg3, ctx);
180:                return ctx.runUntilValue();
181:            }
182:
183:            public Object apply4(ModuleMethod method, Object arg1, Object arg2,
184:                    Object arg3, Object arg4) throws Throwable {
185:                CallContext ctx = CallContext.getInstance();
186:                method.check4(arg1, arg2, arg3, arg4, ctx);
187:                return ctx.runUntilValue();
188:            }
189:
190:            public Object applyN(ModuleMethod method, Object[] args)
191:                    throws Throwable {
192:                CallContext ctx = CallContext.getInstance();
193:                method.checkN(args, ctx);
194:                return ctx.runUntilValue();
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.