Source Code Cross Referenced for ArrayFields.java in  » Code-Analyzer » javapathfinder » gov » nasa » jpf » jvm » 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 » Code Analyzer » javapathfinder » gov.nasa.jpf.jvm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Copyright (C) 2005 United States Government as represented by the
003:        // Administrator of the National Aeronautics and Space Administration
004:        // (NASA).  All Rights Reserved.
005:        // 
006:        // This software is distributed under the NASA Open Source Agreement
007:        // (NOSA), version 1.3.  The NOSA has been approved by the Open Source
008:        // Initiative.  See the file NOSA-1.3-JPF at the top of the distribution
009:        // directory tree for the complete NOSA document.
010:        // 
011:        // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012:        // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013:        // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014:        // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015:        // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016:        // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017:        // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018:        //
019:        package gov.nasa.jpf.jvm;
020:
021:        /**
022:         *a Field (data value) store for array objects
023:         */
024:        public class ArrayFields extends Fields {
025:
026:            private int elementStorageSize;
027:            private int length;
028:            private String elementType;
029:            private boolean isReference;
030:
031:            public ArrayFields(String type, ClassInfo ci, int storageSize,
032:                    int length, boolean isReference) {
033:                super (type, ci, storageSize);
034:                this .length = length;
035:                this .isReference = isReference;
036:                elementType = type.substring(1);
037:                elementStorageSize = Types.getTypeSize(type);
038:
039:                // Ok, this seems to be a design anomaly, but array elements are not fields,
040:                // hence the only non-0 element initialization is for reference arrays, and
041:                // only with const, default 'null' values. All other inits (even the
042:                // static init "a = {...}:") is compiled into explicit NEWARRAY, ASTORE..
043:                // sequences, and does not need any special, automatic init code
044:                if (isReference) {
045:                    for (int i = 0; i < length; i++) {
046:                        values[i] = -1;
047:                    }
048:                }
049:            }
050:
051:            public int arrayLength() {
052:                return length;
053:            }
054:
055:            public int getHeapSize() {
056:                return Types.getTypeSizeInBytes(elementType) * length;
057:            }
058:
059:            public FieldInfo getFieldInfo(String clsBase, String fname) {
060:                // TODO
061:                return null;
062:            }
063:
064:            public int getNumberOfFields() {
065:                // TODO
066:                return 0;
067:            }
068:
069:            public FieldInfo getFieldInfo(int fieldIndex) {
070:                // TODO
071:                return null;
072:            }
073:
074:            /**
075:             * @see gov.nasa.jpf.jvm.iFields#getFieldIndex(String, String)
076:             */
077:            public int getFieldIndex(String name, String referenceType) {
078:                // will this ever happen?
079:                throw new NoSuchFieldError("array does not have any fields!"
080:                        + getClassInfo().getName() + "." + name);
081:            }
082:
083:            public String getFieldName(int index) {
084:                return Integer.toString(index / elementStorageSize);
085:            }
086:
087:            public String getFieldType(String name, String referenceType) {
088:                // will this ever happen?
089:                throw new NoSuchFieldError("array does not have any fields!"
090:                        + getClassInfo().getName() + "." + name);
091:            }
092:
093:            public String getFieldType(int findex) {
094:                if (elementType == null) {
095:                    elementType = getType().substring(1);
096:                }
097:
098:                return elementType;
099:            }
100:
101:            public String getLogChar() {
102:                return "*";
103:            }
104:
105:            public void setLongField(String name, String referenceType,
106:                    long value) {
107:                throw new NoSuchFieldError("array does not have any fields!"
108:                        + getClassInfo().getName() + "." + name);
109:            }
110:
111:            public long getLongField(String name, String referenceType) {
112:                throw new NoSuchFieldError("array does not have any fields!"
113:                        + getClassInfo().getName() + "." + name);
114:            }
115:
116:            public boolean isReferenceArray() {
117:                return isReference;
118:            }
119:
120:            public boolean isRef(String name, String referenceType) {
121:                throw new NoSuchFieldError("array does not have any fields!"
122:                        + getClassInfo().getName() + "." + name);
123:            }
124:
125:            public boolean[] asBooleanArray() {
126:                // <2do> we probably should check the type first
127:                int length = values.length;
128:                boolean[] result = new boolean[length];
129:
130:                for (int i = 0; i < length; i++) {
131:                    result[i] = Types.intToBoolean(values[i]);
132:                }
133:
134:                return result;
135:            }
136:
137:            public byte[] asByteArray() {
138:                // <2do> we probably should check the type first
139:                int length = values.length;
140:                byte[] result = new byte[length];
141:
142:                for (int i = 0; i < length; i++) {
143:                    result[i] = (byte) values[i];
144:                }
145:
146:                return result;
147:            }
148:
149:            public char[] asCharArray() {
150:                // <2do> we probably should check the type first
151:                int length = values.length;
152:                char[] result = new char[length];
153:
154:                for (int i = 0; i < length; i++) {
155:                    result[i] = (char) values[i];
156:                }
157:
158:                return result;
159:            }
160:
161:            public short[] asShortArray() {
162:                // <2do> we probably should check the type first
163:                int length = values.length;
164:                short[] result = new short[length];
165:
166:                for (int i = 0; i < length; i++) {
167:                    result[i] = (short) values[i];
168:                }
169:
170:                return result;
171:            }
172:
173:            public int[] asIntArray() {
174:                // <2do> we probably should check the type first
175:                int length = values.length;
176:                int[] result = new int[length];
177:
178:                for (int i = 0; i < length; i++) {
179:                    result[i] = values[i];
180:                }
181:
182:                return result;
183:            }
184:
185:            public long[] asLongArray() {
186:                // <2do> we probably should check the type first
187:                int length = values.length;
188:                long[] result = new long[length];
189:
190:                length--;
191:                for (int i = 0, j = 0; i < length; i++, j += 2) {
192:                    result[i] = Types.intsToLong(values[j + 1], values[j]);
193:                }
194:
195:                return result;
196:            }
197:
198:            public float[] asFloatArray() {
199:                // <2do> we probably should check the type first
200:                int length = values.length;
201:                float[] result = new float[length];
202:
203:                for (int i = 0; i < length; i++) {
204:                    result[i] = Types.intToFloat(values[i]);
205:                }
206:
207:                return result;
208:            }
209:
210:            public double[] asDoubleArray() {
211:                // <2do> we probably should check the type first
212:                int length = values.length;
213:                double[] result = new double[length];
214:
215:                length--;
216:                for (int i = 0, j = 0; i < length; i++, j += 2) {
217:                    result[i] = Types.intsToDouble(values[j + 1], values[j]);
218:                }
219:
220:                return result;
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.