/* $Id: PartialEvaluator.java,v 1.26 2004/12/11 16:35:23 eric Exp $
*
* ProGuard -- shrinking, optimization, and obfuscation of Java class files.
*
* Copyright (c) 2002-2004 Eric Lafortune (eric@graphics.cornell.edu)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package proguard.optimize.evaluation;
import proguard.classfile.*;
import proguard.classfile.attribute.*;
import proguard.classfile.attribute.annotation.*;
import proguard.classfile.editor.*;
import proguard.classfile.instruction.*;
import proguard.classfile.util.*;
import proguard.classfile.visitor.*;
import proguard.optimize.*;
import proguard.optimize.evaluation.value.*;
/**
* This MemberInfoVisitor performs partial evaluation on the program methods
* that it visits.
*
* @author Eric Lafortune
*/
public class PartialEvaluator
implements MemberInfoVisitor,
AttrInfoVisitor,
ExceptionInfoVisitor,
InstructionVisitor,
CpInfoVisitor
{
//*
private static final boolean DEBUG_RESULTS = false;
private static final boolean DEBUG_ANALYSIS = false;
private static final boolean DEBUG = false;
/*/
private static boolean DEBUG_RESULTS = true;
private static boolean DEBUG_ANALYSIS = true;
private static boolean DEBUG = true;
//*/
private static final int INITIAL_CODE_LENGTH = 1024;
private static final int INITIAL_VALUE_COUNT = 32;
private static final int MAXIMUM_EVALUATION_COUNT = 100;
private InstructionOffsetValue[] varTraceValues = new InstructionOffsetValue[INITIAL_CODE_LENGTH];
private InstructionOffsetValue[] stackTraceValues = new InstructionOffsetValue[INITIAL_CODE_LENGTH];
private InstructionOffsetValue[] branchOriginValues = new InstructionOffsetValue[INITIAL_CODE_LENGTH];
private InstructionOffsetValue[] branchTargetValues = new InstructionOffsetValue[INITIAL_CODE_LENGTH];
private TracedVariables[] vars = new TracedVariables[INITIAL_CODE_LENGTH];
private TracedStack[] stacks = new TracedStack[INITIAL_CODE_LENGTH];
private int[] evaluationCounts = new int[INITIAL_CODE_LENGTH];
private boolean[] initialization = new boolean[INITIAL_CODE_LENGTH];
private boolean[] isNecessary = new boolean[INITIAL_CODE_LENGTH];
private boolean evaluateExceptions;
private TracedVariables parameters = new TracedVariables(INITIAL_VALUE_COUNT);
private TracedVariables variables = new TracedVariables(INITIAL_VALUE_COUNT);
private TracedStack stack = new TracedStack(INITIAL_VALUE_COUNT);
private TracedBranchUnit branchUnit = new TracedBranchUnit();
private ClassFileCleaner classFileCleaner = new ClassFileCleaner();
private SideEffectInstructionChecker sideEffectInstructionChecker = new SideEffectInstructionChecker(true);
private CodeAttrInfoEditor codeAttrInfoEditor = new CodeAttrInfoEditor(INITIAL_CODE_LENGTH);
private boolean isInitializer;
// Implementations for MemberInfoVisitor.
public void visitProgramFieldInfo(ProgramClassFile programClassFile, ProgramFieldInfo programFieldInfo) {}
public void visitProgramMethodInfo(ProgramClassFile programClassFile, ProgramMethodInfo programMethodInfo)
{
// DEBUG = DEBUG_ANALYSIS = DEBUG_RESULTS =
// programClassFile.getName().equals("abc/Def") &&
// programMethodInfo.getName(programClassFile).equals("abc");
// Initialize the parameters.
boolean isStatic =
(programMethodInfo.u2accessFlags & ClassConstants.INTERNAL_ACC_STATIC) != 0;
// Count the number of parameters, taking into account their Categories.
String parameterDescriptor = programMethodInfo.getDescriptor(programClassFile);
int count = (isStatic ? 0 : 1) +
ClassUtil.internalMethodParameterSize(parameterDescriptor);
// Reuse the existing parameters object, ensuring the right size.
parameters.reset(count);
// Go over the parameters again.
InternalTypeEnumeration internalTypeEnumeration =
new InternalTypeEnumeration(parameterDescriptor);
int index = 0;
// Clear the store value of each parameter.
parameters.setStoreValue(InstructionOffsetValueFactory.create());
// Put the caller's reference in parameter 0.
if (!isStatic)
{
parameters.store(index++, ReferenceValueFactory.create(false));
}
while (internalTypeEnumeration.hasMoreTypes())
{
String type = internalTypeEnumeration.nextType();
// Get a generic corresponding value.
Value value = ValueFactory.create(type);
// Store the value in the parameter.
parameters.store(index, value);
// Increment the index according to the Category of the value.
index += value.isCategory2() ? 2 : 1;
}
// Reset the return value.
branchUnit.setTraceReturnValue(null);
try
{
// Process the code.
programMethodInfo.attributesAccept(programClassFile, this);
}
catch (RuntimeException ex)
{
// TODO: Remove this when the partial evaluator has stabilized.
System.err.println("Unexpected error while optimizing after partial evaluation:");
System.err.println(" ClassFile = ["+programClassFile.getName()+"]");
System.err.println(" Method = ["+programMethodInfo.getName(programClassFile)+programMethodInfo.getDescriptor(programClassFile)+"]");
System.err.println("Not optimizing this method");
if (DEBUG)
{
throw ex;
}
}
if (DEBUG)
{
Value returnValue = branchUnit.getTraceReturnValue();
if (returnValue != null)
{
System.out.println("Return value for method "+
ClassUtil.externalFullMethodDescription(programClassFile.getName(),
0,
programMethodInfo.getName(programClassFile),
programMethodInfo.getDescriptor(programClassFile))+
" -> ["+returnValue.toString()+"]");
System.out.println();
}
}
}
public void visitLibraryFieldInfo(LibraryClassFile libraryClassFile, LibraryFieldInfo libraryFieldInfo) {}
public void visitLibraryMethodInfo(LibraryClassFile libraryClassFile, LibraryMethodInfo libraryMethodInfo) {}
// Implementations for AttrInfoVisitor.
public void visitUnknownAttrInfo(ClassFile classFile, UnknownAttrInfo unknownAttrInfo) {}
public void visitInnerClassesAttrInfo(ClassFile classFile, InnerClassesAttrInfo innerClassesAttrInfo) {}
public void visitEnclosingMethodAttrInfo(ClassFile classFile, EnclosingMethodAttrInfo enclosingMethodAttrInfo) {}
public void visitConstantValueAttrInfo(Cla
没有合适的资源?快使用搜索试试~ 我知道了~
混淆器proguard3.2.zip
共425个文件
java:318个
html:52个
gif:20个
需积分: 10 37 下载量 42 浏览量
2008-11-13
11:24:34
上传
评论
收藏 1.46MB ZIP 举报
温馨提示
ProGuard, Java class file shrinker and obfuscator
资源推荐
资源详情
资源评论
收起资源包目录
混淆器proguard3.2.zip (425个子文件)
style.css 2KB
style.css 999B
screenshots_gui_small.gif 88KB
screenshot_console_small.gif 85KB
screenshot_gui1.gif 38KB
screenshot_gui2.gif 30KB
screenshot_gui4.gif 30KB
screenshot_gui7.gif 29KB
screenshot_gui3.gif 29KB
screenshot_gui5.gif 28KB
vtitle.gif 26KB
screenshot_gui8.gif 26KB
screenshot_gui6.gif 23KB
vtitle.gif 22KB
screenshot_console.gif 13KB
steel.gif 3KB
title.gif 3KB
drop1.gif 803B
drop2.gif 620B
drop3.gif 175B
arrow.gif 112B
checkmark.gif 63B
usage.html 39KB
examples.html 25KB
examples.html 17KB
alternatives.html 17KB
gui.html 16KB
GPL.html 16KB
ant.html 16KB
troubleshooting.html 12KB
refcard.html 9KB
FAQ.html 9KB
downloads.html 8KB
sections.html 5KB
introduction.html 5KB
limitations.html 4KB
sections.html 4KB
results.html 4KB
feedback.html 4KB
testimonials.html 3KB
main.html 3KB
usage.html 2KB
package.html 2KB
acknowledgements.html 2KB
screenshots.html 2KB
introduction.html 2KB
wtk.html 2KB
license.html 2KB
GPL_exception.html 2KB
quality.html 1KB
index.html 1KB
index.html 984B
package.html 664B
index.html 600B
title.html 511B
package.html 379B
package.html 162B
package.html 147B
package.html 132B
package.html 129B
package.html 121B
package.html 104B
package.html 99B
package.html 93B
package.html 91B
package.html 89B
package.html 87B
package.html 85B
package.html 84B
package.html 82B
package.html 81B
package.html 69B
package.html 65B
package.html 64B
proguard.jar 346KB
proguardgui.jar 121KB
retrace.jar 5KB
PartialEvaluator.java 84KB
ProGuardGUI.java 61KB
ConfigurationParser.java 38KB
ClassUtil.java 38KB
Processor.java 36KB
ProGuard.java 34KB
UsageMarker.java 29KB
ClassFileRenamer.java 27KB
CodeAttrInfoEditor.java 25KB
ClassFilePrinter.java 24KB
SingleImplementationInliner.java 23KB
ConstantPoolEditor.java 23KB
ConstantPoolRemapper.java 21KB
Instruction.java 20KB
ClassFileReferenceInitializer.java 19KB
GetterSetterInliner.java 19KB
ClassMemberSpecificationDialog.java 18KB
ClassSpecificationDialog.java 18KB
LibraryClassFile.java 17KB
InstructionConstants.java 16KB
ConfigurationWriter.java 15KB
Utf8UsageMarker.java 15KB
ProgramClassFile.java 15KB
共 425 条
- 1
- 2
- 3
- 4
- 5
资源评论
restart2001
- 粉丝: 2
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python语言教程1-python批量图片重命名,将后缀某几个不想要的字去除
- Space Combat Kit 太空战斗套件Unity游戏开发插件资源unitypackage C#
- Universal Device Preview 通用设备预览Unity游戏开发插件资源unitypackage
- Paladin Anim Set 圣骑士动画集Unity游戏动作动画插件资源unitypackage
- 计算机财务管理期末考报表部分题目及答案.doc
- 计算机软件维护论文.doc
- 计算机软件著作权授权书.docx
- 计算机键盘教学案例.doc
- 计算流体力学软件平台方案.pptx
- 计量自动化系统介绍.ppt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功