Source Code Cross Referenced for AbstractInstructionCommand.java in  » Development » jdec » net » sf » jdec » jvminstructions » commands » 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 » Development » jdec » net.sf.jdec.jvminstructions.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.jdec.jvminstructions.commands;
002:
003:        import net.sf.jdec.reflection.Behaviour;
004:        import net.sf.jdec.util.AllExceptionHandler;
005:        import net.sf.jdec.util.ExecutionState;
006:        import net.sf.jdec.core.*;
007:        import net.sf.jdec.lookup.GenericFinder;
008:        import net.sf.jdec.lookup.IFinder;
009:        import net.sf.jdec.lookup.FinderFactory;
010:        import net.sf.jdec.lookup.LoadInstrFinder;
011:
012:        import java.util.Stack;
013:        import java.util.ArrayList;
014:
015:        public abstract class AbstractInstructionCommand implements 
016:                IInstructionCommand {
017:
018:            private GenericFinder genericFinder;
019:
020:            private LoadInstrFinder loadFinder;
021:
022:            private Behaviour context;
023:
024:            private boolean exceptionOccured = false;
025:
026:            private Throwable[] exceptions;
027:
028:            public AbstractInstructionCommand(Behaviour context) {
029:                this .context = context;
030:            }
031:
032:            public abstract int getSkipBytes();
033:
034:            public boolean pollForExceeption() {
035:                return exceptionOccured;
036:            }
037:
038:            protected void registerException(Throwable[] allExceptions) {
039:                exceptions = allExceptions;
040:            }
041:
042:            public void handleExceptions() {
043:
044:                if (exceptions == null)
045:                    return;
046:                AllExceptionHandler handler = null;
047:                for (int i = 0; i < exceptions.length; i++) {
048:                    handler = new AllExceptionHandler(exceptions[i]);
049:                    handler.reportException();
050:                }
051:                System.gc();
052:            }
053:
054:            protected void setExceptionOccured(boolean exceptionOccured) {
055:                this .exceptionOccured = exceptionOccured;
056:            }
057:
058:            public Behaviour getContext() {
059:                return context;
060:            }
061:
062:            protected Operand getTopOfStack() {
063:                return getContext().getOpStack().getTopOfStack();
064:            }
065:
066:            protected OperandStack getStack() {
067:                return getContext().getOpStack();
068:            }
069:
070:            protected int getCurrentInstPosInCode() {
071:                return ExecutionState.getCurrentInstructionPosition();
072:            }
073:
074:            protected byte[] getCode() {
075:                return getContext().getCode();
076:            }
077:
078:            protected Operand createOperand(Object val, int type, int categ) {
079:                Operand opr = new Operand();
080:                opr.setOperandValue(val);
081:                opr.setOperandType(type);
082:                opr.setCategory(categ);
083:                return opr;
084:
085:            }
086:
087:            protected Operand createOperand(Object val) {
088:                Operand opr = new Operand();
089:                opr.setOperandValue(val);
090:                return opr;
091:
092:            }
093:
094:            protected IFinder getGenericFinder() {
095:                return FinderFactory.getFinder(IFinder.BASE);
096:            }
097:
098:            public IFinder getLoadFinder() {
099:                return FinderFactory.getFinder(IFinder.LOAD);
100:            }
101:
102:            public IFinder getStoreFinder() {
103:                return FinderFactory.getFinder(IFinder.STORE);
104:            }
105:
106:            public IFinder getBranchFinder() {
107:                return FinderFactory.getFinder(IFinder.BRANCH);
108:            }
109:
110:            protected boolean newfound() {
111:                Stack newfoundstack = GlobalVariableStore.getNewfoundstack();
112:                if (newfoundstack.size() > 0)
113:                    return true;
114:                return false;
115:            }
116:
117:            protected boolean arrayClosingBracketCount(int current,
118:                    StringBuffer sb) {
119:
120:                Behaviour behaviour = getContext();
121:                ArrayList starts = behaviour.getInstructionStartPositions();
122:                byte[] info = behaviour.getCode();
123:                int next = current + 1;
124:                java.lang.String type = "simple";
125:                int index = -1;
126:                int pos = next;
127:                forloop: for (; pos < info.length; pos++) {
128:                    if (getGenericFinder().isThisInstrStart(pos)) {
129:
130:                        switch (info[pos]) {
131:
132:                        case JvmOpCodes.ASTORE:
133:                            type = "complex";
134:                            index = info[pos + 1];
135:                            break forloop;
136:                        case JvmOpCodes.ASTORE_0:
137:                            index = 0;
138:                            break forloop;
139:                        case JvmOpCodes.ASTORE_1:
140:                            index = 1;
141:                            break forloop;
142:                        case JvmOpCodes.ASTORE_2:
143:                            index = 2;
144:                            break forloop;
145:                        case JvmOpCodes.ASTORE_3:
146:                            index = 3;
147:                            break forloop;
148:
149:                        }
150:
151:                    }
152:                }
153:
154:                if (index != -1) {
155:                    LocalVariable local = null;
156:                    if (type.equals("simple")) {
157:                        local = DecompilerHelper.getLocalVariable(index,
158:                                "store", "java.lang.Object", true, pos);
159:                    } else {
160:
161:                        local = DecompilerHelper.getLocalVariable(index,
162:                                "store", "java.lang.Object", false, pos);
163:                    }
164:                    if (local != null) {
165:                        java.lang.String datatype = local.getDataType();
166:                        if (datatype.indexOf("[") != -1
167:                                && datatype.indexOf("]") != -1) {
168:                            int br = datatype.indexOf("[");
169:                            int count = 0;
170:                            do {
171:                                count++;
172:                                br = datatype.indexOf("[", (br + 1));
173:                            } while (br != -1);
174:                            sb.append((count - 1));
175:                            return true;
176:                        }
177:
178:                    }
179:                }
180:
181:                return false;
182:            }
183:
184:            protected int arrayClosingBracketCount(int current) {
185:
186:                int total = 0;
187:                Behaviour behaviour = getContext();
188:                ArrayList starts = behaviour.getInstructionStartPositions();
189:                byte[] info = behaviour.getCode();
190:                int next = current + 1;
191:                java.lang.String type = "simple";
192:                int index = -1;
193:                int pos = next;
194:                forloop: for (; pos < info.length; pos++) {
195:                    if (getGenericFinder().isThisInstrStart(pos)) {
196:
197:                        switch (info[pos]) {
198:
199:                        case JvmOpCodes.ASTORE:
200:                            type = "complex";
201:                            index = info[pos + 1];
202:                            break forloop;
203:                        case JvmOpCodes.ASTORE_0:
204:                            index = 0;
205:                            break forloop;
206:                        case JvmOpCodes.ASTORE_1:
207:                            index = 1;
208:                            break forloop;
209:                        case JvmOpCodes.ASTORE_2:
210:                            index = 2;
211:                            break forloop;
212:                        case JvmOpCodes.ASTORE_3:
213:                            index = 3;
214:                            break forloop;
215:
216:                        }
217:
218:                    }
219:                }
220:
221:                if (index != -1) {
222:                    LocalVariable local = null;
223:                    if (type.equals("simple")) {
224:                        local = DecompilerHelper.getLocalVariable(index,
225:                                "store", "java.lang.Object", true, pos);
226:                    } else {
227:
228:                        local = DecompilerHelper.getLocalVariable(index,
229:                                "store", "java.lang.Object", false, pos);
230:                    }
231:                    if (local != null) {
232:                        java.lang.String datatype = local.getDataType();
233:                        if (datatype.indexOf("[") != -1
234:                                && datatype.indexOf("]") != -1) {
235:                            int br = datatype.indexOf("[");
236:                            int count = 0;
237:                            do {
238:                                count++;
239:                                br = datatype.indexOf("[", (br + 1));
240:                            } while (br != -1);
241:                            return count - 1;
242:                        }
243:
244:                    }
245:                }
246:
247:                return total;
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.