Source Code Cross Referenced for ConditionalTarget.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) 


01:        package gnu.expr;
02:
03:        import gnu.bytecode.*;
04:
05:        /** This is the Target of a boolean expression, in a conditional context.
06:         * If the expression evaluates to, transfer to the ifTrue label;
07:         * if false, tranfer to the ifFalse label. */
08:
09:        public class ConditionalTarget extends Target {
10:            public Label ifTrue, ifFalse;
11:            Language language;
12:
13:            /**
14:             * @param ifTrue label to jump to if this evaluates to true
15:             * @param ifFalse label to jump to if true
16:             * @param language specifies what values are true
17:             */
18:
19:            public ConditionalTarget(Label ifTrue, Label ifFalse,
20:                    Language language) {
21:                this .ifTrue = ifTrue;
22:                this .ifFalse = ifFalse;
23:                this .language = language;
24:            }
25:
26:            /** True if the ifTrue label comes before the ifFalse label.
27:             * This is used in the hope we can optimize away a branch followed by
28:             * its target. */
29:            public boolean trueBranchComesFirst = true;
30:
31:            public Type getType() {
32:                return Type.boolean_type;
33:            }
34:
35:            public void compileFromStack(Compilation comp, Type stackType) {
36:                CodeAttr code = comp.getCode();
37:                char sig = stackType.getSignature().charAt(0);
38:                switch (sig) {
39:                case 'J':
40:                    code.emitPushLong(0);
41:                    break;
42:                case 'D':
43:                    code.emitPushDouble(0.0);
44:                    break;
45:                case 'F':
46:                    code.emitPushFloat(0.0f);
47:                    break;
48:                default:
49:                    if (trueBranchComesFirst) {
50:                        code.emitGotoIfIntEqZero(ifFalse);
51:                        code.emitGoto(ifTrue);
52:                    } else {
53:                        code.emitGotoIfIntNeZero(ifTrue);
54:                        code.emitGoto(ifFalse);
55:                    }
56:                    return;
57:                case 'L':
58:                case '[':
59:                    comp.compileConstant(language == null ? Boolean.FALSE
60:                            : language.booleanObject(false));
61:                    break;
62:                }
63:                if (trueBranchComesFirst)
64:                    code.emitGotoIfEq(ifFalse);
65:                else
66:                    code.emitGotoIfNE(ifTrue);
67:                emitGotoFirstBranch(code); // Usually a no-op.
68:            }
69:
70:            /** Goto whichever of IfTrue or ifFalse is specified by trueBranchComesFirst.
71:             * Normally, the goto should get optimized away as a no-op. */
72:            public final void emitGotoFirstBranch(CodeAttr code) {
73:                code.emitGoto(trueBranchComesFirst ? ifTrue : ifFalse);
74:            }
75:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.