Source Code Cross Referenced for TranslateArrayOp.java in  » Testing » KeY » de » uka » ilkd » key » proof » decproc » translation » 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.proof.decproc.translation 
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:        //
010:
011:        package de.uka.ilkd.key.proof.decproc.translation;
012:
013:        import org.apache.log4j.Logger;
014:        import de.uka.ilkd.key.logic.op.ArrayOp;
015:        import de.uka.ilkd.key.logic.op.Operator;
016:        import de.uka.ilkd.key.logic.sort.ArraySort;
017:        import de.uka.ilkd.key.logic.sort.ObjectSort;
018:        import de.uka.ilkd.key.logic.sort.Sort;
019:        import de.uka.ilkd.key.proof.decproc.smtlib.*;
020:
021:        /** This class represents the translation rule for <tt>ArrayOp</tt>s.
022:         * <p>
023:         * Thereby the array access represented by the <tt>ArrayOp</tt> is translated into an SMT-LIB 
024:         * <tt>UninterpretedFuncTerm</tt>, if the array is of <tt>Sort</tt> INT or OBJECT. If it is of 
025:         * boolean <tt>Sort</tt>, it is translated into an SMT-LIB <tt>UninterpretedPredFormula</tt>.<br>
026:         * The created functions or predicates consist of two arguments: their first argument represents the
027:         * accessed array itself, and the second argument specifies the index to be accessed
028:         * <p>
029:         *  
030:         * @author akuwertz
031:         * @version 1.3,  12/13/2006  (Minor fixes for AUFLIA support)
032:         */
033:
034:        public class TranslateArrayOp implements  IOperatorTranslation {
035:
036:            /* Additional fields */
037:
038:            /** A prefix used in the names of the uninterpreted functions and predicates respectively to
039:             * indicate that they represent a translation of an <tt>ArrayOp</tt> */
040:            private static final String arrayOpPrefix = "Array";
041:
042:            /** A suffix used in the name of the created uninterpreted function to mark it as function */
043:            private static final String arrayOpUifSuffix = "_UIF";
044:            /** A suffix used in the name of the created uninterpreted predicate to mark it as predicate */
045:            private static final String arrayOpUipSuffix = "_UIP";
046:
047:            /** A suffix used in the name of the created uninterpreted function to indicate that it 
048:             * represents the translation of an integer attribute */
049:            private static final String arrayOpIntSuffix = "_int";
050:
051:            /** A <tt>Logger</tt> for logging and debugging operator translation */
052:            private static final Logger logger = Logger
053:                    .getLogger(TranslateArrayOp.class.getName());
054:            // Logger is created hierarchical to inherit configuration and behaviour from parent
055:
056:            /* String constants for error messages */
057:            private static final String translationFailure = "Translation of array operator failed due to illegal arguments on visitor stack:\n";
058:            private static final String failureCause = " expected an argument of class Term (SMT-LIB) and found the object:\n";
059:            private static final String failureCauseNoFuncTerm = " expected an argument of class UninterpretedFuncTerm (SMT-LIB) and found the object:\n";
060:            private static final String unsupportedArrayOp = "Translation of array op failed because its element sort could not be handled by this class: ";
061:
062:            /* Public method implementation */
063:
064:            /* (non-Javadoc)
065:             * @see de.uka.ilkd.key.proof.decproc.translation.IOperatorTranslation#isApplicable(de.uka.ilkd.key.logic.op.Operator)
066:             */
067:            public boolean isApplicable(Operator op) {
068:                return op instanceof  ArrayOp;
069:            }
070:
071:            /* (non-Javadoc)
072:             * @see de.uka.ilkd.key.proof.decproc.translation.IOperatorTranslation#translate(de.uka.ilkd.key.logic.op.Operator, de.uka.ilkd.key.proof.decproc.translation.TermTranslationVisitor)
073:             */
074:            public Object translate(Operator op,
075:                    TermTranslationVisitor ttVisitor) {
076:
077:                logger.debug("Popping two argument terms from stack");
078:                Object[] args = ttVisitor.getTranslatedArguments(2);
079:                Term[] convArgs;
080:
081:                Sort elementSort = ((ArraySort) ((ArrayOp) op).arraySort())
082:                        .elementSort();
083:                Sort integerSort = ttVisitor.getServices().getTypeConverter()
084:                        .getIntegerLDT().targetSort();
085:                Sort booleanSort = ttVisitor.getServices().getTypeConverter()
086:                        .getBooleanLDT().targetSort();
087:                Signature uiSig;
088:
089:                // The first argument represents the array itself
090:                if (!(args[0] instanceof  UninterpretedFuncTerm || args[0] instanceof  TermVariable)) {
091:                    throw new IllegalArgumentException(translationFailure
092:                            + op.name() + failureCauseNoFuncTerm + args[0]);
093:                }
094:
095:                // The second argument represents the index of the accessed element
096:                if (!(args[1] instanceof  Term))
097:                    throw new IllegalArgumentException(translationFailure
098:                            + op.name() + failureCause + args[1]);
099:
100:                convArgs = new Term[] { (Term) args[0], (Term) args[1] };
101:
102:                // The integer array case:
103:                if (elementSort.extendsTrans(integerSort)) {
104:                    logger
105:                            .info("Found integer array, creating uninterpreted function");
106:                    uiSig = Signature.intSignature(2, true);
107:                    String funcName = arrayOpPrefix + arrayOpUifSuffix
108:                            + arrayOpIntSuffix;
109:                    ttVisitor.createTypePredUif(elementSort, funcName, 2);
110:                    return new UninterpretedFuncTerm(funcName, convArgs, uiSig);
111:                }
112:
113:                // The object array case:
114:                if (elementSort instanceof  ObjectSort) {
115:                    logger
116:                            .info("Found object array, creating uninterpreted function");
117:                    uiSig = Signature.intSignature(2, true);
118:                    String funcName = arrayOpPrefix + arrayOpUifSuffix
119:                            + elementSort;
120:                    ttVisitor.createTypePredUif(elementSort, funcName, 2);
121:                    return new UninterpretedFuncTerm(funcName, convArgs, uiSig);
122:                }
123:
124:                // The boolean array case:
125:                if (elementSort == booleanSort) {
126:                    logger
127:                            .info("Found boolean array, creating uninterpreted predicate");
128:                    uiSig = Signature.intSignature(2, false);
129:                    return new UninterpretedPredFormula(arrayOpPrefix
130:                            + arrayOpUipSuffix, convArgs, uiSig);
131:                }
132:
133:                // The given array is of an untranslatable sort!
134:                logger
135:                        .info("Found unsupported array operator, exiting with exception!");
136:                throw new UnsupportedOperationException(unsupportedArrayOp
137:                        + op.name() + " Sort: " + elementSort);
138:            }
139:        }
w_w__w___.___j__a___va2s.c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.