Source Code Cross Referenced for EvalExp.java in  » Scripting » sisc » sisc » exprs » 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 » sisc » sisc.exprs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package sisc.exprs;
002:
003:        import sisc.data.*;
004:        import sisc.exprs.fp.OptimismUnwarrantedException;
005:        import sisc.exprs.fp.OptimisticExpression;
006:        import sisc.exprs.fp.OptimisticHost;
007:        import sisc.exprs.fp.Utils;
008:
009:        import java.io.*;
010:        import sisc.interpreter.*;
011:        import sisc.ser.Serializer;
012:        import sisc.ser.Deserializer;
013:        import sisc.util.ExpressionVisitor;
014:
015:        public class EvalExp extends Expression implements  OptimisticHost {
016:            public static final int POS_PRE = 0, POS_POST = 1;
017:
018:            public Expression pre, post;
019:            public boolean preImmediate;
020:
021:            public EvalExp(Expression pre, Expression post, boolean preImmediate) {
022:                this .pre = pre;
023:                this .post = post;
024:                this .preImmediate = preImmediate;
025:            }
026:
027:            public void setHosts() {
028:                /*
029:                  'post' must not be an OptimisticExpression if 'pre' is
030:                  non-immediate or an OptimisticExpression. It could end up on
031:                  the stack and hence be evaluated outside the context of the
032:                  eval method here.
033:                 */
034:                if (!preImmediate || pre instanceof  OptimisticExpression) {
035:                    Utils.assertNonOptimistic(post);
036:                }
037:
038:                Utils.linkOptimistic(this , pre, POS_PRE);
039:                Utils.linkOptimistic(this , post, POS_POST);
040:            }
041:
042:            public void eval(Interpreter r) throws ContinuationException {
043:                boolean retry;
044:                do {
045:                    try {
046:                        if (preImmediate) {
047:                            r.acc = pre.getValue(r);
048:                            r.next(post);
049:                        } else {
050:                            r.push(post);
051:                            r.next(pre);
052:                        }
053:                        retry = false;
054:                    } catch (OptimismUnwarrantedException uwe) {
055:                        retry = true;
056:                    }
057:                } while (retry);
058:            }
059:
060:            private Value expressHelper() {
061:                return new Pair(pre.express(),
062:                        ((post instanceof  EvalExp) ? ((EvalExp) post)
063:                                .expressHelper() : list(post.express())));
064:            }
065:
066:            public Value express() {
067:                return new Pair(sym("begin"), expressHelper());
068:            }
069:
070:            public void serialize(Serializer s) throws IOException {
071:                s.writeExpression(pre);
072:                s.writeExpression(post);
073:                s.writeBoolean(preImmediate);
074:            }
075:
076:            public EvalExp() {
077:            }
078:
079:            public void deserialize(Deserializer s) throws IOException {
080:                pre = s.readExpression();
081:                post = s.readExpression();
082:                preImmediate = s.readBoolean();
083:            }
084:
085:            public boolean visit(ExpressionVisitor v) {
086:                return v.visit(pre) && v.visit(post);
087:            }
088:
089:            /* (non-Javadoc)
090:             * @see sisc.exprs.OptimisticHost#alter(int, sisc.data.Expression)
091:             */
092:            public synchronized void alter(Interpreter r, int uexpPosition,
093:                    Expression replaceWith) {
094:                switch (uexpPosition) {
095:                case POS_PRE:
096:                    pre = replaceWith;
097:                    if (preImmediate && !(replaceWith instanceof  Immediate)) {
098:                        preImmediate = false;
099:                    }
100:                    break;
101:                case POS_POST:
102:                    post = replaceWith;
103:                    break;
104:                }
105:            }
106:
107:        }
108:        /*
109:         * The contents of this file are subject to the Mozilla Public
110:         * License Version 1.1 (the "License"); you may not use this file
111:         * except in compliance with the License. You may obtain a copy of
112:         * the License at http://www.mozilla.org/MPL/
113:         * 
114:         * Software distributed under the License is distributed on an "AS
115:         * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
116:         * implied. See the License for the specific language governing
117:         * rights and limitations under the License.
118:         * 
119:         * The Original Code is the Second Interpreter of Scheme Code (SISC).
120:         * 
121:         * The Initial Developer of the Original Code is Scott G. Miller.
122:         * Portions created by Scott G. Miller are Copyright (C) 2000-2007
123:         * Scott G. Miller.  All Rights Reserved.
124:         * 
125:         * Contributor(s):
126:         * Matthias Radestock 
127:         * 
128:         * Alternatively, the contents of this file may be used under the
129:         * terms of the GNU General Public License Version 2 or later (the
130:         * "GPL"), in which case the provisions of the GPL are applicable 
131:         * instead of those above.  If you wish to allow use of your 
132:         * version of this file only under the terms of the GPL and not to
133:         * allow others to use your version of this file under the MPL,
134:         * indicate your decision by deleting the provisions above and
135:         * replace them with the notice and other provisions required by
136:         * the GPL.  If you do not delete the provisions above, a recipient
137:         * may use your version of this file under either the MPL or the
138:         * GPL.
139:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.