Source Code Cross Referenced for AstoreCommand.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:        /*
002:         *  AstoreCommand.java Copyright (c) 2006,07 Swaroop Belur
003:         *
004:         * This program is free software; you can redistribute it and/itor
005:         * modify it under the terms of the GNU General Public License
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         * GNU General Public License for more details.
013:         
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software
016:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
017:         *
018:         */
019:        package net.sf.jdec.jvminstructions.commands;
020:
021:        import java.util.ArrayList;
022:
023:        import net.sf.jdec.core.DecompilerHelper;
024:        import net.sf.jdec.core.GlobalVariableStore;
025:        import net.sf.jdec.core.LocalVariable;
026:        import net.sf.jdec.core.Operand;
027:        import net.sf.jdec.core.OperandStack;
028:        import net.sf.jdec.main.ConsoleLauncher;
029:        import net.sf.jdec.reflection.Behaviour;
030:        import net.sf.jdec.util.Util;
031:
032:        public class AstoreCommand extends AbstractInstructionCommand {
033:
034:            public AstoreCommand(Behaviour context) {
035:                super (context);
036:
037:            }
038:
039:            public int getSkipBytes() {
040:
041:                return 1;
042:            }
043:
044:            public void execute() {
045:
046:                int i = getCurrentInstPosInCode();
047:                int currentForIndex = i;
048:                int instructionPos = i;
049:                Behaviour behaviour = getContext();
050:                boolean doNotPop = GlobalVariableStore.isDoNotPop();
051:                boolean multinewfound = GlobalVariableStore.isMultinewfound();
052:                ArrayList methodTries = getContext().getAllTriesForMethod();
053:                byte[] info = getContext().getCode();
054:                int classIndex = info[++i];
055:                boolean add = DecompilerHelper.checkForStartOfCatch(
056:                        instructionPos, methodTries);
057:                OperandStack opStack = getContext().getOpStack();
058:
059:                ArrayList ternList = GlobalVariableStore.getTernList();
060:                boolean dupnothandled = GlobalVariableStore.isDupnothandled();
061:                if (add == true && !doNotPop) {
062:
063:                    LocalVariable local = DecompilerHelper.getLocalVariable(
064:                            classIndex, "store", "java.lang.Object", false,
065:                            currentForIndex);
066:                    if (local != null) {
067:
068:                        // temp has new <Class Name>[<size>]
069:                        boolean push = getGenericFinder().isPrevInstDup(
070:                                currentForIndex);
071:                        if (!push) {
072:                            Operand objref = (Operand) opStack.pop(); // Pop The Object Ref
073:                            if (local.wasCreated()
074:                                    && objref != null
075:                                    && objref.getClassType().trim().length() > 0)
076:                                local.setDataType(objref.getClassType());
077:                            java.lang.String temp = (java.lang.String) objref
078:                                    .getOperandValue();
079:                            if (!local.isDeclarationGenerated()) {
080:                                local.setBlockIndex(i - 1);
081:                                boolean yes = true;
082:                                if (!multinewfound) {
083:                                    StringBuffer m = new StringBuffer("");
084:                                    DecompilerHelper
085:                                            .checkForImport(local.getDataType()
086:                                                    .replace('/', '.'), m);
087:                                    Object vaf = DecompilerHelper
088:                                            .newVariableAtFront(local
089:                                                    .getVarName(),
090:                                                    m.toString(), "null");
091:                                    GlobalVariableStore.getVariablesatfront()
092:                                            .add(vaf);
093:                                    temp = local.getVarName() + "=" + temp;
094:                                    if (local.getVarName().equals(temp) == true) {
095:                                        yes = false;
096:                                    }
097:                                } else {
098:                                    multinewfound = false;
099:                                    if (GlobalVariableStore
100:                                            .getVariablesatfront() != null) {
101:                                        Integer n = (Integer) GlobalVariableStore
102:                                                .getVariablesatfront().get(
103:                                                        new Integer(classIndex)
104:                                                                .intValue());
105:                                        java.lang.String bracks = "";
106:                                        if (n != null) {
107:                                            for (int o = 0; o < n.intValue(); o++) {
108:                                                bracks += "[]";
109:                                            }
110:                                        }
111:                                        StringBuffer m = new StringBuffer("");
112:                                        DecompilerHelper.checkForImport(local
113:                                                .getDataType()
114:                                                .replace('/', '.'), m);
115:                                        Object vaf = DecompilerHelper
116:                                                .newVariableAtFront(local
117:                                                        .getVarName(), m + " "
118:                                                        + bracks + "  ", "null");
119:                                        GlobalVariableStore
120:                                                .getVariablesatfront().add(vaf);
121:                                        temp = local.getVarName() + "=" + temp;
122:                                    } else {
123:                                        // TODO: IMPORTANT FIXME
124:                                        Object vaf = DecompilerHelper
125:                                                .newVariableAtFront(local
126:                                                        .getVarName(), local
127:                                                        .getDataType().replace(
128:                                                                '/', '.'),
129:                                                        "null");
130:                                        GlobalVariableStore
131:                                                .getVariablesatfront().add(vaf);
132:                                        temp = local.getVarName() + "=" + temp;
133:                                    }
134:                                }
135:                                local.setDeclarationGenerated(true);
136:                                if (yes) {
137:                                    behaviour.appendToBuffer(Util
138:                                            .formatDecompiledStatement(temp
139:                                                    + ";\n"));
140:
141:                                }
142:                            } else {
143:
144:                                if (temp != null
145:                                        && temp.trim().equalsIgnoreCase("this")) {
146:
147:                                    java.lang.String classname = ConsoleLauncher
148:                                            .getClazzRef().getClassName();
149:                                    temp = classname + "  "
150:                                            + local.getVarName() + " =" + temp;
151:                                    behaviour.appendToBuffer(Util
152:                                            .formatDecompiledStatement(temp
153:                                                    + ";\n"));
154:                                    //behaviour.appendToBuffer( ";\n";
155:                                } else {
156:                                    temp = "  " + local.getVarName() + " ="
157:                                            + temp;
158:                                    behaviour.appendToBuffer(Util
159:                                            .formatDecompiledStatement(temp
160:                                                    + ";\n"));
161:                                    //behaviour.appendToBuffer( ";\n";
162:                                }
163:                            }
164:                        } else {
165:
166:                            Operand top = opStack.getTopOfStack();
167:                            if (!dupnothandled)
168:                                opStack.getTopOfStack();
169:                            else
170:                                dupnothandled = false;
171:                            if (local.wasCreated() && top != null
172:                                    && top.getClassType().trim().length() > 0)
173:                                local.setDataType(top.getClassType());
174:                            java.lang.String temp = top.getOperandValue();
175:                            temp = local.getVarName() + " =" + "(" + temp + ")";
176:                            if (!DecompilerHelper.isTernaryCondition(
177:                                    currentForIndex, info)) {
178:                                if (newfound() == false) {
179:                                    behaviour.appendToBuffer(Util
180:                                            .formatDecompiledStatement(temp
181:                                                    + ";\n"));
182:                                    //behaviour.appendToBuffer( ";\n";
183:                                    Operand op6 = createOperand(local
184:                                            .getVarName());
185:                                    opStack.push(op6);
186:                                } else {
187:                                    Operand op6 = createOperand(temp);
188:                                    opStack.push(op6);
189:                                }
190:                            } else {
191:                                boolean ternEndfoundForParentIF = false;//isThisTernaryListEndForParentIF(currentForIndex);
192:                                boolean ternEndfound = false;//isThisTernaryListEnd(currentForIndex);
193:
194:                                boolean dupStoreForTerIf = false;//isThisDUPSTOREAtEndOFTernaryIF(currentForIndex,info,"store");
195:                                boolean n = DecompilerHelper
196:                                        .anydupstoreinternarybesidesthis (
197:                                                currentForIndex, info);
198:                                if (ternEndfound && n) {
199:                                    opStack.push(top);
200:                                } else {
201:                                    Operand p = opStack.getTopOfStack();
202:                                    boolean end = false;//isTernaryEnd(currentForIndex);
203:                                    if (dupStoreForTerIf) {
204:                                        if (!end)
205:                                            p.setOperandValue(p
206:                                                    .getOperandValue()
207:                                                    + "("
208:                                                    + local.getVarName()
209:                                                    + "="
210:                                                    + top.getOperandValue()
211:                                                    + ")");
212:                                        else
213:                                            p.setOperandValue(p
214:                                                    .getOperandValue()
215:                                                    + "("
216:                                                    + local.getVarName()
217:                                                    + "="
218:                                                    + top.getOperandValue()
219:                                                    + "))");
220:                                    }
221:                                    if (!dupStoreForTerIf) {
222:                                        if (!end)
223:                                            p.setOperandValue(p
224:                                                    .getOperandValue()
225:                                                    + "("
226:                                                    + top.getOperandValue()
227:                                                    + ")");
228:                                        else
229:                                            p.setOperandValue(p
230:                                                    .getOperandValue()
231:                                                    + top.getOperandValue()
232:                                                    + "))");
233:                                    }
234:                                    opStack.push(p);
235:                                }
236:                                if (ternEndfoundForParentIF)
237:                                    ternList = new ArrayList();
238:
239:                            }
240:                        }
241:
242:                    }
243:
244:                }
245:                if (doNotPop)
246:                    doNotPop = false;
247:                GlobalVariableStore.setDoNotPop(doNotPop);
248:                GlobalVariableStore.setMultinewfound(multinewfound);
249:                GlobalVariableStore.setTernList(ternList);
250:                GlobalVariableStore.setDupnothandled(dupnothandled);
251:            }
252:
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.