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


001:        // Copyright (c) 1999  Per M.A. Bothner.
002:        // This is free software;  for terms and warranty disclaimer see ./COPYING.
003:
004:        package gnu.expr;
005:
006:        import gnu.bytecode.*;
007:        import gnu.mapping.OutPort;
008:
009:        /**
010:         * Class used to implement a block that can be exited.
011:         * @author	Per Bothner
012:         */
013:
014:        public class BlockExp extends Expression {
015:            Declaration label;
016:            Expression body;
017:
018:            /** If non-null, evaluate this, but only if non-normal exit. */
019:            Expression exitBody;
020:
021:            public BlockExp() {
022:            }
023:
024:            public BlockExp(Expression body) {
025:                setBody(body);
026:            }
027:
028:            public void setBody(Expression body) {
029:                this .body = body;
030:            }
031:
032:            public void setBody(Expression body, Expression exitBody) {
033:                this .body = body;
034:                this .exitBody = exitBody;
035:            }
036:
037:            /* Target used to evaluate body. Temporary only used during compilation. */
038:            Target subTarget;
039:            /* Label to exit to.  Temporary only used during compilation. */
040:            Label exitLabel;
041:
042:            public void compile(Compilation comp, Target target) {
043:                Target subTarget;
044:                if (target instanceof  IgnoreTarget
045:                        || target == Target.pushObject)
046:                    subTarget = target;
047:                else {
048:                    // We can probably do better - and this is probably
049:                    // wrong for TailTargets.  FIXME.
050:                    subTarget = new StackTarget(getType());
051:                }
052:                gnu.bytecode.CodeAttr code = comp.getCode();
053:                exitLabel = new Label(code);
054:                this .subTarget = exitBody == null ? subTarget : Target.Ignore;
055:
056:                initialTryState = code.getTryStack();
057:                body.compileWithPosition(comp, subTarget);
058:
059:                if (exitBody != null) {
060:                    Label doneLabel = new Label(code);
061:                    code.emitGoto(doneLabel);
062:                    exitLabel.define(code);
063:                    exitBody.compileWithPosition(comp, subTarget);
064:                    doneLabel.define(code);
065:                } else
066:                    exitLabel.define(code);
067:                if (subTarget != target)
068:                    target.compileFromStack(comp, subTarget.getType());
069:            }
070:
071:            // The try state in place at the beginning of the block
072:            TryState initialTryState;
073:
074:            void exit(CodeAttr code) {
075:                // Run enclosing finally clauses
076:                for (TryState st = code.getTryStack(); st != initialTryState; st = st.previous) {
077:                    if (st.finally_subr != null)
078:                        code.emitJsr(st.finally_subr);
079:                }
080:
081:                code.emitGoto(exitLabel);
082:            }
083:
084:            protected Expression walk(ExpWalker walker) {
085:                return walker.walkBlockExp(this );
086:            }
087:
088:            protected void walkChildren(ExpWalker walker) {
089:                body = body.walk(walker);
090:                if (walker.exitValue == null && exitBody != null)
091:                    exitBody = exitBody.walk(walker);
092:            }
093:
094:            public void print(OutPort out) {
095:                out.startLogicalBlock("(Block", ")", 2);
096:                if (label != null)
097:                    out.print(label.getName());
098:                out.writeSpaceLinear();
099:                body.print(out);
100:                if (exitBody != null) {
101:                    out.writeSpaceLinear();
102:                    out.print("else ");
103:                    exitBody.print(out);
104:                }
105:                out.endLogicalBlock(")");
106:            }
107:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.