Source Code Cross Referenced for RecoderModelTransformer.java in  » Testing » KeY » de » uka » ilkd » key » java » recoderext » 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 » Testing » KeY » de.uka.ilkd.key.java.recoderext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:        //
009:        // This file is part of KeY - Integrated Deductive Software Design
010:        // Copyright (C) 2001-2004 Universitaet Karlsruhe, Germany
011:        //                         Universitaet Koblenz-Landau, Germany
012:        //                         Chalmers University of Technology, Sweden
013:        //
014:        // The KeY system is protected by the GNU General Public License. 
015:        // See LICENSE.TXT for details.
016:        package de.uka.ilkd.key.java.recoderext;
017:
018:        import recoder.CrossReferenceServiceConfiguration;
019:        import recoder.abstraction.ArrayType;
020:        import recoder.abstraction.ClassType;
021:        import recoder.abstraction.PrimitiveType;
022:        import recoder.abstraction.Type;
023:        import recoder.java.CompilationUnit;
024:        import recoder.java.Expression;
025:        import recoder.java.Identifier;
026:        import recoder.java.declaration.LocalVariableDeclaration;
027:        import recoder.java.declaration.MethodDeclaration;
028:        import recoder.java.declaration.TypeDeclaration;
029:        import recoder.java.expression.literal.*;
030:        import recoder.java.expression.operator.CopyAssignment;
031:        import recoder.java.reference.FieldReference;
032:        import recoder.java.reference.ReferencePrefix;
033:        import recoder.java.reference.TypeReference;
034:        import recoder.kit.TwoPassTransformation;
035:        import recoder.list.CompilationUnitMutableList;
036:        import de.uka.ilkd.key.util.Debug;
037:
038:        /**
039:         * The Java DL requires some implicit fields, that are available in each
040:         * Java class. The name of the implicit fields is usually enclosed
041:         * between two angle brackets. 
042:         * Two access the fields in a uniform way, they are added as usual
043:         * fields to the classes, in particular this allows us to parse them in
044:         * more easier.
045:         *   For further information see also
046:         *   <ul>
047:         *     <li> {@link ImplicitFieldAdder} </li>
048:         *     <li> {@link CreateObjectBuilder}  </li>
049:         *     <li> {@link PrepareObjectBuilder} </li>
050:         *   </ul>
051:         */
052:        public abstract class RecoderModelTransformer extends
053:                TwoPassTransformation {
054:
055:            protected CrossReferenceServiceConfiguration services;
056:            protected CompilationUnitMutableList units;
057:
058:            /**
059:             * creates a transormder for the recoder model
060:             * @param services the CrossReferenceServiceConfiguration to access
061:             * model information 
062:             * @param units the array of CompilationUnits describing the model 
063:             * to be transformed 
064:             */
065:            public RecoderModelTransformer(
066:                    CrossReferenceServiceConfiguration services,
067:                    CompilationUnitMutableList units) {
068:                super (services);
069:                this .services = services;
070:                this .units = units;
071:            }
072:
073:            /** 
074:             * returns the default value of the given type 
075:             * according to JLS Sect. 4.5.5
076:             * @return the default value of the given type 
077:             * according to JLS Sect. 4.5.5
078:             */
079:            public Expression getDefaultValue(Type type) {
080:                if (type instanceof  ClassType || type instanceof  ArrayType) {
081:                    return new NullLiteral();
082:                } else if (type instanceof  PrimitiveType) {
083:                    if ("boolean".equals(type.getName())) {
084:                        return new BooleanLiteral(false);
085:                    } else if ("byte".equals(type.getName())
086:                            || "short".equals(type.getName())
087:                            || "int".equals(type.getName())) {
088:                        return new IntLiteral(0);
089:                    } else if ("long".equals(type.getName())) {
090:                        return new LongLiteral(0);
091:                    } else if ("char".equals(type.getName())) {
092:                        return new CharLiteral((char) 0);
093:                    } else if ("float".equals(type.getName())) {
094:                        return new FloatLiteral(0.0F);
095:                    } else if ("double".equals(type.getName())) {
096:                        return new DoubleLiteral(0.0D);
097:                    }
098:                }
099:                Debug
100:                        .fail("makeImplicitMembersExplicit: unknown primitive type"
101:                                + type);
102:                return null;
103:            }
104:
105:            /** 
106:             * attaches a method declaration to the declaration of type td at
107:             * position idx
108:             * @param md the MethodDeclaration to insert
109:             * @param td the TypeDeclaration that becomes parent of the new
110:             * method
111:             * @param idx the position where to add the method
112:             */
113:            public void attach(MethodDeclaration md, TypeDeclaration td, int idx) {
114:                super .attach(md, td, idx);
115:            }
116:
117:            /**
118:             * returns if changes have to be reported to the change history
119:             * @return true, iff changes have to be reported to the change history
120:             */
121:            public boolean isVisible() {
122:                return true;
123:            }
124:
125:            /**
126:             * The method is called for each type declaration of the compilation
127:             * unit and initiates the syntactical transformation. If you want to
128:             * descend in inner classes you have to implement the recusrsion by
129:             * yourself.
130:             */
131:            protected abstract void makeExplicit(TypeDeclaration td);
132:
133:            // Java construction helper methods for recoder data structures
134:
135:            protected FieldReference attribute(ReferencePrefix prefix,
136:                    Identifier attributeName) {
137:                return new FieldReference(prefix, attributeName);
138:            }
139:
140:            protected CopyAssignment assign(Expression lhs, Expression rhs) {
141:                return new CopyAssignment(lhs, rhs);
142:            }
143:
144:            protected LocalVariableDeclaration declare(String name,
145:                    ClassType type) {
146:                return new LocalVariableDeclaration(new TypeReference(
147:                        new Identifier(type.getName())), new Identifier(name));
148:            }
149:
150:            protected LocalVariableDeclaration declare(String name,
151:                    TypeDeclaration type) {
152:                return new LocalVariableDeclaration(new TypeReference(
153:                        (Identifier) type.getIdentifier().deepClone()),
154:                        new Identifier(name));
155:            }
156:
157:            /**
158:             * invokes model transformation for each top level type declaration
159:             * in any compilation unit. <emph>Not</emph> for inner classes.
160:             */
161:            public void makeExplicit() {
162:                for (int i = 0; i < units.size(); i++) {
163:                    CompilationUnit unit = units.getCompilationUnit(i);
164:                    int typeCount = unit.getTypeDeclarationCount();
165:                    for (int j = 0; j < typeCount; j++) {
166:                        makeExplicit(unit.getTypeDeclarationAt(j));
167:                    }
168:                }
169:            }
170:
171:            /**
172:             * Starts the transformation. 
173:             */
174:            public void transform() {
175:                super.transform();
176:                makeExplicit();
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.