From f72d5de56a522ac3be03873bdde26f23a5eeeb3c Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 18:28:14 -0800 Subject: auto import from //depot/cupcake/@135843 --- dx/.classpath | 7 - dx/.project | 17 - dx/Android.mk | 65 - dx/README.txt | 2 - dx/etc/bytecode.txt | 278 --- dx/etc/dx | 77 - dx/etc/dx.bat | 51 - dx/etc/jasmin | 39 - dx/etc/jasmin.jar | Bin 128775 -> 0 bytes dx/etc/manifest.txt | 1 - dx/etc/opcode-gen | 141 -- dx/etc/run-opcode-gen | 22 - dx/src/Android.mk | 31 - dx/src/com/android/dx/Version.java | 25 - .../android/dx/cf/attrib/AttAnnotationDefault.java | 67 - dx/src/com/android/dx/cf/attrib/AttCode.java | 145 -- .../com/android/dx/cf/attrib/AttConstantValue.java | 77 - dx/src/com/android/dx/cf/attrib/AttDeprecated.java | 37 - .../android/dx/cf/attrib/AttEnclosingMethod.java | 78 - dx/src/com/android/dx/cf/attrib/AttExceptions.java | 68 - .../com/android/dx/cf/attrib/AttInnerClasses.java | 64 - .../android/dx/cf/attrib/AttLineNumberTable.java | 65 - .../dx/cf/attrib/AttLocalVariableTable.java | 36 - .../dx/cf/attrib/AttLocalVariableTypeTable.java | 36 - .../cf/attrib/AttRuntimeInvisibleAnnotations.java | 40 - .../AttRuntimeInvisibleParameterAnnotations.java | 42 - .../dx/cf/attrib/AttRuntimeVisibleAnnotations.java | 40 - .../AttRuntimeVisibleParameterAnnotations.java | 42 - dx/src/com/android/dx/cf/attrib/AttSignature.java | 59 - dx/src/com/android/dx/cf/attrib/AttSourceFile.java | 59 - dx/src/com/android/dx/cf/attrib/AttSynthetic.java | 37 - .../com/android/dx/cf/attrib/BaseAnnotations.java | 72 - dx/src/com/android/dx/cf/attrib/BaseAttribute.java | 46 - .../android/dx/cf/attrib/BaseLocalVariables.java | 65 - .../dx/cf/attrib/BaseParameterAnnotations.java | 73 - .../com/android/dx/cf/attrib/InnerClassList.java | 137 -- dx/src/com/android/dx/cf/attrib/RawAttribute.java | 91 - dx/src/com/android/dx/cf/attrib/package.html | 11 - dx/src/com/android/dx/cf/code/BaseMachine.java | 545 ----- dx/src/com/android/dx/cf/code/BasicBlocker.java | 449 ----- dx/src/com/android/dx/cf/code/ByteBlock.java | 145 -- dx/src/com/android/dx/cf/code/ByteBlockList.java | 75 - dx/src/com/android/dx/cf/code/ByteCatchList.java | 317 --- dx/src/com/android/dx/cf/code/ByteOps.java | 649 ------ dx/src/com/android/dx/cf/code/BytecodeArray.java | 1393 ------------- dx/src/com/android/dx/cf/code/ConcreteMethod.java | 254 --- dx/src/com/android/dx/cf/code/ExecutionStack.java | 305 --- dx/src/com/android/dx/cf/code/Frame.java | 415 ---- dx/src/com/android/dx/cf/code/LineNumberList.java | 184 -- .../com/android/dx/cf/code/LocalVariableList.java | 374 ---- dx/src/com/android/dx/cf/code/LocalsArray.java | 181 -- dx/src/com/android/dx/cf/code/LocalsArraySet.java | 462 ----- dx/src/com/android/dx/cf/code/Machine.java | 208 -- dx/src/com/android/dx/cf/code/Merger.java | 305 --- dx/src/com/android/dx/cf/code/OneLocalsArray.java | 246 --- dx/src/com/android/dx/cf/code/ReturnAddress.java | 108 - dx/src/com/android/dx/cf/code/Ropper.java | 1667 --------------- dx/src/com/android/dx/cf/code/RopperMachine.java | 936 --------- dx/src/com/android/dx/cf/code/SimException.java | 37 - dx/src/com/android/dx/cf/code/Simulator.java | 701 ------- dx/src/com/android/dx/cf/code/SwitchList.java | 193 -- .../com/android/dx/cf/code/ValueAwareMachine.java | 198 -- dx/src/com/android/dx/cf/code/package.html | 10 - .../com/android/dx/cf/cst/ConstantPoolParser.java | 335 --- dx/src/com/android/dx/cf/cst/ConstantTags.java | 55 - .../com/android/dx/cf/direct/AnnotationParser.java | 474 ----- .../com/android/dx/cf/direct/AttributeFactory.java | 134 -- .../android/dx/cf/direct/AttributeListParser.java | 164 -- .../com/android/dx/cf/direct/ClassPathOpener.java | 251 --- dx/src/com/android/dx/cf/direct/CodeObserver.java | 306 --- .../com/android/dx/cf/direct/DirectClassFile.java | 633 ------ .../com/android/dx/cf/direct/FieldListParser.java | 86 - .../com/android/dx/cf/direct/MemberListParser.java | 240 --- .../com/android/dx/cf/direct/MethodListParser.java | 86 - .../android/dx/cf/direct/StdAttributeFactory.java | 764 ------- dx/src/com/android/dx/cf/direct/package.html | 12 - dx/src/com/android/dx/cf/iface/Attribute.java | 38 - dx/src/com/android/dx/cf/iface/AttributeList.java | 75 - dx/src/com/android/dx/cf/iface/ClassFile.java | 123 -- dx/src/com/android/dx/cf/iface/Field.java | 35 - dx/src/com/android/dx/cf/iface/FieldList.java | 48 - dx/src/com/android/dx/cf/iface/Member.java | 74 - dx/src/com/android/dx/cf/iface/Method.java | 34 - dx/src/com/android/dx/cf/iface/MethodList.java | 47 - dx/src/com/android/dx/cf/iface/ParseException.java | 37 - dx/src/com/android/dx/cf/iface/ParseObserver.java | 68 - .../com/android/dx/cf/iface/StdAttributeList.java | 104 - dx/src/com/android/dx/cf/iface/StdField.java | 54 - dx/src/com/android/dx/cf/iface/StdFieldList.java | 49 - dx/src/com/android/dx/cf/iface/StdMember.java | 110 - dx/src/com/android/dx/cf/iface/StdMethod.java | 55 - dx/src/com/android/dx/cf/iface/StdMethodList.java | 49 - dx/src/com/android/dx/cf/iface/package.html | 10 - dx/src/com/android/dx/command/DxConsole.java | 37 - dx/src/com/android/dx/command/Main.java | 170 -- dx/src/com/android/dx/command/UsageException.java | 25 - .../dx/command/annotool/AnnotationLister.java | 283 --- dx/src/com/android/dx/command/annotool/Main.java | 159 -- dx/src/com/android/dx/command/dexer/Main.java | 905 --------- dx/src/com/android/dx/command/dump/Args.java | 56 - dx/src/com/android/dx/command/dump/BaseDumper.java | 299 --- .../com/android/dx/command/dump/BlockDumper.java | 360 ---- .../com/android/dx/command/dump/ClassDumper.java | 74 - dx/src/com/android/dx/command/dump/DotDumper.java | 170 -- dx/src/com/android/dx/command/dump/Main.java | 131 -- dx/src/com/android/dx/command/dump/SsaDumper.java | 160 -- .../com/android/dx/dex/cf/AttributeTranslator.java | 416 ---- dx/src/com/android/dx/dex/cf/CfOptions.java | 50 - dx/src/com/android/dx/dex/cf/CfTranslator.java | 383 ---- dx/src/com/android/dx/dex/cf/CodeStatistics.java | 172 -- dx/src/com/android/dx/dex/cf/OptimizerOptions.java | 183 -- dx/src/com/android/dx/dex/cf/package.html | 15 - dx/src/com/android/dx/dex/code/ArrayData.java | 199 -- dx/src/com/android/dx/dex/code/BlockAddresses.java | 143 -- dx/src/com/android/dx/dex/code/CatchBuilder.java | 48 - .../com/android/dx/dex/code/CatchHandlerList.java | 238 --- dx/src/com/android/dx/dex/code/CatchTable.java | 192 -- dx/src/com/android/dx/dex/code/CodeAddress.java | 57 - dx/src/com/android/dx/dex/code/CstInsn.java | 205 -- dx/src/com/android/dx/dex/code/DalvCode.java | 232 --- dx/src/com/android/dx/dex/code/DalvInsn.java | 422 ---- dx/src/com/android/dx/dex/code/DalvInsnList.java | 268 --- dx/src/com/android/dx/dex/code/DalvOps.java | 298 --- dx/src/com/android/dx/dex/code/Dop.java | 150 -- dx/src/com/android/dx/dex/code/Dops.java | 1231 ------------ dx/src/com/android/dx/dex/code/FixedSizeInsn.java | 73 - .../android/dx/dex/code/HighRegisterPrefix.java | 147 -- dx/src/com/android/dx/dex/code/InsnFormat.java | 578 ------ dx/src/com/android/dx/dex/code/LocalEnd.java | 89 - dx/src/com/android/dx/dex/code/LocalList.java | 402 ---- dx/src/com/android/dx/dex/code/LocalSnapshot.java | 96 - dx/src/com/android/dx/dex/code/LocalStart.java | 98 - dx/src/com/android/dx/dex/code/OddSpacer.java | 75 - .../com/android/dx/dex/code/OutputCollector.java | 118 -- dx/src/com/android/dx/dex/code/OutputFinisher.java | 737 ------- dx/src/com/android/dx/dex/code/PositionList.java | 192 -- dx/src/com/android/dx/dex/code/RopToDop.java | 415 ---- dx/src/com/android/dx/dex/code/RopTranslator.java | 872 -------- dx/src/com/android/dx/dex/code/SimpleInsn.java | 59 - .../com/android/dx/dex/code/StdCatchBuilder.java | 317 --- dx/src/com/android/dx/dex/code/SwitchData.java | 257 --- dx/src/com/android/dx/dex/code/TargetInsn.java | 132 -- .../com/android/dx/dex/code/VariableSizeInsn.java | 49 - dx/src/com/android/dx/dex/code/ZeroSizeInsn.java | 62 - dx/src/com/android/dx/dex/code/form/Form10t.java | 92 - dx/src/com/android/dx/dex/code/form/Form10x.java | 78 - dx/src/com/android/dx/dex/code/form/Form11n.java | 104 - dx/src/com/android/dx/dex/code/form/Form11x.java | 82 - dx/src/com/android/dx/dex/code/form/Form12x.java | 132 -- dx/src/com/android/dx/dex/code/form/Form20t.java | 92 - dx/src/com/android/dx/dex/code/form/Form21c.java | 133 -- dx/src/com/android/dx/dex/code/form/Form21h.java | 120 -- dx/src/com/android/dx/dex/code/form/Form21s.java | 104 - dx/src/com/android/dx/dex/code/form/Form21t.java | 100 - dx/src/com/android/dx/dex/code/form/Form22b.java | 106 - dx/src/com/android/dx/dex/code/form/Form22c.java | 109 - dx/src/com/android/dx/dex/code/form/Form22s.java | 107 - dx/src/com/android/dx/dex/code/form/Form22t.java | 103 - dx/src/com/android/dx/dex/code/form/Form22x.java | 86 - dx/src/com/android/dx/dex/code/form/Form23x.java | 88 - dx/src/com/android/dx/dex/code/form/Form30t.java | 90 - dx/src/com/android/dx/dex/code/form/Form31c.java | 129 -- dx/src/com/android/dx/dex/code/form/Form31i.java | 103 - dx/src/com/android/dx/dex/code/form/Form31t.java | 96 - dx/src/com/android/dx/dex/code/form/Form32x.java | 87 - dx/src/com/android/dx/dex/code/form/Form35c.java | 193 -- dx/src/com/android/dx/dex/code/form/Form3rc.java | 175 -- dx/src/com/android/dx/dex/code/form/Form51l.java | 102 - .../android/dx/dex/code/form/SpecialFormat.java | 79 - dx/src/com/android/dx/dex/file/AnnotationItem.java | 220 -- .../com/android/dx/dex/file/AnnotationSetItem.java | 157 -- .../android/dx/dex/file/AnnotationSetRefItem.java | 80 - .../com/android/dx/dex/file/AnnotationUtils.java | 254 --- .../dx/dex/file/AnnotationsDirectoryItem.java | 385 ---- dx/src/com/android/dx/dex/file/CatchStructs.java | 320 --- dx/src/com/android/dx/dex/file/ClassDataItem.java | 431 ---- dx/src/com/android/dx/dex/file/ClassDefItem.java | 410 ---- .../com/android/dx/dex/file/ClassDefsSection.java | 187 -- dx/src/com/android/dx/dex/file/CodeItem.java | 335 --- .../android/dx/dex/file/DebugInfoConstants.java | 154 -- .../com/android/dx/dex/file/DebugInfoDecoder.java | 563 ------ .../com/android/dx/dex/file/DebugInfoEncoder.java | 1035 ---------- dx/src/com/android/dx/dex/file/DebugInfoItem.java | 170 -- dx/src/com/android/dx/dex/file/DexFile.java | 647 ------ .../com/android/dx/dex/file/EncodedArrayItem.java | 131 -- dx/src/com/android/dx/dex/file/EncodedField.java | 154 -- dx/src/com/android/dx/dex/file/EncodedMember.java | 86 - dx/src/com/android/dx/dex/file/EncodedMethod.java | 196 -- .../android/dx/dex/file/FieldAnnotationStruct.java | 122 -- dx/src/com/android/dx/dex/file/FieldIdItem.java | 70 - .../com/android/dx/dex/file/FieldIdsSection.java | 137 -- dx/src/com/android/dx/dex/file/HeaderItem.java | 123 -- dx/src/com/android/dx/dex/file/HeaderSection.java | 63 - dx/src/com/android/dx/dex/file/IdItem.java | 61 - dx/src/com/android/dx/dex/file/IndexedItem.java | 81 - dx/src/com/android/dx/dex/file/Item.java | 80 - dx/src/com/android/dx/dex/file/ItemType.java | 97 - dx/src/com/android/dx/dex/file/MapItem.java | 235 --- dx/src/com/android/dx/dex/file/MemberIdItem.java | 111 - .../com/android/dx/dex/file/MemberIdsSection.java | 44 - .../dx/dex/file/MethodAnnotationStruct.java | 122 -- dx/src/com/android/dx/dex/file/MethodIdItem.java | 70 - .../com/android/dx/dex/file/MethodIdsSection.java | 137 -- .../com/android/dx/dex/file/MixedItemSection.java | 362 ---- dx/src/com/android/dx/dex/file/OffsettedItem.java | 313 --- .../dx/dex/file/ParameterAnnotationStruct.java | 161 -- dx/src/com/android/dx/dex/file/ProtoIdItem.java | 162 -- .../com/android/dx/dex/file/ProtoIdsSection.java | 140 -- dx/src/com/android/dx/dex/file/Section.java | 287 --- dx/src/com/android/dx/dex/file/Statistics.java | 195 -- dx/src/com/android/dx/dex/file/StringDataItem.java | 99 - dx/src/com/android/dx/dex/file/StringIdItem.java | 128 -- .../com/android/dx/dex/file/StringIdsSection.java | 210 -- dx/src/com/android/dx/dex/file/TypeIdItem.java | 72 - dx/src/com/android/dx/dex/file/TypeIdsSection.java | 192 -- dx/src/com/android/dx/dex/file/TypeListItem.java | 122 -- .../android/dx/dex/file/UniformItemSection.java | 112 -- .../com/android/dx/dex/file/UniformListItem.java | 216 -- dx/src/com/android/dx/dex/file/ValueEncoder.java | 532 ----- .../com/android/dx/rop/annotation/Annotation.java | 232 --- .../dx/rop/annotation/AnnotationVisibility.java | 46 - .../com/android/dx/rop/annotation/Annotations.java | 213 -- .../android/dx/rop/annotation/AnnotationsList.java | 91 - .../android/dx/rop/annotation/NameValuePair.java | 112 -- dx/src/com/android/dx/rop/code/AccessFlags.java | 374 ---- dx/src/com/android/dx/rop/code/BasicBlock.java | 281 --- dx/src/com/android/dx/rop/code/BasicBlockList.java | 398 ---- .../dx/rop/code/ConservativeTranslationAdvice.java | 52 - dx/src/com/android/dx/rop/code/CstInsn.java | 74 - .../android/dx/rop/code/DexTranslationAdvice.java | 119 -- dx/src/com/android/dx/rop/code/Exceptions.java | 133 -- .../com/android/dx/rop/code/FillArrayDataInsn.java | 116 -- dx/src/com/android/dx/rop/code/Insn.java | 458 ----- dx/src/com/android/dx/rop/code/InsnList.java | 130 -- dx/src/com/android/dx/rop/code/LocalItem.java | 144 -- .../dx/rop/code/LocalVariableExtractor.java | 192 -- .../com/android/dx/rop/code/LocalVariableInfo.java | 250 --- dx/src/com/android/dx/rop/code/PlainCstInsn.java | 87 - dx/src/com/android/dx/rop/code/PlainInsn.java | 140 -- dx/src/com/android/dx/rop/code/RegOps.java | 403 ---- dx/src/com/android/dx/rop/code/RegisterSpec.java | 552 ----- .../com/android/dx/rop/code/RegisterSpecList.java | 362 ---- .../com/android/dx/rop/code/RegisterSpecSet.java | 350 ---- dx/src/com/android/dx/rop/code/Rop.java | 407 ---- dx/src/com/android/dx/rop/code/RopMethod.java | 207 -- dx/src/com/android/dx/rop/code/Rops.java | 2124 -------------------- dx/src/com/android/dx/rop/code/SourcePosition.java | 168 -- dx/src/com/android/dx/rop/code/SwitchInsn.java | 119 -- .../com/android/dx/rop/code/ThrowingCstInsn.java | 105 - dx/src/com/android/dx/rop/code/ThrowingInsn.java | 120 -- .../com/android/dx/rop/code/TranslationAdvice.java | 62 - dx/src/com/android/dx/rop/code/package.html | 8 - dx/src/com/android/dx/rop/cst/Constant.java | 68 - dx/src/com/android/dx/rop/cst/ConstantPool.java | 70 - dx/src/com/android/dx/rop/cst/CstAnnotation.java | 96 - dx/src/com/android/dx/rop/cst/CstArray.java | 164 -- .../com/android/dx/rop/cst/CstBaseMethodRef.java | 151 -- dx/src/com/android/dx/rop/cst/CstBoolean.java | 99 - dx/src/com/android/dx/rop/cst/CstByte.java | 99 - dx/src/com/android/dx/rop/cst/CstChar.java | 99 - dx/src/com/android/dx/rop/cst/CstDouble.java | 90 - dx/src/com/android/dx/rop/cst/CstEnumRef.java | 68 - dx/src/com/android/dx/rop/cst/CstFieldRef.java | 79 - dx/src/com/android/dx/rop/cst/CstFloat.java | 91 - dx/src/com/android/dx/rop/cst/CstInteger.java | 116 -- .../android/dx/rop/cst/CstInterfaceMethodRef.java | 60 - dx/src/com/android/dx/rop/cst/CstKnownNull.java | 110 - dx/src/com/android/dx/rop/cst/CstLiteral32.java | 87 - dx/src/com/android/dx/rop/cst/CstLiteral64.java | 87 - dx/src/com/android/dx/rop/cst/CstLiteralBits.java | 82 - dx/src/com/android/dx/rop/cst/CstLong.java | 87 - dx/src/com/android/dx/rop/cst/CstMemberRef.java | 122 -- dx/src/com/android/dx/rop/cst/CstMethodRef.java | 39 - dx/src/com/android/dx/rop/cst/CstNat.java | 170 -- dx/src/com/android/dx/rop/cst/CstShort.java | 100 - dx/src/com/android/dx/rop/cst/CstString.java | 109 - dx/src/com/android/dx/rop/cst/CstType.java | 230 --- dx/src/com/android/dx/rop/cst/CstUtf8.java | 371 ---- dx/src/com/android/dx/rop/cst/StdConstantPool.java | 139 -- dx/src/com/android/dx/rop/cst/TypedConstant.java | 49 - dx/src/com/android/dx/rop/cst/Zeroes.java | 55 - dx/src/com/android/dx/rop/cst/package.html | 9 - dx/src/com/android/dx/rop/package-info.java | 201 -- dx/src/com/android/dx/rop/type/Prototype.java | 397 ---- dx/src/com/android/dx/rop/type/StdTypeList.java | 407 ---- dx/src/com/android/dx/rop/type/Type.java | 855 -------- dx/src/com/android/dx/rop/type/TypeBearer.java | 74 - dx/src/com/android/dx/rop/type/TypeList.java | 69 - dx/src/com/android/dx/rop/type/package.html | 8 - dx/src/com/android/dx/ssa/BasicRegisterMapper.java | 127 -- dx/src/com/android/dx/ssa/ConstCollector.java | 378 ---- dx/src/com/android/dx/ssa/DeadCodeRemover.java | 226 --- dx/src/com/android/dx/ssa/DomFront.java | 188 -- dx/src/com/android/dx/ssa/Dominators.java | 240 --- .../android/dx/ssa/InterferenceRegisterMapper.java | 164 -- dx/src/com/android/dx/ssa/LiteralOpUpgrader.java | 160 -- .../com/android/dx/ssa/LocalVariableExtractor.java | 208 -- dx/src/com/android/dx/ssa/LocalVariableInfo.java | 251 --- dx/src/com/android/dx/ssa/MoveParamCombiner.java | 156 -- dx/src/com/android/dx/ssa/NormalSsaInsn.java | 235 --- dx/src/com/android/dx/ssa/Optimizer.java | 246 --- dx/src/com/android/dx/ssa/PhiInsn.java | 364 ---- dx/src/com/android/dx/ssa/PhiTypeResolver.java | 200 -- dx/src/com/android/dx/ssa/RegisterMapper.java | 63 - dx/src/com/android/dx/ssa/SCCP.java | 486 ----- dx/src/com/android/dx/ssa/SetFactory.java | 95 - dx/src/com/android/dx/ssa/SsaBasicBlock.java | 949 --------- dx/src/com/android/dx/ssa/SsaConverter.java | 365 ---- dx/src/com/android/dx/ssa/SsaInsn.java | 260 --- dx/src/com/android/dx/ssa/SsaMethod.java | 831 -------- dx/src/com/android/dx/ssa/SsaRenamer.java | 621 ------ dx/src/com/android/dx/ssa/_tests/_DomFront.java | 32 - .../com/android/dx/ssa/back/FirstFitAllocator.java | 152 -- .../ssa/back/FirstFitLocalCombiningAllocator.java | 950 --------- .../dx/ssa/back/IdenticalBlockCombiner.java | 174 -- .../com/android/dx/ssa/back/InterferenceGraph.java | 108 - .../com/android/dx/ssa/back/LivenessAnalyzer.java | 278 --- .../android/dx/ssa/back/NullRegisterAllocator.java | 61 - .../com/android/dx/ssa/back/RegisterAllocator.java | 204 -- dx/src/com/android/dx/ssa/back/SsaToRop.java | 393 ---- dx/src/com/android/dx/ssa/package-info.java | 103 - dx/src/com/android/dx/util/AnnotatedOutput.java | 79 - dx/src/com/android/dx/util/BitIntSet.java | 151 -- dx/src/com/android/dx/util/Bits.java | 236 --- dx/src/com/android/dx/util/ByteArray.java | 379 ---- .../android/dx/util/ByteArrayAnnotatedOutput.java | 639 ------ .../com/android/dx/util/ExceptionWithContext.java | 149 -- dx/src/com/android/dx/util/FileUtils.java | 92 - dx/src/com/android/dx/util/FixedSizeList.java | 276 --- dx/src/com/android/dx/util/Hex.java | 303 --- dx/src/com/android/dx/util/HexParser.java | 145 -- dx/src/com/android/dx/util/IndentingWriter.java | 169 -- dx/src/com/android/dx/util/IntIterator.java | 44 - dx/src/com/android/dx/util/IntList.java | 452 ----- dx/src/com/android/dx/util/IntSet.java | 67 - dx/src/com/android/dx/util/LabeledItem.java | 30 - dx/src/com/android/dx/util/LabeledList.java | 161 -- dx/src/com/android/dx/util/Leb128Utils.java | 78 - dx/src/com/android/dx/util/ListIntSet.java | 137 -- dx/src/com/android/dx/util/MutabilityControl.java | 89 - .../com/android/dx/util/MutabilityException.java | 35 - dx/src/com/android/dx/util/Output.java | 129 -- dx/src/com/android/dx/util/ToHuman.java | 31 - dx/src/com/android/dx/util/TwoColumnOutput.java | 254 --- dx/src/com/android/dx/util/Warning.java | 31 - dx/src/com/android/dx/util/Writers.java | 48 - dx/src/com/android/dx/util/_tests/_BitIntSet.java | 211 -- dx/src/com/android/dx/util/_tests/_Bits.java | 351 ---- dx/src/com/android/dx/util/_tests/_IntList.java | 72 - dx/src/com/android/dx/util/_tests/_ListIntSet.java | 203 -- dx/src/com/android/dx/util/package.html | 3 - dx/src/junit/extensions/ActiveTestSuite.java | 64 - dx/src/junit/extensions/ExceptionTestCase.java | 46 - dx/src/junit/extensions/RepeatedTest.java | 31 - dx/src/junit/extensions/TestDecorator.java | 38 - dx/src/junit/extensions/TestSetup.java | 37 - dx/src/junit/framework/Assert.java | 291 --- dx/src/junit/framework/AssertionFailedError.java | 13 - dx/src/junit/framework/ComparisonFailure.java | 68 - dx/src/junit/framework/Protectable.java | 14 - dx/src/junit/framework/Test.java | 17 - dx/src/junit/framework/TestCase.java | 197 -- dx/src/junit/framework/TestFailure.java | 57 - dx/src/junit/framework/TestListener.java | 23 - dx/src/junit/framework/TestResult.java | 166 -- dx/src/junit/framework/TestSuite.java | 265 --- dx/src/junit/runner/BaseTestRunner.java | 323 --- dx/src/junit/runner/ClassPathTestCollector.java | 80 - dx/src/junit/runner/FailureDetailView.java | 23 - dx/src/junit/runner/LoadingTestCollector.java | 69 - dx/src/junit/runner/ReloadingTestSuiteLoader.java | 19 - dx/src/junit/runner/SimpleTestCollector.java | 20 - dx/src/junit/runner/Sorter.java | 38 - dx/src/junit/runner/StandardTestSuiteLoader.java | 19 - dx/src/junit/runner/TestCaseClassLoader.java | 226 --- dx/src/junit/runner/TestCollector.java | 16 - dx/src/junit/runner/TestRunListener.java | 19 - dx/src/junit/runner/TestSuiteLoader.java | 9 - dx/src/junit/runner/Version.java | 14 - dx/src/junit/runner/excluded.properties | 12 - dx/src/junit/runner/logo.gif | Bin 964 -> 0 bytes dx/src/junit/runner/smalllogo.gif | Bin 883 -> 0 bytes dx/src/junit/textui/ResultPrinter.java | 139 -- dx/src/junit/textui/TestRunner.java | 189 -- dx/tests/001-nop/expected.txt | 1 - dx/tests/001-nop/info.txt | 2 - dx/tests/001-nop/run | 17 - dx/tests/002-minimal-valid/expected.txt | 46 - dx/tests/002-minimal-valid/info.txt | 1 - dx/tests/002-minimal-valid/run | 17 - dx/tests/002-minimal-valid/small-class.txt | 49 - .../003-magic-version-access/class-bad-magic.txt | 25 - .../class-version-44.0.txt | 25 - .../class-version-44.65535.txt | 25 - .../class-version-45.0.txt | 25 - .../class-version-45.65535.txt | 25 - .../class-version-48.0.txt | 25 - .../class-version-48.65535.txt | 25 - .../class-version-49.0.txt | 25 - .../class-version-49.1.txt | 26 - .../class-version-49.65535.txt | 26 - .../class-version-50.0.txt | 26 - .../class-version-50.1.txt | 26 - .../class-version-50.65535.txt | 26 - .../class-version-51.0.txt | 26 - dx/tests/003-magic-version-access/expected.txt | 243 --- dx/tests/003-magic-version-access/info.txt | 9 - dx/tests/003-magic-version-access/run | 46 - dx/tests/003-magic-version-access/small-class.txt | 25 - dx/tests/004-cp-bottom-up/expected.txt | 34 - dx/tests/004-cp-bottom-up/info.txt | 8 - dx/tests/004-cp-bottom-up/run | 17 - dx/tests/004-cp-bottom-up/small-class.txt | 38 - dx/tests/005-cp-top-down/expected.txt | 34 - dx/tests/005-cp-top-down/info.txt | 8 - dx/tests/005-cp-top-down/run | 17 - dx/tests/005-cp-top-down/small-class.txt | 38 - dx/tests/006-interfaces/expected.txt | 31 - dx/tests/006-interfaces/info.txt | 6 - dx/tests/006-interfaces/run | 17 - dx/tests/006-interfaces/small-class.txt | 33 - dx/tests/007-no-superclass/expected.txt | 19 - dx/tests/007-no-superclass/info.txt | 6 - dx/tests/007-no-superclass/run | 17 - dx/tests/007-no-superclass/small-class.txt | 24 - dx/tests/008-field/expected.txt | 30 - dx/tests/008-field/info.txt | 7 - dx/tests/008-field/run | 17 - dx/tests/008-field/small-class.txt | 34 - dx/tests/009-method/expected.txt | 30 - dx/tests/009-method/info.txt | 7 - dx/tests/009-method/run | 17 - dx/tests/009-method/small-class.txt | 34 - .../010-class-attrib-InnerClasses/expected.txt | 46 - dx/tests/010-class-attrib-InnerClasses/info.txt | 7 - dx/tests/010-class-attrib-InnerClasses/run | 17 - .../010-class-attrib-InnerClasses/small-class.txt | 38 - dx/tests/011-class-attrib-Synthetic/expected.txt | 27 - dx/tests/011-class-attrib-Synthetic/info.txt | 6 - dx/tests/011-class-attrib-Synthetic/run | 17 - .../011-class-attrib-Synthetic/small-class.txt | 30 - dx/tests/012-class-attrib-SourceFile/expected.txt | 29 - dx/tests/012-class-attrib-SourceFile/info.txt | 6 - dx/tests/012-class-attrib-SourceFile/run | 17 - .../012-class-attrib-SourceFile/small-class.txt | 32 - dx/tests/013-class-attrib-Deprecated/expected.txt | 27 - dx/tests/013-class-attrib-Deprecated/info.txt | 6 - dx/tests/013-class-attrib-Deprecated/run | 17 - .../013-class-attrib-Deprecated/small-class.txt | 30 - .../014-field-attrib-ConstantValue/expected.txt | 162 -- dx/tests/014-field-attrib-ConstantValue/info.txt | 7 - dx/tests/014-field-attrib-ConstantValue/run | 17 - .../014-field-attrib-ConstantValue/small-class.txt | 140 -- dx/tests/015-field-attrib-Synthetic/expected.txt | 36 - dx/tests/015-field-attrib-Synthetic/info.txt | 6 - dx/tests/015-field-attrib-Synthetic/run | 17 - .../015-field-attrib-Synthetic/small-class.txt | 38 - dx/tests/016-field-attrib-Deprecated/expected.txt | 36 - dx/tests/016-field-attrib-Deprecated/info.txt | 6 - dx/tests/016-field-attrib-Deprecated/run | 17 - .../016-field-attrib-Deprecated/small-class.txt | 38 - dx/tests/017-method-attrib-Code/expected.txt | 42 - dx/tests/017-method-attrib-Code/info.txt | 6 - dx/tests/017-method-attrib-Code/run | 17 - dx/tests/017-method-attrib-Code/small-class.txt | 43 - dx/tests/018-method-attrib-Exceptions/expected.txt | 40 - dx/tests/018-method-attrib-Exceptions/info.txt | 6 - dx/tests/018-method-attrib-Exceptions/run | 17 - .../018-method-attrib-Exceptions/small-class.txt | 41 - dx/tests/019-method-attrib-Synthetic/expected.txt | 36 - dx/tests/019-method-attrib-Synthetic/info.txt | 6 - dx/tests/019-method-attrib-Synthetic/run | 17 - .../019-method-attrib-Synthetic/small-class.txt | 37 - dx/tests/020-method-attrib-Deprecated/expected.txt | 36 - dx/tests/020-method-attrib-Deprecated/info.txt | 6 - dx/tests/020-method-attrib-Deprecated/run | 17 - .../020-method-attrib-Deprecated/small-class.txt | 37 - .../021-code-attrib-LineNumberTable/expected.txt | 52 - dx/tests/021-code-attrib-LineNumberTable/info.txt | 8 - dx/tests/021-code-attrib-LineNumberTable/run | 17 - .../small-class.txt | 51 - .../expected.txt | 57 - .../022-code-attrib-LocalVariableTable/info.txt | 8 - dx/tests/022-code-attrib-LocalVariableTable/run | 17 - .../small-class.txt | 56 - dx/tests/023-code-exception-table/expected.txt | 51 - dx/tests/023-code-exception-table/info.txt | 8 - dx/tests/023-code-exception-table/run | 17 - dx/tests/023-code-exception-table/small-class.txt | 52 - dx/tests/024-code-bytecode/expected.txt | 294 --- dx/tests/024-code-bytecode/info.txt | 7 - dx/tests/024-code-bytecode/run | 17 - dx/tests/024-code-bytecode/small-class.txt | 304 --- dx/tests/025-class-attrib-Signature/expected.txt | 29 - dx/tests/025-class-attrib-Signature/info.txt | 6 - dx/tests/025-class-attrib-Signature/run | 17 - .../025-class-attrib-Signature/small-class.txt | 32 - dx/tests/026-field-attrib-Signature/expected.txt | 38 - dx/tests/026-field-attrib-Signature/info.txt | 6 - dx/tests/026-field-attrib-Signature/run | 17 - .../026-field-attrib-Signature/small-class.txt | 40 - dx/tests/027-method-attrib-Signature/expected.txt | 38 - dx/tests/027-method-attrib-Signature/info.txt | 6 - dx/tests/027-method-attrib-Signature/run | 17 - .../027-method-attrib-Signature/small-class.txt | 39 - .../028-class-attrib-EnclosingMethod/expected.txt | 61 - dx/tests/028-class-attrib-EnclosingMethod/info.txt | 9 - dx/tests/028-class-attrib-EnclosingMethod/run | 17 - .../small-class-1.txt | 32 - .../small-class-2.txt | 35 - dx/tests/029-unit-Bits/expected.txt | 1 - dx/tests/029-unit-Bits/info.txt | 1 - dx/tests/029-unit-Bits/run | 23 - dx/tests/030-minimal-jasmin/blort.j | 28 - dx/tests/030-minimal-jasmin/expected.txt | 7 - dx/tests/030-minimal-jasmin/info.txt | 2 - dx/tests/030-minimal-jasmin/run | 18 - dx/tests/031-bb-dead-code/blort.j | 183 -- dx/tests/031-bb-dead-code/expected.txt | 190 -- dx/tests/031-bb-dead-code/info.txt | 3 - dx/tests/031-bb-dead-code/run | 18 - dx/tests/032-bb-live-code/blort.j | 343 ---- dx/tests/032-bb-live-code/expected.txt | 497 ----- dx/tests/032-bb-live-code/info.txt | 5 - dx/tests/032-bb-live-code/run | 18 - dx/tests/033-unit-IntList/expected.txt | 1 - dx/tests/033-unit-IntList/info.txt | 1 - dx/tests/033-unit-IntList/run | 23 - dx/tests/034-dex-minimal/blort.j | 16 - dx/tests/034-dex-minimal/expected.txt | 70 - dx/tests/034-dex-minimal/info.txt | 9 - dx/tests/034-dex-minimal/run | 24 - dx/tests/035-dex-instance-var/blort.j | 18 - dx/tests/035-dex-instance-var/expected.txt | 1 - dx/tests/035-dex-instance-var/info.txt | 4 - dx/tests/035-dex-instance-var/run | 21 - dx/tests/036-dex-static-var/blort.j | 18 - dx/tests/036-dex-static-var/expected.txt | 1 - dx/tests/036-dex-static-var/info.txt | 4 - dx/tests/036-dex-static-var/run | 21 - dx/tests/037-dex-static-final-var/blort.j | 18 - dx/tests/037-dex-static-final-var/expected.txt | 1 - dx/tests/037-dex-static-final-var/info.txt | 4 - dx/tests/037-dex-static-final-var/run | 21 - dx/tests/038-dex-instance-method/blort.j | 21 - dx/tests/038-dex-instance-method/expected.txt | 1 - dx/tests/038-dex-instance-method/info.txt | 5 - dx/tests/038-dex-instance-method/run | 21 - dx/tests/039-dex-static-method/blort.j | 21 - dx/tests/039-dex-static-method/expected.txt | 1 - dx/tests/039-dex-static-method/info.txt | 4 - dx/tests/039-dex-static-method/run | 21 - dx/tests/040-dex-constructor/blort.j | 21 - dx/tests/040-dex-constructor/expected.txt | 1 - dx/tests/040-dex-constructor/info.txt | 4 - dx/tests/040-dex-constructor/run | 21 - dx/tests/041-dex-abstract-method/blort.j | 19 - dx/tests/041-dex-abstract-method/expected.txt | 1 - dx/tests/041-dex-abstract-method/info.txt | 4 - dx/tests/041-dex-abstract-method/run | 21 - dx/tests/042-dex-ignore-result/Blort.java | 27 - dx/tests/042-dex-ignore-result/expected.txt | 1 - dx/tests/042-dex-ignore-result/info.txt | 5 - dx/tests/042-dex-ignore-result/run | 21 - dx/tests/043-dex-two-classes/Blort.java | 20 - dx/tests/043-dex-two-classes/Zorch.java | 20 - dx/tests/043-dex-two-classes/expected.txt | 3 - dx/tests/043-dex-two-classes/info.txt | 4 - dx/tests/043-dex-two-classes/run | 21 - dx/tests/044-dex-math-ops/Blort.java | 73 - dx/tests/044-dex-math-ops/expected.txt | 213 -- dx/tests/044-dex-math-ops/info.txt | 6 - dx/tests/044-dex-math-ops/run | 19 - dx/tests/045-dex-switch-ops/Blort.java | 56 - dx/tests/045-dex-switch-ops/expected.txt | 53 - dx/tests/045-dex-switch-ops/info.txt | 6 - dx/tests/045-dex-switch-ops/run | 19 - dx/tests/046-dex-exceptions/Blort.java | 58 - dx/tests/046-dex-exceptions/expected.txt | 48 - dx/tests/046-dex-exceptions/info.txt | 6 - dx/tests/046-dex-exceptions/run | 18 - dx/tests/047-dex-wide-args/Blort.java | 26 - dx/tests/047-dex-wide-args/expected.txt | 34 - dx/tests/047-dex-wide-args/info.txt | 6 - dx/tests/047-dex-wide-args/run | 19 - dx/tests/048-dex-new-array/Blort.java | 34 - dx/tests/048-dex-new-array/expected.txt | 29 - dx/tests/048-dex-new-array/info.txt | 6 - dx/tests/048-dex-new-array/run | 18 - dx/tests/049-dex-instanceof/Blort.java | 22 - dx/tests/049-dex-instanceof/expected.txt | 7 - dx/tests/049-dex-instanceof/info.txt | 6 - dx/tests/049-dex-instanceof/run | 19 - dx/tests/050-dex-checkcast/Blort.java | 22 - dx/tests/050-dex-checkcast/expected.txt | 7 - dx/tests/050-dex-checkcast/info.txt | 6 - dx/tests/050-dex-checkcast/run | 19 - dx/tests/051-dex-explicit-null/Blort.java | 26 - dx/tests/051-dex-explicit-null/expected.txt | 10 - dx/tests/051-dex-explicit-null/info.txt | 7 - dx/tests/051-dex-explicit-null/run | 19 - dx/tests/052-dex-static-var-access/Blort.java | 51 - dx/tests/052-dex-static-var-access/expected.txt | 59 - dx/tests/052-dex-static-var-access/info.txt | 6 - dx/tests/052-dex-static-var-access/run | 19 - dx/tests/053-dex-instance-var-access/Blort.java | 51 - dx/tests/053-dex-instance-var-access/expected.txt | 79 - dx/tests/053-dex-instance-var-access/info.txt | 6 - dx/tests/053-dex-instance-var-access/run | 19 - dx/tests/054-dex-high16/Blort.java | 74 - dx/tests/054-dex-high16/expected.txt | 68 - dx/tests/054-dex-high16/info.txt | 6 - dx/tests/054-dex-high16/run | 19 - dx/tests/055-dex-explicit-throw/Blort.java | 32 - dx/tests/055-dex-explicit-throw/expected.txt | 17 - dx/tests/055-dex-explicit-throw/info.txt | 6 - dx/tests/055-dex-explicit-throw/run | 19 - dx/tests/056-dex-call-interface/Blort.java | 26 - dx/tests/056-dex-call-interface/Zorch.java | 23 - dx/tests/056-dex-call-interface/expected.txt | 24 - dx/tests/056-dex-call-interface/info.txt | 6 - dx/tests/056-dex-call-interface/run | 19 - dx/tests/057-dex-call-virtual/Blort.java | 23 - dx/tests/057-dex-call-virtual/Zorch.java | 26 - dx/tests/057-dex-call-virtual/expected.txt | 11 - dx/tests/057-dex-call-virtual/info.txt | 6 - dx/tests/057-dex-call-virtual/run | 19 - dx/tests/058-dex-call-direct/Blort.java | 31 - dx/tests/058-dex-call-direct/expected.txt | 11 - dx/tests/058-dex-call-direct/info.txt | 6 - dx/tests/058-dex-call-direct/run | 19 - dx/tests/059-dex-call-super/Blort.java | 28 - dx/tests/059-dex-call-super/Zorch.java | 30 - dx/tests/059-dex-call-super/expected.txt | 17 - dx/tests/059-dex-call-super/info.txt | 6 - dx/tests/059-dex-call-super/run | 19 - dx/tests/060-dex-call-static/Blort.java | 23 - dx/tests/060-dex-call-static/Zorch.java | 26 - dx/tests/060-dex-call-static/expected.txt | 7 - dx/tests/060-dex-call-static/info.txt | 6 - dx/tests/060-dex-call-static/run | 19 - dx/tests/061-dex-try-catch/Blort.java | 66 - dx/tests/061-dex-try-catch/expected.txt | 49 - dx/tests/061-dex-try-catch/info.txt | 6 - dx/tests/061-dex-try-catch/run | 19 - dx/tests/062-dex-synch-method/Blort.java | 66 - dx/tests/062-dex-synch-method/expected.txt | 116 -- dx/tests/062-dex-synch-method/info.txt | 6 - dx/tests/062-dex-synch-method/run | 19 - dx/tests/063-dex-empty-switch/Blort.java | 32 - dx/tests/063-dex-empty-switch/expected.txt | 18 - dx/tests/063-dex-empty-switch/info.txt | 7 - dx/tests/063-dex-empty-switch/run | 19 - dx/tests/064-dex-array-access/Blort.java | 74 - dx/tests/064-dex-array-access/expected.txt | 157 -- dx/tests/064-dex-array-access/info.txt | 6 - dx/tests/064-dex-array-access/run | 19 - dx/tests/065-dex-new-array/Blort.java | 54 - dx/tests/065-dex-new-array/expected.txt | 63 - dx/tests/065-dex-new-array/info.txt | 6 - dx/tests/065-dex-new-array/run | 19 - dx/tests/066-dex-try-catch-rethrow/Blort.java | 78 - dx/tests/066-dex-try-catch-rethrow/expected.txt | 95 - dx/tests/066-dex-try-catch-rethrow/info.txt | 6 - dx/tests/066-dex-try-catch-rethrow/run | 19 - dx/tests/067-dex-switch-and-try/Blort.java | 114 -- dx/tests/067-dex-switch-and-try/expected.txt | 100 - dx/tests/067-dex-switch-and-try/info.txt | 7 - dx/tests/067-dex-switch-and-try/run | 19 - dx/tests/068-dex-infinite-loop/Blort.java | 52 - dx/tests/068-dex-infinite-loop/expected.txt | 28 - dx/tests/068-dex-infinite-loop/info.txt | 6 - dx/tests/068-dex-infinite-loop/run | 19 - dx/tests/069-dex-source-position/Blort.java | 32 - dx/tests/069-dex-source-position/expected.txt | 134 -- dx/tests/069-dex-source-position/info.txt | 6 - dx/tests/069-dex-source-position/run | 23 - dx/tests/070-dex-multianewarray/Blort.java | 98 - dx/tests/070-dex-multianewarray/expected.txt | 246 --- dx/tests/070-dex-multianewarray/info.txt | 6 - dx/tests/070-dex-multianewarray/run | 19 - dx/tests/071-dex-java-stack-ops/blort.j | 319 --- dx/tests/071-dex-java-stack-ops/expected.txt | 210 -- dx/tests/071-dex-java-stack-ops/info.txt | 7 - dx/tests/071-dex-java-stack-ops/run | 19 - dx/tests/072-dex-switch-edge-cases/Blort.java | 97 - dx/tests/072-dex-switch-edge-cases/expected.txt | 126 -- dx/tests/072-dex-switch-edge-cases/info.txt | 6 - dx/tests/072-dex-switch-edge-cases/run | 19 - dx/tests/073-dex-null-array-refs/Blort.java | 73 - dx/tests/073-dex-null-array-refs/expected.txt | 85 - dx/tests/073-dex-null-array-refs/info.txt | 7 - dx/tests/073-dex-null-array-refs/run | 19 - dx/tests/074-dex-form35c-edge-case/Blort.java | 41 - dx/tests/074-dex-form35c-edge-case/expected.txt | 33 - dx/tests/074-dex-form35c-edge-case/info.txt | 8 - dx/tests/074-dex-form35c-edge-case/run | 19 - dx/tests/075-dex-cat2-value-merge/Blort.java | 27 - dx/tests/075-dex-cat2-value-merge/expected.txt | 12 - dx/tests/075-dex-cat2-value-merge/info.txt | 7 - dx/tests/075-dex-cat2-value-merge/run | 19 - dx/tests/076-dex-synch-and-stack/Blort.java | 22 - dx/tests/076-dex-synch-and-stack/expected.txt | 19 - dx/tests/076-dex-synch-and-stack/info.txt | 7 - dx/tests/076-dex-synch-and-stack/run | 19 - dx/tests/077-dex-code-alignment/Blort.java | 26 - dx/tests/077-dex-code-alignment/expected.txt | 0 dx/tests/077-dex-code-alignment/info.txt | 6 - dx/tests/077-dex-code-alignment/run | 30 - dx/tests/078-dex-local-variable-table/Blort.java | 112 -- dx/tests/078-dex-local-variable-table/expected.txt | 314 --- dx/tests/078-dex-local-variable-table/info.txt | 6 - dx/tests/078-dex-local-variable-table/run | 19 - .../079-dex-local-variable-renumbering/Blort.java | 39 - .../expected.txt | 87 - .../079-dex-local-variable-renumbering/info.txt | 7 - dx/tests/079-dex-local-variable-renumbering/run | 19 - dx/tests/080-dex-exception-tables/Blort.java | 199 -- dx/tests/080-dex-exception-tables/expected.txt | 286 --- dx/tests/080-dex-exception-tables/info.txt | 8 - dx/tests/080-dex-exception-tables/run | 19 - dx/tests/081-dex-throws-list/Blort.java | 28 - dx/tests/081-dex-throws-list/expected.txt | 4 - dx/tests/081-dex-throws-list/info.txt | 7 - dx/tests/081-dex-throws-list/run | 19 - dx/tests/082-dex-throws-list-sharing/Blort.java | 38 - dx/tests/082-dex-throws-list-sharing/expected.txt | 2 - dx/tests/082-dex-throws-list-sharing/info.txt | 7 - dx/tests/082-dex-throws-list-sharing/run | 20 - dx/tests/083-ssa-phi-placement/Blort.java | 67 - dx/tests/083-ssa-phi-placement/expected.txt | 345 ---- dx/tests/083-ssa-phi-placement/info.txt | 5 - dx/tests/083-ssa-phi-placement/run | 18 - dx/tests/084-dex-high-register-moves/Blort.java | 49 - dx/tests/084-dex-high-register-moves/expected.txt | 60 - dx/tests/084-dex-high-register-moves/info.txt | 7 - dx/tests/084-dex-high-register-moves/run | 19 - dx/tests/085-dex-jsr-ret/blort.j | 71 - dx/tests/085-dex-jsr-ret/expected.txt | 171 -- dx/tests/085-dex-jsr-ret/info.txt | 2 - dx/tests/085-dex-jsr-ret/run | 18 - dx/tests/086-ssa-edge-split/Blort.java | 75 - dx/tests/086-ssa-edge-split/expected.txt | 343 ---- dx/tests/086-ssa-edge-split/info.txt | 5 - dx/tests/086-ssa-edge-split/run | 18 - dx/tests/087-ssa-local-vars/Blort.java | 95 - dx/tests/087-ssa-local-vars/expected.txt | 1266 ------------ dx/tests/087-ssa-local-vars/info.txt | 5 - dx/tests/087-ssa-local-vars/run | 18 - dx/tests/088-ssa-combine-blocks/Blort.java | 45 - dx/tests/088-ssa-combine-blocks/expected.txt | 82 - dx/tests/088-ssa-combine-blocks/info.txt | 5 - dx/tests/088-ssa-combine-blocks/run | 18 - dx/tests/089-dex-define-object/Class.java | 21 - dx/tests/089-dex-define-object/Object.java | 50 - dx/tests/089-dex-define-object/String.java | 21 - dx/tests/089-dex-define-object/expected.txt | 1 - dx/tests/089-dex-define-object/info.txt | 4 - dx/tests/089-dex-define-object/run | 21 - dx/tests/090-dex-unify-arrays/Blort.java | 60 - dx/tests/090-dex-unify-arrays/expected.txt | 122 -- dx/tests/090-dex-unify-arrays/info.txt | 6 - dx/tests/090-dex-unify-arrays/run | 19 - dx/tests/091-ssa-const-collector/Blort.java | 65 - dx/tests/091-ssa-const-collector/expected.txt | 475 ----- dx/tests/091-ssa-const-collector/info.txt | 5 - dx/tests/091-ssa-const-collector/run | 18 - dx/tests/092-ssa-cfg-edge-cases/Blort.java | 21 - dx/tests/092-ssa-cfg-edge-cases/expected.txt | 120 -- dx/tests/092-ssa-cfg-edge-cases/info.txt | 5 - dx/tests/092-ssa-cfg-edge-cases/run | 18 - dx/tests/093-ssa-invoke-range/Blort.java | 70 - dx/tests/093-ssa-invoke-range/expected.txt | 301 --- dx/tests/093-ssa-invoke-range/info.txt | 6 - dx/tests/093-ssa-invoke-range/run | 18 - dx/tests/094-scala-locals/blort.j | 45 - dx/tests/094-scala-locals/expected.txt | 85 - dx/tests/094-scala-locals/info.txt | 8 - dx/tests/094-scala-locals/run | 18 - dx/tests/095-dex-const-string-jumbo/Blort.java | 25 - dx/tests/095-dex-const-string-jumbo/expected.txt | 6 - dx/tests/095-dex-const-string-jumbo/info.txt | 6 - dx/tests/095-dex-const-string-jumbo/run | 42 - dx/tests/096-dex-giant-catch/Blort.java | 22 - dx/tests/096-dex-giant-catch/expected.txt | 5 - dx/tests/096-dex-giant-catch/info.txt | 7 - dx/tests/096-dex-giant-catch/run | 40 - dx/tests/097-dex-branch-offset-zero/Blort.java | 30 - dx/tests/097-dex-branch-offset-zero/expected.txt | 1 - dx/tests/097-dex-branch-offset-zero/info.txt | 6 - dx/tests/097-dex-branch-offset-zero/run | 27 - .../ViewDebug$ViewServer.class | Bin 5381 -> 0 bytes dx/tests/098-dex-jsr-ret-throw/expected.txt | 652 ------ dx/tests/098-dex-jsr-ret-throw/info.txt | 5 - dx/tests/098-dex-jsr-ret-throw/run | 17 - dx/tests/099-dex-core-library-error/Blort.java | 5 - dx/tests/099-dex-core-library-error/Muffins.java | 5 - dx/tests/099-dex-core-library-error/Zorch.java | 5 - dx/tests/099-dex-core-library-error/expected.txt | 5 - dx/tests/099-dex-core-library-error/info.txt | 3 - dx/tests/099-dex-core-library-error/run | 37 - dx/tests/100-local-mismatch/blort1.j | 28 - dx/tests/100-local-mismatch/blort2.j | 28 - dx/tests/100-local-mismatch/blort3.j | 28 - dx/tests/100-local-mismatch/blort4.j | 28 - dx/tests/100-local-mismatch/expected.txt | 9 - dx/tests/100-local-mismatch/info.txt | 3 - dx/tests/100-local-mismatch/run | 34 - dx/tests/101-verify-wide-math/expected.txt | 54 - dx/tests/101-verify-wide-math/info.txt | 3 - dx/tests/101-verify-wide-math/op_d2f.j | 25 - dx/tests/101-verify-wide-math/op_d2i.j | 25 - dx/tests/101-verify-wide-math/op_d2l.j | 25 - dx/tests/101-verify-wide-math/op_dadd.j | 26 - dx/tests/101-verify-wide-math/op_dcmpg.j | 26 - dx/tests/101-verify-wide-math/op_dcmpl.j | 26 - dx/tests/101-verify-wide-math/op_ddiv.j | 26 - dx/tests/101-verify-wide-math/op_dmul.j | 26 - dx/tests/101-verify-wide-math/op_dneg.j | 25 - dx/tests/101-verify-wide-math/op_drem.j | 26 - dx/tests/101-verify-wide-math/op_dsub.j | 26 - dx/tests/101-verify-wide-math/op_l2d.j | 25 - dx/tests/101-verify-wide-math/op_l2f.j | 25 - dx/tests/101-verify-wide-math/op_l2i.j | 25 - dx/tests/101-verify-wide-math/op_ladd.j | 26 - dx/tests/101-verify-wide-math/op_land.j | 26 - dx/tests/101-verify-wide-math/op_lcmp.j | 26 - dx/tests/101-verify-wide-math/op_ldiv.j | 26 - dx/tests/101-verify-wide-math/op_lmul.j | 26 - dx/tests/101-verify-wide-math/op_lneg.j | 25 - dx/tests/101-verify-wide-math/op_lor.j | 26 - dx/tests/101-verify-wide-math/op_lrem.j | 26 - dx/tests/101-verify-wide-math/op_lshl.j | 26 - dx/tests/101-verify-wide-math/op_lshr.j | 26 - dx/tests/101-verify-wide-math/op_lsub.j | 26 - dx/tests/101-verify-wide-math/op_lushr.j | 26 - dx/tests/101-verify-wide-math/op_lxor.j | 26 - dx/tests/101-verify-wide-math/run | 54 - dx/tests/102-verify-nonwide-math/expected.txt | 48 - dx/tests/102-verify-nonwide-math/info.txt | 3 - dx/tests/102-verify-nonwide-math/op_f2d.j | 25 - dx/tests/102-verify-nonwide-math/op_f2i.j | 25 - dx/tests/102-verify-nonwide-math/op_f2l.j | 25 - dx/tests/102-verify-nonwide-math/op_fadd.j | 26 - dx/tests/102-verify-nonwide-math/op_fdiv.j | 26 - dx/tests/102-verify-nonwide-math/op_fmul.j | 26 - dx/tests/102-verify-nonwide-math/op_fneg.j | 25 - dx/tests/102-verify-nonwide-math/op_frem.j | 26 - dx/tests/102-verify-nonwide-math/op_fsub.j | 26 - dx/tests/102-verify-nonwide-math/op_i2d.j | 25 - dx/tests/102-verify-nonwide-math/op_i2f.j | 25 - dx/tests/102-verify-nonwide-math/op_i2l.j | 25 - dx/tests/102-verify-nonwide-math/op_iadd.j | 26 - dx/tests/102-verify-nonwide-math/op_iand.j | 26 - dx/tests/102-verify-nonwide-math/op_idiv.j | 26 - dx/tests/102-verify-nonwide-math/op_imul.j | 26 - dx/tests/102-verify-nonwide-math/op_ineg.j | 25 - dx/tests/102-verify-nonwide-math/op_ior.j | 26 - dx/tests/102-verify-nonwide-math/op_irem.j | 26 - dx/tests/102-verify-nonwide-math/op_ishl.j | 26 - dx/tests/102-verify-nonwide-math/op_ishr.j | 26 - dx/tests/102-verify-nonwide-math/op_isub.j | 26 - dx/tests/102-verify-nonwide-math/op_iushr.j | 26 - dx/tests/102-verify-nonwide-math/op_ixor.j | 26 - dx/tests/102-verify-nonwide-math/run | 51 - dx/tests/103-verify-branch-ops/expected.txt | 36 - dx/tests/103-verify-branch-ops/info.txt | 2 - dx/tests/103-verify-branch-ops/op_if_acmpeq.j | 28 - dx/tests/103-verify-branch-ops/op_if_acmpne.j | 28 - dx/tests/103-verify-branch-ops/op_if_icmpeq.j | 28 - dx/tests/103-verify-branch-ops/op_if_icmpge.j | 28 - dx/tests/103-verify-branch-ops/op_if_icmpgt.j | 28 - dx/tests/103-verify-branch-ops/op_if_icmple.j | 28 - dx/tests/103-verify-branch-ops/op_if_icmplt.j | 28 - dx/tests/103-verify-branch-ops/op_if_icmpne.j | 28 - dx/tests/103-verify-branch-ops/op_ifeq.j | 27 - dx/tests/103-verify-branch-ops/op_ifge.j | 27 - dx/tests/103-verify-branch-ops/op_ifgt.j | 27 - dx/tests/103-verify-branch-ops/op_ifle.j | 27 - dx/tests/103-verify-branch-ops/op_iflt.j | 27 - dx/tests/103-verify-branch-ops/op_ifne.j | 27 - dx/tests/103-verify-branch-ops/op_ifnonnull.j | 27 - dx/tests/103-verify-branch-ops/op_ifnull.j | 27 - dx/tests/103-verify-branch-ops/op_lookupswitch.j | 33 - dx/tests/103-verify-branch-ops/op_tableswitch.j | 33 - dx/tests/103-verify-branch-ops/run | 45 - dx/tests/104-verify-return-ops/expected.txt | 22 - dx/tests/104-verify-return-ops/info.txt | 2 - dx/tests/104-verify-return-ops/op_areturn.j | 24 - dx/tests/104-verify-return-ops/op_dreturn.j | 24 - dx/tests/104-verify-return-ops/op_freturn.j | 24 - dx/tests/104-verify-return-ops/op_ireturn.j | 24 - dx/tests/104-verify-return-ops/op_lreturn.j | 24 - dx/tests/104-verify-return-ops/op_sig_areturn.j | 24 - dx/tests/104-verify-return-ops/op_sig_dreturn.j | 24 - dx/tests/104-verify-return-ops/op_sig_freturn.j | 24 - dx/tests/104-verify-return-ops/op_sig_ireturn.j | 24 - dx/tests/104-verify-return-ops/op_sig_lreturn.j | 24 - dx/tests/104-verify-return-ops/op_sig_return.j | 23 - dx/tests/104-verify-return-ops/run | 39 - dx/tests/105-verify-load-store-ops/expected.txt | 82 - dx/tests/105-verify-load-store-ops/info.txt | 3 - dx/tests/105-verify-load-store-ops/op_aaload.j | 26 - dx/tests/105-verify-load-store-ops/op_aastore.j | 27 - dx/tests/105-verify-load-store-ops/op_astore.j | 25 - dx/tests/105-verify-load-store-ops/op_astore_0.j | 25 - dx/tests/105-verify-load-store-ops/op_astore_1.j | 25 - dx/tests/105-verify-load-store-ops/op_astore_2.j | 25 - dx/tests/105-verify-load-store-ops/op_astore_3.j | 25 - dx/tests/105-verify-load-store-ops/op_baload.j | 26 - dx/tests/105-verify-load-store-ops/op_bastore.j | 27 - dx/tests/105-verify-load-store-ops/op_caload.j | 26 - dx/tests/105-verify-load-store-ops/op_castore.j | 27 - dx/tests/105-verify-load-store-ops/op_daload.j | 26 - dx/tests/105-verify-load-store-ops/op_dastore.j | 27 - dx/tests/105-verify-load-store-ops/op_dstore.j | 25 - dx/tests/105-verify-load-store-ops/op_dstore_0.j | 25 - dx/tests/105-verify-load-store-ops/op_dstore_1.j | 25 - dx/tests/105-verify-load-store-ops/op_dstore_2.j | 25 - dx/tests/105-verify-load-store-ops/op_dstore_3.j | 25 - dx/tests/105-verify-load-store-ops/op_faload.j | 26 - dx/tests/105-verify-load-store-ops/op_fastore.j | 27 - dx/tests/105-verify-load-store-ops/op_fstore.j | 25 - dx/tests/105-verify-load-store-ops/op_fstore_0.j | 25 - dx/tests/105-verify-load-store-ops/op_fstore_1.j | 25 - dx/tests/105-verify-load-store-ops/op_fstore_2.j | 25 - dx/tests/105-verify-load-store-ops/op_fstore_3.j | 25 - dx/tests/105-verify-load-store-ops/op_iaload.j | 26 - dx/tests/105-verify-load-store-ops/op_iastore.j | 27 - dx/tests/105-verify-load-store-ops/op_istore.j | 25 - dx/tests/105-verify-load-store-ops/op_istore_0.j | 25 - dx/tests/105-verify-load-store-ops/op_istore_1.j | 25 - dx/tests/105-verify-load-store-ops/op_istore_2.j | 25 - dx/tests/105-verify-load-store-ops/op_istore_3.j | 25 - dx/tests/105-verify-load-store-ops/op_laload.j | 26 - dx/tests/105-verify-load-store-ops/op_lastore.j | 27 - dx/tests/105-verify-load-store-ops/op_lstore.j | 25 - dx/tests/105-verify-load-store-ops/op_lstore_0.j | 25 - dx/tests/105-verify-load-store-ops/op_lstore_1.j | 25 - dx/tests/105-verify-load-store-ops/op_lstore_2.j | 25 - dx/tests/105-verify-load-store-ops/op_lstore_3.j | 25 - dx/tests/105-verify-load-store-ops/op_saload.j | 26 - dx/tests/105-verify-load-store-ops/op_sastore.j | 27 - dx/tests/105-verify-load-store-ops/run | 68 - dx/tests/106-verify-object-ops/expected.txt | 32 - dx/tests/106-verify-object-ops/info.txt | 2 - dx/tests/106-verify-object-ops/op_anewarray.j | 25 - dx/tests/106-verify-object-ops/op_arraylength.j | 25 - dx/tests/106-verify-object-ops/op_athrow.j | 25 - dx/tests/106-verify-object-ops/op_checkcast.j | 25 - dx/tests/106-verify-object-ops/op_getfield.j | 25 - dx/tests/106-verify-object-ops/op_instanceof.j | 25 - .../106-verify-object-ops/op_invokeinterface.j | 25 - dx/tests/106-verify-object-ops/op_invokespecial.j | 25 - dx/tests/106-verify-object-ops/op_invokestatic.j | 25 - dx/tests/106-verify-object-ops/op_invokevirtual.j | 25 - dx/tests/106-verify-object-ops/op_monitorenter.j | 25 - dx/tests/106-verify-object-ops/op_monitorexit.j | 25 - dx/tests/106-verify-object-ops/op_multianewarray.j | 26 - dx/tests/106-verify-object-ops/op_newarray.j | 25 - dx/tests/106-verify-object-ops/op_putfield.j | 26 - dx/tests/106-verify-object-ops/op_putstatic.j | 25 - dx/tests/106-verify-object-ops/run | 43 - dx/tests/107-verify-stack-ops/expected.txt | 34 - dx/tests/107-verify-stack-ops/info.txt | 2 - dx/tests/107-verify-stack-ops/op_dup.j | 25 - dx/tests/107-verify-stack-ops/op_dup2.j | 26 - dx/tests/107-verify-stack-ops/op_dup2_case1.j | 26 - dx/tests/107-verify-stack-ops/op_dup2_x1_case1.j | 27 - dx/tests/107-verify-stack-ops/op_dup2_x1_case2.j | 27 - dx/tests/107-verify-stack-ops/op_dup2_x1_case3.j | 27 - dx/tests/107-verify-stack-ops/op_dup2_x2_case1.j | 28 - dx/tests/107-verify-stack-ops/op_dup2_x2_case2.j | 28 - dx/tests/107-verify-stack-ops/op_dup2_x2_case3.j | 27 - dx/tests/107-verify-stack-ops/op_dup_x1_case1.j | 26 - dx/tests/107-verify-stack-ops/op_dup_x1_case2.j | 26 - dx/tests/107-verify-stack-ops/op_dup_x2_case1.j | 27 - dx/tests/107-verify-stack-ops/op_dup_x2_case2.j | 27 - dx/tests/107-verify-stack-ops/op_dup_x2_case3.j | 27 - dx/tests/107-verify-stack-ops/op_pop.j | 25 - dx/tests/107-verify-stack-ops/op_pop2.j | 26 - dx/tests/107-verify-stack-ops/op_pop2_case2.j | 26 - dx/tests/107-verify-stack-ops/op_swap_case1.j | 26 - dx/tests/107-verify-stack-ops/op_swap_case2.j | 26 - dx/tests/107-verify-stack-ops/run | 44 - dx/tests/108-string-annotation/Blort.java | 32 - dx/tests/108-string-annotation/Fizmo.java | 19 - dx/tests/108-string-annotation/Frotz.java | 19 - dx/tests/108-string-annotation/expected.txt | 12 - dx/tests/108-string-annotation/info.txt | 6 - dx/tests/108-string-annotation/run | 47 - dx/tests/109-int-branch/blort.j | 99 - dx/tests/109-int-branch/expected.txt | 67 - dx/tests/109-int-branch/info.txt | 6 - dx/tests/109-int-branch/run | 18 - dx/tests/110-dex-preserve-this/Blort.java | 26 - dx/tests/110-dex-preserve-this/expected.txt | 1 - dx/tests/110-dex-preserve-this/info.txt | 10 - dx/tests/110-dex-preserve-this/run | 41 - dx/tests/run-all-tests | 58 - dx/tests/run-test | 149 -- 1001 files changed, 96948 deletions(-) delete mode 100644 dx/.classpath delete mode 100644 dx/.project delete mode 100644 dx/Android.mk delete mode 100644 dx/README.txt delete mode 100644 dx/etc/bytecode.txt delete mode 100644 dx/etc/dx delete mode 100755 dx/etc/dx.bat delete mode 100644 dx/etc/jasmin delete mode 100644 dx/etc/jasmin.jar delete mode 100644 dx/etc/manifest.txt delete mode 100755 dx/etc/opcode-gen delete mode 100755 dx/etc/run-opcode-gen delete mode 100644 dx/src/Android.mk delete mode 100644 dx/src/com/android/dx/Version.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttAnnotationDefault.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttCode.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttConstantValue.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttDeprecated.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttEnclosingMethod.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttExceptions.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttInnerClasses.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttLineNumberTable.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttLocalVariableTable.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttLocalVariableTypeTable.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleAnnotations.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleParameterAnnotations.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleAnnotations.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleParameterAnnotations.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttSignature.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttSourceFile.java delete mode 100644 dx/src/com/android/dx/cf/attrib/AttSynthetic.java delete mode 100644 dx/src/com/android/dx/cf/attrib/BaseAnnotations.java delete mode 100644 dx/src/com/android/dx/cf/attrib/BaseAttribute.java delete mode 100644 dx/src/com/android/dx/cf/attrib/BaseLocalVariables.java delete mode 100644 dx/src/com/android/dx/cf/attrib/BaseParameterAnnotations.java delete mode 100644 dx/src/com/android/dx/cf/attrib/InnerClassList.java delete mode 100644 dx/src/com/android/dx/cf/attrib/RawAttribute.java delete mode 100644 dx/src/com/android/dx/cf/attrib/package.html delete mode 100644 dx/src/com/android/dx/cf/code/BaseMachine.java delete mode 100644 dx/src/com/android/dx/cf/code/BasicBlocker.java delete mode 100644 dx/src/com/android/dx/cf/code/ByteBlock.java delete mode 100644 dx/src/com/android/dx/cf/code/ByteBlockList.java delete mode 100644 dx/src/com/android/dx/cf/code/ByteCatchList.java delete mode 100644 dx/src/com/android/dx/cf/code/ByteOps.java delete mode 100644 dx/src/com/android/dx/cf/code/BytecodeArray.java delete mode 100644 dx/src/com/android/dx/cf/code/ConcreteMethod.java delete mode 100644 dx/src/com/android/dx/cf/code/ExecutionStack.java delete mode 100644 dx/src/com/android/dx/cf/code/Frame.java delete mode 100644 dx/src/com/android/dx/cf/code/LineNumberList.java delete mode 100644 dx/src/com/android/dx/cf/code/LocalVariableList.java delete mode 100644 dx/src/com/android/dx/cf/code/LocalsArray.java delete mode 100644 dx/src/com/android/dx/cf/code/LocalsArraySet.java delete mode 100644 dx/src/com/android/dx/cf/code/Machine.java delete mode 100644 dx/src/com/android/dx/cf/code/Merger.java delete mode 100644 dx/src/com/android/dx/cf/code/OneLocalsArray.java delete mode 100644 dx/src/com/android/dx/cf/code/ReturnAddress.java delete mode 100644 dx/src/com/android/dx/cf/code/Ropper.java delete mode 100644 dx/src/com/android/dx/cf/code/RopperMachine.java delete mode 100644 dx/src/com/android/dx/cf/code/SimException.java delete mode 100644 dx/src/com/android/dx/cf/code/Simulator.java delete mode 100644 dx/src/com/android/dx/cf/code/SwitchList.java delete mode 100644 dx/src/com/android/dx/cf/code/ValueAwareMachine.java delete mode 100644 dx/src/com/android/dx/cf/code/package.html delete mode 100644 dx/src/com/android/dx/cf/cst/ConstantPoolParser.java delete mode 100644 dx/src/com/android/dx/cf/cst/ConstantTags.java delete mode 100644 dx/src/com/android/dx/cf/direct/AnnotationParser.java delete mode 100644 dx/src/com/android/dx/cf/direct/AttributeFactory.java delete mode 100644 dx/src/com/android/dx/cf/direct/AttributeListParser.java delete mode 100644 dx/src/com/android/dx/cf/direct/ClassPathOpener.java delete mode 100644 dx/src/com/android/dx/cf/direct/CodeObserver.java delete mode 100644 dx/src/com/android/dx/cf/direct/DirectClassFile.java delete mode 100644 dx/src/com/android/dx/cf/direct/FieldListParser.java delete mode 100644 dx/src/com/android/dx/cf/direct/MemberListParser.java delete mode 100644 dx/src/com/android/dx/cf/direct/MethodListParser.java delete mode 100644 dx/src/com/android/dx/cf/direct/StdAttributeFactory.java delete mode 100644 dx/src/com/android/dx/cf/direct/package.html delete mode 100644 dx/src/com/android/dx/cf/iface/Attribute.java delete mode 100644 dx/src/com/android/dx/cf/iface/AttributeList.java delete mode 100644 dx/src/com/android/dx/cf/iface/ClassFile.java delete mode 100644 dx/src/com/android/dx/cf/iface/Field.java delete mode 100644 dx/src/com/android/dx/cf/iface/FieldList.java delete mode 100644 dx/src/com/android/dx/cf/iface/Member.java delete mode 100644 dx/src/com/android/dx/cf/iface/Method.java delete mode 100644 dx/src/com/android/dx/cf/iface/MethodList.java delete mode 100644 dx/src/com/android/dx/cf/iface/ParseException.java delete mode 100644 dx/src/com/android/dx/cf/iface/ParseObserver.java delete mode 100644 dx/src/com/android/dx/cf/iface/StdAttributeList.java delete mode 100644 dx/src/com/android/dx/cf/iface/StdField.java delete mode 100644 dx/src/com/android/dx/cf/iface/StdFieldList.java delete mode 100644 dx/src/com/android/dx/cf/iface/StdMember.java delete mode 100644 dx/src/com/android/dx/cf/iface/StdMethod.java delete mode 100644 dx/src/com/android/dx/cf/iface/StdMethodList.java delete mode 100644 dx/src/com/android/dx/cf/iface/package.html delete mode 100644 dx/src/com/android/dx/command/DxConsole.java delete mode 100644 dx/src/com/android/dx/command/Main.java delete mode 100644 dx/src/com/android/dx/command/UsageException.java delete mode 100644 dx/src/com/android/dx/command/annotool/AnnotationLister.java delete mode 100644 dx/src/com/android/dx/command/annotool/Main.java delete mode 100644 dx/src/com/android/dx/command/dexer/Main.java delete mode 100644 dx/src/com/android/dx/command/dump/Args.java delete mode 100644 dx/src/com/android/dx/command/dump/BaseDumper.java delete mode 100644 dx/src/com/android/dx/command/dump/BlockDumper.java delete mode 100644 dx/src/com/android/dx/command/dump/ClassDumper.java delete mode 100644 dx/src/com/android/dx/command/dump/DotDumper.java delete mode 100644 dx/src/com/android/dx/command/dump/Main.java delete mode 100644 dx/src/com/android/dx/command/dump/SsaDumper.java delete mode 100644 dx/src/com/android/dx/dex/cf/AttributeTranslator.java delete mode 100644 dx/src/com/android/dx/dex/cf/CfOptions.java delete mode 100644 dx/src/com/android/dx/dex/cf/CfTranslator.java delete mode 100644 dx/src/com/android/dx/dex/cf/CodeStatistics.java delete mode 100644 dx/src/com/android/dx/dex/cf/OptimizerOptions.java delete mode 100644 dx/src/com/android/dx/dex/cf/package.html delete mode 100644 dx/src/com/android/dx/dex/code/ArrayData.java delete mode 100644 dx/src/com/android/dx/dex/code/BlockAddresses.java delete mode 100644 dx/src/com/android/dx/dex/code/CatchBuilder.java delete mode 100644 dx/src/com/android/dx/dex/code/CatchHandlerList.java delete mode 100644 dx/src/com/android/dx/dex/code/CatchTable.java delete mode 100644 dx/src/com/android/dx/dex/code/CodeAddress.java delete mode 100644 dx/src/com/android/dx/dex/code/CstInsn.java delete mode 100644 dx/src/com/android/dx/dex/code/DalvCode.java delete mode 100644 dx/src/com/android/dx/dex/code/DalvInsn.java delete mode 100644 dx/src/com/android/dx/dex/code/DalvInsnList.java delete mode 100644 dx/src/com/android/dx/dex/code/DalvOps.java delete mode 100644 dx/src/com/android/dx/dex/code/Dop.java delete mode 100644 dx/src/com/android/dx/dex/code/Dops.java delete mode 100644 dx/src/com/android/dx/dex/code/FixedSizeInsn.java delete mode 100644 dx/src/com/android/dx/dex/code/HighRegisterPrefix.java delete mode 100644 dx/src/com/android/dx/dex/code/InsnFormat.java delete mode 100644 dx/src/com/android/dx/dex/code/LocalEnd.java delete mode 100644 dx/src/com/android/dx/dex/code/LocalList.java delete mode 100644 dx/src/com/android/dx/dex/code/LocalSnapshot.java delete mode 100644 dx/src/com/android/dx/dex/code/LocalStart.java delete mode 100644 dx/src/com/android/dx/dex/code/OddSpacer.java delete mode 100644 dx/src/com/android/dx/dex/code/OutputCollector.java delete mode 100644 dx/src/com/android/dx/dex/code/OutputFinisher.java delete mode 100644 dx/src/com/android/dx/dex/code/PositionList.java delete mode 100644 dx/src/com/android/dx/dex/code/RopToDop.java delete mode 100644 dx/src/com/android/dx/dex/code/RopTranslator.java delete mode 100644 dx/src/com/android/dx/dex/code/SimpleInsn.java delete mode 100644 dx/src/com/android/dx/dex/code/StdCatchBuilder.java delete mode 100644 dx/src/com/android/dx/dex/code/SwitchData.java delete mode 100644 dx/src/com/android/dx/dex/code/TargetInsn.java delete mode 100644 dx/src/com/android/dx/dex/code/VariableSizeInsn.java delete mode 100644 dx/src/com/android/dx/dex/code/ZeroSizeInsn.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form10t.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form10x.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form11n.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form11x.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form12x.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form20t.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form21c.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form21h.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form21s.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form21t.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form22b.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form22c.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form22s.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form22t.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form22x.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form23x.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form30t.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form31c.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form31i.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form31t.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form32x.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form35c.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form3rc.java delete mode 100644 dx/src/com/android/dx/dex/code/form/Form51l.java delete mode 100644 dx/src/com/android/dx/dex/code/form/SpecialFormat.java delete mode 100644 dx/src/com/android/dx/dex/file/AnnotationItem.java delete mode 100644 dx/src/com/android/dx/dex/file/AnnotationSetItem.java delete mode 100644 dx/src/com/android/dx/dex/file/AnnotationSetRefItem.java delete mode 100644 dx/src/com/android/dx/dex/file/AnnotationUtils.java delete mode 100644 dx/src/com/android/dx/dex/file/AnnotationsDirectoryItem.java delete mode 100644 dx/src/com/android/dx/dex/file/CatchStructs.java delete mode 100644 dx/src/com/android/dx/dex/file/ClassDataItem.java delete mode 100644 dx/src/com/android/dx/dex/file/ClassDefItem.java delete mode 100644 dx/src/com/android/dx/dex/file/ClassDefsSection.java delete mode 100644 dx/src/com/android/dx/dex/file/CodeItem.java delete mode 100644 dx/src/com/android/dx/dex/file/DebugInfoConstants.java delete mode 100644 dx/src/com/android/dx/dex/file/DebugInfoDecoder.java delete mode 100644 dx/src/com/android/dx/dex/file/DebugInfoEncoder.java delete mode 100644 dx/src/com/android/dx/dex/file/DebugInfoItem.java delete mode 100644 dx/src/com/android/dx/dex/file/DexFile.java delete mode 100644 dx/src/com/android/dx/dex/file/EncodedArrayItem.java delete mode 100644 dx/src/com/android/dx/dex/file/EncodedField.java delete mode 100644 dx/src/com/android/dx/dex/file/EncodedMember.java delete mode 100644 dx/src/com/android/dx/dex/file/EncodedMethod.java delete mode 100644 dx/src/com/android/dx/dex/file/FieldAnnotationStruct.java delete mode 100644 dx/src/com/android/dx/dex/file/FieldIdItem.java delete mode 100644 dx/src/com/android/dx/dex/file/FieldIdsSection.java delete mode 100644 dx/src/com/android/dx/dex/file/HeaderItem.java delete mode 100644 dx/src/com/android/dx/dex/file/HeaderSection.java delete mode 100644 dx/src/com/android/dx/dex/file/IdItem.java delete mode 100644 dx/src/com/android/dx/dex/file/IndexedItem.java delete mode 100644 dx/src/com/android/dx/dex/file/Item.java delete mode 100644 dx/src/com/android/dx/dex/file/ItemType.java delete mode 100644 dx/src/com/android/dx/dex/file/MapItem.java delete mode 100644 dx/src/com/android/dx/dex/file/MemberIdItem.java delete mode 100644 dx/src/com/android/dx/dex/file/MemberIdsSection.java delete mode 100644 dx/src/com/android/dx/dex/file/MethodAnnotationStruct.java delete mode 100644 dx/src/com/android/dx/dex/file/MethodIdItem.java delete mode 100644 dx/src/com/android/dx/dex/file/MethodIdsSection.java delete mode 100644 dx/src/com/android/dx/dex/file/MixedItemSection.java delete mode 100644 dx/src/com/android/dx/dex/file/OffsettedItem.java delete mode 100644 dx/src/com/android/dx/dex/file/ParameterAnnotationStruct.java delete mode 100644 dx/src/com/android/dx/dex/file/ProtoIdItem.java delete mode 100644 dx/src/com/android/dx/dex/file/ProtoIdsSection.java delete mode 100644 dx/src/com/android/dx/dex/file/Section.java delete mode 100644 dx/src/com/android/dx/dex/file/Statistics.java delete mode 100644 dx/src/com/android/dx/dex/file/StringDataItem.java delete mode 100644 dx/src/com/android/dx/dex/file/StringIdItem.java delete mode 100644 dx/src/com/android/dx/dex/file/StringIdsSection.java delete mode 100644 dx/src/com/android/dx/dex/file/TypeIdItem.java delete mode 100644 dx/src/com/android/dx/dex/file/TypeIdsSection.java delete mode 100644 dx/src/com/android/dx/dex/file/TypeListItem.java delete mode 100644 dx/src/com/android/dx/dex/file/UniformItemSection.java delete mode 100644 dx/src/com/android/dx/dex/file/UniformListItem.java delete mode 100644 dx/src/com/android/dx/dex/file/ValueEncoder.java delete mode 100644 dx/src/com/android/dx/rop/annotation/Annotation.java delete mode 100644 dx/src/com/android/dx/rop/annotation/AnnotationVisibility.java delete mode 100644 dx/src/com/android/dx/rop/annotation/Annotations.java delete mode 100644 dx/src/com/android/dx/rop/annotation/AnnotationsList.java delete mode 100644 dx/src/com/android/dx/rop/annotation/NameValuePair.java delete mode 100644 dx/src/com/android/dx/rop/code/AccessFlags.java delete mode 100644 dx/src/com/android/dx/rop/code/BasicBlock.java delete mode 100644 dx/src/com/android/dx/rop/code/BasicBlockList.java delete mode 100644 dx/src/com/android/dx/rop/code/ConservativeTranslationAdvice.java delete mode 100644 dx/src/com/android/dx/rop/code/CstInsn.java delete mode 100644 dx/src/com/android/dx/rop/code/DexTranslationAdvice.java delete mode 100644 dx/src/com/android/dx/rop/code/Exceptions.java delete mode 100644 dx/src/com/android/dx/rop/code/FillArrayDataInsn.java delete mode 100644 dx/src/com/android/dx/rop/code/Insn.java delete mode 100644 dx/src/com/android/dx/rop/code/InsnList.java delete mode 100644 dx/src/com/android/dx/rop/code/LocalItem.java delete mode 100644 dx/src/com/android/dx/rop/code/LocalVariableExtractor.java delete mode 100644 dx/src/com/android/dx/rop/code/LocalVariableInfo.java delete mode 100644 dx/src/com/android/dx/rop/code/PlainCstInsn.java delete mode 100644 dx/src/com/android/dx/rop/code/PlainInsn.java delete mode 100644 dx/src/com/android/dx/rop/code/RegOps.java delete mode 100644 dx/src/com/android/dx/rop/code/RegisterSpec.java delete mode 100644 dx/src/com/android/dx/rop/code/RegisterSpecList.java delete mode 100644 dx/src/com/android/dx/rop/code/RegisterSpecSet.java delete mode 100644 dx/src/com/android/dx/rop/code/Rop.java delete mode 100644 dx/src/com/android/dx/rop/code/RopMethod.java delete mode 100644 dx/src/com/android/dx/rop/code/Rops.java delete mode 100644 dx/src/com/android/dx/rop/code/SourcePosition.java delete mode 100644 dx/src/com/android/dx/rop/code/SwitchInsn.java delete mode 100644 dx/src/com/android/dx/rop/code/ThrowingCstInsn.java delete mode 100644 dx/src/com/android/dx/rop/code/ThrowingInsn.java delete mode 100644 dx/src/com/android/dx/rop/code/TranslationAdvice.java delete mode 100644 dx/src/com/android/dx/rop/code/package.html delete mode 100644 dx/src/com/android/dx/rop/cst/Constant.java delete mode 100644 dx/src/com/android/dx/rop/cst/ConstantPool.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstAnnotation.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstArray.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstBaseMethodRef.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstBoolean.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstByte.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstChar.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstDouble.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstEnumRef.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstFieldRef.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstFloat.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstInteger.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstInterfaceMethodRef.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstKnownNull.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstLiteral32.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstLiteral64.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstLiteralBits.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstLong.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstMemberRef.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstMethodRef.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstNat.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstShort.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstString.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstType.java delete mode 100644 dx/src/com/android/dx/rop/cst/CstUtf8.java delete mode 100644 dx/src/com/android/dx/rop/cst/StdConstantPool.java delete mode 100644 dx/src/com/android/dx/rop/cst/TypedConstant.java delete mode 100644 dx/src/com/android/dx/rop/cst/Zeroes.java delete mode 100644 dx/src/com/android/dx/rop/cst/package.html delete mode 100644 dx/src/com/android/dx/rop/package-info.java delete mode 100644 dx/src/com/android/dx/rop/type/Prototype.java delete mode 100644 dx/src/com/android/dx/rop/type/StdTypeList.java delete mode 100644 dx/src/com/android/dx/rop/type/Type.java delete mode 100644 dx/src/com/android/dx/rop/type/TypeBearer.java delete mode 100644 dx/src/com/android/dx/rop/type/TypeList.java delete mode 100644 dx/src/com/android/dx/rop/type/package.html delete mode 100644 dx/src/com/android/dx/ssa/BasicRegisterMapper.java delete mode 100644 dx/src/com/android/dx/ssa/ConstCollector.java delete mode 100644 dx/src/com/android/dx/ssa/DeadCodeRemover.java delete mode 100644 dx/src/com/android/dx/ssa/DomFront.java delete mode 100644 dx/src/com/android/dx/ssa/Dominators.java delete mode 100644 dx/src/com/android/dx/ssa/InterferenceRegisterMapper.java delete mode 100644 dx/src/com/android/dx/ssa/LiteralOpUpgrader.java delete mode 100644 dx/src/com/android/dx/ssa/LocalVariableExtractor.java delete mode 100644 dx/src/com/android/dx/ssa/LocalVariableInfo.java delete mode 100644 dx/src/com/android/dx/ssa/MoveParamCombiner.java delete mode 100644 dx/src/com/android/dx/ssa/NormalSsaInsn.java delete mode 100644 dx/src/com/android/dx/ssa/Optimizer.java delete mode 100644 dx/src/com/android/dx/ssa/PhiInsn.java delete mode 100644 dx/src/com/android/dx/ssa/PhiTypeResolver.java delete mode 100644 dx/src/com/android/dx/ssa/RegisterMapper.java delete mode 100644 dx/src/com/android/dx/ssa/SCCP.java delete mode 100644 dx/src/com/android/dx/ssa/SetFactory.java delete mode 100644 dx/src/com/android/dx/ssa/SsaBasicBlock.java delete mode 100644 dx/src/com/android/dx/ssa/SsaConverter.java delete mode 100644 dx/src/com/android/dx/ssa/SsaInsn.java delete mode 100644 dx/src/com/android/dx/ssa/SsaMethod.java delete mode 100644 dx/src/com/android/dx/ssa/SsaRenamer.java delete mode 100644 dx/src/com/android/dx/ssa/_tests/_DomFront.java delete mode 100644 dx/src/com/android/dx/ssa/back/FirstFitAllocator.java delete mode 100644 dx/src/com/android/dx/ssa/back/FirstFitLocalCombiningAllocator.java delete mode 100644 dx/src/com/android/dx/ssa/back/IdenticalBlockCombiner.java delete mode 100644 dx/src/com/android/dx/ssa/back/InterferenceGraph.java delete mode 100644 dx/src/com/android/dx/ssa/back/LivenessAnalyzer.java delete mode 100644 dx/src/com/android/dx/ssa/back/NullRegisterAllocator.java delete mode 100644 dx/src/com/android/dx/ssa/back/RegisterAllocator.java delete mode 100644 dx/src/com/android/dx/ssa/back/SsaToRop.java delete mode 100644 dx/src/com/android/dx/ssa/package-info.java delete mode 100644 dx/src/com/android/dx/util/AnnotatedOutput.java delete mode 100644 dx/src/com/android/dx/util/BitIntSet.java delete mode 100644 dx/src/com/android/dx/util/Bits.java delete mode 100644 dx/src/com/android/dx/util/ByteArray.java delete mode 100644 dx/src/com/android/dx/util/ByteArrayAnnotatedOutput.java delete mode 100644 dx/src/com/android/dx/util/ExceptionWithContext.java delete mode 100644 dx/src/com/android/dx/util/FileUtils.java delete mode 100644 dx/src/com/android/dx/util/FixedSizeList.java delete mode 100644 dx/src/com/android/dx/util/Hex.java delete mode 100644 dx/src/com/android/dx/util/HexParser.java delete mode 100644 dx/src/com/android/dx/util/IndentingWriter.java delete mode 100644 dx/src/com/android/dx/util/IntIterator.java delete mode 100644 dx/src/com/android/dx/util/IntList.java delete mode 100644 dx/src/com/android/dx/util/IntSet.java delete mode 100644 dx/src/com/android/dx/util/LabeledItem.java delete mode 100644 dx/src/com/android/dx/util/LabeledList.java delete mode 100644 dx/src/com/android/dx/util/Leb128Utils.java delete mode 100644 dx/src/com/android/dx/util/ListIntSet.java delete mode 100644 dx/src/com/android/dx/util/MutabilityControl.java delete mode 100644 dx/src/com/android/dx/util/MutabilityException.java delete mode 100644 dx/src/com/android/dx/util/Output.java delete mode 100644 dx/src/com/android/dx/util/ToHuman.java delete mode 100644 dx/src/com/android/dx/util/TwoColumnOutput.java delete mode 100644 dx/src/com/android/dx/util/Warning.java delete mode 100644 dx/src/com/android/dx/util/Writers.java delete mode 100644 dx/src/com/android/dx/util/_tests/_BitIntSet.java delete mode 100644 dx/src/com/android/dx/util/_tests/_Bits.java delete mode 100644 dx/src/com/android/dx/util/_tests/_IntList.java delete mode 100644 dx/src/com/android/dx/util/_tests/_ListIntSet.java delete mode 100644 dx/src/com/android/dx/util/package.html delete mode 100644 dx/src/junit/extensions/ActiveTestSuite.java delete mode 100644 dx/src/junit/extensions/ExceptionTestCase.java delete mode 100644 dx/src/junit/extensions/RepeatedTest.java delete mode 100644 dx/src/junit/extensions/TestDecorator.java delete mode 100644 dx/src/junit/extensions/TestSetup.java delete mode 100644 dx/src/junit/framework/Assert.java delete mode 100644 dx/src/junit/framework/AssertionFailedError.java delete mode 100644 dx/src/junit/framework/ComparisonFailure.java delete mode 100644 dx/src/junit/framework/Protectable.java delete mode 100644 dx/src/junit/framework/Test.java delete mode 100644 dx/src/junit/framework/TestCase.java delete mode 100644 dx/src/junit/framework/TestFailure.java delete mode 100644 dx/src/junit/framework/TestListener.java delete mode 100644 dx/src/junit/framework/TestResult.java delete mode 100644 dx/src/junit/framework/TestSuite.java delete mode 100644 dx/src/junit/runner/BaseTestRunner.java delete mode 100644 dx/src/junit/runner/ClassPathTestCollector.java delete mode 100644 dx/src/junit/runner/FailureDetailView.java delete mode 100644 dx/src/junit/runner/LoadingTestCollector.java delete mode 100644 dx/src/junit/runner/ReloadingTestSuiteLoader.java delete mode 100644 dx/src/junit/runner/SimpleTestCollector.java delete mode 100644 dx/src/junit/runner/Sorter.java delete mode 100644 dx/src/junit/runner/StandardTestSuiteLoader.java delete mode 100644 dx/src/junit/runner/TestCaseClassLoader.java delete mode 100644 dx/src/junit/runner/TestCollector.java delete mode 100644 dx/src/junit/runner/TestRunListener.java delete mode 100644 dx/src/junit/runner/TestSuiteLoader.java delete mode 100644 dx/src/junit/runner/Version.java delete mode 100644 dx/src/junit/runner/excluded.properties delete mode 100644 dx/src/junit/runner/logo.gif delete mode 100644 dx/src/junit/runner/smalllogo.gif delete mode 100644 dx/src/junit/textui/ResultPrinter.java delete mode 100644 dx/src/junit/textui/TestRunner.java delete mode 100644 dx/tests/001-nop/expected.txt delete mode 100644 dx/tests/001-nop/info.txt delete mode 100644 dx/tests/001-nop/run delete mode 100644 dx/tests/002-minimal-valid/expected.txt delete mode 100644 dx/tests/002-minimal-valid/info.txt delete mode 100644 dx/tests/002-minimal-valid/run delete mode 100644 dx/tests/002-minimal-valid/small-class.txt delete mode 100644 dx/tests/003-magic-version-access/class-bad-magic.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-44.0.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-44.65535.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-45.0.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-45.65535.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-48.0.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-48.65535.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-49.0.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-49.1.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-49.65535.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-50.0.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-50.1.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-50.65535.txt delete mode 100644 dx/tests/003-magic-version-access/class-version-51.0.txt delete mode 100644 dx/tests/003-magic-version-access/expected.txt delete mode 100644 dx/tests/003-magic-version-access/info.txt delete mode 100644 dx/tests/003-magic-version-access/run delete mode 100644 dx/tests/003-magic-version-access/small-class.txt delete mode 100644 dx/tests/004-cp-bottom-up/expected.txt delete mode 100644 dx/tests/004-cp-bottom-up/info.txt delete mode 100644 dx/tests/004-cp-bottom-up/run delete mode 100644 dx/tests/004-cp-bottom-up/small-class.txt delete mode 100644 dx/tests/005-cp-top-down/expected.txt delete mode 100644 dx/tests/005-cp-top-down/info.txt delete mode 100644 dx/tests/005-cp-top-down/run delete mode 100644 dx/tests/005-cp-top-down/small-class.txt delete mode 100644 dx/tests/006-interfaces/expected.txt delete mode 100644 dx/tests/006-interfaces/info.txt delete mode 100644 dx/tests/006-interfaces/run delete mode 100644 dx/tests/006-interfaces/small-class.txt delete mode 100644 dx/tests/007-no-superclass/expected.txt delete mode 100644 dx/tests/007-no-superclass/info.txt delete mode 100644 dx/tests/007-no-superclass/run delete mode 100644 dx/tests/007-no-superclass/small-class.txt delete mode 100644 dx/tests/008-field/expected.txt delete mode 100644 dx/tests/008-field/info.txt delete mode 100644 dx/tests/008-field/run delete mode 100644 dx/tests/008-field/small-class.txt delete mode 100644 dx/tests/009-method/expected.txt delete mode 100644 dx/tests/009-method/info.txt delete mode 100644 dx/tests/009-method/run delete mode 100644 dx/tests/009-method/small-class.txt delete mode 100644 dx/tests/010-class-attrib-InnerClasses/expected.txt delete mode 100644 dx/tests/010-class-attrib-InnerClasses/info.txt delete mode 100644 dx/tests/010-class-attrib-InnerClasses/run delete mode 100644 dx/tests/010-class-attrib-InnerClasses/small-class.txt delete mode 100644 dx/tests/011-class-attrib-Synthetic/expected.txt delete mode 100644 dx/tests/011-class-attrib-Synthetic/info.txt delete mode 100644 dx/tests/011-class-attrib-Synthetic/run delete mode 100644 dx/tests/011-class-attrib-Synthetic/small-class.txt delete mode 100644 dx/tests/012-class-attrib-SourceFile/expected.txt delete mode 100644 dx/tests/012-class-attrib-SourceFile/info.txt delete mode 100644 dx/tests/012-class-attrib-SourceFile/run delete mode 100644 dx/tests/012-class-attrib-SourceFile/small-class.txt delete mode 100644 dx/tests/013-class-attrib-Deprecated/expected.txt delete mode 100644 dx/tests/013-class-attrib-Deprecated/info.txt delete mode 100644 dx/tests/013-class-attrib-Deprecated/run delete mode 100644 dx/tests/013-class-attrib-Deprecated/small-class.txt delete mode 100644 dx/tests/014-field-attrib-ConstantValue/expected.txt delete mode 100644 dx/tests/014-field-attrib-ConstantValue/info.txt delete mode 100644 dx/tests/014-field-attrib-ConstantValue/run delete mode 100644 dx/tests/014-field-attrib-ConstantValue/small-class.txt delete mode 100644 dx/tests/015-field-attrib-Synthetic/expected.txt delete mode 100644 dx/tests/015-field-attrib-Synthetic/info.txt delete mode 100644 dx/tests/015-field-attrib-Synthetic/run delete mode 100644 dx/tests/015-field-attrib-Synthetic/small-class.txt delete mode 100644 dx/tests/016-field-attrib-Deprecated/expected.txt delete mode 100644 dx/tests/016-field-attrib-Deprecated/info.txt delete mode 100644 dx/tests/016-field-attrib-Deprecated/run delete mode 100644 dx/tests/016-field-attrib-Deprecated/small-class.txt delete mode 100644 dx/tests/017-method-attrib-Code/expected.txt delete mode 100644 dx/tests/017-method-attrib-Code/info.txt delete mode 100644 dx/tests/017-method-attrib-Code/run delete mode 100644 dx/tests/017-method-attrib-Code/small-class.txt delete mode 100644 dx/tests/018-method-attrib-Exceptions/expected.txt delete mode 100644 dx/tests/018-method-attrib-Exceptions/info.txt delete mode 100644 dx/tests/018-method-attrib-Exceptions/run delete mode 100644 dx/tests/018-method-attrib-Exceptions/small-class.txt delete mode 100644 dx/tests/019-method-attrib-Synthetic/expected.txt delete mode 100644 dx/tests/019-method-attrib-Synthetic/info.txt delete mode 100644 dx/tests/019-method-attrib-Synthetic/run delete mode 100644 dx/tests/019-method-attrib-Synthetic/small-class.txt delete mode 100644 dx/tests/020-method-attrib-Deprecated/expected.txt delete mode 100644 dx/tests/020-method-attrib-Deprecated/info.txt delete mode 100644 dx/tests/020-method-attrib-Deprecated/run delete mode 100644 dx/tests/020-method-attrib-Deprecated/small-class.txt delete mode 100644 dx/tests/021-code-attrib-LineNumberTable/expected.txt delete mode 100644 dx/tests/021-code-attrib-LineNumberTable/info.txt delete mode 100644 dx/tests/021-code-attrib-LineNumberTable/run delete mode 100644 dx/tests/021-code-attrib-LineNumberTable/small-class.txt delete mode 100644 dx/tests/022-code-attrib-LocalVariableTable/expected.txt delete mode 100644 dx/tests/022-code-attrib-LocalVariableTable/info.txt delete mode 100644 dx/tests/022-code-attrib-LocalVariableTable/run delete mode 100644 dx/tests/022-code-attrib-LocalVariableTable/small-class.txt delete mode 100644 dx/tests/023-code-exception-table/expected.txt delete mode 100644 dx/tests/023-code-exception-table/info.txt delete mode 100644 dx/tests/023-code-exception-table/run delete mode 100644 dx/tests/023-code-exception-table/small-class.txt delete mode 100644 dx/tests/024-code-bytecode/expected.txt delete mode 100644 dx/tests/024-code-bytecode/info.txt delete mode 100644 dx/tests/024-code-bytecode/run delete mode 100644 dx/tests/024-code-bytecode/small-class.txt delete mode 100644 dx/tests/025-class-attrib-Signature/expected.txt delete mode 100644 dx/tests/025-class-attrib-Signature/info.txt delete mode 100644 dx/tests/025-class-attrib-Signature/run delete mode 100644 dx/tests/025-class-attrib-Signature/small-class.txt delete mode 100644 dx/tests/026-field-attrib-Signature/expected.txt delete mode 100644 dx/tests/026-field-attrib-Signature/info.txt delete mode 100644 dx/tests/026-field-attrib-Signature/run delete mode 100644 dx/tests/026-field-attrib-Signature/small-class.txt delete mode 100644 dx/tests/027-method-attrib-Signature/expected.txt delete mode 100644 dx/tests/027-method-attrib-Signature/info.txt delete mode 100644 dx/tests/027-method-attrib-Signature/run delete mode 100644 dx/tests/027-method-attrib-Signature/small-class.txt delete mode 100644 dx/tests/028-class-attrib-EnclosingMethod/expected.txt delete mode 100644 dx/tests/028-class-attrib-EnclosingMethod/info.txt delete mode 100644 dx/tests/028-class-attrib-EnclosingMethod/run delete mode 100644 dx/tests/028-class-attrib-EnclosingMethod/small-class-1.txt delete mode 100644 dx/tests/028-class-attrib-EnclosingMethod/small-class-2.txt delete mode 100644 dx/tests/029-unit-Bits/expected.txt delete mode 100644 dx/tests/029-unit-Bits/info.txt delete mode 100644 dx/tests/029-unit-Bits/run delete mode 100644 dx/tests/030-minimal-jasmin/blort.j delete mode 100644 dx/tests/030-minimal-jasmin/expected.txt delete mode 100644 dx/tests/030-minimal-jasmin/info.txt delete mode 100644 dx/tests/030-minimal-jasmin/run delete mode 100644 dx/tests/031-bb-dead-code/blort.j delete mode 100644 dx/tests/031-bb-dead-code/expected.txt delete mode 100644 dx/tests/031-bb-dead-code/info.txt delete mode 100644 dx/tests/031-bb-dead-code/run delete mode 100644 dx/tests/032-bb-live-code/blort.j delete mode 100644 dx/tests/032-bb-live-code/expected.txt delete mode 100644 dx/tests/032-bb-live-code/info.txt delete mode 100644 dx/tests/032-bb-live-code/run delete mode 100644 dx/tests/033-unit-IntList/expected.txt delete mode 100644 dx/tests/033-unit-IntList/info.txt delete mode 100644 dx/tests/033-unit-IntList/run delete mode 100644 dx/tests/034-dex-minimal/blort.j delete mode 100644 dx/tests/034-dex-minimal/expected.txt delete mode 100644 dx/tests/034-dex-minimal/info.txt delete mode 100644 dx/tests/034-dex-minimal/run delete mode 100644 dx/tests/035-dex-instance-var/blort.j delete mode 100644 dx/tests/035-dex-instance-var/expected.txt delete mode 100644 dx/tests/035-dex-instance-var/info.txt delete mode 100644 dx/tests/035-dex-instance-var/run delete mode 100644 dx/tests/036-dex-static-var/blort.j delete mode 100644 dx/tests/036-dex-static-var/expected.txt delete mode 100644 dx/tests/036-dex-static-var/info.txt delete mode 100644 dx/tests/036-dex-static-var/run delete mode 100644 dx/tests/037-dex-static-final-var/blort.j delete mode 100644 dx/tests/037-dex-static-final-var/expected.txt delete mode 100644 dx/tests/037-dex-static-final-var/info.txt delete mode 100644 dx/tests/037-dex-static-final-var/run delete mode 100644 dx/tests/038-dex-instance-method/blort.j delete mode 100644 dx/tests/038-dex-instance-method/expected.txt delete mode 100644 dx/tests/038-dex-instance-method/info.txt delete mode 100644 dx/tests/038-dex-instance-method/run delete mode 100644 dx/tests/039-dex-static-method/blort.j delete mode 100644 dx/tests/039-dex-static-method/expected.txt delete mode 100644 dx/tests/039-dex-static-method/info.txt delete mode 100644 dx/tests/039-dex-static-method/run delete mode 100644 dx/tests/040-dex-constructor/blort.j delete mode 100644 dx/tests/040-dex-constructor/expected.txt delete mode 100644 dx/tests/040-dex-constructor/info.txt delete mode 100644 dx/tests/040-dex-constructor/run delete mode 100644 dx/tests/041-dex-abstract-method/blort.j delete mode 100644 dx/tests/041-dex-abstract-method/expected.txt delete mode 100644 dx/tests/041-dex-abstract-method/info.txt delete mode 100644 dx/tests/041-dex-abstract-method/run delete mode 100644 dx/tests/042-dex-ignore-result/Blort.java delete mode 100644 dx/tests/042-dex-ignore-result/expected.txt delete mode 100644 dx/tests/042-dex-ignore-result/info.txt delete mode 100644 dx/tests/042-dex-ignore-result/run delete mode 100644 dx/tests/043-dex-two-classes/Blort.java delete mode 100644 dx/tests/043-dex-two-classes/Zorch.java delete mode 100644 dx/tests/043-dex-two-classes/expected.txt delete mode 100644 dx/tests/043-dex-two-classes/info.txt delete mode 100644 dx/tests/043-dex-two-classes/run delete mode 100644 dx/tests/044-dex-math-ops/Blort.java delete mode 100644 dx/tests/044-dex-math-ops/expected.txt delete mode 100644 dx/tests/044-dex-math-ops/info.txt delete mode 100644 dx/tests/044-dex-math-ops/run delete mode 100644 dx/tests/045-dex-switch-ops/Blort.java delete mode 100644 dx/tests/045-dex-switch-ops/expected.txt delete mode 100644 dx/tests/045-dex-switch-ops/info.txt delete mode 100644 dx/tests/045-dex-switch-ops/run delete mode 100644 dx/tests/046-dex-exceptions/Blort.java delete mode 100644 dx/tests/046-dex-exceptions/expected.txt delete mode 100644 dx/tests/046-dex-exceptions/info.txt delete mode 100644 dx/tests/046-dex-exceptions/run delete mode 100644 dx/tests/047-dex-wide-args/Blort.java delete mode 100644 dx/tests/047-dex-wide-args/expected.txt delete mode 100644 dx/tests/047-dex-wide-args/info.txt delete mode 100644 dx/tests/047-dex-wide-args/run delete mode 100644 dx/tests/048-dex-new-array/Blort.java delete mode 100644 dx/tests/048-dex-new-array/expected.txt delete mode 100644 dx/tests/048-dex-new-array/info.txt delete mode 100644 dx/tests/048-dex-new-array/run delete mode 100644 dx/tests/049-dex-instanceof/Blort.java delete mode 100644 dx/tests/049-dex-instanceof/expected.txt delete mode 100644 dx/tests/049-dex-instanceof/info.txt delete mode 100644 dx/tests/049-dex-instanceof/run delete mode 100644 dx/tests/050-dex-checkcast/Blort.java delete mode 100644 dx/tests/050-dex-checkcast/expected.txt delete mode 100644 dx/tests/050-dex-checkcast/info.txt delete mode 100644 dx/tests/050-dex-checkcast/run delete mode 100644 dx/tests/051-dex-explicit-null/Blort.java delete mode 100644 dx/tests/051-dex-explicit-null/expected.txt delete mode 100644 dx/tests/051-dex-explicit-null/info.txt delete mode 100644 dx/tests/051-dex-explicit-null/run delete mode 100644 dx/tests/052-dex-static-var-access/Blort.java delete mode 100644 dx/tests/052-dex-static-var-access/expected.txt delete mode 100644 dx/tests/052-dex-static-var-access/info.txt delete mode 100644 dx/tests/052-dex-static-var-access/run delete mode 100644 dx/tests/053-dex-instance-var-access/Blort.java delete mode 100644 dx/tests/053-dex-instance-var-access/expected.txt delete mode 100644 dx/tests/053-dex-instance-var-access/info.txt delete mode 100644 dx/tests/053-dex-instance-var-access/run delete mode 100644 dx/tests/054-dex-high16/Blort.java delete mode 100644 dx/tests/054-dex-high16/expected.txt delete mode 100644 dx/tests/054-dex-high16/info.txt delete mode 100644 dx/tests/054-dex-high16/run delete mode 100644 dx/tests/055-dex-explicit-throw/Blort.java delete mode 100644 dx/tests/055-dex-explicit-throw/expected.txt delete mode 100644 dx/tests/055-dex-explicit-throw/info.txt delete mode 100644 dx/tests/055-dex-explicit-throw/run delete mode 100644 dx/tests/056-dex-call-interface/Blort.java delete mode 100644 dx/tests/056-dex-call-interface/Zorch.java delete mode 100644 dx/tests/056-dex-call-interface/expected.txt delete mode 100644 dx/tests/056-dex-call-interface/info.txt delete mode 100644 dx/tests/056-dex-call-interface/run delete mode 100644 dx/tests/057-dex-call-virtual/Blort.java delete mode 100644 dx/tests/057-dex-call-virtual/Zorch.java delete mode 100644 dx/tests/057-dex-call-virtual/expected.txt delete mode 100644 dx/tests/057-dex-call-virtual/info.txt delete mode 100644 dx/tests/057-dex-call-virtual/run delete mode 100644 dx/tests/058-dex-call-direct/Blort.java delete mode 100644 dx/tests/058-dex-call-direct/expected.txt delete mode 100644 dx/tests/058-dex-call-direct/info.txt delete mode 100644 dx/tests/058-dex-call-direct/run delete mode 100644 dx/tests/059-dex-call-super/Blort.java delete mode 100644 dx/tests/059-dex-call-super/Zorch.java delete mode 100644 dx/tests/059-dex-call-super/expected.txt delete mode 100644 dx/tests/059-dex-call-super/info.txt delete mode 100644 dx/tests/059-dex-call-super/run delete mode 100644 dx/tests/060-dex-call-static/Blort.java delete mode 100644 dx/tests/060-dex-call-static/Zorch.java delete mode 100644 dx/tests/060-dex-call-static/expected.txt delete mode 100644 dx/tests/060-dex-call-static/info.txt delete mode 100644 dx/tests/060-dex-call-static/run delete mode 100644 dx/tests/061-dex-try-catch/Blort.java delete mode 100644 dx/tests/061-dex-try-catch/expected.txt delete mode 100644 dx/tests/061-dex-try-catch/info.txt delete mode 100644 dx/tests/061-dex-try-catch/run delete mode 100644 dx/tests/062-dex-synch-method/Blort.java delete mode 100644 dx/tests/062-dex-synch-method/expected.txt delete mode 100644 dx/tests/062-dex-synch-method/info.txt delete mode 100644 dx/tests/062-dex-synch-method/run delete mode 100644 dx/tests/063-dex-empty-switch/Blort.java delete mode 100644 dx/tests/063-dex-empty-switch/expected.txt delete mode 100644 dx/tests/063-dex-empty-switch/info.txt delete mode 100644 dx/tests/063-dex-empty-switch/run delete mode 100644 dx/tests/064-dex-array-access/Blort.java delete mode 100644 dx/tests/064-dex-array-access/expected.txt delete mode 100644 dx/tests/064-dex-array-access/info.txt delete mode 100644 dx/tests/064-dex-array-access/run delete mode 100644 dx/tests/065-dex-new-array/Blort.java delete mode 100644 dx/tests/065-dex-new-array/expected.txt delete mode 100644 dx/tests/065-dex-new-array/info.txt delete mode 100644 dx/tests/065-dex-new-array/run delete mode 100644 dx/tests/066-dex-try-catch-rethrow/Blort.java delete mode 100644 dx/tests/066-dex-try-catch-rethrow/expected.txt delete mode 100644 dx/tests/066-dex-try-catch-rethrow/info.txt delete mode 100644 dx/tests/066-dex-try-catch-rethrow/run delete mode 100644 dx/tests/067-dex-switch-and-try/Blort.java delete mode 100644 dx/tests/067-dex-switch-and-try/expected.txt delete mode 100644 dx/tests/067-dex-switch-and-try/info.txt delete mode 100644 dx/tests/067-dex-switch-and-try/run delete mode 100644 dx/tests/068-dex-infinite-loop/Blort.java delete mode 100644 dx/tests/068-dex-infinite-loop/expected.txt delete mode 100644 dx/tests/068-dex-infinite-loop/info.txt delete mode 100644 dx/tests/068-dex-infinite-loop/run delete mode 100644 dx/tests/069-dex-source-position/Blort.java delete mode 100644 dx/tests/069-dex-source-position/expected.txt delete mode 100644 dx/tests/069-dex-source-position/info.txt delete mode 100644 dx/tests/069-dex-source-position/run delete mode 100644 dx/tests/070-dex-multianewarray/Blort.java delete mode 100644 dx/tests/070-dex-multianewarray/expected.txt delete mode 100644 dx/tests/070-dex-multianewarray/info.txt delete mode 100644 dx/tests/070-dex-multianewarray/run delete mode 100644 dx/tests/071-dex-java-stack-ops/blort.j delete mode 100644 dx/tests/071-dex-java-stack-ops/expected.txt delete mode 100644 dx/tests/071-dex-java-stack-ops/info.txt delete mode 100644 dx/tests/071-dex-java-stack-ops/run delete mode 100644 dx/tests/072-dex-switch-edge-cases/Blort.java delete mode 100644 dx/tests/072-dex-switch-edge-cases/expected.txt delete mode 100644 dx/tests/072-dex-switch-edge-cases/info.txt delete mode 100644 dx/tests/072-dex-switch-edge-cases/run delete mode 100644 dx/tests/073-dex-null-array-refs/Blort.java delete mode 100644 dx/tests/073-dex-null-array-refs/expected.txt delete mode 100644 dx/tests/073-dex-null-array-refs/info.txt delete mode 100644 dx/tests/073-dex-null-array-refs/run delete mode 100644 dx/tests/074-dex-form35c-edge-case/Blort.java delete mode 100644 dx/tests/074-dex-form35c-edge-case/expected.txt delete mode 100644 dx/tests/074-dex-form35c-edge-case/info.txt delete mode 100644 dx/tests/074-dex-form35c-edge-case/run delete mode 100644 dx/tests/075-dex-cat2-value-merge/Blort.java delete mode 100644 dx/tests/075-dex-cat2-value-merge/expected.txt delete mode 100644 dx/tests/075-dex-cat2-value-merge/info.txt delete mode 100644 dx/tests/075-dex-cat2-value-merge/run delete mode 100644 dx/tests/076-dex-synch-and-stack/Blort.java delete mode 100644 dx/tests/076-dex-synch-and-stack/expected.txt delete mode 100644 dx/tests/076-dex-synch-and-stack/info.txt delete mode 100644 dx/tests/076-dex-synch-and-stack/run delete mode 100644 dx/tests/077-dex-code-alignment/Blort.java delete mode 100644 dx/tests/077-dex-code-alignment/expected.txt delete mode 100644 dx/tests/077-dex-code-alignment/info.txt delete mode 100644 dx/tests/077-dex-code-alignment/run delete mode 100644 dx/tests/078-dex-local-variable-table/Blort.java delete mode 100644 dx/tests/078-dex-local-variable-table/expected.txt delete mode 100644 dx/tests/078-dex-local-variable-table/info.txt delete mode 100644 dx/tests/078-dex-local-variable-table/run delete mode 100644 dx/tests/079-dex-local-variable-renumbering/Blort.java delete mode 100644 dx/tests/079-dex-local-variable-renumbering/expected.txt delete mode 100644 dx/tests/079-dex-local-variable-renumbering/info.txt delete mode 100644 dx/tests/079-dex-local-variable-renumbering/run delete mode 100644 dx/tests/080-dex-exception-tables/Blort.java delete mode 100644 dx/tests/080-dex-exception-tables/expected.txt delete mode 100644 dx/tests/080-dex-exception-tables/info.txt delete mode 100644 dx/tests/080-dex-exception-tables/run delete mode 100644 dx/tests/081-dex-throws-list/Blort.java delete mode 100644 dx/tests/081-dex-throws-list/expected.txt delete mode 100644 dx/tests/081-dex-throws-list/info.txt delete mode 100644 dx/tests/081-dex-throws-list/run delete mode 100644 dx/tests/082-dex-throws-list-sharing/Blort.java delete mode 100644 dx/tests/082-dex-throws-list-sharing/expected.txt delete mode 100644 dx/tests/082-dex-throws-list-sharing/info.txt delete mode 100644 dx/tests/082-dex-throws-list-sharing/run delete mode 100644 dx/tests/083-ssa-phi-placement/Blort.java delete mode 100644 dx/tests/083-ssa-phi-placement/expected.txt delete mode 100644 dx/tests/083-ssa-phi-placement/info.txt delete mode 100644 dx/tests/083-ssa-phi-placement/run delete mode 100644 dx/tests/084-dex-high-register-moves/Blort.java delete mode 100644 dx/tests/084-dex-high-register-moves/expected.txt delete mode 100644 dx/tests/084-dex-high-register-moves/info.txt delete mode 100644 dx/tests/084-dex-high-register-moves/run delete mode 100644 dx/tests/085-dex-jsr-ret/blort.j delete mode 100644 dx/tests/085-dex-jsr-ret/expected.txt delete mode 100644 dx/tests/085-dex-jsr-ret/info.txt delete mode 100644 dx/tests/085-dex-jsr-ret/run delete mode 100644 dx/tests/086-ssa-edge-split/Blort.java delete mode 100644 dx/tests/086-ssa-edge-split/expected.txt delete mode 100644 dx/tests/086-ssa-edge-split/info.txt delete mode 100644 dx/tests/086-ssa-edge-split/run delete mode 100644 dx/tests/087-ssa-local-vars/Blort.java delete mode 100644 dx/tests/087-ssa-local-vars/expected.txt delete mode 100644 dx/tests/087-ssa-local-vars/info.txt delete mode 100644 dx/tests/087-ssa-local-vars/run delete mode 100644 dx/tests/088-ssa-combine-blocks/Blort.java delete mode 100644 dx/tests/088-ssa-combine-blocks/expected.txt delete mode 100644 dx/tests/088-ssa-combine-blocks/info.txt delete mode 100644 dx/tests/088-ssa-combine-blocks/run delete mode 100644 dx/tests/089-dex-define-object/Class.java delete mode 100644 dx/tests/089-dex-define-object/Object.java delete mode 100644 dx/tests/089-dex-define-object/String.java delete mode 100644 dx/tests/089-dex-define-object/expected.txt delete mode 100644 dx/tests/089-dex-define-object/info.txt delete mode 100644 dx/tests/089-dex-define-object/run delete mode 100644 dx/tests/090-dex-unify-arrays/Blort.java delete mode 100644 dx/tests/090-dex-unify-arrays/expected.txt delete mode 100644 dx/tests/090-dex-unify-arrays/info.txt delete mode 100644 dx/tests/090-dex-unify-arrays/run delete mode 100644 dx/tests/091-ssa-const-collector/Blort.java delete mode 100644 dx/tests/091-ssa-const-collector/expected.txt delete mode 100644 dx/tests/091-ssa-const-collector/info.txt delete mode 100644 dx/tests/091-ssa-const-collector/run delete mode 100644 dx/tests/092-ssa-cfg-edge-cases/Blort.java delete mode 100644 dx/tests/092-ssa-cfg-edge-cases/expected.txt delete mode 100644 dx/tests/092-ssa-cfg-edge-cases/info.txt delete mode 100644 dx/tests/092-ssa-cfg-edge-cases/run delete mode 100644 dx/tests/093-ssa-invoke-range/Blort.java delete mode 100644 dx/tests/093-ssa-invoke-range/expected.txt delete mode 100644 dx/tests/093-ssa-invoke-range/info.txt delete mode 100644 dx/tests/093-ssa-invoke-range/run delete mode 100644 dx/tests/094-scala-locals/blort.j delete mode 100644 dx/tests/094-scala-locals/expected.txt delete mode 100644 dx/tests/094-scala-locals/info.txt delete mode 100644 dx/tests/094-scala-locals/run delete mode 100644 dx/tests/095-dex-const-string-jumbo/Blort.java delete mode 100644 dx/tests/095-dex-const-string-jumbo/expected.txt delete mode 100644 dx/tests/095-dex-const-string-jumbo/info.txt delete mode 100644 dx/tests/095-dex-const-string-jumbo/run delete mode 100644 dx/tests/096-dex-giant-catch/Blort.java delete mode 100644 dx/tests/096-dex-giant-catch/expected.txt delete mode 100644 dx/tests/096-dex-giant-catch/info.txt delete mode 100644 dx/tests/096-dex-giant-catch/run delete mode 100644 dx/tests/097-dex-branch-offset-zero/Blort.java delete mode 100644 dx/tests/097-dex-branch-offset-zero/expected.txt delete mode 100644 dx/tests/097-dex-branch-offset-zero/info.txt delete mode 100644 dx/tests/097-dex-branch-offset-zero/run delete mode 100644 dx/tests/098-dex-jsr-ret-throw/ViewDebug$ViewServer.class delete mode 100644 dx/tests/098-dex-jsr-ret-throw/expected.txt delete mode 100644 dx/tests/098-dex-jsr-ret-throw/info.txt delete mode 100755 dx/tests/098-dex-jsr-ret-throw/run delete mode 100644 dx/tests/099-dex-core-library-error/Blort.java delete mode 100644 dx/tests/099-dex-core-library-error/Muffins.java delete mode 100644 dx/tests/099-dex-core-library-error/Zorch.java delete mode 100644 dx/tests/099-dex-core-library-error/expected.txt delete mode 100644 dx/tests/099-dex-core-library-error/info.txt delete mode 100644 dx/tests/099-dex-core-library-error/run delete mode 100644 dx/tests/100-local-mismatch/blort1.j delete mode 100644 dx/tests/100-local-mismatch/blort2.j delete mode 100644 dx/tests/100-local-mismatch/blort3.j delete mode 100644 dx/tests/100-local-mismatch/blort4.j delete mode 100644 dx/tests/100-local-mismatch/expected.txt delete mode 100644 dx/tests/100-local-mismatch/info.txt delete mode 100644 dx/tests/100-local-mismatch/run delete mode 100644 dx/tests/101-verify-wide-math/expected.txt delete mode 100644 dx/tests/101-verify-wide-math/info.txt delete mode 100644 dx/tests/101-verify-wide-math/op_d2f.j delete mode 100644 dx/tests/101-verify-wide-math/op_d2i.j delete mode 100644 dx/tests/101-verify-wide-math/op_d2l.j delete mode 100644 dx/tests/101-verify-wide-math/op_dadd.j delete mode 100644 dx/tests/101-verify-wide-math/op_dcmpg.j delete mode 100644 dx/tests/101-verify-wide-math/op_dcmpl.j delete mode 100644 dx/tests/101-verify-wide-math/op_ddiv.j delete mode 100644 dx/tests/101-verify-wide-math/op_dmul.j delete mode 100644 dx/tests/101-verify-wide-math/op_dneg.j delete mode 100644 dx/tests/101-verify-wide-math/op_drem.j delete mode 100644 dx/tests/101-verify-wide-math/op_dsub.j delete mode 100644 dx/tests/101-verify-wide-math/op_l2d.j delete mode 100644 dx/tests/101-verify-wide-math/op_l2f.j delete mode 100644 dx/tests/101-verify-wide-math/op_l2i.j delete mode 100644 dx/tests/101-verify-wide-math/op_ladd.j delete mode 100644 dx/tests/101-verify-wide-math/op_land.j delete mode 100644 dx/tests/101-verify-wide-math/op_lcmp.j delete mode 100644 dx/tests/101-verify-wide-math/op_ldiv.j delete mode 100644 dx/tests/101-verify-wide-math/op_lmul.j delete mode 100644 dx/tests/101-verify-wide-math/op_lneg.j delete mode 100644 dx/tests/101-verify-wide-math/op_lor.j delete mode 100644 dx/tests/101-verify-wide-math/op_lrem.j delete mode 100644 dx/tests/101-verify-wide-math/op_lshl.j delete mode 100644 dx/tests/101-verify-wide-math/op_lshr.j delete mode 100644 dx/tests/101-verify-wide-math/op_lsub.j delete mode 100644 dx/tests/101-verify-wide-math/op_lushr.j delete mode 100644 dx/tests/101-verify-wide-math/op_lxor.j delete mode 100644 dx/tests/101-verify-wide-math/run delete mode 100644 dx/tests/102-verify-nonwide-math/expected.txt delete mode 100644 dx/tests/102-verify-nonwide-math/info.txt delete mode 100644 dx/tests/102-verify-nonwide-math/op_f2d.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_f2i.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_f2l.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_fadd.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_fdiv.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_fmul.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_fneg.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_frem.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_fsub.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_i2d.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_i2f.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_i2l.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_iadd.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_iand.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_idiv.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_imul.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_ineg.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_ior.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_irem.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_ishl.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_ishr.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_isub.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_iushr.j delete mode 100644 dx/tests/102-verify-nonwide-math/op_ixor.j delete mode 100644 dx/tests/102-verify-nonwide-math/run delete mode 100644 dx/tests/103-verify-branch-ops/expected.txt delete mode 100644 dx/tests/103-verify-branch-ops/info.txt delete mode 100644 dx/tests/103-verify-branch-ops/op_if_acmpeq.j delete mode 100644 dx/tests/103-verify-branch-ops/op_if_acmpne.j delete mode 100644 dx/tests/103-verify-branch-ops/op_if_icmpeq.j delete mode 100644 dx/tests/103-verify-branch-ops/op_if_icmpge.j delete mode 100644 dx/tests/103-verify-branch-ops/op_if_icmpgt.j delete mode 100644 dx/tests/103-verify-branch-ops/op_if_icmple.j delete mode 100644 dx/tests/103-verify-branch-ops/op_if_icmplt.j delete mode 100644 dx/tests/103-verify-branch-ops/op_if_icmpne.j delete mode 100644 dx/tests/103-verify-branch-ops/op_ifeq.j delete mode 100644 dx/tests/103-verify-branch-ops/op_ifge.j delete mode 100644 dx/tests/103-verify-branch-ops/op_ifgt.j delete mode 100644 dx/tests/103-verify-branch-ops/op_ifle.j delete mode 100644 dx/tests/103-verify-branch-ops/op_iflt.j delete mode 100644 dx/tests/103-verify-branch-ops/op_ifne.j delete mode 100644 dx/tests/103-verify-branch-ops/op_ifnonnull.j delete mode 100644 dx/tests/103-verify-branch-ops/op_ifnull.j delete mode 100644 dx/tests/103-verify-branch-ops/op_lookupswitch.j delete mode 100644 dx/tests/103-verify-branch-ops/op_tableswitch.j delete mode 100644 dx/tests/103-verify-branch-ops/run delete mode 100644 dx/tests/104-verify-return-ops/expected.txt delete mode 100644 dx/tests/104-verify-return-ops/info.txt delete mode 100644 dx/tests/104-verify-return-ops/op_areturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_dreturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_freturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_ireturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_lreturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_sig_areturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_sig_dreturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_sig_freturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_sig_ireturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_sig_lreturn.j delete mode 100644 dx/tests/104-verify-return-ops/op_sig_return.j delete mode 100644 dx/tests/104-verify-return-ops/run delete mode 100644 dx/tests/105-verify-load-store-ops/expected.txt delete mode 100644 dx/tests/105-verify-load-store-ops/info.txt delete mode 100644 dx/tests/105-verify-load-store-ops/op_aaload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_aastore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_astore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_astore_0.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_astore_1.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_astore_2.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_astore_3.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_baload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_bastore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_caload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_castore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_daload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_dastore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_dstore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_dstore_0.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_dstore_1.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_dstore_2.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_dstore_3.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_faload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_fastore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_fstore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_fstore_0.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_fstore_1.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_fstore_2.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_fstore_3.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_iaload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_iastore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_istore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_istore_0.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_istore_1.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_istore_2.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_istore_3.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_laload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_lastore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_lstore.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_lstore_0.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_lstore_1.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_lstore_2.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_lstore_3.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_saload.j delete mode 100644 dx/tests/105-verify-load-store-ops/op_sastore.j delete mode 100644 dx/tests/105-verify-load-store-ops/run delete mode 100644 dx/tests/106-verify-object-ops/expected.txt delete mode 100644 dx/tests/106-verify-object-ops/info.txt delete mode 100644 dx/tests/106-verify-object-ops/op_anewarray.j delete mode 100644 dx/tests/106-verify-object-ops/op_arraylength.j delete mode 100644 dx/tests/106-verify-object-ops/op_athrow.j delete mode 100644 dx/tests/106-verify-object-ops/op_checkcast.j delete mode 100644 dx/tests/106-verify-object-ops/op_getfield.j delete mode 100644 dx/tests/106-verify-object-ops/op_instanceof.j delete mode 100644 dx/tests/106-verify-object-ops/op_invokeinterface.j delete mode 100644 dx/tests/106-verify-object-ops/op_invokespecial.j delete mode 100644 dx/tests/106-verify-object-ops/op_invokestatic.j delete mode 100644 dx/tests/106-verify-object-ops/op_invokevirtual.j delete mode 100644 dx/tests/106-verify-object-ops/op_monitorenter.j delete mode 100644 dx/tests/106-verify-object-ops/op_monitorexit.j delete mode 100644 dx/tests/106-verify-object-ops/op_multianewarray.j delete mode 100644 dx/tests/106-verify-object-ops/op_newarray.j delete mode 100644 dx/tests/106-verify-object-ops/op_putfield.j delete mode 100644 dx/tests/106-verify-object-ops/op_putstatic.j delete mode 100644 dx/tests/106-verify-object-ops/run delete mode 100644 dx/tests/107-verify-stack-ops/expected.txt delete mode 100644 dx/tests/107-verify-stack-ops/info.txt delete mode 100644 dx/tests/107-verify-stack-ops/op_dup.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2_case1.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2_x1_case1.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2_x1_case2.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2_x1_case3.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2_x2_case1.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2_x2_case2.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup2_x2_case3.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup_x1_case1.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup_x1_case2.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup_x2_case1.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup_x2_case2.j delete mode 100644 dx/tests/107-verify-stack-ops/op_dup_x2_case3.j delete mode 100644 dx/tests/107-verify-stack-ops/op_pop.j delete mode 100644 dx/tests/107-verify-stack-ops/op_pop2.j delete mode 100644 dx/tests/107-verify-stack-ops/op_pop2_case2.j delete mode 100644 dx/tests/107-verify-stack-ops/op_swap_case1.j delete mode 100644 dx/tests/107-verify-stack-ops/op_swap_case2.j delete mode 100644 dx/tests/107-verify-stack-ops/run delete mode 100644 dx/tests/108-string-annotation/Blort.java delete mode 100644 dx/tests/108-string-annotation/Fizmo.java delete mode 100644 dx/tests/108-string-annotation/Frotz.java delete mode 100644 dx/tests/108-string-annotation/expected.txt delete mode 100644 dx/tests/108-string-annotation/info.txt delete mode 100644 dx/tests/108-string-annotation/run delete mode 100644 dx/tests/109-int-branch/blort.j delete mode 100644 dx/tests/109-int-branch/expected.txt delete mode 100644 dx/tests/109-int-branch/info.txt delete mode 100644 dx/tests/109-int-branch/run delete mode 100644 dx/tests/110-dex-preserve-this/Blort.java delete mode 100644 dx/tests/110-dex-preserve-this/expected.txt delete mode 100644 dx/tests/110-dex-preserve-this/info.txt delete mode 100644 dx/tests/110-dex-preserve-this/run delete mode 100755 dx/tests/run-all-tests delete mode 100755 dx/tests/run-test (limited to 'dx') diff --git a/dx/.classpath b/dx/.classpath deleted file mode 100644 index 5b6d9c718..000000000 --- a/dx/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/dx/.project b/dx/.project deleted file mode 100644 index bcae232c9..000000000 --- a/dx/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - dx - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/dx/Android.mk b/dx/Android.mk deleted file mode 100644 index 7ae0039c8..000000000 --- a/dx/Android.mk +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2006 The Android Open Source Project -# -LOCAL_PATH := $(call my-dir) - -# We use copy-file-to-new-target so that the installed -# script files' timestamps are at least as new as the -# .jar files they wrap. - -# the dx script -# ============================================================ -include $(CLEAR_VARS) -LOCAL_IS_HOST_MODULE := true -LOCAL_MODULE_CLASS := EXECUTABLES -LOCAL_MODULE := dx - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/dx$(COMMON_JAVA_PACKAGE_SUFFIX) -$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/dx | $(ACP) - @echo "Copy: $(PRIVATE_MODULE) ($@)" - $(copy-file-to-new-target) - $(hide) chmod 755 $@ - -INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE) - -# the jasmin script -# ============================================================ -include $(CLEAR_VARS) -LOCAL_IS_HOST_MODULE := true -LOCAL_MODULE_CLASS := EXECUTABLES -LOCAL_MODULE := jasmin - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/jasmin.jar -$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/jasmin | $(ACP) - @echo "Copy: $(PRIVATE_MODULE) ($@)" - $(copy-file-to-new-target) - $(hide) chmod 755 $@ - -INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE) - -# the jasmin lib -# ============================================================ -include $(CLEAR_VARS) -LOCAL_IS_HOST_MODULE := true -LOCAL_MODULE_CLASS := JAVA_LIBRARIES -LOCAL_MODULE := jasmin.jar - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/jasmin.jar | $(ACP) - @echo "Copy: $(PRIVATE_MODULE) ($@)" - $(copy-file-to-target) - $(hide) chmod 644 $@ - -INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE) - -# the other stuff -# ============================================================ -subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \ - src \ - )) - -include $(subdirs) diff --git a/dx/README.txt b/dx/README.txt deleted file mode 100644 index 5421e7ba5..000000000 --- a/dx/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -Home of Dalvik eXchange, the thing that takes in class files and -reformulates them for consumption in the VM. diff --git a/dx/etc/bytecode.txt b/dx/etc/bytecode.txt deleted file mode 100644 index f1df5bffb..000000000 --- a/dx/etc/bytecode.txt +++ /dev/null @@ -1,278 +0,0 @@ -# Copyright (C) 2007 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Bytecode definition file -# -# Columns are: -# hex for opcode -# format -# has result register (y/n) -# opcode name - -00 10x n nop -01 12x y move -02 22x y move/from16 -03 32x y move/16 -04 12x y move-wide -05 22x y move-wide/from16 -06 32x y move-wide/16 -07 12x y move-object -08 22x y move-object/from16 -09 32x y move-object/16 -0a 11x y move-result -0b 11x y move-result-wide -0c 11x y move-result-object -0d 11x y move-exception -0e 10x n return-void -0f 11x n return -10 11x n return-wide -11 11x n return-object -12 11n y const/4 -13 21s y const/16 -14 31i y const -15 21h y const/high16 -16 21s y const-wide/16 -17 31i y const-wide/32 -18 51l y const-wide -19 21h y const-wide/high16 -1a 21c y const-string -1b 31c y const-string/jumbo -1c 21c y const-class -1d 11x n monitor-enter -1e 11x n monitor-exit -1f 21c y check-cast -20 22c y instance-of -21 12x y array-length -22 21c y new-instance -23 22c y new-array -24 35c n filled-new-array -25 3rc n filled-new-array/range -26 31t n fill-array-data -27 11x n throw -28 10t n goto -29 20t n goto/16 -2a 30t n goto/32 -2b 31t n packed-switch -2c 31t n sparse-switch -2d 23x y cmpl-float -2e 23x y cmpg-float -2f 23x y cmpl-double -30 23x y cmpg-double -31 23x y cmp-long -32 22t n if-eq -33 22t n if-ne -34 22t n if-lt -35 22t n if-ge -36 22t n if-gt -37 22t n if-le -38 21t n if-eqz -39 21t n if-nez -3a 21t n if-ltz -3b 21t n if-gez -3c 21t n if-gtz -3d 21t n if-lez -3e 10x n unused-3e -3f 10x n unused-3f -40 10x n unused-40 -41 10x n unused-41 -42 10x n unused-42 -43 10x n unused-43 -44 23x y aget -45 23x y aget-wide -46 23x y aget-object -47 23x y aget-boolean -48 23x y aget-byte -49 23x y aget-char -4a 23x y aget-short -4b 23x n aput -4c 23x n aput-wide -4d 23x n aput-object -4e 23x n aput-boolean -4f 23x n aput-byte -50 23x n aput-char -51 23x n aput-short -52 22c y iget -53 22c y iget-wide -54 22c y iget-object -55 22c y iget-boolean -56 22c y iget-byte -57 22c y iget-char -58 22c y iget-short -59 22c n iput -5a 22c n iput-wide -5b 22c n iput-object -5c 22c n iput-boolean -5d 22c n iput-byte -5e 22c n iput-char -5f 22c n iput-short -60 21c y sget -61 21c y sget-wide -62 21c y sget-object -63 21c y sget-boolean -64 21c y sget-byte -65 21c y sget-char -66 21c y sget-short -67 21c n sput -68 21c n sput-wide -69 21c n sput-object -6a 21c n sput-boolean -6b 21c n sput-byte -6c 21c n sput-char -6d 21c n sput-short -6e 35c n invoke-virtual -6f 35c n invoke-super -70 35c n invoke-direct -71 35c n invoke-static -72 35c n invoke-interface -73 10x n unused-73 -74 3rc n invoke-virtual/range -75 3rc n invoke-super/range -76 3rc n invoke-direct/range -77 3rc n invoke-static/range -78 3rc n invoke-interface/range -79 10x n unused-79 -7a 10x n unused-7a -7b 12x y neg-int -7c 12x y not-int -7d 12x y neg-long -7e 12x y not-long -7f 12x y neg-float -80 12x y neg-double -81 12x y int-to-long -82 12x y int-to-float -83 12x y int-to-double -84 12x y long-to-int -85 12x y long-to-float -86 12x y long-to-double -87 12x y float-to-int -88 12x y float-to-long -89 12x y float-to-double -8a 12x y double-to-int -8b 12x y double-to-long -8c 12x y double-to-float -8d 12x y int-to-byte -8e 12x y int-to-char -8f 12x y int-to-short -90 23x y add-int -91 23x y sub-int -92 23x y mul-int -93 23x y div-int -94 23x y rem-int -95 23x y and-int -96 23x y or-int -97 23x y xor-int -98 23x y shl-int -99 23x y shr-int -9a 23x y ushr-int -9b 23x y add-long -9c 23x y sub-long -9d 23x y mul-long -9e 23x y div-long -9f 23x y rem-long -a0 23x y and-long -a1 23x y or-long -a2 23x y xor-long -a3 23x y shl-long -a4 23x y shr-long -a5 23x y ushr-long -a6 23x y add-float -a7 23x y sub-float -a8 23x y mul-float -a9 23x y div-float -aa 23x y rem-float -ab 23x y add-double -ac 23x y sub-double -ad 23x y mul-double -ae 23x y div-double -af 23x y rem-double -b0 12x y add-int/2addr -b1 12x y sub-int/2addr -b2 12x y mul-int/2addr -b3 12x y div-int/2addr -b4 12x y rem-int/2addr -b5 12x y and-int/2addr -b6 12x y or-int/2addr -b7 12x y xor-int/2addr -b8 12x y shl-int/2addr -b9 12x y shr-int/2addr -ba 12x y ushr-int/2addr -bb 12x y add-long/2addr -bc 12x y sub-long/2addr -bd 12x y mul-long/2addr -be 12x y div-long/2addr -bf 12x y rem-long/2addr -c0 12x y and-long/2addr -c1 12x y or-long/2addr -c2 12x y xor-long/2addr -c3 12x y shl-long/2addr -c4 12x y shr-long/2addr -c5 12x y ushr-long/2addr -c6 12x y add-float/2addr -c7 12x y sub-float/2addr -c8 12x y mul-float/2addr -c9 12x y div-float/2addr -ca 12x y rem-float/2addr -cb 12x y add-double/2addr -cc 12x y sub-double/2addr -cd 12x y mul-double/2addr -ce 12x y div-double/2addr -cf 12x y rem-double/2addr -d0 22s y add-int/lit16 -d1 22s y rsub-int -d2 22s y mul-int/lit16 -d3 22s y div-int/lit16 -d4 22s y rem-int/lit16 -d5 22s y and-int/lit16 -d6 22s y or-int/lit16 -d7 22s y xor-int/lit16 -d8 22b y add-int/lit8 -d9 22b y rsub-int/lit8 -da 22b y mul-int/lit8 -db 22b y div-int/lit8 -dc 22b y rem-int/lit8 -dd 22b y and-int/lit8 -de 22b y or-int/lit8 -df 22b y xor-int/lit8 -e0 22b y shl-int/lit8 -e1 22b y shr-int/lit8 -e2 22b y ushr-int/lit8 -e3 10x n unused-e3 -e4 10x n unused-e4 -e5 10x n unused-e5 -e6 10x n unused-e6 -e7 10x n unused-e7 -e8 10x n unused-e8 -e9 10x n unused-e9 -ea 10x n unused-ea -eb 10x n unused-eb -ec 10x n unused-ec -ed 10x n unused-ed -ee 10x n unused-ee -ef 10x n unused-ef -f0 10x n unused-f0 -f1 10x n unused-f1 -f2 10x n unused-f2 -f3 10x n unused-f3 -f4 10x n unused-f4 -f5 10x n unused-f5 -f6 10x n unused-f6 -f7 10x n unused-f7 -f8 10x n unused-f8 -f9 10x n unused-f9 -fa 10x n unused-fa -fb 10x n unused-fb -fc 10x n unused-fc -fd 10x n unused-fd -fe 10x n unused-fe -ff 10x n unused-ff diff --git a/dx/etc/dx b/dx/etc/dx deleted file mode 100644 index dae587490..000000000 --- a/dx/etc/dx +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2007 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Set up prog to be the path of this script, including following symlinks, -# and set up progdir to be the fully-qualified pathname of its directory. -prog="$0" -while [ -h "${prog}" ]; do - newProg=`/bin/ls -ld "${prog}"` - newProg=`expr "${newProg}" : ".* -> \(.*\)$"` - if expr "x${newProg}" : 'x/' >/dev/null; then - prog="${newProg}" - else - progdir=`dirname "${prog}"` - prog="${progdir}/${newProg}" - fi -done -oldwd=`pwd` -progdir=`dirname "${prog}"` -cd "${progdir}" -progdir=`pwd` -prog="${progdir}"/`basename "${prog}"` -cd "${oldwd}" - -jarfile=dx.jar -libdir="$progdir" -if [ ! -r "$libdir/$jarfile" ] -then - libdir=`dirname "$progdir"`/tools/lib -fi -if [ ! -r "$libdir/$jarfile" ] -then - libdir=`dirname "$progdir"`/framework -fi -if [ ! -r "$libdir/$jarfile" ] -then - echo `basename "$prog"`": can't find $jarfile" - exit 1 -fi - -javaOpts="" - -# If you want DX to have more memory when executing, uncomment the following -# line and adjust the value accordingly. Use "java -X" for a list of options -# you can pass here. -# -# javaOpts="-Xmx256M" - -# Alternatively, this will extract any parameter "-Jxxx" from the command line -# and pass them to Java (instead of to dx). This makes it possible for you to -# add a command-line parameter such as "-JXmx256M" in your ant scripts, for -# example. -while expr "x$1" : 'x-J' >/dev/null; do - opt=`expr "$1" : '-J\(.*\)'` - javaOpts="${javaOpts} -${opt}" - shift -done - -if [ "$OSTYPE" = "cygwin" ] ; then - jarpath=`cygpath -w "$libdir/$jarfile"` -else - jarpath="$libdir/$jarfile" -fi - -exec java $javaOpts -jar "$jarpath" "$@" diff --git a/dx/etc/dx.bat b/dx/etc/dx.bat deleted file mode 100755 index 2686d6a3b..000000000 --- a/dx/etc/dx.bat +++ /dev/null @@ -1,51 +0,0 @@ -@echo off -REM Copyright (C) 2007 The Android Open Source Project -REM -REM Licensed under the Apache License, Version 2.0 (the "License"); -REM you may not use this file except in compliance with the License. -REM You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. - -REM don't modify the caller's environment -setlocal - -REM Locate dx.jar in the directory where dx.bat was found and start it. - -REM Set up prog to be the path of this script, including following symlinks, -REM and set up progdir to be the fully-qualified pathname of its directory. -set prog=%~f0 - -REM Change current directory to where dx is, to avoid issues with directories -REM containing whitespaces. -cd /d %~dp0 - -set jarfile=dx.jar -set frameworkdir= - -if exist %frameworkdir%%jarfile% goto JarFileOk - set frameworkdir=lib\ - -if exist %frameworkdir%%jarfile% goto JarFileOk - set frameworkdir=..\framework\ - -:JarFileOk - -set jarpath=%frameworkdir%%jarfile% - -set javaOpts= - -REM If you want DX to have more memory when executing, uncomment the -REM following line and adjust the value accordingly. Use "java -X" for -REM a list of options you can pass here. -REM -REM set javaOpts=-Xmx256M - -call java %javaOpts% -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %* - diff --git a/dx/etc/jasmin b/dx/etc/jasmin deleted file mode 100644 index f44c16f6c..000000000 --- a/dx/etc/jasmin +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2007 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Set up prog to be the path of this script, including following symlinks, -# and set up progdir to be the fully-qualified pathname of its directory. -prog="$0" -while [ -h "${prog}" ]; do - newProg=`/bin/ls -ld "${prog}"` - newProg=`expr "${newProg}" : ".* -> \(.*\)$"` - if expr "x${newProg}" : 'x/' >/dev/null; then - prog="${newProg}" - else - progdir=`dirname "${prog}"` - prog="${progdir}/${newProg}" - fi -done -oldwd=`pwd` -progdir=`dirname "${prog}"` -cd "${progdir}" -progdir=`pwd` -prog="${progdir}"/`basename "${prog}"` -cd "${oldwd}" - -libdir=`dirname $progdir`/framework - -exec java -jar $libdir/jasmin.jar "$@" diff --git a/dx/etc/jasmin.jar b/dx/etc/jasmin.jar deleted file mode 100644 index 87db0d034..000000000 Binary files a/dx/etc/jasmin.jar and /dev/null differ diff --git a/dx/etc/manifest.txt b/dx/etc/manifest.txt deleted file mode 100644 index 46bbe63a1..000000000 --- a/dx/etc/manifest.txt +++ /dev/null @@ -1 +0,0 @@ -Main-Class: com.android.dx.command.Main diff --git a/dx/etc/opcode-gen b/dx/etc/opcode-gen deleted file mode 100755 index 390a6c329..000000000 --- a/dx/etc/opcode-gen +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2007 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# opcode-gen -# -# Use the file bytecodes.txt to generate code inside , based on -# the directives found in that file: -# -# opcodes: static final ints for each opcode -# dops: static final objects for each opcode -# dops-init: initialization code for the "dops" - -file="$1" -tmpfile="/tmp/$$.txt" - -if [ "x$1" = "x" ]; then - echo "must specify a file" - exit 1 -fi - -# Set up prog to be the path of this script, including following symlinks, -# and set up progdir to be the fully-qualified pathname of its directory. -prog="$0" -while [ -h "${prog}" ]; do - newProg=`/bin/ls -ld "${prog}"` - newProg=`expr "${newProg}" : ".* -> \(.*\)$"` - if expr "x${newProg}" : 'x/' >/dev/null; then - prog="${newProg}" - else - progdir=`dirname "${prog}"` - prog="${progdir}/${newProg}" - fi -done -oldwd=`pwd` -progdir=`dirname "${prog}"` -cd "${progdir}" -progdir=`pwd` -prog="${progdir}"/`basename "${prog}"` -cd "${oldwd}" - -bytecodeFile="$progdir/bytecode.txt" - -awk -v "bytecodeFile=$bytecodeFile" ' - -BEGIN { - readBytecodes(); - consumeUntil = ""; -} - -consumeUntil != "" { - if (index($0, consumeUntil) != 0) { - consumeUntil = ""; - } else { - next; - } -} - -/BEGIN\(opcodes\)/ { - consumeUntil = "END(opcodes)"; - print; - - for (i = 0; i < 256; i++) { - printf(" public static final int %s = 0x%s;\n", - uppername[i], hex[i]); - } - - next; -} - -/BEGIN\(dops\)/ { - consumeUntil = "END(dops)"; - print; - - for (i = 0; i < 256; i++) { - if (index(name[i], "unused") != 0) { - continue; - } - printf(" public static final Dop %s =\n" \ - " new Dop(DalvOps.%s, DalvOps.%s,\n" \ - " Form%s.THE_ONE, %s, \"%s\");\n\n", - uppername[i], uppername[i], family[i], format[i], hasres[i], - name[i]); - } - - next; -} - -/BEGIN\(dops-init\)/ { - consumeUntil = "END(dops-init)"; - print; - - for (i = 0; i < 256; i++) { - if (index(name[i], "unused") != 0) { - continue; - } - printf(" set(%s);\n", uppername[i]); - } - - next; -} - -{ print; } - -function readBytecodes(i, parts) { - for (i = 0; i < 256; i++) { - $0 = ""; - while (($0 == "") || (index($0, "#") != 0)) { - if ((getline "$tmpfile" - -cp "$tmpfile" "$file" -rm "$tmpfile" diff --git a/dx/etc/run-opcode-gen b/dx/etc/run-opcode-gen deleted file mode 100755 index 70e970778..000000000 --- a/dx/etc/run-opcode-gen +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2007 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Run this from this directory. - -./opcode-gen ../src/com/android/dx/dex/code/DalvOps.java -./opcode-gen ../src/com/android/dx/dex/code/Dops.java - - diff --git a/dx/src/Android.mk b/dx/src/Android.mk deleted file mode 100644 index ef3d32d14..000000000 --- a/dx/src/Android.mk +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2006 The Android Open Source Project -# -LOCAL_PATH := $(call my-dir) - - -# dx java library -# ============================================================ -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-subdir-java-files) -LOCAL_JAR_MANIFEST := ../etc/manifest.txt - -LOCAL_MODULE:= dx - -include $(BUILD_HOST_JAVA_LIBRARY) - -INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE) - -# the documentation -# ============================================================ -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-subdir-java-files) $(call all-subdir-html-files) - -LOCAL_MODULE:= dx -LOCAL_DROIDDOC_OPTIONS := -hidden -LOCAL_MODULE_CLASS := JAVA_LIBRARIES -LOCAL_IS_HOST_MODULE := true - -include $(BUILD_DROIDDOC) - diff --git a/dx/src/com/android/dx/Version.java b/dx/src/com/android/dx/Version.java deleted file mode 100644 index 02dc7b248..000000000 --- a/dx/src/com/android/dx/Version.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx; - -/** - * Version number for dx. - */ -public class Version { - /** non-null; version string */ - public static final String VERSION = "1.2"; -} diff --git a/dx/src/com/android/dx/cf/attrib/AttAnnotationDefault.java b/dx/src/com/android/dx/cf/attrib/AttAnnotationDefault.java deleted file mode 100644 index 12e1f74ba..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttAnnotationDefault.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.cst.Constant; - -/** - * Attribute class for AnnotationDefault attributes. - */ -public final class AttAnnotationDefault extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "AnnotationDefault"; - - /** non-null; the annotation default value */ - private final Constant value; - - /** >= 0; attribute data length in the original classfile (not - * including the attribute header) */ - private final int byteLength; - - /** - * Constructs an instance. - * - * @param value non-null; the annotation default value - * @param byteLength >= 0; attribute data length in the original - * classfile (not including the attribute header) - */ - public AttAnnotationDefault(Constant value, int byteLength) { - super(ATTRIBUTE_NAME); - - if (value == null) { - throw new NullPointerException("value == null"); - } - - this.value = value; - this.byteLength = byteLength; - } - - /** {@inheritDoc} */ - public int byteLength() { - // Add six for the standard attribute header. - return byteLength + 6; - } - - /** - * Gets the annotation default value. - * - * @return non-null; the value - */ - public Constant getValue() { - return value; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttCode.java b/dx/src/com/android/dx/cf/attrib/AttCode.java deleted file mode 100644 index f00da2fde..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttCode.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.cf.code.ByteCatchList; -import com.android.dx.cf.code.BytecodeArray; -import com.android.dx.cf.iface.AttributeList; -import com.android.dx.util.MutabilityException; - -/** - * Attribute class for standard Code attributes. - */ -public final class AttCode extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "Code"; - - /** >= 0; the stack size */ - private final int maxStack; - - /** >= 0; the number of locals */ - private final int maxLocals; - - /** non-null; array containing the bytecode per se */ - private final BytecodeArray code; - - /** non-null; the exception table */ - private final ByteCatchList catches; - - /** non-null; the associated list of attributes */ - private final AttributeList attributes; - - /** - * Constructs an instance. - * - * @param maxStack >= 0; the stack size - * @param maxLocals >= 0; the number of locals - * @param code non-null; array containing the bytecode per se - * @param catches non-null; the exception table - * @param attributes non-null; the associated list of attributes - */ - public AttCode(int maxStack, int maxLocals, BytecodeArray code, - ByteCatchList catches, AttributeList attributes) { - super(ATTRIBUTE_NAME); - - if (maxStack < 0) { - throw new IllegalArgumentException("maxStack < 0"); - } - - if (maxLocals < 0) { - throw new IllegalArgumentException("maxLocals < 0"); - } - - if (code == null) { - throw new NullPointerException("code == null"); - } - - try { - if (catches.isMutable()) { - throw new MutabilityException("catches.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("catches == null"); - } - - try { - if (attributes.isMutable()) { - throw new MutabilityException("attributes.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("attributes == null"); - } - - this.maxStack = maxStack; - this.maxLocals = maxLocals; - this.code = code; - this.catches = catches; - this.attributes = attributes; - } - - public int byteLength() { - return 10 + code.byteLength() + catches.byteLength() + - attributes.byteLength(); - } - - /** - * Gets the maximum stack size. - * - * @return >= 0; the maximum stack size - */ - public int getMaxStack() { - return maxStack; - } - - /** - * Gets the number of locals. - * - * @return >= 0; the number of locals - */ - public int getMaxLocals() { - return maxLocals; - } - - /** - * Gets the bytecode array. - * - * @return non-null; the bytecode array - */ - public BytecodeArray getCode() { - return code; - } - - /** - * Gets the exception table. - * - * @return non-null; the exception table - */ - public ByteCatchList getCatches() { - return catches; - } - - /** - * Gets the associated attribute list. - * - * @return non-null; the attribute list - */ - public AttributeList getAttributes() { - return attributes; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttConstantValue.java b/dx/src/com/android/dx/cf/attrib/AttConstantValue.java deleted file mode 100644 index a84da4342..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttConstantValue.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.cst.CstDouble; -import com.android.dx.rop.cst.CstFloat; -import com.android.dx.rop.cst.CstInteger; -import com.android.dx.rop.cst.CstLong; -import com.android.dx.rop.cst.CstString; -import com.android.dx.rop.cst.TypedConstant; - -/** - * Attribute class for standard ConstantValue attributes. - */ -public final class AttConstantValue extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "ConstantValue"; - - /** non-null; the constant value */ - private final TypedConstant constantValue; - - /** - * Constructs an instance. - * - * @param constantValue non-null; the constant value, which must - * be an instance of one of: CstString, - * CstInteger, CstLong, - * CstFloat, or CstDouble - */ - public AttConstantValue(TypedConstant constantValue) { - super(ATTRIBUTE_NAME); - - if (!((constantValue instanceof CstString) || - (constantValue instanceof CstInteger) || - (constantValue instanceof CstLong) || - (constantValue instanceof CstFloat) || - (constantValue instanceof CstDouble))) { - if (constantValue == null) { - throw new NullPointerException("constantValue == null"); - } - throw new IllegalArgumentException("bad type for constantValue"); - } - - this.constantValue = constantValue; - } - - /** {@inheritDoc} */ - public int byteLength() { - return 8; - } - - /** - * Gets the constant value of this instance. The returned value - * is an instance of one of: CstString, - * CstInteger, CstLong, - * CstFloat, or CstDouble. - * - * @return non-null; the constant value - */ - public TypedConstant getConstantValue() { - return constantValue; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttDeprecated.java b/dx/src/com/android/dx/cf/attrib/AttDeprecated.java deleted file mode 100644 index cd1dd2463..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttDeprecated.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -/** - * Attribute class for standard Deprecated attributes. - */ -public final class AttDeprecated extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "Deprecated"; - - /** - * Constructs an instance. - */ - public AttDeprecated() { - super(ATTRIBUTE_NAME); - } - - /** {@inheritDoc} */ - public int byteLength() { - return 6; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttEnclosingMethod.java b/dx/src/com/android/dx/cf/attrib/AttEnclosingMethod.java deleted file mode 100644 index 7cccad703..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttEnclosingMethod.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; - -/** - * Attribute class for standards-track EnclosingMethod - * attributes. - */ -public final class AttEnclosingMethod extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "EnclosingMethod"; - - /** non-null; the innermost enclosing class */ - private final CstType type; - - /** null-ok; the name-and-type of the innermost enclosing method, if any */ - private final CstNat method; - - /** - * Constructs an instance. - * - * @param type non-null; the innermost enclosing class - * @param method null-ok; the name-and-type of the innermost enclosing - * method, if any - */ - public AttEnclosingMethod(CstType type, CstNat method) { - super(ATTRIBUTE_NAME); - - if (type == null) { - throw new NullPointerException("type == null"); - } - - this.type = type; - this.method = method; - } - - /** {@inheritDoc} */ - public int byteLength() { - return 10; - } - - /** - * Gets the innermost enclosing class. - * - * @return non-null; the innermost enclosing class - */ - public CstType getEnclosingClass() { - return type; - } - - /** - * Gets the name-and-type of the innermost enclosing method, if - * any. - * - * @return null-ok; the name-and-type of the innermost enclosing - * method, if any - */ - public CstNat getMethod() { - return method; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttExceptions.java b/dx/src/com/android/dx/cf/attrib/AttExceptions.java deleted file mode 100644 index 59e624ef8..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttExceptions.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.type.TypeList; -import com.android.dx.util.MutabilityException; - -/** - * Attribute class for standard Exceptions attributes. - */ -public final class AttExceptions extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "Exceptions"; - - /** non-null; list of exception classes */ - private final TypeList exceptions; - - /** - * Constructs an instance. - * - * @param exceptions non-null; list of classes, presumed but not - * verified to be subclasses of Throwable - */ - public AttExceptions(TypeList exceptions) { - super(ATTRIBUTE_NAME); - - try { - if (exceptions.isMutable()) { - throw new MutabilityException("exceptions.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("exceptions == null"); - } - - this.exceptions = exceptions; - } - - /** {@inheritDoc} */ - public int byteLength() { - return 8 + exceptions.size() * 2; - } - - /** - * Gets the list of classes associated with this instance. In - * general, these classes are not pre-verified to be subclasses of - * Throwable. - * - * @return non-null; the list of classes - */ - public TypeList getExceptions() { - return exceptions; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttInnerClasses.java b/dx/src/com/android/dx/cf/attrib/AttInnerClasses.java deleted file mode 100644 index df305395b..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttInnerClasses.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.util.MutabilityException; - -/** - * Attribute class for standard InnerClasses attributes. - */ -public final class AttInnerClasses extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "InnerClasses"; - - /** non-null; list of inner class entries */ - private final InnerClassList innerClasses; - - /** - * Constructs an instance. - * - * @param innerClasses non-null; list of inner class entries - */ - public AttInnerClasses(InnerClassList innerClasses) { - super(ATTRIBUTE_NAME); - - try { - if (innerClasses.isMutable()) { - throw new MutabilityException("innerClasses.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("innerClasses == null"); - } - - this.innerClasses = innerClasses; - } - - /** {@inheritDoc} */ - public int byteLength() { - return 8 + innerClasses.size() * 8; - } - - /** - * Gets the list of "inner class" entries associated with this instance. - * - * @return non-null; the list - */ - public InnerClassList getInnerClasses() { - return innerClasses; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttLineNumberTable.java b/dx/src/com/android/dx/cf/attrib/AttLineNumberTable.java deleted file mode 100644 index c5e65e80d..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttLineNumberTable.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.cf.code.LineNumberList; -import com.android.dx.util.MutabilityException; - -/** - * Attribute class for standard LineNumberTable attributes. - */ -public final class AttLineNumberTable extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "LineNumberTable"; - - /** non-null; list of line number entries */ - private final LineNumberList lineNumbers; - - /** - * Constructs an instance. - * - * @param lineNumbers non-null; list of line number entries - */ - public AttLineNumberTable(LineNumberList lineNumbers) { - super(ATTRIBUTE_NAME); - - try { - if (lineNumbers.isMutable()) { - throw new MutabilityException("lineNumbers.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("lineNumbers == null"); - } - - this.lineNumbers = lineNumbers; - } - - /** {@inheritDoc} */ - public int byteLength() { - return 8 + 4 * lineNumbers.size(); - } - - /** - * Gets the list of "line number" entries associated with this instance. - * - * @return non-null; the list - */ - public LineNumberList getLineNumbers() { - return lineNumbers; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttLocalVariableTable.java b/dx/src/com/android/dx/cf/attrib/AttLocalVariableTable.java deleted file mode 100644 index 893f25477..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttLocalVariableTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.cf.code.LocalVariableList; - -/** - * Attribute class for standard LocalVariableTable attributes. - */ -public final class AttLocalVariableTable extends BaseLocalVariables { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "LocalVariableTable"; - - /** - * Constructs an instance. - * - * @param localVariables non-null; list of local variable entries - */ - public AttLocalVariableTable(LocalVariableList localVariables) { - super(ATTRIBUTE_NAME, localVariables); - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttLocalVariableTypeTable.java b/dx/src/com/android/dx/cf/attrib/AttLocalVariableTypeTable.java deleted file mode 100644 index 7037b7401..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttLocalVariableTypeTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.cf.code.LocalVariableList; - -/** - * Attribute class for standard LocalVariableTypeTable attributes. - */ -public final class AttLocalVariableTypeTable extends BaseLocalVariables { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "LocalVariableTypeTable"; - - /** - * Constructs an instance. - * - * @param localVariables non-null; list of local variable entries - */ - public AttLocalVariableTypeTable(LocalVariableList localVariables) { - super(ATTRIBUTE_NAME, localVariables); - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleAnnotations.java b/dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleAnnotations.java deleted file mode 100644 index 583ab17be..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleAnnotations.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.annotation.Annotations; - -/** - * Attribute class for standard RuntimeInvisibleAnnotations - * attributes. - */ -public final class AttRuntimeInvisibleAnnotations extends BaseAnnotations { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "RuntimeInvisibleAnnotations"; - - /** - * Constructs an instance. - * - * @param annotations non-null; the list of annotations - * @param byteLength >= 0; attribute data length in the original - * classfile (not including the attribute header) - */ - public AttRuntimeInvisibleAnnotations(Annotations annotations, - int byteLength) { - super(ATTRIBUTE_NAME, annotations, byteLength); - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleParameterAnnotations.java b/dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleParameterAnnotations.java deleted file mode 100644 index 08865e153..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttRuntimeInvisibleParameterAnnotations.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.annotation.AnnotationsList; - -/** - * Attribute class for standard - * RuntimeInvisibleParameterAnnotations attributes. - */ -public final class AttRuntimeInvisibleParameterAnnotations - extends BaseParameterAnnotations { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = - "RuntimeInvisibleParameterAnnotations"; - - /** - * Constructs an instance. - * - * @param parameterAnnotations non-null; the parameter annotations - * @param byteLength >= 0; attribute data length in the original - * classfile (not including the attribute header) - */ - public AttRuntimeInvisibleParameterAnnotations( - AnnotationsList parameterAnnotations, int byteLength) { - super(ATTRIBUTE_NAME, parameterAnnotations, byteLength); - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleAnnotations.java b/dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleAnnotations.java deleted file mode 100644 index c61acb5c2..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleAnnotations.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.annotation.Annotations; - -/** - * Attribute class for standard RuntimeVisibleAnnotations - * attributes. - */ -public final class AttRuntimeVisibleAnnotations extends BaseAnnotations { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "RuntimeVisibleAnnotations"; - - /** - * Constructs an instance. - * - * @param annotations non-null; the list of annotations - * @param byteLength >= 0; attribute data length in the original - * classfile (not including the attribute header) - */ - public AttRuntimeVisibleAnnotations(Annotations annotations, - int byteLength) { - super(ATTRIBUTE_NAME, annotations, byteLength); - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleParameterAnnotations.java b/dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleParameterAnnotations.java deleted file mode 100644 index dfe57b2b6..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttRuntimeVisibleParameterAnnotations.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.annotation.AnnotationsList; - -/** - * Attribute class for standard RuntimeVisibleParameterAnnotations - * attributes. - */ -public final class AttRuntimeVisibleParameterAnnotations - extends BaseParameterAnnotations { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = - "RuntimeVisibleParameterAnnotations"; - - /** - * Constructs an instance. - * - * @param annotations non-null; the parameter annotations - * @param byteLength >= 0; attribute data length in the original - * classfile (not including the attribute header) - */ - public AttRuntimeVisibleParameterAnnotations( - AnnotationsList annotations, int byteLength) { - super(ATTRIBUTE_NAME, annotations, byteLength); - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttSignature.java b/dx/src/com/android/dx/cf/attrib/AttSignature.java deleted file mode 100644 index 97edbbdd0..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttSignature.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.cst.CstUtf8; - -/** - * Attribute class for standards-track Signature attributes. - */ -public final class AttSignature extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "Signature"; - - /** non-null; the signature string */ - private final CstUtf8 signature; - - /** - * Constructs an instance. - * - * @param signature non-null; the signature string - */ - public AttSignature(CstUtf8 signature) { - super(ATTRIBUTE_NAME); - - if (signature == null) { - throw new NullPointerException("signature == null"); - } - - this.signature = signature; - } - - /** {@inheritDoc} */ - public int byteLength() { - return 8; - } - - /** - * Gets the signature string. - * - * @return non-null; the signature string - */ - public CstUtf8 getSignature() { - return signature; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttSourceFile.java b/dx/src/com/android/dx/cf/attrib/AttSourceFile.java deleted file mode 100644 index f0872178f..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttSourceFile.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.cst.CstUtf8; - -/** - * Attribute class for standard SourceFile attributes. - */ -public final class AttSourceFile extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "SourceFile"; - - /** non-null; name of the source file */ - private final CstUtf8 sourceFile; - - /** - * Constructs an instance. - * - * @param sourceFile non-null; the name of the source file - */ - public AttSourceFile(CstUtf8 sourceFile) { - super(ATTRIBUTE_NAME); - - if (sourceFile == null) { - throw new NullPointerException("sourceFile == null"); - } - - this.sourceFile = sourceFile; - } - - /** {@inheritDoc} */ - public int byteLength() { - return 8; - } - - /** - * Gets the source file name of this instance. - * - * @return non-null; the source file - */ - public CstUtf8 getSourceFile() { - return sourceFile; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/AttSynthetic.java b/dx/src/com/android/dx/cf/attrib/AttSynthetic.java deleted file mode 100644 index daa9b0c23..000000000 --- a/dx/src/com/android/dx/cf/attrib/AttSynthetic.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -/** - * Attribute class for standard Synthetic attributes. - */ -public final class AttSynthetic extends BaseAttribute { - /** non-null; attribute name for attributes of this type */ - public static final String ATTRIBUTE_NAME = "Synthetic"; - - /** - * Constructs an instance. - */ - public AttSynthetic() { - super(ATTRIBUTE_NAME); - } - - /** {@inheritDoc} */ - public int byteLength() { - return 6; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/BaseAnnotations.java b/dx/src/com/android/dx/cf/attrib/BaseAnnotations.java deleted file mode 100644 index 0163e2cb4..000000000 --- a/dx/src/com/android/dx/cf/attrib/BaseAnnotations.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.annotation.Annotations; -import com.android.dx.util.MutabilityException; - -/** - * Base class for annotations attributes. - */ -public abstract class BaseAnnotations extends BaseAttribute { - /** non-null; list of annotations */ - private final Annotations annotations; - - /** >= 0; attribute data length in the original classfile (not - * including the attribute header) */ - private final int byteLength; - - /** - * Constructs an instance. - * - * @param attributeName non-null; the name of the attribute - * @param annotations non-null; the list of annotations - * @param byteLength >= 0; attribute data length in the original - * classfile (not including the attribute header) - */ - public BaseAnnotations(String attributeName, Annotations annotations, - int byteLength) { - super(attributeName); - - try { - if (annotations.isMutable()) { - throw new MutabilityException("annotations.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("annotations == null"); - } - - this.annotations = annotations; - this.byteLength = byteLength; - } - - /** {@inheritDoc} */ - public final int byteLength() { - // Add six for the standard attribute header. - return byteLength + 6; - } - - /** - * Gets the list of annotations associated with this instance. - * - * @return non-null; the list - */ - public final Annotations getAnnotations() { - return annotations; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/BaseAttribute.java b/dx/src/com/android/dx/cf/attrib/BaseAttribute.java deleted file mode 100644 index ef1c6ac0d..000000000 --- a/dx/src/com/android/dx/cf/attrib/BaseAttribute.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.cf.iface.Attribute; - -/** - * Base implementation of {@link Attribute}, which directly stores - * the attribute name but leaves the rest up to subclasses. - */ -public abstract class BaseAttribute implements Attribute { - /** non-null; attribute name */ - private final String name; - - /** - * Constructs an instance. - * - * @param name non-null; attribute name - */ - public BaseAttribute(String name) { - if (name == null) { - throw new NullPointerException("name == null"); - } - - this.name = name; - } - - /** {@inheritDoc} */ - public String getName() { - return name; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/BaseLocalVariables.java b/dx/src/com/android/dx/cf/attrib/BaseLocalVariables.java deleted file mode 100644 index a39e72438..000000000 --- a/dx/src/com/android/dx/cf/attrib/BaseLocalVariables.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.cf.code.LocalVariableList; -import com.android.dx.util.MutabilityException; - -/** - * Base attribute class for standard LocalVariableTable - * and LocalVariableTypeTable attributes. - */ -public abstract class BaseLocalVariables extends BaseAttribute { - /** non-null; list of local variable entries */ - private final LocalVariableList localVariables; - - /** - * Constructs an instance. - * - * @param name non-null; attribute name - * @param localVariables non-null; list of local variable entries - */ - public BaseLocalVariables(String name, - LocalVariableList localVariables) { - super(name); - - try { - if (localVariables.isMutable()) { - throw new MutabilityException("localVariables.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("localVariables == null"); - } - - this.localVariables = localVariables; - } - - /** {@inheritDoc} */ - public final int byteLength() { - return 8 + localVariables.size() * 10; - } - - /** - * Gets the list of "local variable" entries associated with this instance. - * - * @return non-null; the list - */ - public final LocalVariableList getLocalVariables() { - return localVariables; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/BaseParameterAnnotations.java b/dx/src/com/android/dx/cf/attrib/BaseParameterAnnotations.java deleted file mode 100644 index a927e3d5f..000000000 --- a/dx/src/com/android/dx/cf/attrib/BaseParameterAnnotations.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.annotation.AnnotationsList; -import com.android.dx.util.MutabilityException; - -/** - * Base class for parameter annotation list attributes. - */ -public abstract class BaseParameterAnnotations extends BaseAttribute { - /** non-null; list of annotations */ - private final AnnotationsList parameterAnnotations; - - /** >= 0; attribute data length in the original classfile (not - * including the attribute header) */ - private final int byteLength; - - /** - * Constructs an instance. - * - * @param attributeName non-null; the name of the attribute - * @param parameterAnnotations non-null; the annotations - * @param byteLength >= 0; attribute data length in the original - * classfile (not including the attribute header) - */ - public BaseParameterAnnotations(String attributeName, - AnnotationsList parameterAnnotations, int byteLength) { - super(attributeName); - - try { - if (parameterAnnotations.isMutable()) { - throw new MutabilityException( - "parameterAnnotations.isMutable()"); - } - } catch (NullPointerException ex) { - // Translate the exception. - throw new NullPointerException("parameterAnnotations == null"); - } - - this.parameterAnnotations = parameterAnnotations; - this.byteLength = byteLength; - } - - /** {@inheritDoc} */ - public final int byteLength() { - // Add six for the standard attribute header. - return byteLength + 6; - } - - /** - * Gets the list of annotation lists associated with this instance. - * - * @return non-null; the list - */ - public final AnnotationsList getParameterAnnotations() { - return parameterAnnotations; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/InnerClassList.java b/dx/src/com/android/dx/cf/attrib/InnerClassList.java deleted file mode 100644 index 3585f1db8..000000000 --- a/dx/src/com/android/dx/cf/attrib/InnerClassList.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.util.FixedSizeList; - -/** - * List of "inner class" entries, which are the contents of - * InnerClasses attributes. - */ -public final class InnerClassList extends FixedSizeList { - /** - * Constructs an instance. - * - * @param count the number of elements to be in the list of inner classes - */ - public InnerClassList(int count) { - super(count); - } - - /** - * Gets the indicated item. - * - * @param n >= 0; which item - * @return null-ok; the indicated item - */ - public Item get(int n) { - return (Item) get0(n); - } - - /** - * Sets the item at the given index. - * - * @param n >= 0, < size(); which class - * @param innerClass non-null; class this item refers to - * @param outerClass null-ok; outer class that this class is a - * member of, if any - * @param innerName null-ok; original simple name of this class, - * if not anonymous - * @param accessFlags original declared access flags - */ - public void set(int n, CstType innerClass, CstType outerClass, - CstUtf8 innerName, int accessFlags) { - set0(n, new Item(innerClass, outerClass, innerName, accessFlags)); - } - - /** - * Item in an inner classes list. - */ - public static class Item { - /** non-null; class this item refers to */ - private final CstType innerClass; - - /** null-ok; outer class that this class is a member of, if any */ - private final CstType outerClass; - - /** null-ok; original simple name of this class, if not anonymous */ - private final CstUtf8 innerName; - - /** original declared access flags */ - private final int accessFlags; - - /** - * Constructs an instance. - * - * @param innerClass non-null; class this item refers to - * @param outerClass null-ok; outer class that this class is a - * member of, if any - * @param innerName null-ok; original simple name of this - * class, if not anonymous - * @param accessFlags original declared access flags - */ - public Item(CstType innerClass, CstType outerClass, - CstUtf8 innerName, int accessFlags) { - if (innerClass == null) { - throw new NullPointerException("innerClass == null"); - } - - this.innerClass = innerClass; - this.outerClass = outerClass; - this.innerName = innerName; - this.accessFlags = accessFlags; - } - - /** - * Gets the class this item refers to. - * - * @return non-null; the class - */ - public CstType getInnerClass() { - return innerClass; - } - - /** - * Gets the outer class that this item's class is a member of, if any. - * - * @return null-ok; the class - */ - public CstType getOuterClass() { - return outerClass; - } - - /** - * Gets the original name of this item's class, if not anonymous. - * - * @return null-ok; the name - */ - public CstUtf8 getInnerName() { - return innerName; - } - - /** - * Gets the original declared access flags. - * - * @return the access flags - */ - public int getAccessFlags() { - return accessFlags; - } - } -} diff --git a/dx/src/com/android/dx/cf/attrib/RawAttribute.java b/dx/src/com/android/dx/cf/attrib/RawAttribute.java deleted file mode 100644 index b89926d8a..000000000 --- a/dx/src/com/android/dx/cf/attrib/RawAttribute.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.attrib; - -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.util.ByteArray; - -/** - * Raw attribute, for holding onto attributes that are unrecognized. - */ -public final class RawAttribute extends BaseAttribute { - /** non-null; attribute data */ - private final ByteArray data; - - /** - * null-ok; constant pool to use for resolution of cpis in {@link - * #data} - */ - private final ConstantPool pool; - - /** - * Constructs an instance. - * - * @param name non-null; attribute name - * @param data non-null; attribute data - * @param pool null-ok; constant pool to use for cpi resolution - */ - public RawAttribute(String name, ByteArray data, ConstantPool pool) { - super(name); - - if (data == null) { - throw new NullPointerException("data == null"); - } - - this.data = data; - this.pool = pool; - } - - /** - * Constructs an instance from a sub-array of a {@link ByteArray}. - * - * @param name non-null; attribute name - * @param data non-null; array containing the attribute data - * @param offset offset in data to the attribute data - * @param length length of the attribute data, in bytes - * @param pool null-ok; constant pool to use for cpi resolution - */ - public RawAttribute(String name, ByteArray data, int offset, - int length, ConstantPool pool) { - this(name, data.slice(offset, offset + length), pool); - } - - /** - * Get the raw data of the attribute. - * - * @return non-null; the data - */ - public ByteArray getData() { - return data; - } - - /** {@inheritDoc} */ - public int byteLength() { - return data.size() + 6; - } - - /** - * Gets the constant pool to use for cpi resolution, if any. It - * presumably came from the class file that this attribute came - * from. - * - * @return null-ok; the constant pool - */ - public ConstantPool getPool() { - return pool; - } -} diff --git a/dx/src/com/android/dx/cf/attrib/package.html b/dx/src/com/android/dx/cf/attrib/package.html deleted file mode 100644 index 8125079a4..000000000 --- a/dx/src/com/android/dx/cf/attrib/package.html +++ /dev/null @@ -1,11 +0,0 @@ - -

Implementation of containers and utilities for all the standard Java -attribute types.

- -

PACKAGES USED: -

    -
  • com.android.dx.cf.iface
  • -
  • com.android.dx.rop.pool
  • -
  • com.android.dx.util
  • -
- diff --git a/dx/src/com/android/dx/cf/code/BaseMachine.java b/dx/src/com/android/dx/cf/code/BaseMachine.java deleted file mode 100644 index 430e48be7..000000000 --- a/dx/src/com/android/dx/cf/code/BaseMachine.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.code.RegisterSpec; -import com.android.dx.rop.code.LocalItem; -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.type.Prototype; -import com.android.dx.rop.type.StdTypeList; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import java.util.ArrayList; - -/** - * Base implementation of {@link Machine}. - * - *

Note: For the most part, the documentation for this class - * ignores the distinction between {@link Type} and {@link - * TypeBearer}.

- */ -public abstract class BaseMachine implements Machine { - /* non-null; the prototype for the associated method */ - private final Prototype prototype; - - /** non-null; primary arguments */ - private TypeBearer[] args; - - /** >= 0; number of primary arguments */ - private int argCount; - - /** null-ok; type of the operation, if salient */ - private Type auxType; - - /** auxiliary int argument */ - private int auxInt; - - /** null-ok; auxiliary constant argument */ - private Constant auxCst; - - /** auxiliary branch target argument */ - private int auxTarget; - - /** null-ok; auxiliary switch cases argument */ - private SwitchList auxCases; - - /** null-ok; auxiliary initial value list for newarray */ - private ArrayList auxInitValues; - - /** >= -1; last local accessed */ - private int localIndex; - - /** null-ok; local target spec, if salient and calculated */ - private RegisterSpec localTarget; - - /** non-null; results */ - private TypeBearer[] results; - - /** - * >= -1; count of the results, or -1 if no results - * have been set - */ - private int resultCount; - - /** - * Constructs an instance. - * - * @param prototype non-null; the prototype for the associated method - */ - public BaseMachine(Prototype prototype) { - if (prototype == null) { - throw new NullPointerException("prototype == null"); - } - - this.prototype = prototype; - args = new TypeBearer[10]; - results = new TypeBearer[6]; - clearArgs(); - } - - /** {@inheritDoc} */ - public Prototype getPrototype() { - return prototype; - } - - /** {@inheritDoc} */ - public final void clearArgs() { - argCount = 0; - auxType = null; - auxInt = 0; - auxCst = null; - auxTarget = 0; - auxCases = null; - auxInitValues = null; - localIndex = -1; - localTarget = null; - resultCount = -1; - } - - /** {@inheritDoc} */ - public final void popArgs(Frame frame, int count) { - ExecutionStack stack = frame.getStack(); - - clearArgs(); - - if (count > args.length) { - // Grow args, and add a little extra room to grow even more. - args = new TypeBearer[count + 10]; - } - - for (int i = count - 1; i >= 0; i--) { - args[i] = stack.pop(); - } - - argCount = count; - } - - /** {@inheritDoc} */ - public void popArgs(Frame frame, Prototype prototype) { - StdTypeList types = prototype.getParameterTypes(); - int size = types.size(); - - // Use the above method to do the actual popping... - popArgs(frame, size); - - // ...and then verify the popped types. - - for (int i = 0; i < size; i++) { - if (! Merger.isPossiblyAssignableFrom(types.getType(i), args[i])) { - throw new SimException("at stack depth " + (size - 1 - i) + - ", expected type " + types.getType(i).toHuman() + - " but found " + args[i].getType().toHuman()); - } - } - } - - public final void popArgs(Frame frame, Type type) { - // Use the above method to do the actual popping... - popArgs(frame, 1); - - // ...and then verify the popped type. - if (! Merger.isPossiblyAssignableFrom(type, args[0])) { - throw new SimException("expected type " + type.toHuman() + - " but found " + args[0].getType().toHuman()); - } - } - - /** {@inheritDoc} */ - public final void popArgs(Frame frame, Type type1, Type type2) { - // Use the above method to do the actual popping... - popArgs(frame, 2); - - // ...and then verify the popped types. - - if (! Merger.isPossiblyAssignableFrom(type1, args[0])) { - throw new SimException("expected type " + type1.toHuman() + - " but found " + args[0].getType().toHuman()); - } - - if (! Merger.isPossiblyAssignableFrom(type2, args[1])) { - throw new SimException("expected type " + type2.toHuman() + - " but found " + args[1].getType().toHuman()); - } - } - - /** {@inheritDoc} */ - public final void popArgs(Frame frame, Type type1, Type type2, - Type type3) { - // Use the above method to do the actual popping... - popArgs(frame, 3); - - // ...and then verify the popped types. - - if (! Merger.isPossiblyAssignableFrom(type1, args[0])) { - throw new SimException("expected type " + type1.toHuman() + - " but found " + args[0].getType().toHuman()); - } - - if (! Merger.isPossiblyAssignableFrom(type2, args[1])) { - throw new SimException("expected type " + type2.toHuman() + - " but found " + args[1].getType().toHuman()); - } - - if (! Merger.isPossiblyAssignableFrom(type3, args[2])) { - throw new SimException("expected type " + type2.toHuman() + - " but found " + args[2].getType().toHuman()); - } - } - - /** {@inheritDoc} */ - public final void localArg(Frame frame, int idx) { - clearArgs(); - args[0] = frame.getLocals().get(idx); - argCount = 1; - localIndex = idx; - } - - /** {@inheritDoc} */ - public final void auxType(Type type) { - auxType = type; - } - - /** {@inheritDoc} */ - public final void auxIntArg(int value) { - auxInt = value; - } - - /** {@inheritDoc} */ - public final void auxCstArg(Constant cst) { - if (cst == null) { - throw new NullPointerException("cst == null"); - } - - auxCst = cst; - } - - /** {@inheritDoc} */ - public final void auxTargetArg(int target) { - auxTarget = target; - } - - /** {@inheritDoc} */ - public final void auxSwitchArg(SwitchList cases) { - if (cases == null) { - throw new NullPointerException("cases == null"); - } - - auxCases = cases; - } - - /** {@inheritDoc} */ - public final void auxInitValues(ArrayList initValues) { - auxInitValues = initValues; - } - - /** {@inheritDoc} */ - public final void localTarget(int idx, Type type, LocalItem local) { - localTarget = RegisterSpec.makeLocalOptional(idx, type, local); - } - - /** - * Gets the number of primary arguments. - * - * @return >= 0; the number of primary arguments - */ - protected final int argCount() { - return argCount; - } - - /** - * Gets the width of the arguments (where a category-2 value counts as - * two). - * - * @return >= 0; the argument width - */ - protected final int argWidth() { - int result = 0; - - for (int i = 0; i < argCount; i++) { - result += args[i].getType().getCategory(); - } - - return result; - } - - /** - * Gets the nth primary argument. - * - * @param n >= 0, < argCount(); which argument - * @return non-null; the indicated argument - */ - protected final TypeBearer arg(int n) { - if (n >= argCount) { - throw new IllegalArgumentException("n >= argCount"); - } - - try { - return args[n]; - } catch (ArrayIndexOutOfBoundsException ex) { - // Translate the exception. - throw new IllegalArgumentException("n < 0"); - } - } - - /** - * Gets the type auxiliary argument. - * - * @return null-ok; the salient type - */ - protected final Type getAuxType() { - return auxType; - } - - /** - * Gets the int auxiliary argument. - * - * @return the argument value - */ - protected final int getAuxInt() { - return auxInt; - } - - /** - * Gets the constant auxiliary argument. - * - * @return null-ok; the argument value - */ - protected final Constant getAuxCst() { - return auxCst; - } - - /** - * Gets the branch target auxiliary argument. - * - * @return the argument value - */ - protected final int getAuxTarget() { - return auxTarget; - } - - /** - * Gets the switch cases auxiliary argument. - * - * @return null-ok; the argument value - */ - protected final SwitchList getAuxCases() { - return auxCases; - } - - /** - * Gets the init values auxiliary argument. - * - * @return null-ok; the argument value - */ - protected final ArrayList getInitValues() { - return auxInitValues; - } - /** - * Gets the last local index accessed. - * - * @return >= -1; the salient local index or -1 if none - * was set since the last time {@link #clearArgs} was called - */ - protected final int getLocalIndex() { - return localIndex; - } - - /** - * Gets the target local register spec of the current operation, if any. - * The local target spec is the combination of the values indicated - * by a previous call to {@link #localTarget} with the type of what - * should be the sole result set by a call to {@link #setResult} (or - * the combination {@link #clearResult} then {@link #addResult}. - * - * @return null-ok; the salient register spec or null if no - * local target was set since the last time {@link #clearArgs} was - * called - */ - protected final RegisterSpec getLocalTarget() { - if (localTarget == null) { - return null; - } - - if (resultCount != 1) { - throw new SimException("local target with " + - ((resultCount == 0) ? "no" : "multiple") + " results"); - } - - TypeBearer result = results[0]; - Type resultType = result.getType(); - Type localType = localTarget.getType(); - - if (resultType == localType) { - return localTarget; - } - - if (! Merger.isPossiblyAssignableFrom(localType, resultType)) { - // The result and local types are inconsistent. Complain! - throwLocalMismatch(resultType, localType); - return null; - } - - if (localType == Type.OBJECT) { - /* - * The result type is more specific than the local type, - * so use that instead. - */ - localTarget = localTarget.withType(result); - } - - return localTarget; - } - - /** - * Clears the results. - */ - protected final void clearResult() { - resultCount = 0; - } - - /** - * Sets the results list to be the given single value. - * - *

Note: If there is more than one result value, the - * others may be added by using {@link #addResult}.

- * - * @param result non-null; result value - */ - protected final void setResult(TypeBearer result) { - if (result == null) { - throw new NullPointerException("result == null"); - } - - results[0] = result; - resultCount = 1; - } - - /** - * Adds an additional element to the list of results. - * - * @see #setResult - * - * @param result non-null; result value - */ - protected final void addResult(TypeBearer result) { - if (result == null) { - throw new NullPointerException("result == null"); - } - - results[resultCount] = result; - resultCount++; - } - - /** - * Gets the count of results. This throws an exception if results were - * never set. (Explicitly clearing the results counts as setting them.) - * - * @return >= 0; the count - */ - protected final int resultCount() { - if (resultCount < 0) { - throw new SimException("results never set"); - } - - return resultCount; - } - - /** - * Gets the width of the results (where a category-2 value counts as - * two). - * - * @return >= 0; the result width - */ - protected final int resultWidth() { - int width = 0; - - for (int i = 0; i < resultCount; i++) { - width += results[i].getType().getCategory(); - } - - return width; - } - - /** - * Gets the nth result value. - * - * @param n >= 0, < resultCount(); which result - * @return non-null; the indicated result value - */ - protected final TypeBearer result(int n) { - if (n >= resultCount) { - throw new IllegalArgumentException("n >= resultCount"); - } - - try { - return results[n]; - } catch (ArrayIndexOutOfBoundsException ex) { - // Translate the exception. - throw new IllegalArgumentException("n < 0"); - } - } - - /** - * Stores the results of the latest operation into the given frame. If - * there is a local target (see {@link #localTarget}), then the sole - * result is stored to that target; otherwise any results are pushed - * onto the stack. - * - * @param frame non-null; frame to operate on - */ - protected final void storeResults(Frame frame) { - if (resultCount < 0) { - throw new SimException("results never set"); - } - - if (resultCount == 0) { - // Nothing to do. - return; - } - - if (localTarget != null) { - /* - * Note: getLocalTarget() doesn't necessarily return - * localTarget directly. - */ - frame.getLocals().set(getLocalTarget()); - } else { - ExecutionStack stack = frame.getStack(); - for (int i = 0; i < resultCount; i++) { - stack.push(results[i]); - } - } - } - - /** - * Throws an exception that indicates a mismatch in local variable - * types. - * - * @param found non-null; the encountered type - * @param local non-null; the local variable's claimed type - */ - public static void throwLocalMismatch(TypeBearer found, - TypeBearer local) { - throw new SimException("local variable type mismatch: " + - "attempt to set or access a value of type " + - found.toHuman() + - " using a local variable of type " + - local.toHuman() + - ". This is symptomatic of .class transformation tools " + - "that ignore local variable information."); - } -} diff --git a/dx/src/com/android/dx/cf/code/BasicBlocker.java b/dx/src/com/android/dx/cf/code/BasicBlocker.java deleted file mode 100644 index 82e4a08d0..000000000 --- a/dx/src/com/android/dx/cf/code/BasicBlocker.java +++ /dev/null @@ -1,449 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.CstMemberRef; -import com.android.dx.rop.cst.CstString; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.Type; -import com.android.dx.util.Bits; -import com.android.dx.util.IntList; -import java.util.ArrayList; - -/** - * Utility that identifies basic blocks in bytecode. - */ -public final class BasicBlocker implements BytecodeArray.Visitor { - /** non-null; method being converted */ - private final ConcreteMethod method; - - /** non-null; work set; bits indicate offsets in need of examination */ - private final int[] workSet; - - /** - * non-null; live set; bits indicate potentially-live opcodes; contrawise, - * a bit that isn't on is either in the middle of an instruction or is - * a definitely-dead opcode - */ - private final int[] liveSet; - - /** - * non-null; block start set; bits indicate the starts of basic blocks, - * including the opcodes that start blocks of definitely-dead code - */ - private final int[] blockSet; - - /** - * non-null, sparse; for each instruction offset to a branch of - * some sort, the list of targets for that instruction - */ - private final IntList[] targetLists; - - /** - * non-null, sparse; for each instruction offset to a throwing - * instruction, the list of exception handlers for that instruction - */ - private final ByteCatchList[] catchLists; - - /** offset of the previously parsed bytecode */ - private int previousOffset; - - /** - * Identifies and enumerates the basic blocks in the given method, - * returning a list of them. The returned list notably omits any - * definitely-dead code that is identified in the process. - * - * @param method non-null; method to convert - * @return non-null; list of basic blocks - */ - public static ByteBlockList identifyBlocks(ConcreteMethod method) { - BasicBlocker bb = new BasicBlocker(method); - - bb.doit(); - return bb.getBlockList(); - } - - /** - * Constructs an instance. This class is not publicly instantiable; use - * {@link #identifyBlocks}. - * - * @param method non-null; method to convert - */ - private BasicBlocker(ConcreteMethod method) { - if (method == null) { - throw new NullPointerException("method == null"); - } - - this.method = method; - - /* - * The "+1" below is so the idx-past-end is also valid, - * avoiding a special case, but without preventing - * flow-of-control falling past the end of the method from - * getting properly reported. - */ - int sz = method.getCode().size() + 1; - - workSet = Bits.makeBitSet(sz); - liveSet = Bits.makeBitSet(sz); - blockSet = Bits.makeBitSet(sz); - targetLists = new IntList[sz]; - catchLists = new ByteCatchList[sz]; - previousOffset = -1; - } - - /* - * Note: These methods are defined implementation of the interface - * BytecodeArray.Visitor; since the class isn't publicly - * instantiable, no external code ever gets a chance to actually - * call these methods. - */ - - /** {@inheritDoc} */ - public void visitInvalid(int opcode, int offset, int length) { - visitCommon(offset, length, true); - } - - /** {@inheritDoc} */ - public void visitNoArgs(int opcode, int offset, int length, Type type) { - switch (opcode) { - case ByteOps.IRETURN: - case ByteOps.RETURN: { - visitCommon(offset, length, false); - targetLists[offset] = IntList.EMPTY; - break; - } - case ByteOps.ATHROW: { - visitCommon(offset, length, false); - visitThrowing(offset, length, false); - break; - } - case ByteOps.IALOAD: - case ByteOps.LALOAD: - case ByteOps.FALOAD: - case ByteOps.DALOAD: - case ByteOps.AALOAD: - case ByteOps.BALOAD: - case ByteOps.CALOAD: - case ByteOps.SALOAD: - case ByteOps.IASTORE: - case ByteOps.LASTORE: - case ByteOps.FASTORE: - case ByteOps.DASTORE: - case ByteOps.AASTORE: - case ByteOps.BASTORE: - case ByteOps.CASTORE: - case ByteOps.SASTORE: - case ByteOps.ARRAYLENGTH: - case ByteOps.MONITORENTER: - case ByteOps.MONITOREXIT: { - /* - * These instructions can all throw, so they have to end - * the block they appear in (since throws are branches). - */ - visitCommon(offset, length, true); - visitThrowing(offset, length, true); - break; - } - case ByteOps.IDIV: - case ByteOps.IREM: { - /* - * The int and long versions of division and remainder may - * throw, but not the other types. - */ - visitCommon(offset, length, true); - if ((type == Type.INT) || (type == Type.LONG)) { - visitThrowing(offset, length, true); - } - break; - } - default: { - visitCommon(offset, length, true); - break; - } - } - } - - /** {@inheritDoc} */ - public void visitLocal(int opcode, int offset, int length, - int idx, Type type, int value) { - if (opcode == ByteOps.RET) { - visitCommon(offset, length, false); - targetLists[offset] = IntList.EMPTY; - } else { - visitCommon(offset, length, true); - } - } - - /** {@inheritDoc} */ - public void visitConstant(int opcode, int offset, int length, - Constant cst, int value) { - visitCommon(offset, length, true); - - if ((cst instanceof CstMemberRef) || (cst instanceof CstType) || - (cst instanceof CstString)) { - /* - * Instructions with these sorts of constants have the - * possibility of throwing, so this instruction needs to - * end its block (since it can throw, and possible-throws - * are branch points). - */ - visitThrowing(offset, length, true); - } - } - - /** {@inheritDoc} */ - public void visitBranch(int opcode, int offset, int length, - int target) { - switch (opcode) { - case ByteOps.GOTO: { - visitCommon(offset, length, false); - targetLists[offset] = IntList.makeImmutable(target); - break; - } - case ByteOps.JSR: { - /* - * Each jsr is quarantined into a separate block (containing - * only the jsr instruction) but is otherwise treated - * as a conditional branch. (That is to say, both its - * target and next instruction begin new blocks.) - */ - addWorkIfNecessary(offset, true); - // Fall through to next case... - } - default: { - int next = offset + length; - visitCommon(offset, length, true); - addWorkIfNecessary(next, true); - targetLists[offset] = IntList.makeImmutable(next, target); - break; - } - } - - addWorkIfNecessary(target, true); - } - - /** {@inheritDoc} */ - public void visitSwitch(int opcode, int offset, int length, - SwitchList cases, int padding) { - visitCommon(offset, length, false); - addWorkIfNecessary(cases.getDefaultTarget(), true); - - int sz = cases.size(); - for (int i = 0; i < sz; i++) { - addWorkIfNecessary(cases.getTarget(i), true); - } - - targetLists[offset] = cases.getTargets(); - } - - /** {@inheritDoc} */ - public void visitNewarray(int offset, int length, CstType type, - ArrayList intVals) { - visitCommon(offset, length, true); - visitThrowing(offset, length, true); - } - - /** - * Extracts the list of basic blocks from the bit sets. - * - * @return non-null; the list of basic blocks - */ - private ByteBlockList getBlockList() { - ByteCatchList catches = method.getCatches(); - BytecodeArray bytes = method.getCode(); - ByteBlock[] bbs = new ByteBlock[bytes.size()]; - int count = 0; - - for (int at = 0, next; /*at*/; at = next) { - next = Bits.findFirst(blockSet, at + 1); - if (next < 0) { - break; - } - - if (Bits.get(liveSet, at)) { - /* - * Search backward for the branch or throwing - * instruction at the end of this block, if any. If - * there isn't any, then "next" is the sole target. - */ - IntList targets = null; - int targetsAt = -1; - ByteCatchList blockCatches; - - for (int i = next - 1; i >= at; i--) { - targets = targetLists[i]; - if (targets != null) { - targetsAt = i; - break; - } - } - - if (targets == null) { - targets = IntList.makeImmutable(next); - blockCatches = ByteCatchList.EMPTY; - } else { - blockCatches = catchLists[targetsAt]; - if (blockCatches == null) { - blockCatches = ByteCatchList.EMPTY; - } - } - - bbs[count] = - new ByteBlock(at, at, next, targets, blockCatches); - count++; - } - } - - ByteBlockList result = new ByteBlockList(count); - for (int i = 0; i < count; i++) { - result.set(i, bbs[i]); - } - - return result; - } - - /** - * Does basic block identification. - */ - private void doit() { - BytecodeArray bytes = method.getCode(); - ByteCatchList catches = method.getCatches(); - int catchSz = catches.size(); - - /* - * Start by setting offset 0 as the start of a block and in need - * of work... - */ - Bits.set(workSet, 0); - Bits.set(blockSet, 0); - - /* - * And then process the work set, add new work based on - * exception ranges that are active, and iterate until there's - * nothing left to work on. - */ - while (!Bits.isEmpty(workSet)) { - try { - bytes.processWorkSet(workSet, this); - } catch (IllegalArgumentException ex) { - // Translate the exception. - throw new SimException("flow of control falls off " + - "end of method", - ex); - } - - for (int i = 0; i < catchSz; i++) { - ByteCatchList.Item item = catches.get(i); - int start = item.getStartPc(); - int end = item.getEndPc(); - if (Bits.anyInRange(liveSet, start, end)) { - Bits.set(blockSet, start); - Bits.set(blockSet, end); - addWorkIfNecessary(item.getHandlerPc(), true); - } - } - } - } - - /** - * Sets a bit in the work set, but only if the instruction in question - * isn't yet known to be possibly-live. - * - * @param offset offset to the instruction in question - * @param blockStart true iff this instruction starts a - * basic block - */ - private void addWorkIfNecessary(int offset, boolean blockStart) { - if (!Bits.get(liveSet, offset)) { - Bits.set(workSet, offset); - } - - if (blockStart) { - Bits.set(blockSet, offset); - } - } - - /** - * Helper method used by all the visitor methods. - * - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param nextIsLive true iff the instruction after - * the indicated one is possibly-live (because this one isn't an - * unconditional branch, a return, or a switch) - */ - private void visitCommon(int offset, int length, boolean nextIsLive) { - Bits.set(liveSet, offset); - - if (nextIsLive) { - /* - * If the next instruction is flowed to by this one, just - * add it to the work set, and then a subsequent visit*() - * will deal with it as appropriate. - */ - addWorkIfNecessary(offset + length, false); - } else { - /* - * If the next instruction isn't flowed to by this one, - * then mark it as a start of a block but *don't* add it - * to the work set, so that in the final phase we can know - * dead code blocks as those marked as blocks but not also marked - * live. - */ - Bits.set(blockSet, offset + length); - } - } - - /** - * Helper method used by all the visitor methods that deal with - * opcodes that possibly throw. This method should be called after calling - * {@link #visitCommon}. - * - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param nextIsLive true iff the instruction after - * the indicated one is possibly-live (because this one isn't an - * unconditional throw) - */ - private void visitThrowing(int offset, int length, boolean nextIsLive) { - int next = offset + length; - - if (nextIsLive) { - addWorkIfNecessary(next, true); - } - - ByteCatchList catches = method.getCatches().listFor(offset); - catchLists[offset] = catches; - targetLists[offset] = catches.toTargetList(nextIsLive ? next : -1); - } - - /** - * {@inheritDoc} - */ - public void setPreviousOffset(int offset) { - previousOffset = offset; - } - - /** - * {@inheritDoc} - */ - public int getPreviousOffset() { - return previousOffset; - } -} diff --git a/dx/src/com/android/dx/cf/code/ByteBlock.java b/dx/src/com/android/dx/cf/code/ByteBlock.java deleted file mode 100644 index 065c5221c..000000000 --- a/dx/src/com/android/dx/cf/code/ByteBlock.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.util.Hex; -import com.android.dx.util.IntList; -import com.android.dx.util.LabeledItem; - -/** - * Representation of a basic block in a bytecode array. - */ -public final class ByteBlock implements LabeledItem { - /** >= 0; label for this block */ - private final int label; - - /** >= 0; bytecode offset (inclusive) of the start of the block */ - private final int start; - - /** > start; bytecode offset (exclusive) of the end of the block */ - private final int end; - - /** non-null; list of successors that this block may branch to */ - private final IntList successors; - - /** non-null; list of exceptions caught and their handler targets */ - private final ByteCatchList catches; - - /** - * Constructs an instance. - * - * @param label >= 0; target label for this block - * @param start >= 0; bytecode offset (inclusive) of the start - * of the block - * @param end > start; bytecode offset (exclusive) of the end - * of the block - * @param successors non-null; list of successors that this block may - * branch to - * @param catches non-null; list of exceptions caught and their - * handler targets - */ - public ByteBlock(int label, int start, int end, IntList successors, - ByteCatchList catches) { - if (label < 0) { - throw new IllegalArgumentException("label < 0"); - } - - if (start < 0) { - throw new IllegalArgumentException("start < 0"); - } - - if (end <= start) { - throw new IllegalArgumentException("end <= start"); - } - - if (successors == null) { - throw new NullPointerException("targets == null"); - } - - int sz = successors.size(); - for (int i = 0; i < sz; i++) { - if (successors.get(i) < 0) { - throw new IllegalArgumentException("successors[" + i + - "] == " + - successors.get(i)); - } - } - - if (catches == null) { - throw new NullPointerException("catches == null"); - } - - this.label = label; - this.start = start; - this.end = end; - this.successors = successors; - this.catches = catches; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return '{' + Hex.u2(label) + ": " + Hex.u2(start) + ".." + - Hex.u2(end) + '}'; - } - - /** - * Gets the label of this block. - * - * @return >= 0; the label - */ - public int getLabel() { - return label; - } - - /** - * Gets the bytecode offset (inclusive) of the start of this block. - * - * @return >= 0; the start offset - */ - public int getStart() { - return start; - } - - /** - * Gets the bytecode offset (exclusive) of the end of this block. - * - * @return > getStart(); the end offset - */ - public int getEnd() { - return end; - } - - /** - * Gets the list of successors that this block may branch to - * non-exceptionally. - * - * @return non-null; the successor list - */ - public IntList getSuccessors() { - return successors; - } - - /** - * Gets the list of exceptions caught and their handler targets. - * - * @return non-null; the catch list - */ - public ByteCatchList getCatches() { - return catches; - } -} diff --git a/dx/src/com/android/dx/cf/code/ByteBlockList.java b/dx/src/com/android/dx/cf/code/ByteBlockList.java deleted file mode 100644 index 9d27b7fd9..000000000 --- a/dx/src/com/android/dx/cf/code/ByteBlockList.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.util.FixedSizeList; -import com.android.dx.util.Hex; -import com.android.dx.util.LabeledList; - -/** - * List of {@link ByteBlock} instances. - */ -public final class ByteBlockList extends LabeledList { - - /** - * Constructs an instance. - * - * @param size >= 0; the number of elements to be in the list - */ - public ByteBlockList(int size) { - super(size); - } - - /** - * Gets the indicated element. It is an error to call this with the - * index for an element which was never set; if you do that, this - * will throw NullPointerException. - * - * @param n >= 0, < size(); which element - * @return non-null; the indicated element - */ - public ByteBlock get(int n) { - return (ByteBlock) get0(n); - } - - /** - * Gets the block with the given label. - * - * @param label the label to look for - * @return non-null; the block with the given label - */ - public ByteBlock labelToBlock(int label) { - int idx = indexOfLabel(label); - - if (idx < 0) { - throw new IllegalArgumentException("no such label: " - + Hex.u2(label)); - } - - return get(idx); - } - - /** - * Sets the element at the given index. - * - * @param n >= 0, < size(); which element - * @param bb null-ok; the value to store - */ - public void set(int n, ByteBlock bb) { - super.set(n, bb); - } -} diff --git a/dx/src/com/android/dx/cf/code/ByteCatchList.java b/dx/src/com/android/dx/cf/code/ByteCatchList.java deleted file mode 100644 index 375831e55..000000000 --- a/dx/src/com/android/dx/cf/code/ByteCatchList.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.StdTypeList; -import com.android.dx.rop.type.TypeList; -import com.android.dx.util.FixedSizeList; -import com.android.dx.util.IntList; - -/** - * List of catch entries, that is, the elements of an "exception table," - * which is part of a standard Code attribute. - */ -public final class ByteCatchList extends FixedSizeList { - /** non-null; convenient zero-entry instance */ - public static final ByteCatchList EMPTY = new ByteCatchList(0); - - /** - * Constructs an instance. - * - * @param count the number of elements to be in the table - */ - public ByteCatchList(int count) { - super(count); - } - - /** - * Gets the total length of this structure in bytes, when included in - * a Code attribute. The returned value includes the - * two bytes for exception_table_length. - * - * @return >= 2; the total length, in bytes - */ - public int byteLength() { - return 2 + size() * 8; - } - - /** - * Gets the indicated item. - * - * @param n >= 0; which item - * @return null-ok; the indicated item - */ - public Item get(int n) { - return (Item) get0(n); - } - - /** - * Sets the item at the given index. - * - * @param n >= 0, < size(); which entry to set - * @param item non-null; the item - */ - public void set(int n, Item item) { - if (item == null) { - throw new NullPointerException("item == null"); - } - - set0(n, item); - } - - /** - * Sets the item at the given index. - * - * @param n >= 0, < size(); which entry to set - * @param startPc >= 0; the start pc (inclusive) of the handler's range - * @param endPc >= startPc; the end pc (exclusive) of the - * handler's range - * @param handlerPc >= 0; the pc of the exception handler - * @param exceptionClass null-ok; the exception class or - * null to catch all exceptions with this handler - */ - public void set(int n, int startPc, int endPc, int handlerPc, - CstType exceptionClass) { - set0(n, new Item(startPc, endPc, handlerPc, exceptionClass)); - } - - /** - * Gets the list of items active at the given address. The result is - * automatically made immutable. - * - * @param pc which address - * @return non-null; list of exception handlers active at - * pc - */ - public ByteCatchList listFor(int pc) { - int sz = size(); - Item[] resultArr = new Item[sz]; - int resultSz = 0; - - for (int i = 0; i < sz; i++) { - Item one = get(i); - if (one.covers(pc) && typeNotFound(one, resultArr, resultSz)) { - resultArr[resultSz] = one; - resultSz++; - } - } - - if (resultSz == 0) { - return EMPTY; - } - - ByteCatchList result = new ByteCatchList(resultSz); - for (int i = 0; i < resultSz; i++) { - result.set(i, resultArr[i]); - } - - result.setImmutable(); - return result; - } - - /** - * Helper method for {@link #listFor}, which tells whether a match - * is not found for the exception type of the given item in - * the given array. A match is considered to be either an exact type - * match or the class Object which represents a catch-all. - * - * @param item non-null; item with the exception type to look for - * @param arr non-null; array to search in - * @param count non-null; maximum number of elements in the array to check - * @return true iff the exception type is not found - */ - private static boolean typeNotFound(Item item, Item[] arr, int count) { - CstType type = item.getExceptionClass(); - - for (int i = 0; i < count; i++) { - CstType one = arr[i].getExceptionClass(); - if ((one == type) || (one == CstType.OBJECT)) { - return false; - } - } - - return true; - } - - /** - * Returns a target list corresponding to this instance. The result - * is a list of all the exception handler addresses, with the given - * noException address appended if appropriate. The - * result is automatically made immutable. - * - * @param noException >= -1; the no-exception address to append, or - * -1 not to append anything - * @return non-null; list of exception targets, with - * noException appended if necessary - */ - public IntList toTargetList(int noException) { - if (noException < -1) { - throw new IllegalArgumentException("noException < -1"); - } - - boolean hasDefault = (noException >= 0); - int sz = size(); - - if (sz == 0) { - if (hasDefault) { - /* - * The list is empty, but there is a no-exception - * address; so, the result is just that address. - */ - return IntList.makeImmutable(noException); - } - /* - * The list is empty and there isn't even a no-exception - * address. - */ - return IntList.EMPTY; - } - - IntList result = new IntList(sz + (hasDefault ? 1 : 0)); - - for (int i = 0; i < sz; i++) { - result.add(get(i).getHandlerPc()); - } - - if (hasDefault) { - result.add(noException); - } - - result.setImmutable(); - return result; - } - - /** - * Returns a rop-style catches list equivalent to this one. - * - * @return non-null; the converted instance - */ - public TypeList toRopCatchList() { - int sz = size(); - if (sz == 0) { - return StdTypeList.EMPTY; - } - - StdTypeList result = new StdTypeList(sz); - - for (int i = 0; i < sz; i++) { - result.set(i, get(i).getExceptionClass().getClassType()); - } - - result.setImmutable(); - return result; - } - - /** - * Item in an exception handler list. - */ - public static class Item { - /** >= 0; the start pc (inclusive) of the handler's range */ - private final int startPc; - - /** >= startPc; the end pc (exclusive) of the handler's range */ - private final int endPc; - - /** >= 0; the pc of the exception handler */ - private final int handlerPc; - - /** null-ok; the exception class or null to catch all - * exceptions with this handler */ - private final CstType exceptionClass; - - /** - * Constructs an instance. - * - * @param startPc >= 0; the start pc (inclusive) of the - * handler's range - * @param endPc >= startPc; the end pc (exclusive) of the - * handler's range - * @param handlerPc >= 0; the pc of the exception handler - * @param exceptionClass null-ok; the exception class or - * null to catch all exceptions with this handler - */ - public Item(int startPc, int endPc, int handlerPc, - CstType exceptionClass) { - if (startPc < 0) { - throw new IllegalArgumentException("startPc < 0"); - } - - if (endPc < startPc) { - throw new IllegalArgumentException("endPc < startPc"); - } - - if (handlerPc < 0) { - throw new IllegalArgumentException("handlerPc < 0"); - } - - this.startPc = startPc; - this.endPc = endPc; - this.handlerPc = handlerPc; - this.exceptionClass = exceptionClass; - } - - /** - * Gets the start pc (inclusive) of the handler's range. - * - * @return >= 0; the start pc (inclusive) of the handler's range. - */ - public int getStartPc() { - return startPc; - } - - /** - * Gets the end pc (exclusive) of the handler's range. - * - * @return >= startPc; the end pc (exclusive) of the - * handler's range. - */ - public int getEndPc() { - return endPc; - } - - /** - * Gets the pc of the exception handler. - * - * @return >= 0; the pc of the exception handler - */ - public int getHandlerPc() { - return handlerPc; - } - - /** - * Gets the class of exception handled. - * - * @return non-null; the exception class; {@link CstType#OBJECT} - * if this entry handles all possible exceptions - */ - public CstType getExceptionClass() { - return (exceptionClass != null) ? - exceptionClass : CstType.OBJECT; - } - - /** - * Returns whether the given address is in the range of this item. - * - * @param pc the address - * @return true iff this item covers pc - */ - public boolean covers(int pc) { - return (pc >= startPc) && (pc < endPc); - } - } -} diff --git a/dx/src/com/android/dx/cf/code/ByteOps.java b/dx/src/com/android/dx/cf/code/ByteOps.java deleted file mode 100644 index 4c420f6f6..000000000 --- a/dx/src/com/android/dx/cf/code/ByteOps.java +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.util.Hex; - -/** - * Constants and utility methods for dealing with bytecode arrays at an - * opcode level. - */ -public class ByteOps { - // one constant per opcode - public static final int NOP = 0x00; - public static final int ACONST_NULL = 0x01; - public static final int ICONST_M1 = 0x02; - public static final int ICONST_0 = 0x03; - public static final int ICONST_1 = 0x04; - public static final int ICONST_2 = 0x05; - public static final int ICONST_3 = 0x06; - public static final int ICONST_4 = 0x07; - public static final int ICONST_5 = 0x08; - public static final int LCONST_0 = 0x09; - public static final int LCONST_1 = 0x0a; - public static final int FCONST_0 = 0x0b; - public static final int FCONST_1 = 0x0c; - public static final int FCONST_2 = 0x0d; - public static final int DCONST_0 = 0x0e; - public static final int DCONST_1 = 0x0f; - public static final int BIPUSH = 0x10; - public static final int SIPUSH = 0x11; - public static final int LDC = 0x12; - public static final int LDC_W = 0x13; - public static final int LDC2_W = 0x14; - public static final int ILOAD = 0x15; - public static final int LLOAD = 0x16; - public static final int FLOAD = 0x17; - public static final int DLOAD = 0x18; - public static final int ALOAD = 0x19; - public static final int ILOAD_0 = 0x1a; - public static final int ILOAD_1 = 0x1b; - public static final int ILOAD_2 = 0x1c; - public static final int ILOAD_3 = 0x1d; - public static final int LLOAD_0 = 0x1e; - public static final int LLOAD_1 = 0x1f; - public static final int LLOAD_2 = 0x20; - public static final int LLOAD_3 = 0x21; - public static final int FLOAD_0 = 0x22; - public static final int FLOAD_1 = 0x23; - public static final int FLOAD_2 = 0x24; - public static final int FLOAD_3 = 0x25; - public static final int DLOAD_0 = 0x26; - public static final int DLOAD_1 = 0x27; - public static final int DLOAD_2 = 0x28; - public static final int DLOAD_3 = 0x29; - public static final int ALOAD_0 = 0x2a; - public static final int ALOAD_1 = 0x2b; - public static final int ALOAD_2 = 0x2c; - public static final int ALOAD_3 = 0x2d; - public static final int IALOAD = 0x2e; - public static final int LALOAD = 0x2f; - public static final int FALOAD = 0x30; - public static final int DALOAD = 0x31; - public static final int AALOAD = 0x32; - public static final int BALOAD = 0x33; - public static final int CALOAD = 0x34; - public static final int SALOAD = 0x35; - public static final int ISTORE = 0x36; - public static final int LSTORE = 0x37; - public static final int FSTORE = 0x38; - public static final int DSTORE = 0x39; - public static final int ASTORE = 0x3a; - public static final int ISTORE_0 = 0x3b; - public static final int ISTORE_1 = 0x3c; - public static final int ISTORE_2 = 0x3d; - public static final int ISTORE_3 = 0x3e; - public static final int LSTORE_0 = 0x3f; - public static final int LSTORE_1 = 0x40; - public static final int LSTORE_2 = 0x41; - public static final int LSTORE_3 = 0x42; - public static final int FSTORE_0 = 0x43; - public static final int FSTORE_1 = 0x44; - public static final int FSTORE_2 = 0x45; - public static final int FSTORE_3 = 0x46; - public static final int DSTORE_0 = 0x47; - public static final int DSTORE_1 = 0x48; - public static final int DSTORE_2 = 0x49; - public static final int DSTORE_3 = 0x4a; - public static final int ASTORE_0 = 0x4b; - public static final int ASTORE_1 = 0x4c; - public static final int ASTORE_2 = 0x4d; - public static final int ASTORE_3 = 0x4e; - public static final int IASTORE = 0x4f; - public static final int LASTORE = 0x50; - public static final int FASTORE = 0x51; - public static final int DASTORE = 0x52; - public static final int AASTORE = 0x53; - public static final int BASTORE = 0x54; - public static final int CASTORE = 0x55; - public static final int SASTORE = 0x56; - public static final int POP = 0x57; - public static final int POP2 = 0x58; - public static final int DUP = 0x59; - public static final int DUP_X1 = 0x5a; - public static final int DUP_X2 = 0x5b; - public static final int DUP2 = 0x5c; - public static final int DUP2_X1 = 0x5d; - public static final int DUP2_X2 = 0x5e; - public static final int SWAP = 0x5f; - public static final int IADD = 0x60; - public static final int LADD = 0x61; - public static final int FADD = 0x62; - public static final int DADD = 0x63; - public static final int ISUB = 0x64; - public static final int LSUB = 0x65; - public static final int FSUB = 0x66; - public static final int DSUB = 0x67; - public static final int IMUL = 0x68; - public static final int LMUL = 0x69; - public static final int FMUL = 0x6a; - public static final int DMUL = 0x6b; - public static final int IDIV = 0x6c; - public static final int LDIV = 0x6d; - public static final int FDIV = 0x6e; - public static final int DDIV = 0x6f; - public static final int IREM = 0x70; - public static final int LREM = 0x71; - public static final int FREM = 0x72; - public static final int DREM = 0x73; - public static final int INEG = 0x74; - public static final int LNEG = 0x75; - public static final int FNEG = 0x76; - public static final int DNEG = 0x77; - public static final int ISHL = 0x78; - public static final int LSHL = 0x79; - public static final int ISHR = 0x7a; - public static final int LSHR = 0x7b; - public static final int IUSHR = 0x7c; - public static final int LUSHR = 0x7d; - public static final int IAND = 0x7e; - public static final int LAND = 0x7f; - public static final int IOR = 0x80; - public static final int LOR = 0x81; - public static final int IXOR = 0x82; - public static final int LXOR = 0x83; - public static final int IINC = 0x84; - public static final int I2L = 0x85; - public static final int I2F = 0x86; - public static final int I2D = 0x87; - public static final int L2I = 0x88; - public static final int L2F = 0x89; - public static final int L2D = 0x8a; - public static final int F2I = 0x8b; - public static final int F2L = 0x8c; - public static final int F2D = 0x8d; - public static final int D2I = 0x8e; - public static final int D2L = 0x8f; - public static final int D2F = 0x90; - public static final int I2B = 0x91; - public static final int I2C = 0x92; - public static final int I2S = 0x93; - public static final int LCMP = 0x94; - public static final int FCMPL = 0x95; - public static final int FCMPG = 0x96; - public static final int DCMPL = 0x97; - public static final int DCMPG = 0x98; - public static final int IFEQ = 0x99; - public static final int IFNE = 0x9a; - public static final int IFLT = 0x9b; - public static final int IFGE = 0x9c; - public static final int IFGT = 0x9d; - public static final int IFLE = 0x9e; - public static final int IF_ICMPEQ = 0x9f; - public static final int IF_ICMPNE = 0xa0; - public static final int IF_ICMPLT = 0xa1; - public static final int IF_ICMPGE = 0xa2; - public static final int IF_ICMPGT = 0xa3; - public static final int IF_ICMPLE = 0xa4; - public static final int IF_ACMPEQ = 0xa5; - public static final int IF_ACMPNE = 0xa6; - public static final int GOTO = 0xa7; - public static final int JSR = 0xa8; - public static final int RET = 0xa9; - public static final int TABLESWITCH = 0xaa; - public static final int LOOKUPSWITCH = 0xab; - public static final int IRETURN = 0xac; - public static final int LRETURN = 0xad; - public static final int FRETURN = 0xae; - public static final int DRETURN = 0xaf; - public static final int ARETURN = 0xb0; - public static final int RETURN = 0xb1; - public static final int GETSTATIC = 0xb2; - public static final int PUTSTATIC = 0xb3; - public static final int GETFIELD = 0xb4; - public static final int PUTFIELD = 0xb5; - public static final int INVOKEVIRTUAL = 0xb6; - public static final int INVOKESPECIAL = 0xb7; - public static final int INVOKESTATIC = 0xb8; - public static final int INVOKEINTERFACE = 0xb9; - public static final int NEW = 0xbb; - public static final int NEWARRAY = 0xbc; - public static final int ANEWARRAY = 0xbd; - public static final int ARRAYLENGTH = 0xbe; - public static final int ATHROW = 0xbf; - public static final int CHECKCAST = 0xc0; - public static final int INSTANCEOF = 0xc1; - public static final int MONITORENTER = 0xc2; - public static final int MONITOREXIT = 0xc3; - public static final int WIDE = 0xc4; - public static final int MULTIANEWARRAY = 0xc5; - public static final int IFNULL = 0xc6; - public static final int IFNONNULL = 0xc7; - public static final int GOTO_W = 0xc8; - public static final int JSR_W = 0xc9; - - // a constant for each valid argument to "newarray" - - public static final int NEWARRAY_BOOLEAN = 4; - public static final int NEWARRAY_CHAR = 5; - public static final int NEWARRAY_FLOAT = 6; - public static final int NEWARRAY_DOUBLE = 7; - public static final int NEWARRAY_BYTE = 8; - public static final int NEWARRAY_SHORT = 9; - public static final int NEWARRAY_INT = 10; - public static final int NEWARRAY_LONG = 11; - - // a constant for each possible instruction format - - /** invalid */ - public static final int FMT_INVALID = 0; - - /** "-": op */ - public static final int FMT_NO_ARGS = 1; - - /** "0": op; implies max_locals >= 1 */ - public static final int FMT_NO_ARGS_LOCALS_1 = 2; - - /** "1": op; implies max_locals >= 2 */ - public static final int FMT_NO_ARGS_LOCALS_2 = 3; - - /** "2": op; implies max_locals >= 3 */ - public static final int FMT_NO_ARGS_LOCALS_3 = 4; - - /** "3": op; implies max_locals >= 4 */ - public static final int FMT_NO_ARGS_LOCALS_4 = 5; - - /** "4": op; implies max_locals >= 5 */ - public static final int FMT_NO_ARGS_LOCALS_5 = 6; - - /** "b": op target target */ - public static final int FMT_BRANCH = 7; - - /** "c": op target target target target */ - public static final int FMT_WIDE_BRANCH = 8; - - /** "p": op #cpi #cpi; constant restricted as specified */ - public static final int FMT_CPI = 9; - - /** - * "l": op local; category-1 local; implies - * max_locals is at least two more than the given - * local number - */ - public static final int FMT_LOCAL_1 = 10; - - /** - * "m": op local; category-2 local; implies - * max_locals is at least two more than the given - * local number - */ - public static final int FMT_LOCAL_2 = 11; - - /** - * "y": op #byte (bipush and - * newarray) - */ - public static final int FMT_LITERAL_BYTE = 12; - - /** "I": invokeinterface cpi cpi count 0 */ - public static final int FMT_INVOKEINTERFACE = 13; - - /** "L": ldc #cpi; constant restricted as specified */ - public static final int FMT_LDC = 14; - - /** "S": sipush #byte #byte */ - public static final int FMT_SIPUSH = 15; - - /** "T": tableswitch ... */ - public static final int FMT_TABLESWITCH = 16; - - /** "U": lookupswitch ... */ - public static final int FMT_LOOKUPSWITCH = 17; - - /** "M": multianewarray cpi cpi dims */ - public static final int FMT_MULTIANEWARRAY = 18; - - /** "W": wide ... */ - public static final int FMT_WIDE = 19; - - /** mask for the bits representing the opcode format */ - public static final int FMT_MASK = 0x1f; - - /** "I": flag bit for valid cp type for Integer */ - public static final int CPOK_Integer = 0x20; - - /** "F": flag bit for valid cp type for Float */ - public static final int CPOK_Float = 0x40; - - /** "J": flag bit for valid cp type for Long */ - public static final int CPOK_Long = 0x80; - - /** "D": flag bit for valid cp type for Double */ - public static final int CPOK_Double = 0x100; - - /** "c": flag bit for valid cp type for Class */ - public static final int CPOK_Class = 0x200; - - /** "s": flag bit for valid cp type for String */ - public static final int CPOK_String = 0x400; - - /** "f": flag bit for valid cp type for Fieldref */ - public static final int CPOK_Fieldref = 0x800; - - /** "m": flag bit for valid cp type for Methodref */ - public static final int CPOK_Methodref = 0x1000; - - /** "i": flag bit for valid cp type for InterfaceMethodref */ - public static final int CPOK_InterfaceMethodref = 0x2000; - - /** - * non-null; map from opcodes to format or'ed with allowed constant - * pool types - */ - private static final int[] OPCODE_INFO = new int[256]; - - /** non-null; map from opcodes to their names */ - private static final String[] OPCODE_NAMES = new String[256]; - - /** non-null; bigass string describing all the opcodes */ - private static final String OPCODE_DETAILS = - "00 - nop;" + - "01 - aconst_null;" + - "02 - iconst_m1;" + - "03 - iconst_0;" + - "04 - iconst_1;" + - "05 - iconst_2;" + - "06 - iconst_3;" + - "07 - iconst_4;" + - "08 - iconst_5;" + - "09 - lconst_0;" + - "0a - lconst_1;" + - "0b - fconst_0;" + - "0c - fconst_1;" + - "0d - fconst_2;" + - "0e - dconst_0;" + - "0f - dconst_1;" + - "10 y bipush;" + - "11 S sipush;" + - "12 L:IFcs ldc;" + - "13 p:IFcs ldc_w;" + - "14 p:DJ ldc2_w;" + - "15 l iload;" + - "16 m lload;" + - "17 l fload;" + - "18 m dload;" + - "19 l aload;" + - "1a 0 iload_0;" + - "1b 1 iload_1;" + - "1c 2 iload_2;" + - "1d 3 iload_3;" + - "1e 1 lload_0;" + - "1f 2 lload_1;" + - "20 3 lload_2;" + - "21 4 lload_3;" + - "22 0 fload_0;" + - "23 1 fload_1;" + - "24 2 fload_2;" + - "25 3 fload_3;" + - "26 1 dload_0;" + - "27 2 dload_1;" + - "28 3 dload_2;" + - "29 4 dload_3;" + - "2a 0 aload_0;" + - "2b 1 aload_1;" + - "2c 2 aload_2;" + - "2d 3 aload_3;" + - "2e - iaload;" + - "2f - laload;" + - "30 - faload;" + - "31 - daload;" + - "32 - aaload;" + - "33 - baload;" + - "34 - caload;" + - "35 - saload;" + - "36 - istore;" + - "37 - lstore;" + - "38 - fstore;" + - "39 - dstore;" + - "3a - astore;" + - "3b 0 istore_0;" + - "3c 1 istore_1;" + - "3d 2 istore_2;" + - "3e 3 istore_3;" + - "3f 1 lstore_0;" + - "40 2 lstore_1;" + - "41 3 lstore_2;" + - "42 4 lstore_3;" + - "43 0 fstore_0;" + - "44 1 fstore_1;" + - "45 2 fstore_2;" + - "46 3 fstore_3;" + - "47 1 dstore_0;" + - "48 2 dstore_1;" + - "49 3 dstore_2;" + - "4a 4 dstore_3;" + - "4b 0 astore_0;" + - "4c 1 astore_1;" + - "4d 2 astore_2;" + - "4e 3 astore_3;" + - "4f - iastore;" + - "50 - lastore;" + - "51 - fastore;" + - "52 - dastore;" + - "53 - aastore;" + - "54 - bastore;" + - "55 - castore;" + - "56 - sastore;" + - "57 - pop;" + - "58 - pop2;" + - "59 - dup;" + - "5a - dup_x1;" + - "5b - dup_x2;" + - "5c - dup2;" + - "5d - dup2_x1;" + - "5e - dup2_x2;" + - "5f - swap;" + - "60 - iadd;" + - "61 - ladd;" + - "62 - fadd;" + - "63 - dadd;" + - "64 - isub;" + - "65 - lsub;" + - "66 - fsub;" + - "67 - dsub;" + - "68 - imul;" + - "69 - lmul;" + - "6a - fmul;" + - "6b - dmul;" + - "6c - idiv;" + - "6d - ldiv;" + - "6e - fdiv;" + - "6f - ddiv;" + - "70 - irem;" + - "71 - lrem;" + - "72 - frem;" + - "73 - drem;" + - "74 - ineg;" + - "75 - lneg;" + - "76 - fneg;" + - "77 - dneg;" + - "78 - ishl;" + - "79 - lshl;" + - "7a - ishr;" + - "7b - lshr;" + - "7c - iushr;" + - "7d - lushr;" + - "7e - iand;" + - "7f - land;" + - "80 - ior;" + - "81 - lor;" + - "82 - ixor;" + - "83 - lxor;" + - "84 l iinc;" + - "85 - i2l;" + - "86 - i2f;" + - "87 - i2d;" + - "88 - l2i;" + - "89 - l2f;" + - "8a - l2d;" + - "8b - f2i;" + - "8c - f2l;" + - "8d - f2d;" + - "8e - d2i;" + - "8f - d2l;" + - "90 - d2f;" + - "91 - i2b;" + - "92 - i2c;" + - "93 - i2s;" + - "94 - lcmp;" + - "95 - fcmpl;" + - "96 - fcmpg;" + - "97 - dcmpl;" + - "98 - dcmpg;" + - "99 b ifeq;" + - "9a b ifne;" + - "9b b iflt;" + - "9c b ifge;" + - "9d b ifgt;" + - "9e b ifle;" + - "9f b if_icmpeq;" + - "a0 b if_icmpne;" + - "a1 b if_icmplt;" + - "a2 b if_icmpge;" + - "a3 b if_icmpgt;" + - "a4 b if_icmple;" + - "a5 b if_acmpeq;" + - "a6 b if_acmpne;" + - "a7 b goto;" + - "a8 b jsr;" + - "a9 l ret;" + - "aa T tableswitch;" + - "ab U lookupswitch;" + - "ac - ireturn;" + - "ad - lreturn;" + - "ae - freturn;" + - "af - dreturn;" + - "b0 - areturn;" + - "b1 - return;" + - "b2 p:f getstatic;" + - "b3 p:f putstatic;" + - "b4 p:f getfield;" + - "b5 p:f putfield;" + - "b6 p:m invokevirtual;" + - "b7 p:m invokespecial;" + - "b8 p:m invokestatic;" + - "b9 I:i invokeinterface;" + - "bb p:c new;" + - "bc y newarray;" + - "bd p:c anewarray;" + - "be - arraylength;" + - "bf - athrow;" + - "c0 p:c checkcast;" + - "c1 p:c instanceof;" + - "c2 - monitorenter;" + - "c3 - monitorexit;" + - "c4 W wide;" + - "c5 M:c multianewarray;" + - "c6 b ifnull;" + - "c7 b ifnonnull;" + - "c8 c goto_w;" + - "c9 c jsr_w;"; - - static { - // Set up OPCODE_INFO and OPCODE_NAMES. - String s = OPCODE_DETAILS; - int len = s.length(); - - for (int i = 0; i < len; /*i*/) { - int idx = (Character.digit(s.charAt(i), 16) << 4) | - Character.digit(s.charAt(i + 1), 16); - int info; - switch (s.charAt(i + 3)) { - case '-': info = FMT_NO_ARGS; break; - case '0': info = FMT_NO_ARGS_LOCALS_1; break; - case '1': info = FMT_NO_ARGS_LOCALS_2; break; - case '2': info = FMT_NO_ARGS_LOCALS_3; break; - case '3': info = FMT_NO_ARGS_LOCALS_4; break; - case '4': info = FMT_NO_ARGS_LOCALS_5; break; - case 'b': info = FMT_BRANCH; break; - case 'c': info = FMT_WIDE_BRANCH; break; - case 'p': info = FMT_CPI; break; - case 'l': info = FMT_LOCAL_1; break; - case 'm': info = FMT_LOCAL_2; break; - case 'y': info = FMT_LITERAL_BYTE; break; - case 'I': info = FMT_INVOKEINTERFACE; break; - case 'L': info = FMT_LDC; break; - case 'S': info = FMT_SIPUSH; break; - case 'T': info = FMT_TABLESWITCH; break; - case 'U': info = FMT_LOOKUPSWITCH; break; - case 'M': info = FMT_MULTIANEWARRAY; break; - case 'W': info = FMT_WIDE; break; - default: info = FMT_INVALID; break; - } - - i += 5; - if (s.charAt(i - 1) == ':') { - inner: - for (;;) { - switch (s.charAt(i)) { - case 'I': info |= CPOK_Integer; break; - case 'F': info |= CPOK_Float; break; - case 'J': info |= CPOK_Long; break; - case 'D': info |= CPOK_Double; break; - case 'c': info |= CPOK_Class; break; - case 's': info |= CPOK_String; break; - case 'f': info |= CPOK_Fieldref; break; - case 'm': info |= CPOK_Methodref; break; - case 'i': info |= CPOK_InterfaceMethodref; break; - default: break inner; - } - i++; - } - i++; - } - - int endAt = s.indexOf(';', i); - OPCODE_INFO[idx] = info; - OPCODE_NAMES[idx] = s.substring(i, endAt); - i = endAt + 1; - } - } - - /** - * This class is uninstantiable. - */ - private ByteOps() { - // This space intentionally left blank. - } - - /** - * Gets the name of the given opcode. - * - * @param opcode >= 0, <= 255; the opcode - * @return non-null; its name - */ - public static String opName(int opcode) { - String result = OPCODE_NAMES[opcode]; - - if (result == null) { - result = "unused_" + Hex.u1(opcode); - OPCODE_NAMES[opcode] = result; - } - - return result; - } - - /** - * Gets the format and allowed cp types of the given opcode. - * - * @param opcode >= 0, <= 255; the opcode - * @return its format and allowed cp types - */ - public static int opInfo(int opcode) { - return OPCODE_INFO[opcode]; - } -} diff --git a/dx/src/com/android/dx/cf/code/BytecodeArray.java b/dx/src/com/android/dx/cf/code/BytecodeArray.java deleted file mode 100644 index 71ba029f6..000000000 --- a/dx/src/com/android/dx/cf/code/BytecodeArray.java +++ /dev/null @@ -1,1393 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.rop.cst.CstDouble; -import com.android.dx.rop.cst.CstFloat; -import com.android.dx.rop.cst.CstInteger; -import com.android.dx.rop.cst.CstKnownNull; -import com.android.dx.rop.cst.CstLiteralBits; -import com.android.dx.rop.cst.CstLong; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.Type; -import com.android.dx.util.Bits; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; -import java.util.ArrayList; - -/** - * Bytecode array, which is part of a standard Code attribute. - */ -public final class BytecodeArray { - /** convenient no-op implementation of {@link Visitor} */ - public static final Visitor EMPTY_VISITOR = new BaseVisitor(); - - /** non-null; underlying bytes */ - private final ByteArray bytes; - - /** non-null; constant pool to use when resolving constant pool indices */ - private final ConstantPool pool; - - /** - * Constructs an instance. - * - * @param bytes non-null; underlying bytes - * @param pool non-null; constant pool to use when resolving constant - * pool indices - */ - public BytecodeArray(ByteArray bytes, ConstantPool pool) { - if (bytes == null) { - throw new NullPointerException("bytes == null"); - } - - if (pool == null) { - throw new NullPointerException("pool == null"); - } - - this.bytes = bytes; - this.pool = pool; - } - - /** - * Gets the underlying byte array. - * - * @return non-null; the byte array - */ - public ByteArray getBytes() { - return bytes; - } - - /** - * Gets the size of the bytecode array, per se. - * - * @return >= 0; the length of the bytecode array - */ - public int size() { - return bytes.size(); - } - - /** - * Gets the total length of this structure in bytes, when included in - * a Code attribute. The returned value includes the - * array size plus four bytes for code_length. - * - * @return >= 4; the total length, in bytes - */ - public int byteLength() { - return 4 + bytes.size(); - } - - /** - * Parses each instruction in the array, in order. - * - * @param visitor null-ok; visitor to call back to for each instruction - */ - public void forEach(Visitor visitor) { - int sz = bytes.size(); - int at = 0; - - while (at < sz) { - /* - * Don't record the previous offset here, so that we get to see the - * raw code that initializes the array - */ - at += parseInstruction(at, visitor); - } - } - - /** - * Finds the offset to each instruction in the bytecode array. The - * result is a bit set with the offset of each opcode-per-se flipped on. - * - * @see Bits - * @return non-null; appropriately constructed bit set - */ - public int[] getInstructionOffsets() { - int sz = bytes.size(); - int[] result = Bits.makeBitSet(sz); - int at = 0; - - while (at < sz) { - Bits.set(result, at, true); - int length = parseInstruction(at, null); - at += length; - } - - return result; - } - - /** - * Processes the given "work set" by repeatedly finding the lowest bit - * in the set, clearing it, and parsing and visiting the instruction at - * the indicated offset (that is, the bit index), repeating until the - * work set is empty. It is expected that the visitor will regularly - * set new bits in the work set during the process. - * - * @param workSet non-null; the work set to process - * @param visitor non-null; visitor to call back to for each instruction - */ - public void processWorkSet(int[] workSet, Visitor visitor) { - if (visitor == null) { - throw new NullPointerException("visitor == null"); - } - - for (;;) { - int offset = Bits.findFirst(workSet, 0); - if (offset < 0) { - break; - } - Bits.clear(workSet, offset); - parseInstruction(offset, visitor); - visitor.setPreviousOffset(offset); - } - } - - /** - * Parses the instruction at the indicated offset. Indicate the - * result by calling the visitor if supplied and by returning the - * number of bytes consumed by the instruction. - * - *

In order to simplify further processing, the opcodes passed - * to the visitor are canonicalized, altering the opcode to a more - * universal one and making formerly implicit arguments - * explicit. In particular:

- * - *
    - *
  • The opcodes to push literal constants of primitive types all become - * ldc. - * E.g., fconst_0, sipush, and - * lconst_0 qualify for this treatment.
  • - *
  • aconst_null becomes ldc of a - * "known null."
  • - *
  • Shorthand local variable accessors become the corresponding - * longhand. E.g. aload_2 becomes aload.
  • - *
  • goto_w and jsr_w become goto - * and jsr (respectively).
  • - *
  • ldc_w becomes ldc.
  • - *
  • tableswitch becomes lookupswitch. - *
  • Arithmetic, array, and value-returning ops are collapsed - * to the int variant opcode, with the type - * argument set to indicate the actual type. E.g., - * fadd becomes iadd, but - * type is passed as Type.FLOAT in that - * case. Similarly, areturn becomes - * ireturn. (However, return remains - * unchanged.
  • - *
  • Local variable access ops are collapsed to the int - * variant opcode, with the type argument set to indicate - * the actual type. E.g., aload becomes iload, - * but type is passed as Type.OBJECT in - * that case.
  • - *
  • Numeric conversion ops (i2l, etc.) are left alone - * to avoid too much confustion, but their type is - * the pushed type. E.g., i2b gets type - * Type.INT, and f2d gets type - * Type.DOUBLE. Other unaltered opcodes also get - * their pushed type. E.g., arraylength gets type - * Type.INT.
  • - *
- * - * @param offset >= 0, < bytes.size(); offset to the start of the - * instruction - * @param visitor null-ok; visitor to call back to - * @return the length of the instruction, in bytes - */ - public int parseInstruction(int offset, Visitor visitor) { - if (visitor == null) { - visitor = EMPTY_VISITOR; - } - - try { - int opcode = bytes.getUnsignedByte(offset); - int info = ByteOps.opInfo(opcode); - int fmt = info & ByteOps.FMT_MASK; - - switch (opcode) { - case ByteOps.NOP: { - visitor.visitNoArgs(opcode, offset, 1, Type.VOID); - return 1; - } - case ByteOps.ACONST_NULL: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstKnownNull.THE_ONE, 0); - return 1; - } - case ByteOps.ICONST_M1: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstInteger.VALUE_M1, -1); - return 1; - } - case ByteOps.ICONST_0: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstInteger.VALUE_0, 0); - return 1; - } - case ByteOps.ICONST_1: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstInteger.VALUE_1, 1); - return 1; - } - case ByteOps.ICONST_2: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstInteger.VALUE_2, 2); - return 1; - } - case ByteOps.ICONST_3: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstInteger.VALUE_3, 3); - return 1; - } - case ByteOps.ICONST_4: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstInteger.VALUE_4, 4); - return 1; - } - case ByteOps.ICONST_5: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstInteger.VALUE_5, 5); - return 1; - } - case ByteOps.LCONST_0: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstLong.VALUE_0, 0); - return 1; - } - case ByteOps.LCONST_1: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstLong.VALUE_1, 0); - return 1; - } - case ByteOps.FCONST_0: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstFloat.VALUE_0, 0); - return 1; - } - case ByteOps.FCONST_1: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstFloat.VALUE_1, 0); - return 1; - } - case ByteOps.FCONST_2: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstFloat.VALUE_2, 0); - return 1; - } - case ByteOps.DCONST_0: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstDouble.VALUE_0, 0); - return 1; - } - case ByteOps.DCONST_1: { - visitor.visitConstant(ByteOps.LDC, offset, 1, - CstDouble.VALUE_1, 0); - return 1; - } - case ByteOps.BIPUSH: { - int value = bytes.getByte(offset + 1); - visitor.visitConstant(ByteOps.LDC, offset, 2, - CstInteger.make(value), value); - return 2; - } - case ByteOps.SIPUSH: { - int value = bytes.getShort(offset + 1); - visitor.visitConstant(ByteOps.LDC, offset, 3, - CstInteger.make(value), value); - return 3; - } - case ByteOps.LDC: { - int idx = bytes.getUnsignedByte(offset + 1); - Constant cst = pool.get(idx); - int value = (cst instanceof CstInteger) ? - ((CstInteger) cst).getValue() : 0; - visitor.visitConstant(ByteOps.LDC, offset, 2, cst, value); - return 2; - } - case ByteOps.LDC_W: { - int idx = bytes.getUnsignedShort(offset + 1); - Constant cst = pool.get(idx); - int value = (cst instanceof CstInteger) ? - ((CstInteger) cst).getValue() : 0; - visitor.visitConstant(ByteOps.LDC, offset, 3, cst, value); - return 3; - } - case ByteOps.LDC2_W: { - int idx = bytes.getUnsignedShort(offset + 1); - Constant cst = pool.get(idx); - visitor.visitConstant(ByteOps.LDC2_W, offset, 3, cst, 0); - return 3; - } - case ByteOps.ILOAD: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ILOAD, offset, 2, idx, - Type.INT, 0); - return 2; - } - case ByteOps.LLOAD: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ILOAD, offset, 2, idx, - Type.LONG, 0); - return 2; - } - case ByteOps.FLOAD: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ILOAD, offset, 2, idx, - Type.FLOAT, 0); - return 2; - } - case ByteOps.DLOAD: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ILOAD, offset, 2, idx, - Type.DOUBLE, 0); - return 2; - } - case ByteOps.ALOAD: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ILOAD, offset, 2, idx, - Type.OBJECT, 0); - return 2; - } - case ByteOps.ILOAD_0: - case ByteOps.ILOAD_1: - case ByteOps.ILOAD_2: - case ByteOps.ILOAD_3: { - int idx = opcode - ByteOps.ILOAD_0; - visitor.visitLocal(ByteOps.ILOAD, offset, 1, idx, - Type.INT, 0); - return 1; - } - case ByteOps.LLOAD_0: - case ByteOps.LLOAD_1: - case ByteOps.LLOAD_2: - case ByteOps.LLOAD_3: { - int idx = opcode - ByteOps.LLOAD_0; - visitor.visitLocal(ByteOps.ILOAD, offset, 1, idx, - Type.LONG, 0); - return 1; - } - case ByteOps.FLOAD_0: - case ByteOps.FLOAD_1: - case ByteOps.FLOAD_2: - case ByteOps.FLOAD_3: { - int idx = opcode - ByteOps.FLOAD_0; - visitor.visitLocal(ByteOps.ILOAD, offset, 1, idx, - Type.FLOAT, 0); - return 1; - } - case ByteOps.DLOAD_0: - case ByteOps.DLOAD_1: - case ByteOps.DLOAD_2: - case ByteOps.DLOAD_3: { - int idx = opcode - ByteOps.DLOAD_0; - visitor.visitLocal(ByteOps.ILOAD, offset, 1, idx, - Type.DOUBLE, 0); - return 1; - } - case ByteOps.ALOAD_0: - case ByteOps.ALOAD_1: - case ByteOps.ALOAD_2: - case ByteOps.ALOAD_3: { - int idx = opcode - ByteOps.ALOAD_0; - visitor.visitLocal(ByteOps.ILOAD, offset, 1, idx, - Type.OBJECT, 0); - return 1; - } - case ByteOps.IALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, Type.INT); - return 1; - } - case ByteOps.LALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, Type.LONG); - return 1; - } - case ByteOps.FALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, - Type.FLOAT); - return 1; - } - case ByteOps.DALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, - Type.DOUBLE); - return 1; - } - case ByteOps.AALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, - Type.OBJECT); - return 1; - } - case ByteOps.BALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, Type.BYTE); - return 1; - } - case ByteOps.CALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, Type.CHAR); - return 1; - } - case ByteOps.SALOAD: { - visitor.visitNoArgs(ByteOps.IALOAD, offset, 1, - Type.SHORT); - return 1; - } - case ByteOps.ISTORE: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ISTORE, offset, 2, idx, - Type.INT, 0); - return 2; - } - case ByteOps.LSTORE: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ISTORE, offset, 2, idx, - Type.LONG, 0); - return 2; - } - case ByteOps.FSTORE: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ISTORE, offset, 2, idx, - Type.FLOAT, 0); - return 2; - } - case ByteOps.DSTORE: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ISTORE, offset, 2, idx, - Type.DOUBLE, 0); - return 2; - } - case ByteOps.ASTORE: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(ByteOps.ISTORE, offset, 2, idx, - Type.OBJECT, 0); - return 2; - } - case ByteOps.ISTORE_0: - case ByteOps.ISTORE_1: - case ByteOps.ISTORE_2: - case ByteOps.ISTORE_3: { - int idx = opcode - ByteOps.ISTORE_0; - visitor.visitLocal(ByteOps.ISTORE, offset, 1, idx, - Type.INT, 0); - return 1; - } - case ByteOps.LSTORE_0: - case ByteOps.LSTORE_1: - case ByteOps.LSTORE_2: - case ByteOps.LSTORE_3: { - int idx = opcode - ByteOps.LSTORE_0; - visitor.visitLocal(ByteOps.ISTORE, offset, 1, idx, - Type.LONG, 0); - return 1; - } - case ByteOps.FSTORE_0: - case ByteOps.FSTORE_1: - case ByteOps.FSTORE_2: - case ByteOps.FSTORE_3: { - int idx = opcode - ByteOps.FSTORE_0; - visitor.visitLocal(ByteOps.ISTORE, offset, 1, idx, - Type.FLOAT, 0); - return 1; - } - case ByteOps.DSTORE_0: - case ByteOps.DSTORE_1: - case ByteOps.DSTORE_2: - case ByteOps.DSTORE_3: { - int idx = opcode - ByteOps.DSTORE_0; - visitor.visitLocal(ByteOps.ISTORE, offset, 1, idx, - Type.DOUBLE, 0); - return 1; - } - case ByteOps.ASTORE_0: - case ByteOps.ASTORE_1: - case ByteOps.ASTORE_2: - case ByteOps.ASTORE_3: { - int idx = opcode - ByteOps.ASTORE_0; - visitor.visitLocal(ByteOps.ISTORE, offset, 1, idx, - Type.OBJECT, 0); - return 1; - } - case ByteOps.IASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, Type.INT); - return 1; - } - case ByteOps.LASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, - Type.LONG); - return 1; - } - case ByteOps.FASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, - Type.FLOAT); - return 1; - } - case ByteOps.DASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, - Type.DOUBLE); - return 1; - } - case ByteOps.AASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, - Type.OBJECT); - return 1; - } - case ByteOps.BASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, - Type.BYTE); - return 1; - } - case ByteOps.CASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, - Type.CHAR); - return 1; - } - case ByteOps.SASTORE: { - visitor.visitNoArgs(ByteOps.IASTORE, offset, 1, - Type.SHORT); - return 1; - } - case ByteOps.POP: - case ByteOps.POP2: - case ByteOps.DUP: - case ByteOps.DUP_X1: - case ByteOps.DUP_X2: - case ByteOps.DUP2: - case ByteOps.DUP2_X1: - case ByteOps.DUP2_X2: - case ByteOps.SWAP: { - visitor.visitNoArgs(opcode, offset, 1, Type.VOID); - return 1; - } - case ByteOps.IADD: - case ByteOps.ISUB: - case ByteOps.IMUL: - case ByteOps.IDIV: - case ByteOps.IREM: - case ByteOps.INEG: - case ByteOps.ISHL: - case ByteOps.ISHR: - case ByteOps.IUSHR: - case ByteOps.IAND: - case ByteOps.IOR: - case ByteOps.IXOR: { - visitor.visitNoArgs(opcode, offset, 1, Type.INT); - return 1; - } - case ByteOps.LADD: - case ByteOps.LSUB: - case ByteOps.LMUL: - case ByteOps.LDIV: - case ByteOps.LREM: - case ByteOps.LNEG: - case ByteOps.LSHL: - case ByteOps.LSHR: - case ByteOps.LUSHR: - case ByteOps.LAND: - case ByteOps.LOR: - case ByteOps.LXOR: { - /* - * It's "opcode - 1" because, conveniently enough, all - * these long ops are one past the int variants. - */ - visitor.visitNoArgs(opcode - 1, offset, 1, Type.LONG); - return 1; - } - case ByteOps.FADD: - case ByteOps.FSUB: - case ByteOps.FMUL: - case ByteOps.FDIV: - case ByteOps.FREM: - case ByteOps.FNEG: { - /* - * It's "opcode - 2" because, conveniently enough, all - * these float ops are two past the int variants. - */ - visitor.visitNoArgs(opcode - 2, offset, 1, Type.FLOAT); - return 1; - } - case ByteOps.DADD: - case ByteOps.DSUB: - case ByteOps.DMUL: - case ByteOps.DDIV: - case ByteOps.DREM: - case ByteOps.DNEG: { - /* - * It's "opcode - 3" because, conveniently enough, all - * these double ops are three past the int variants. - */ - visitor.visitNoArgs(opcode - 3, offset, 1, Type.DOUBLE); - return 1; - } - case ByteOps.IINC: { - int idx = bytes.getUnsignedByte(offset + 1); - int value = bytes.getByte(offset + 2); - visitor.visitLocal(opcode, offset, 3, idx, - Type.INT, value); - return 3; - } - case ByteOps.I2L: - case ByteOps.F2L: - case ByteOps.D2L: { - visitor.visitNoArgs(opcode, offset, 1, Type.LONG); - return 1; - } - case ByteOps.I2F: - case ByteOps.L2F: - case ByteOps.D2F: { - visitor.visitNoArgs(opcode, offset, 1, Type.FLOAT); - return 1; - } - case ByteOps.I2D: - case ByteOps.L2D: - case ByteOps.F2D: { - visitor.visitNoArgs(opcode, offset, 1, Type.DOUBLE); - return 1; - } - case ByteOps.L2I: - case ByteOps.F2I: - case ByteOps.D2I: - case ByteOps.I2B: - case ByteOps.I2C: - case ByteOps.I2S: - case ByteOps.LCMP: - case ByteOps.FCMPL: - case ByteOps.FCMPG: - case ByteOps.DCMPL: - case ByteOps.DCMPG: - case ByteOps.ARRAYLENGTH: { - visitor.visitNoArgs(opcode, offset, 1, Type.INT); - return 1; - } - case ByteOps.IFEQ: - case ByteOps.IFNE: - case ByteOps.IFLT: - case ByteOps.IFGE: - case ByteOps.IFGT: - case ByteOps.IFLE: - case ByteOps.IF_ICMPEQ: - case ByteOps.IF_ICMPNE: - case ByteOps.IF_ICMPLT: - case ByteOps.IF_ICMPGE: - case ByteOps.IF_ICMPGT: - case ByteOps.IF_ICMPLE: - case ByteOps.IF_ACMPEQ: - case ByteOps.IF_ACMPNE: - case ByteOps.GOTO: - case ByteOps.JSR: - case ByteOps.IFNULL: - case ByteOps.IFNONNULL: { - int target = offset + bytes.getShort(offset + 1); - visitor.visitBranch(opcode, offset, 3, target); - return 3; - } - case ByteOps.RET: { - int idx = bytes.getUnsignedByte(offset + 1); - visitor.visitLocal(opcode, offset, 2, idx, - Type.RETURN_ADDRESS, 0); - return 2; - } - case ByteOps.TABLESWITCH: { - return parseTableswitch(offset, visitor); - } - case ByteOps.LOOKUPSWITCH: { - return parseLookupswitch(offset, visitor); - } - case ByteOps.IRETURN: { - visitor.visitNoArgs(ByteOps.IRETURN, offset, 1, Type.INT); - return 1; - } - case ByteOps.LRETURN: { - visitor.visitNoArgs(ByteOps.IRETURN, offset, 1, - Type.LONG); - return 1; - } - case ByteOps.FRETURN: { - visitor.visitNoArgs(ByteOps.IRETURN, offset, 1, - Type.FLOAT); - return 1; - } - case ByteOps.DRETURN: { - visitor.visitNoArgs(ByteOps.IRETURN, offset, 1, - Type.DOUBLE); - return 1; - } - case ByteOps.ARETURN: { - visitor.visitNoArgs(ByteOps.IRETURN, offset, 1, - Type.OBJECT); - return 1; - } - case ByteOps.RETURN: - case ByteOps.ATHROW: - case ByteOps.MONITORENTER: - case ByteOps.MONITOREXIT: { - visitor.visitNoArgs(opcode, offset, 1, Type.VOID); - return 1; - } - case ByteOps.GETSTATIC: - case ByteOps.PUTSTATIC: - case ByteOps.GETFIELD: - case ByteOps.PUTFIELD: - case ByteOps.INVOKEVIRTUAL: - case ByteOps.INVOKESPECIAL: - case ByteOps.INVOKESTATIC: - case ByteOps.NEW: - case ByteOps.ANEWARRAY: - case ByteOps.CHECKCAST: - case ByteOps.INSTANCEOF: { - int idx = bytes.getUnsignedShort(offset + 1); - Constant cst = pool.get(idx); - visitor.visitConstant(opcode, offset, 3, cst, 0); - return 3; - } - case ByteOps.INVOKEINTERFACE: { - int idx = bytes.getUnsignedShort(offset + 1); - int count = bytes.getUnsignedByte(offset + 3); - int expectZero = bytes.getUnsignedByte(offset + 4); - Constant cst = pool.get(idx); - visitor.visitConstant(opcode, offset, 5, cst, - count | (expectZero << 8)); - return 5; - } - case ByteOps.NEWARRAY: { - return parseNewarray(offset, visitor); - } - case ByteOps.WIDE: { - return parseWide(offset, visitor); - } - case ByteOps.MULTIANEWARRAY: { - int idx = bytes.getUnsignedShort(offset + 1); - int dimensions = bytes.getUnsignedByte(offset + 3); - Constant cst = pool.get(idx); - visitor.visitConstant(opcode, offset, 4, cst, dimensions); - return 4; - } - case ByteOps.GOTO_W: - case ByteOps.JSR_W: { - int target = offset + bytes.getInt(offset + 1); - int newop = - (opcode == ByteOps.GOTO_W) ? ByteOps.GOTO : - ByteOps.JSR; - visitor.visitBranch(newop, offset, 5, target); - return 5; - } - default: { - visitor.visitInvalid(opcode, offset, 1); - return 1; - } - } - } catch (SimException ex) { - ex.addContext("...at bytecode offset " + Hex.u4(offset)); - throw ex; - } catch (RuntimeException ex) { - SimException se = new SimException(ex); - se.addContext("...at bytecode offset " + Hex.u4(offset)); - throw se; - } - } - - /** - * Helper to deal with tableswitch. - * - * @param offset the offset to the tableswitch opcode itself - * @param visitor non-null; visitor to use - * @return instruction length, in bytes - */ - private int parseTableswitch(int offset, Visitor visitor) { - int at = (offset + 4) & ~3; // "at" skips the padding. - - // Collect the padding. - int padding = 0; - for (int i = offset + 1; i < at; i++) { - padding = (padding << 8) | bytes.getUnsignedByte(i); - } - - int defaultTarget = offset + bytes.getInt(at); - int low = bytes.getInt(at + 4); - int high = bytes.getInt(at + 8); - int count = high - low + 1; - at += 12; - - if (low > high) { - throw new SimException("low / high inversion"); - } - - SwitchList cases = new SwitchList(count); - for (int i = 0; i < count; i++) { - int target = offset + bytes.getInt(at); - at += 4; - cases.add(low + i, target); - } - cases.setDefaultTarget(defaultTarget); - cases.removeSuperfluousDefaults(); - cases.setImmutable(); - - int length = at - offset; - visitor.visitSwitch(ByteOps.LOOKUPSWITCH, offset, length, cases, - padding); - - return length; - } - - /** - * Helper to deal with lookupswitch. - * - * @param offset the offset to the lookupswitch opcode itself - * @param visitor non-null; visitor to use - * @return instruction length, in bytes - */ - private int parseLookupswitch(int offset, Visitor visitor) { - int at = (offset + 4) & ~3; // "at" skips the padding. - - // Collect the padding. - int padding = 0; - for (int i = offset + 1; i < at; i++) { - padding = (padding << 8) | bytes.getUnsignedByte(i); - } - - int defaultTarget = offset + bytes.getInt(at); - int npairs = bytes.getInt(at + 4); - at += 8; - - SwitchList cases = new SwitchList(npairs); - for (int i = 0; i < npairs; i++) { - int match = bytes.getInt(at); - int target = offset + bytes.getInt(at + 4); - at += 8; - cases.add(match, target); - } - cases.setDefaultTarget(defaultTarget); - cases.removeSuperfluousDefaults(); - cases.setImmutable(); - - int length = at - offset; - visitor.visitSwitch(ByteOps.LOOKUPSWITCH, offset, length, cases, - padding); - - return length; - } - - /** - * Helper to deal with newarray. - * - * @param offset the offset to the newarray opcode itself - * @param visitor non-null; visitor to use - * @return instruction length, in bytes - */ - private int parseNewarray(int offset, Visitor visitor) { - int value = bytes.getUnsignedByte(offset + 1); - CstType type; - switch (value) { - case ByteOps.NEWARRAY_BOOLEAN: { - type = CstType.BOOLEAN_ARRAY; - break; - } - case ByteOps.NEWARRAY_CHAR: { - type = CstType.CHAR_ARRAY; - break; - } - case ByteOps.NEWARRAY_DOUBLE: { - type = CstType.DOUBLE_ARRAY; - break; - } - case ByteOps.NEWARRAY_FLOAT: { - type = CstType.FLOAT_ARRAY; - break; - } - case ByteOps.NEWARRAY_BYTE: { - type = CstType.BYTE_ARRAY; - break; - } - case ByteOps.NEWARRAY_SHORT: { - type = CstType.SHORT_ARRAY; - break; - } - case ByteOps.NEWARRAY_INT: { - type = CstType.INT_ARRAY; - break; - } - case ByteOps.NEWARRAY_LONG: { - type = CstType.LONG_ARRAY; - break; - } - default: { - throw new SimException("bad newarray code " + - Hex.u1(value)); - } - } - - // Revisit the previous bytecode to find out the length of the array - int previousOffset = visitor.getPreviousOffset(); - ConstantParserVisitor constantVisitor = new ConstantParserVisitor(); - int arrayLength = 0; - - /* - * For visitors that don't record the previous offset, -1 will be - * seen here - */ - if (previousOffset >= 0) { - parseInstruction(previousOffset, constantVisitor); - if (constantVisitor.cst instanceof CstInteger && - constantVisitor.length + previousOffset == offset) { - arrayLength = constantVisitor.value; - - } - } - - /* - * Try to match the array initialization idiom. For example, if the - * subsequent code is initializing an int array, we are expecting the - * following pattern repeatedly: - * dup - * push index - * push value - * *astore - * - * where the index value will be incrimented sequentially from 0 up. - */ - int nInit = 0; - int curOffset = offset+2; - int lastOffset = curOffset; - ArrayList initVals = new ArrayList(); - - if (arrayLength != 0) { - while (true) { - boolean punt = false; - - // First check if the next bytecode is dup - int nextByte = bytes.getUnsignedByte(curOffset++); - if (nextByte != ByteOps.DUP) - break; - - // Next check if the expected array index is pushed to the stack - parseInstruction(curOffset, constantVisitor); - if (constantVisitor.length == 0 || - !(constantVisitor.cst instanceof CstInteger) || - constantVisitor.value != nInit) - break; - - // Next, fetch the init value and record it - curOffset += constantVisitor.length; - - // Next find out what kind of constant is pushed onto the stack - parseInstruction(curOffset, constantVisitor); - if (constantVisitor.length == 0 || - !(constantVisitor.cst instanceof CstLiteralBits)) - break; - - curOffset += constantVisitor.length; - initVals.add(constantVisitor.cst); - - nextByte = bytes.getUnsignedByte(curOffset++); - // Now, check if the value is stored to the array properly - switch (value) { - case ByteOps.NEWARRAY_BYTE: - case ByteOps.NEWARRAY_BOOLEAN: { - if (nextByte != ByteOps.BASTORE) { - punt = true; - } - break; - } - case ByteOps.NEWARRAY_CHAR: { - if (nextByte != ByteOps.CASTORE) { - punt = true; - } - break; - } - case ByteOps.NEWARRAY_DOUBLE: { - if (nextByte != ByteOps.DASTORE) { - punt = true; - } - break; - } - case ByteOps.NEWARRAY_FLOAT: { - if (nextByte != ByteOps.FASTORE) { - punt = true; - } - break; - } - case ByteOps.NEWARRAY_SHORT: { - if (nextByte != ByteOps.SASTORE) { - punt = true; - } - break; - } - case ByteOps.NEWARRAY_INT: { - if (nextByte != ByteOps.IASTORE) { - punt = true; - } - break; - } - case ByteOps.NEWARRAY_LONG: { - if (nextByte != ByteOps.LASTORE) { - punt = true; - } - break; - } - default: - punt = true; - break; - } - if (punt) { - break; - } - lastOffset = curOffset; - nInit++; - } - } - - /* - * For singleton arrays it is still more economical to - * generate the aput. - */ - if (nInit < 2 || nInit != arrayLength) { - visitor.visitNewarray(offset, 2, type, null); - return 2; - } else { - visitor.visitNewarray(offset, lastOffset - offset, type, initVals); - return lastOffset - offset; - } - } - - - /** - * Helper to deal with wide. - * - * @param offset the offset to the wide opcode itself - * @param visitor non-null; visitor to use - * @return instruction length, in bytes - */ - private int parseWide(int offset, Visitor visitor) { - int opcode = bytes.getUnsignedByte(offset + 1); - int idx = bytes.getUnsignedShort(offset + 2); - switch (opcode) { - case ByteOps.ILOAD: { - visitor.visitLocal(ByteOps.ILOAD, offset, 4, idx, - Type.INT, 0); - return 4; - } - case ByteOps.LLOAD: { - visitor.visitLocal(ByteOps.ILOAD, offset, 4, idx, - Type.LONG, 0); - return 4; - } - case ByteOps.FLOAD: { - visitor.visitLocal(ByteOps.ILOAD, offset, 4, idx, - Type.FLOAT, 0); - return 4; - } - case ByteOps.DLOAD: { - visitor.visitLocal(ByteOps.ILOAD, offset, 4, idx, - Type.DOUBLE, 0); - return 4; - } - case ByteOps.ALOAD: { - visitor.visitLocal(ByteOps.ILOAD, offset, 4, idx, - Type.OBJECT, 0); - return 4; - } - case ByteOps.ISTORE: { - visitor.visitLocal(ByteOps.ISTORE, offset, 4, idx, - Type.INT, 0); - return 4; - } - case ByteOps.LSTORE: { - visitor.visitLocal(ByteOps.ISTORE, offset, 4, idx, - Type.LONG, 0); - return 4; - } - case ByteOps.FSTORE: { - visitor.visitLocal(ByteOps.ISTORE, offset, 4, idx, - Type.FLOAT, 0); - return 4; - } - case ByteOps.DSTORE: { - visitor.visitLocal(ByteOps.ISTORE, offset, 4, idx, - Type.DOUBLE, 0); - return 4; - } - case ByteOps.ASTORE: { - visitor.visitLocal(ByteOps.ISTORE, offset, 4, idx, - Type.OBJECT, 0); - return 4; - } - case ByteOps.RET: { - visitor.visitLocal(opcode, offset, 4, idx, - Type.RETURN_ADDRESS, 0); - return 4; - } - case ByteOps.IINC: { - int value = bytes.getShort(offset + 4); - visitor.visitLocal(opcode, offset, 6, idx, - Type.INT, value); - return 6; - } - default: { - visitor.visitInvalid(ByteOps.WIDE, offset, 1); - return 1; - } - } - } - - /** - * Instruction visitor interface. - */ - public interface Visitor { - /** - * Visits an invalid instruction. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - */ - public void visitInvalid(int opcode, int offset, int length); - - /** - * Visits an instruction which has no inline arguments - * (implicit or explicit). - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param type non-null; type the instruction operates on - */ - public void visitNoArgs(int opcode, int offset, int length, - Type type); - - /** - * Visits an instruction which has a local variable index argument. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param idx the local variable index - * @param type non-null; the type of the accessed value - * @param value additional literal integer argument, if salient (i.e., - * for iinc) - */ - public void visitLocal(int opcode, int offset, int length, - int idx, Type type, int value); - - /** - * Visits an instruction which has a (possibly synthetic) - * constant argument, and possibly also an - * additional literal integer argument. In the case of - * multianewarray, the argument is the count of - * dimensions. In the case of invokeinterface, - * the argument is the parameter count or'ed with the - * should-be-zero value left-shifted by 8. In the case of entries - * of type int, the value field always - * holds the raw value (for convenience of clients). - * - *

Note: In order to avoid giving it a barely-useful - * visitor all its own, newarray also uses this - * form, passing value as the array type code and - * cst as a {@link CstType} instance - * corresponding to the array type.

- * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param cst non-null; the constant - * @param value additional literal integer argument, if salient - * (ignore if not) - */ - public void visitConstant(int opcode, int offset, int length, - Constant cst, int value); - - /** - * Visits an instruction which has a branch target argument. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param target the absolute (not relative) branch target - */ - public void visitBranch(int opcode, int offset, int length, - int target); - - /** - * Visits a switch instruction. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param cases non-null; list of (value, target) pairs, plus the - * default target - * @param padding the bytes found in the padding area (if any), - * packed - */ - public void visitSwitch(int opcode, int offset, int length, - SwitchList cases, int padding); - - /** - * Visits a newarray instruction. - * - * @param offset offset to the instruction - * @param length length of the instruction, in bytes - * @param cst non-null; the type of the array - * @param initVals non-null; list of bytecode offsets for init values - */ - public void visitNewarray(int offset, int length, CstType type, - ArrayList initVals); - - /** - * Set previous bytecode offset - * @param offset offset of the previous fully parsed bytecode - */ - public void setPreviousOffset(int offset); - - /** - * Get previous bytecode offset - * @return return the recored offset of the previous bytecode - */ - public int getPreviousOffset(); - } - - /** - * Base implementation of {@link Visitor}, which has empty method - * bodies for all methods. - */ - public static class BaseVisitor implements Visitor { - - /** offset of the previously parsed bytecode */ - private int previousOffset; - - BaseVisitor() { - previousOffset = -1; - } - - /** {@inheritDoc} */ - public void visitInvalid(int opcode, int offset, int length) { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public void visitNoArgs(int opcode, int offset, int length, - Type type) { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public void visitLocal(int opcode, int offset, int length, - int idx, Type type, int value) { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public void visitConstant(int opcode, int offset, int length, - Constant cst, int value) { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public void visitBranch(int opcode, int offset, int length, - int target) { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public void visitSwitch(int opcode, int offset, int length, - SwitchList cases, int padding) { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public void visitNewarray(int offset, int length, CstType type, - ArrayList initValues) { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - public void setPreviousOffset(int offset) { - previousOffset = offset; - } - - /** {@inheritDoc} */ - public int getPreviousOffset() { - return previousOffset; - } - } - - /** - * Base implementation of {@link Visitor}, which has empty method - * bodies for all methods. - */ - class ConstantParserVisitor extends BaseVisitor { - Constant cst; - int length; - int value; - - /** Empty constructor */ - ConstantParserVisitor() { - } - - private void clear() { - length = 0; - } - - /** {@inheritDoc} */ - public void visitInvalid(int opcode, int offset, int length) { - clear(); - } - - /** {@inheritDoc} */ - public void visitNoArgs(int opcode, int offset, int length, - Type type) { - clear(); - } - - /** {@inheritDoc} */ - public void visitLocal(int opcode, int offset, int length, - int idx, Type type, int value) { - clear(); - } - - /** {@inheritDoc} */ - public void visitConstant(int opcode, int offset, int length, - Constant cst, int value) { - this.cst = cst; - this.length = length; - this.value = value; - } - - /** {@inheritDoc} */ - public void visitBranch(int opcode, int offset, int length, - int target) { - clear(); - } - - /** {@inheritDoc} */ - public void visitSwitch(int opcode, int offset, int length, - SwitchList cases, int padding) { - clear(); - } - - /** {@inheritDoc} */ - public void visitNewarray(int offset, int length, CstType type, - ArrayList initVals) { - clear(); - } - - /** {@inheritDoc} */ - public void setPreviousOffset(int offset) { - // Intentionally left empty - } - - /** {@inheritDoc} */ - public int getPreviousOffset() { - // Intentionally left empty - return -1; - } - } -} diff --git a/dx/src/com/android/dx/cf/code/ConcreteMethod.java b/dx/src/com/android/dx/cf/code/ConcreteMethod.java deleted file mode 100644 index 47f698dc2..000000000 --- a/dx/src/com/android/dx/cf/code/ConcreteMethod.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.cf.attrib.AttCode; -import com.android.dx.cf.attrib.AttLineNumberTable; -import com.android.dx.cf.attrib.AttLocalVariableTable; -import com.android.dx.cf.attrib.AttLocalVariableTypeTable; -import com.android.dx.cf.attrib.AttSourceFile; -import com.android.dx.cf.iface.AttributeList; -import com.android.dx.cf.iface.ClassFile; -import com.android.dx.cf.iface.Method; -import com.android.dx.rop.code.AccessFlags; -import com.android.dx.rop.code.SourcePosition; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.type.Prototype; - -/** - * Container for all the giblets that make up a concrete Java bytecode method. - * It implements {@link Method}, so it provides all the original access - * (by delegation), but it also constructs and keeps useful versions of - * stuff extracted from the method's Code attribute. - */ -public final class ConcreteMethod implements Method { - /** non-null; method being wrapped */ - private final Method method; - - /** - * null-ok; the class's SourceFile attribute value, - * if any - */ - private final CstUtf8 sourceFile; - - /** - * whether the class that this method is part of is defined with - * ACC_SUPER - */ - private final boolean accSuper; - - /** non-null; the code attribute */ - private final AttCode attCode; - - /** non-null; line number list */ - private final LineNumberList lineNumbers; - - /** non-null; local variable list */ - private final LocalVariableList localVariables; - - /** - * Constructs an instance. - * - * @param method non-null; the method to be based on - * @param cf non-null; the class file that contains this method - * @param keepLines whether to keep the line number information - * (if any) - * @param keepLocals whether to keep the local variable - * information (if any) - */ - public ConcreteMethod(Method method, ClassFile cf, boolean keepLines, - boolean keepLocals) { - this.method = method; - this.accSuper = (cf.getAccessFlags() & AccessFlags.ACC_SUPER) != 0; - this.sourceFile = cf.getSourceFile(); - - AttributeList attribs = method.getAttributes(); - this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME); - - AttributeList codeAttribs = attCode.getAttributes(); - - /* - * Combine all LineNumberTable attributes into one, with the - * combined result saved into the instance. The following code - * isn't particularly efficient for doing merges, but as far - * as I know, this situation rarely occurs "in the - * wild," so there's not much point in optimizing for it. - */ - LineNumberList lineNumbers = LineNumberList.EMPTY; - if (keepLines) { - for (AttLineNumberTable lnt = (AttLineNumberTable) - codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME); - lnt != null; - lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) { - lineNumbers = LineNumberList.concat(lineNumbers, - lnt.getLineNumbers()); - } - } - this.lineNumbers = lineNumbers; - - LocalVariableList localVariables = LocalVariableList.EMPTY; - if (keepLocals) { - /* - * Do likewise (and with the same caveat) for - * LocalVariableTable and LocalVariableTypeTable attributes. - * This combines both of these kinds of attribute into a - * single LocalVariableList. - */ - for (AttLocalVariableTable lvt = (AttLocalVariableTable) - codeAttribs.findFirst( - AttLocalVariableTable.ATTRIBUTE_NAME); - lvt != null; - lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) { - localVariables = - LocalVariableList.concat(localVariables, - lvt.getLocalVariables()); - } - - LocalVariableList typeList = LocalVariableList.EMPTY; - for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable) - codeAttribs.findFirst( - AttLocalVariableTypeTable.ATTRIBUTE_NAME); - lvtt != null; - lvtt = - (AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) { - typeList = - LocalVariableList.concat(typeList, - lvtt.getLocalVariables()); - } - - if (typeList.size() != 0) { - localVariables = - LocalVariableList.mergeDescriptorsAndSignatures( - localVariables, typeList); - } - } - this.localVariables = localVariables; - } - - /** {@inheritDoc} */ - public CstNat getNat() { - return method.getNat(); - } - - /** {@inheritDoc} */ - public CstUtf8 getName() { - return method.getName(); - } - - /** {@inheritDoc} */ - public CstUtf8 getDescriptor() { - return method.getDescriptor(); - } - - /** {@inheritDoc} */ - public int getAccessFlags() { - return method.getAccessFlags(); - } - - /** {@inheritDoc} */ - public AttributeList getAttributes() { - return method.getAttributes(); - } - - /** {@inheritDoc} */ - public CstType getDefiningClass() { - return method.getDefiningClass(); - } - - /** {@inheritDoc} */ - public Prototype getEffectiveDescriptor() { - return method.getEffectiveDescriptor(); - } - - /** - * Gets whether the class that this method is part of is defined with - * ACC_SUPER. - * - * @return the ACC_SUPER value - */ - public boolean getAccSuper() { - return accSuper; - } - - /** - * Gets the maximum stack size. - * - * @return >= 0; the maximum stack size - */ - public int getMaxStack() { - return attCode.getMaxStack(); - } - - /** - * Gets the number of locals. - * - * @return >= 0; the number of locals - */ - public int getMaxLocals() { - return attCode.getMaxLocals(); - } - - /** - * Gets the bytecode array. - * - * @return non-null; the bytecode array - */ - public BytecodeArray getCode() { - return attCode.getCode(); - } - - /** - * Gets the exception table. - * - * @return non-null; the exception table - */ - public ByteCatchList getCatches() { - return attCode.getCatches(); - } - - /** - * Gets the line number list. - * - * @return non-null; the line number list - */ - public LineNumberList getLineNumbers() { - return lineNumbers; - } - - /** - * Gets the local variable list. - * - * @return non-null; the local variable list - */ - public LocalVariableList getLocalVariables() { - return localVariables; - } - - /** - * Returns a {@link SourcePosition} instance corresponding to the - * given bytecode offset. - * - * @param offset >= 0; the bytecode offset - * @return non-null; an appropriate instance - */ - public SourcePosition makeSourcePosistion(int offset) { - return new SourcePosition(sourceFile, offset, - lineNumbers.pcToLine(offset)); - } -} diff --git a/dx/src/com/android/dx/cf/code/ExecutionStack.java b/dx/src/com/android/dx/cf/code/ExecutionStack.java deleted file mode 100644 index 1a2b565dd..000000000 --- a/dx/src/com/android/dx/cf/code/ExecutionStack.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.util.ExceptionWithContext; -import com.android.dx.util.Hex; -import com.android.dx.util.MutabilityControl; - -/** - * Representation of a Java method execution stack. - * - *

Note: For the most part, the documentation for this class - * ignores the distinction between {@link Type} and {@link - * TypeBearer}.

- */ -public final class ExecutionStack extends MutabilityControl { - /** non-null; array of stack contents */ - private final TypeBearer[] stack; - - /** - * >= 0; stack pointer (points one past the end) / current stack - * size - */ - private int stackPtr; - - /** - * Constructs an instance. - * - * @param maxStack >= 0; the maximum size of the stack for this - * instance - */ - public ExecutionStack(int maxStack) { - super(maxStack != 0); - stack = new TypeBearer[maxStack]; - stackPtr = 0; - } - - /** - * Makes and returns a mutable copy of this instance. - * - * @return non-null; the copy - */ - public ExecutionStack copy() { - ExecutionStack result = new ExecutionStack(stack.length); - - System.arraycopy(stack, 0, result.stack, 0, stack.length); - result.stackPtr = stackPtr; - - return result; - } - - /** - * Annotates (adds context to) the given exception with information - * about this instance. - * - * @param ex non-null; the exception to annotate - */ - public void annotate(ExceptionWithContext ex) { - int limit = stackPtr - 1; - - for (int i = 0; i <= limit; i++) { - String idx = (i == limit) ? "top0" : Hex.u2(limit - i); - - ex.addContext("stack[" + idx + "]: " + - stackElementString(stack[i])); - } - } - - /** - * Replaces all the occurrences of the given uninitialized type in - * this stack with its initialized equivalent. - * - * @param type non-null; type to replace - */ - public void makeInitialized(Type type) { - if (stackPtr == 0) { - // We have to check for this before checking for immutability. - return; - } - - throwIfImmutable(); - - Type initializedType = type.getInitializedType(); - - for (int i = 0; i < stackPtr; i++) { - if (stack[i] == type) { - stack[i] = initializedType; - } - } - } - - /** - * Gets the maximum stack size for this instance. - * - * @return >= 0; the max stack size - */ - public int getMaxStack() { - return stack.length; - } - - /** - * Gets the current stack size. - * - * @return >= 0, < getMaxStack(); the current stack size - */ - public int size() { - return stackPtr; - } - - /** - * Clears the stack. (That is, this method pops everything off.) - */ - public void clear() { - throwIfImmutable(); - - for (int i = 0; i < stackPtr; i++) { - stack[i] = null; - } - - stackPtr = 0; - } - - /** - * Pushes a value of the given type onto the stack. - * - * @param type non-null; type of the value - * @throws SimException thrown if there is insufficient room on the - * stack for the value - */ - public void push(TypeBearer type) { - throwIfImmutable(); - - int category; - - try { - type = type.getFrameType(); - category = type.getType().getCategory(); - } catch (NullPointerException ex) { - // Elucidate the exception. - throw new NullPointerException("type == null"); - } - - if ((stackPtr + category) > stack.length) { - throwSimException("overflow"); - return; - } - - if (category == 2) { - stack[stackPtr] = null; - stackPtr++; - } - - stack[stackPtr] = type; - stackPtr++; - } - - /** - * Peeks at the nth element down from the top of the stack. - * n == 0 means to peek at the top of the stack. Note that - * this will return null if the indicated element is the - * deeper half of a category-2 value. - * - * @param n >= 0; which element to peek at - * @return null-ok; the type of value stored at that element - * @throws SimException thrown if n >= size() - */ - public TypeBearer peek(int n) { - if (n < 0) { - throw new IllegalArgumentException("n < 0"); - } - - if (n >= stackPtr) { - return throwSimException("underflow"); - } - - return stack[stackPtr - n - 1]; - } - - /** - * Peeks at the nth element down from the top of the - * stack, returning the type per se, as opposed to the - * type-bearer. This method is just a convenient shorthand - * for peek(n).getType(). - * - * @see #peek - */ - public Type peekType(int n) { - return peek(n).getType(); - } - - /** - * Pops the top element off of the stack. - * - * @return non-null; the type formerly on the top of the stack - * @throws SimException thrown if the stack is empty - */ - public TypeBearer pop() { - throwIfImmutable(); - - TypeBearer result = peek(0); - - stack[stackPtr - 1] = null; - stackPtr -= result.getType().getCategory(); - - return result; - } - - /** - * Changes an element already on a stack. This method is useful in limited - * contexts, particularly when merging two instances. As such, it places - * the following restriction on its behavior: You may only replace - * values with other values of the same category. - * - * @param n >= 0; which element to change, where 0 is - * the top element of the stack - * @param type non-null; type of the new value - * @throws SimException thrown if n >= size() or - * the action is otherwise prohibited - */ - public void change(int n, TypeBearer type) { - throwIfImmutable(); - - try { - type = type.getFrameType(); - } catch (NullPointerException ex) { - // Elucidate the exception. - throw new NullPointerException("type == null"); - } - - int idx = stackPtr - n - 1; - TypeBearer orig = stack[idx]; - - if ((orig == null) || - (orig.getType().getCategory() != type.getType().getCategory())) { - throwSimException("incompatible substitution: " + - stackElementString(orig) + " -> " + - stackElementString(type)); - } - - stack[idx] = type; - } - - /** - * Merges this stack with another stack. A new instance is returned if - * this merge results in a change. If no change results, this instance is - * returned. See {@link Merger#mergeStack(ExecutionStack,ExecutionStack) - * Merger.mergeStack()} - * - * @param other non-null; a stack to merge with - * @return non-null; the result of the merge - */ - public ExecutionStack merge(ExecutionStack other) { - try { - return Merger.mergeStack(this, other); - } catch (SimException ex) { - ex.addContext("underlay stack:"); - this.annotate(ex); - ex.addContext("overlay stack:"); - other.annotate(ex); - throw ex; - } - } - - /** - * Gets the string form for a stack element. This is the same as - * toString() except that null is converted - * to "<invalid>". - * - * @param type null-ok; the stack element - * @return non-null; the string form - */ - private static String stackElementString(TypeBearer type) { - if (type == null) { - return ""; - } - - return type.toString(); - } - - /** - * Throws a properly-formatted exception. - * - * @param msg non-null; useful message - * @return never (keeps compiler happy) - */ - private static TypeBearer throwSimException(String msg) { - throw new SimException("stack: " + msg); - } -} diff --git a/dx/src/com/android/dx/cf/code/Frame.java b/dx/src/com/android/dx/cf/code/Frame.java deleted file mode 100644 index a74d142ee..000000000 --- a/dx/src/com/android/dx/cf/code/Frame.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.StdTypeList; -import com.android.dx.rop.type.Type; -import com.android.dx.util.ExceptionWithContext; -import com.android.dx.util.IntList; - -/** - * Representation of a Java method execution frame. A frame consists - * of a set of locals and a value stack, and it can be told to act on - * them to load and store values between them and an "arguments / - * results" area. - */ -public final class Frame { - /** non-null; the locals */ - private final LocalsArray locals; - - /** non-null; the stack */ - private final ExecutionStack stack; - - /** null-ok; stack of labels of subroutines that this block is nested in */ - private final IntList subroutines; - - /** - * Constructs an instance. - * - * @param locals non-null; the locals array to use - * @param stack non-null; the execution stack to use - */ - private Frame(LocalsArray locals, ExecutionStack stack) { - this(locals, stack, IntList.EMPTY); - } - - /** - * Constructs an instance. - * - * @param locals non-null; the locals array to use - * @param stack non-null; the execution stack to use - * @param subroutines non-null; list of subroutine start labels for - * subroutines this frame is nested in - */ - private Frame(LocalsArray locals, - ExecutionStack stack, IntList subroutines) { - if (locals == null) { - throw new NullPointerException("locals == null"); - } - - if (stack == null) { - throw new NullPointerException("stack == null"); - } - - subroutines.throwIfMutable(); - - this.locals = locals; - this.stack = stack; - this.subroutines = subroutines; - } - - /** - * Constructs an instance. The locals array initially consists of - * all-uninitialized values (represented as nulls) and - * the stack starts out empty. - * - * @param maxLocals >= 0; the maximum number of locals this instance - * can refer to - * @param maxStack >= 0; the maximum size of the stack for this - * instance - */ - public Frame(int maxLocals, int maxStack) { - this(new OneLocalsArray(maxLocals), new ExecutionStack(maxStack)); - } - - /** - * Makes and returns a mutable copy of this instance. The copy - * contains copies of the locals and stack (that is, it doesn't - * share them with the original). - * - * @return non-null; the copy - */ - public Frame copy() { - return new Frame(locals.copy(), stack.copy(), subroutines); - } - - /** - * Makes this instance immutable. - */ - public void setImmutable() { - locals.setImmutable(); - stack.setImmutable(); - // "subroutines" is always immutable - } - - /** - * Replaces all the occurrences of the given uninitialized type in - * this frame with its initialized equivalent. - * - * @param type non-null; type to replace - */ - public void makeInitialized(Type type) { - locals.makeInitialized(type); - stack.makeInitialized(type); - } - - /** - * Gets the locals array for this instance. - * - * @return non-null; the locals array - */ - public LocalsArray getLocals() { - return locals; - } - - /** - * Gets the execution stack for this instance. - * - * @return non-null; the execution stack - */ - public ExecutionStack getStack() { - return stack; - } - - /** - * Returns the largest subroutine nesting this block may be in. An - * empty list is returned if this block is not in any subroutine. - * Subroutines are identified by the label of their start block. The - * list is ordered such that the deepest nesting (the actual subroutine - * this block is in) is the last label in the list. - * - * @return non-null; list as noted above - */ - public IntList getSubroutines() { - return subroutines; - } - - /** - * Initialize this frame with the method's parameters. Used for the first - * frame. - * - * @param params Type list of method parameters. - */ - public void initializeWithParameters(StdTypeList params) { - int at = 0; - int sz = params.size(); - - for (int i = 0; i < sz; i++) { - Type one = params.get(i); - locals.set(at, one); - at += one.getCategory(); - } - } - - /** - * Returns a Frame instance representing the frame state that should - * be used when returning from a subroutine. The stack state of all - * subroutine invocations is identical, but the locals state may differ. - * - * @param startLabel >=0; The label of the returning subroutine's - * start block - * @param subLabel >=0; A calling label of a subroutine - * @return null-ok; an appropriatly-constructed instance, or null - * if label is not in the set - */ - public Frame subFrameForLabel(int startLabel, int subLabel) { - LocalsArray subLocals = null; - - if (locals instanceof LocalsArraySet) { - subLocals = ((LocalsArraySet)locals).subArrayForLabel(subLabel); - } - - IntList newSubroutines; - try { - newSubroutines = subroutines.mutableCopy(); - - if (newSubroutines.pop() != startLabel) { - throw new RuntimeException("returning from invalid subroutine"); - } - newSubroutines.setImmutable(); - } catch (IndexOutOfBoundsException ex) { - throw new RuntimeException("returning from invalid subroutine"); - } catch (NullPointerException ex) { - throw new NullPointerException("can't return from non-subroutine"); - } - - return (subLocals == null) ? null - : new Frame(subLocals, stack, newSubroutines); - } - - /** - * Merges two frames. If the merged result is the same as this frame, - * then this instance is returned. - * - * @param other non-null; another frame - * @return non-null; the result of merging the two frames - */ - public Frame mergeWith(Frame other) { - LocalsArray resultLocals; - ExecutionStack resultStack; - IntList resultSubroutines; - - resultLocals = getLocals().merge(other.getLocals()); - resultStack = getStack().merge(other.getStack()); - resultSubroutines = mergeSubroutineLists(other.subroutines); - - resultLocals = adjustLocalsForSubroutines( - resultLocals, resultSubroutines); - - if ((resultLocals == getLocals()) - && (resultStack == getStack()) - && subroutines == resultSubroutines) { - return this; - } - - return new Frame(resultLocals, resultStack, resultSubroutines); - } - - /** - * Merges this frame's subroutine lists with another. The result - * is the deepest common nesting (effectively, the common prefix of the - * two lists). - * - * @param otherSubroutines label list of subroutine start blocks, from - * least-nested to most-nested. - * @return non-null; merged subroutine nest list as described above - */ - private IntList mergeSubroutineLists(IntList otherSubroutines) { - if (subroutines.equals(otherSubroutines)) { - return subroutines; - } - - IntList resultSubroutines = new IntList(); - - int szSubroutines = subroutines.size(); - int szOthers = otherSubroutines.size(); - for (int i = 0; i < szSubroutines && i < szOthers - && (subroutines.get(i) == otherSubroutines.get(i)); i++) { - resultSubroutines.add(i); - } - - resultSubroutines.setImmutable(); - - return resultSubroutines; - } - - /** - * Adjusts a locals array to account for a merged subroutines list. - * If a frame merge results in, effectively, a subroutine return through - * a throw then the current locals will be a LocalsArraySet that will - * need to be trimmed of all OneLocalsArray elements that relevent to - * the subroutine that is returning. - * - * @param locals non-null; LocalsArray from before a merge - * @param subroutines non-null; a label list of subroutine start blocks - * representing the subroutine nesting of the block being merged into. - * @return non-null; locals set appropriate for merge - */ - private static LocalsArray adjustLocalsForSubroutines( - LocalsArray locals, IntList subroutines) { - if (! (locals instanceof LocalsArraySet)) { - // nothing to see here - return locals; - } - - LocalsArraySet laSet = (LocalsArraySet)locals; - - if (subroutines.size() == 0) { - /* - * We've merged from a subroutine context to a non-subroutine - * context, likely via a throw. Our successor will only need - * to consider the primary locals state, not the state of - * all possible subroutine paths. - */ - - return laSet.getPrimary(); - } - - /* - * It's unclear to me if the locals set needs to be trimmed here. - * If it does, then I believe it is all of the calling blocks - * in the subroutine at the end of "subroutines" passed into - * this method that should be removed. - */ - return laSet; - } - - /** - * Merges this frame with the frame of a subroutine caller at - * predLabel. Only called on the frame at the first - * block of a subroutine. - * - * @param other non-null; another frame - * @param subLabel label of subroutine start block - * @param predLabel label of calling block - * @return non-null; the result of merging the two frames - */ - public Frame mergeWithSubroutineCaller(Frame other, int subLabel, - int predLabel) { - LocalsArray resultLocals; - ExecutionStack resultStack; - - resultLocals = getLocals().mergeWithSubroutineCaller( - other.getLocals(), predLabel); - resultStack = getStack().merge(other.getStack()); - - IntList newOtherSubroutines = other.subroutines.mutableCopy(); - newOtherSubroutines.add(subLabel); - newOtherSubroutines.setImmutable(); - - if ((resultLocals == getLocals()) - && (resultStack == getStack()) - && subroutines.equals(newOtherSubroutines)) { - return this; - } - - IntList resultSubroutines; - - if (subroutines.equals(newOtherSubroutines)) { - resultSubroutines = subroutines; - } else { - /* - * The new subroutines list should be the deepest of the two - * lists being merged, but the postfix of the resultant list - * must be equal to the shorter list. - */ - IntList nonResultSubroutines; - - if (subroutines.size() > newOtherSubroutines.size()) { - resultSubroutines = subroutines; - nonResultSubroutines = newOtherSubroutines; - } else { - resultSubroutines = newOtherSubroutines; - nonResultSubroutines = subroutines; - } - - int szResult = resultSubroutines.size(); - int szNonResult = nonResultSubroutines.size(); - - for (int i = szNonResult - 1; i >=0; i-- ) { - if (nonResultSubroutines.get(i) - != resultSubroutines.get( - i + (szResult - szNonResult))) { - throw new - RuntimeException("Incompatible merged subroutines"); - } - } - - } - - return new Frame(resultLocals, resultStack, resultSubroutines); - } - - /** - * Makes a frame for a subroutine start block, given that this is the - * ending frame of one of the subroutine's calling blocks. Subroutine - * calls may be nested and thus may have nested locals state, so we - * start with an initial state as seen by the subroutine, but keep track - * of the individual locals states that will be expected when the individual - * subroutine calls return. - * - * @param subLabel label of subroutine start block - * @param callerLabel >=0 label of the caller block where this frame - * came from. - * @return a new instance to begin a called subroutine. - */ - public Frame makeNewSubroutineStartFrame(int subLabel, int callerLabel) { - IntList newSubroutines = subroutines.mutableCopy(); - newSubroutines.add(subLabel); - Frame newFrame = new Frame(locals.getPrimary(), stack, - IntList.makeImmutable(subLabel)); - return newFrame.mergeWithSubroutineCaller(this, subLabel, callerLabel); - } - - /** - * Makes a new frame for an exception handler block invoked from this - * frame. - * - * @param exceptionClass exception that the handler block will handle - * @return new frame - */ - public Frame makeExceptionHandlerStartFrame(CstType exceptionClass) { - ExecutionStack newStack = getStack().copy(); - - newStack.clear(); - newStack.push(exceptionClass); - - return new Frame(getLocals(), newStack, subroutines); - } - - /** - * Annotates (adds context to) the given exception with information - * about this frame. - * - * @param ex non-null; the exception to annotate - */ - public void annotate(ExceptionWithContext ex) { - locals.annotate(ex); - stack.annotate(ex); - } -} diff --git a/dx/src/com/android/dx/cf/code/LineNumberList.java b/dx/src/com/android/dx/cf/code/LineNumberList.java deleted file mode 100644 index 35875b0a7..000000000 --- a/dx/src/com/android/dx/cf/code/LineNumberList.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.util.FixedSizeList; - -/** - * List of "line number" entries, which are the contents of - * LineNumberTable attributes. - */ -public final class LineNumberList extends FixedSizeList { - /** non-null; zero-size instance */ - public static final LineNumberList EMPTY = new LineNumberList(0); - - /** - * Returns an instance which is the concatenation of the two given - * instances. - * - * @param list1 non-null; first instance - * @param list2 non-null; second instance - * @return non-null; combined instance - */ - public static LineNumberList concat(LineNumberList list1, - LineNumberList list2) { - if (list1 == EMPTY) { - // easy case - return list2; - } - - int sz1 = list1.size(); - int sz2 = list2.size(); - LineNumberList result = new LineNumberList(sz1 + sz2); - - for (int i = 0; i < sz1; i++) { - result.set(i, list1.get(i)); - } - - for (int i = 0; i < sz2; i++) { - result.set(sz1 + i, list2.get(i)); - } - - return result; - } - - /** - * Constructs an instance. - * - * @param count the number of elements to be in the list - */ - public LineNumberList(int count) { - super(count); - } - - /** - * Gets the indicated item. - * - * @param n >= 0; which item - * @return null-ok; the indicated item - */ - public Item get(int n) { - return (Item) get0(n); - } - - /** - * Sets the item at the given index. - * - * @param n >= 0, < size(); which element - * @param item non-null; the item - */ - public void set(int n, Item item) { - if (item == null) { - throw new NullPointerException("item == null"); - } - - set0(n, item); - } - - /** - * Sets the item at the given index. - * - * @param n >= 0, < size(); which element - * @param startPc >= 0; start pc of this item - * @param lineNumber >= 0; corresponding line number - */ - public void set(int n, int startPc, int lineNumber) { - set0(n, new Item(startPc, lineNumber)); - } - - /** - * Gets the line number associated with the given address. - * - * @param pc >= 0; the address to look up - * @return >= -1; the associated line number, or -1 if - * none is known - */ - public int pcToLine(int pc) { - /* - * Line number entries don't have to appear in any particular - * order, so we have to do a linear search. TODO: If - * this turns out to be a bottleneck, consider sorting the - * list prior to use. - */ - int sz = size(); - int bestPc = -1; - int bestLine = -1; - - for (int i = 0; i < sz; i++) { - Item one = get(i); - int onePc = one.getStartPc(); - if ((onePc <= pc) && (onePc > bestPc)) { - bestPc = onePc; - bestLine = one.getLineNumber(); - if (bestPc == pc) { - // We can't do better than this - break; - } - } - } - - return bestLine; - } - - /** - * Item in a line number table. - */ - public static class Item { - /** >= 0; start pc of this item */ - private final int startPc; - - /** >= 0; corresponding line number */ - private final int lineNumber; - - /** - * Constructs an instance. - * - * @param startPc >= 0; start pc of this item - * @param lineNumber >= 0; corresponding line number - */ - public Item(int startPc, int lineNumber) { - if (startPc < 0) { - throw new IllegalArgumentException("startPc < 0"); - } - - if (lineNumber < 0) { - throw new IllegalArgumentException("lineNumber < 0"); - } - - this.startPc = startPc; - this.lineNumber = lineNumber; - } - - /** - * Gets the start pc of this item. - * - * @return the start pc - */ - public int getStartPc() { - return startPc; - } - - /** - * Gets the line number of this item. - * - * @return the line number - */ - public int getLineNumber() { - return lineNumber; - } - } -} diff --git a/dx/src/com/android/dx/cf/code/LocalVariableList.java b/dx/src/com/android/dx/cf/code/LocalVariableList.java deleted file mode 100644 index 10876036b..000000000 --- a/dx/src/com/android/dx/cf/code/LocalVariableList.java +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.code.LocalItem; -import com.android.dx.util.FixedSizeList; - -/** - * List of "local variable" entries, which are the contents of - * LocalVariableTable and LocalVariableTypeTable - * attributes, as well as combinations of the two. - */ -public final class LocalVariableList extends FixedSizeList { - /** non-null; zero-size instance */ - public static final LocalVariableList EMPTY = new LocalVariableList(0); - - /** - * Returns an instance which is the concatenation of the two given - * instances. The result is immutable. - * - * @param list1 non-null; first instance - * @param list2 non-null; second instance - * @return non-null; combined instance - */ - public static LocalVariableList concat(LocalVariableList list1, - LocalVariableList list2) { - if (list1 == EMPTY) { - // easy case - return list2; - } - - int sz1 = list1.size(); - int sz2 = list2.size(); - LocalVariableList result = new LocalVariableList(sz1 + sz2); - - for (int i = 0; i < sz1; i++) { - result.set(i, list1.get(i)); - } - - for (int i = 0; i < sz2; i++) { - result.set(sz1 + i, list2.get(i)); - } - - result.setImmutable(); - return result; - } - - /** - * Returns an instance which is the result of merging the two - * given instances, where one instance should have only type - * descriptors and the other only type signatures. The merged - * result is identical to the one with descriptors, except that - * any element whose {name, index, start, length} matches an - * element in the signature list gets augmented with the - * corresponding signature. The result is immutable. - * - * @param descriptorList non-null; list with descriptors - * @param signatureList non-null; list with signatures - * @return non-null; the merged result - */ - public static LocalVariableList mergeDescriptorsAndSignatures( - LocalVariableList descriptorList, - LocalVariableList signatureList) { - int signatureSize = signatureList.size(); - int descriptorSize = descriptorList.size(); - LocalVariableList result = new LocalVariableList(descriptorSize); - - for (int i = 0; i < descriptorSize; i++) { - Item item = descriptorList.get(i); - Item signatureItem = signatureList.itemToLocal(item); - if (signatureItem != null) { - CstUtf8 signature = signatureItem.getSignature(); - item = item.withSignature(signature); - } - result.set(i, item); - } - - result.setImmutable(); - return result; - } - - /** - * Constructs an instance. - * - * @param count the number of elements to be in the list - */ - public LocalVariableList(int count) { - super(count); - } - - /** - * Gets the indicated item. - * - * @param n >= 0; which item - * @return null-ok; the indicated item - */ - public Item get(int n) { - return (Item) get0(n); - } - - /** - * Sets the item at the given index. - * - * @param n >= 0, < size(); which element - * @param item non-null; the item - */ - public void set(int n, Item item) { - if (item == null) { - throw new NullPointerException("item == null"); - } - - set0(n, item); - } - - /** - * Sets the item at the given index. - * - *

Note: At least one of descriptor or - * signature must be passed as non-null.

- * - * @param n >= 0, < size(); which element - * @param startPc >= 0; the start pc of this variable's scope - * @param length >= 0; the length (in bytecodes) of this variable's - * scope - * @param name non-null; the variable's name - * @param descriptor null-ok; the variable's type descriptor - * @param signature null-ok; the variable's type signature - * @param index >= 0; the variable's local index - */ - public void set(int n, int startPc, int length, CstUtf8 name, - CstUtf8 descriptor, CstUtf8 signature, int index) { - set0(n, new Item(startPc, length, name, descriptor, signature, index)); - } - - /** - * Gets the local variable information in this instance which matches - * the given {@link com.android.dx.cf.code.LocalVariableList.Item} - * in all respects but the type descriptor and signature, if any. - * - * @param item non-null; local variable information to match - * @return null-ok; the corresponding local variable information stored - * in this instance, or null if there is no matching - * information - */ - public Item itemToLocal(Item item) { - int sz = size(); - - for (int i = 0; i < sz; i++) { - Item one = (Item) get0(i); - - if ((one != null) && one.matchesAllButType(item)) { - return one; - } - } - - return null; - } - - /** - * Gets the local variable information associated with a given address - * and local index, if any. Note: In standard classfiles, a - * variable's start point is listed as the address of the instruction - * just past the one that sets the variable. - * - * @param pc >= 0; the address to look up - * @param index >= 0; the local variable index - * @return null-ok; the associated local variable information, or - * null if none is known - */ - public Item pcAndIndexToLocal(int pc, int index) { - int sz = size(); - - for (int i = 0; i < sz; i++) { - Item one = (Item) get0(i); - - if ((one != null) && one.matchesPcAndIndex(pc, index)) { - return one; - } - } - - return null; - } - - /** - * Item in a local variable table. - */ - public static class Item { - /** >= 0; the start pc of this variable's scope */ - private final int startPc; - - /** >= 0; the length (in bytecodes) of this variable's scope */ - private final int length; - - /** non-null; the variable's name */ - private final CstUtf8 name; - - /** null-ok; the variable's type descriptor */ - private final CstUtf8 descriptor; - - /** null-ok; the variable's type signature */ - private final CstUtf8 signature; - - /** >= 0; the variable's local index */ - private final int index; - - /** - * Constructs an instance. - * - *

Note: At least one of descriptor or - * signature must be passed as non-null.

- * - * @param startPc >= 0; the start pc of this variable's scope - * @param length >= 0; the length (in bytecodes) of this variable's - * scope - * @param name non-null; the variable's name - * @param descriptor null-ok; the variable's type descriptor - * @param signature null-ok; the variable's type signature - * @param index >= 0; the variable's local index - */ - public Item(int startPc, int length, CstUtf8 name, - CstUtf8 descriptor, CstUtf8 signature, int index) { - if (startPc < 0) { - throw new IllegalArgumentException("startPc < 0"); - } - - if (length < 0) { - throw new IllegalArgumentException("length < 0"); - } - - if (name == null) { - throw new NullPointerException("name == null"); - } - - if ((descriptor == null) && (signature == null)) { - throw new NullPointerException( - "(descriptor == null) && (signature == null)"); - } - - if (index < 0) { - throw new IllegalArgumentException("index < 0"); - } - - this.startPc = startPc; - this.length = length; - this.name = name; - this.descriptor = descriptor; - this.signature = signature; - this.index = index; - } - - /** - * Gets the start pc of this variable's scope. - * - * @return >= 0; the start pc of this variable's scope - */ - public int getStartPc() { - return startPc; - } - - /** - * Gets the length (in bytecodes) of this variable's scope. - * - * @return >= 0; the length (in bytecodes) of this variable's scope - */ - public int getLength() { - return length; - } - - /** - * Gets the variable's type descriptor. - * - * @return null-ok; the variable's type descriptor - */ - public CstUtf8 getDescriptor() { - return descriptor; - } - - /** - * Gets the variable's LocalItem, a (name, signature) tuple - * - * @return null-ok; the variable's type descriptor - */ - public LocalItem getLocalItem() { - return LocalItem.make(name, signature); - } - - /** - * Gets the variable's type signature. Private because if you need this, - * you want getLocalItem() instead. - * - * @return null-ok; the variable's type signature - */ - private CstUtf8 getSignature() { - return signature; - } - - /** - * Gets the variable's local index. - * - * @return >= 0; the variable's local index - */ - public int getIndex() { - return index; - } - - /** - * Gets the variable's type descriptor. This is a convenient shorthand - * for Type.intern(getDescriptor().getString()). - * - * @return non-null; the variable's type - */ - public Type getType() { - return Type.intern(descriptor.getString()); - } - - /** - * Constructs and returns an instance which is identical to this - * one, except that the signature is changed to the given value. - * - * @param newSignature non-null; the new signature - * @return non-null; an appropriately-constructed instance - */ - public Item withSignature(CstUtf8 newSignature) { - return new Item(startPc, length, name, descriptor, newSignature, - index); - } - - /** - * Gets whether this instance matches (describes) the given - * address and index. - * - * @param pc >= 0; the address in question - * @param index >= 0; the local variable index in question - * @return true iff this instance matches pc - * and index - */ - public boolean matchesPcAndIndex(int pc, int index) { - return (index == this.index) && - (pc >= startPc) && - (pc < (startPc + length)); - } - - /** - * Gets whether this instance matches (describes) the given - * other instance exactly in all fields except type descriptor and - * type signature. - * - * @param other non-null; the instance to compare to - * @return true iff this instance matches - */ - public boolean matchesAllButType(Item other) { - return (startPc == other.startPc) - && (length == other.length) - && (index == other.index) - && name.equals(other.name); - } - } -} diff --git a/dx/src/com/android/dx/cf/code/LocalsArray.java b/dx/src/com/android/dx/cf/code/LocalsArray.java deleted file mode 100644 index 1c324ca07..000000000 --- a/dx/src/com/android/dx/cf/code/LocalsArray.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.code.RegisterSpec; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.util.ExceptionWithContext; -import com.android.dx.util.Hex; -import com.android.dx.util.MutabilityControl; -import com.android.dx.util.ToHuman; - -/** - * Representation of an array of local variables, with Java semantics. - * - *

Note: For the most part, the documentation for this class - * ignores the distinction between {@link Type} and {@link - * TypeBearer}.

- */ -public abstract class LocalsArray extends MutabilityControl implements ToHuman { - - /** - * Constructs an instance, explicitly indicating the mutability. - * - * @param mutable true if this instance is mutable - */ - protected LocalsArray(boolean mutable) { - super(mutable); - } - - /** - * Makes and returns a mutable copy of this instance. - * - * @return non-null; the copy - */ - public abstract LocalsArray copy(); - - /** - * Annotates (adds context to) the given exception with information - * about this instance. - * - * @param ex non-null; the exception to annotate - */ - public abstract void annotate(ExceptionWithContext ex); - - /** - * Replaces all the occurrences of the given uninitialized type in - * this array with its initialized equivalent. - * - * @param type non-null; type to replace - */ - public abstract void makeInitialized(Type type); - - /** - * Gets the maximum number of locals this instance can refer to. - * - * @return the max locals - */ - public abstract int getMaxLocals(); - /** - * Sets the type stored at the given local index. If the given type - * is category-2, then (a) the index must be at least two less than - * getMaxLocals() and (b) the next index gets invalidated - * by the operation. In case of either category, if the previous - * local contains a category-2 value, then it too is invalidated by - * this operation. - * - * @param idx >= 0, < getMaxLocals(); which local - * @param type non-null; new type for the local at idx - */ - public abstract void set(int idx, TypeBearer type); - - /** - * Sets the type for the local indicated by the given register spec - * to that register spec (which includes type and optional name - * information). This is identical to calling - * set(spec.getReg(), spec). - * - * @param spec non-null; register spec to use as the basis for the update - */ - public abstract void set(RegisterSpec spec); - - /** - * Invalidates the local at the given index. - * - * @param idx >= 0, < getMaxLocals(); which local - */ - public abstract void invalidate(int idx); - - /** - * Gets the type stored at the given local index, or null - * if the given local is uninitialized / invalid. - * - * @param idx >= 0, < getMaxLocals(); which local - * @return null-ok; the type of value stored in that local - */ - public abstract TypeBearer getOrNull(int idx); - - /** - * Gets the type stored at the given local index, only succeeding if - * the given local contains a valid type (though it is allowed to - * be an uninitialized instance). - * - * @param idx >= 0, < getMaxLocals(); which local - * @return non-null; the type of value stored in that local - * @throws SimException thrown if idx is valid, but - * the contents are invalid - */ - public abstract TypeBearer get(int idx); - - /** - * Gets the type stored at the given local index, which is expected - * to be an initialized category-1 value. - * - * @param idx >= 0, < getMaxLocals(); which local - * @return non-null; the type of value stored in that local - * @throws SimException thrown if idx is valid, but - * one of the following holds: (a) the local is invalid; (b) the local - * contains an uninitialized instance; (c) the local contains a - * category-2 value - */ - public abstract TypeBearer getCategory1(int idx); - - /** - * Gets the type stored at the given local index, which is expected - * to be a category-2 value. - * - * @param idx >= 0, < getMaxLocals(); which local - * @return non-null; the type of value stored in that local - * @throws SimException thrown if idx is valid, but - * one of the following holds: (a) the local is invalid; (b) the local - * contains a category-1 value - */ - public abstract TypeBearer getCategory2(int idx); - - /** - * Merges this instance with other. If the merged result is - * the same as this instance, then this is returned (not a copy). - * - * @param other non-null; another LocalsArray - * @return non-null; the merge result, a new instance or this - */ - public abstract LocalsArray merge(LocalsArray other); - - /** - * Merges this instance with a LocalsSet from a subroutine - * caller. To be used when merging in the first block of a subroutine. - * - * @param other other non-null; another LocalsArray. The final locals - * state of a subroutine caller. - * @param predLabel the label of the subroutine caller block. - * @return non-null; the merge result, a new instance or this - */ - public abstract LocalsArraySet mergeWithSubroutineCaller - (LocalsArray other, int predLabel); - - /** - * Gets the locals set appropriate for the current execution context. - * That is, if this is a OneLocalsArray instance, then return - * this, otherwise return LocalsArraySet's - * primary. - * - * @return locals for this execution context. - */ - protected abstract OneLocalsArray getPrimary(); - -} diff --git a/dx/src/com/android/dx/cf/code/LocalsArraySet.java b/dx/src/com/android/dx/cf/code/LocalsArraySet.java deleted file mode 100644 index 9e24da9b9..000000000 --- a/dx/src/com/android/dx/cf/code/LocalsArraySet.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.code.RegisterSpec; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.util.ExceptionWithContext; -import com.android.dx.util.Hex; -import com.android.dx.util.MutabilityControl; - -import java.util.ArrayList; - -/** - * Representation of a set of local variable arrays, with Java semantics. - * This peculiar case is to support in-method subroutines, which can - * have different locals sets for each caller. - * - *

Note: For the most part, the documentation for this class - * ignores the distinction between {@link com.android.dx.rop.type.Type} and {@link - * com.android.dx.rop.type.TypeBearer}.

- */ -public class LocalsArraySet extends LocalsArray { - - /** - * The primary LocalsArray represents the locals as seen from - * the subroutine itself, which is the merged representation of all the - * individual locals states. - */ - private final OneLocalsArray primary; - - /** - * Indexed by label of caller block: the locals specific to each caller's - * invocation of the subroutine. - */ - private final ArrayList secondaries; - - /** - * Constructs an instance. The locals array initially consists of - * all-uninitialized values (represented as nulls). - * - * @param maxLocals >= 0; the maximum number of locals this instance - * can refer to - */ - public LocalsArraySet(int maxLocals) { - super(maxLocals != 0); - primary = new OneLocalsArray(maxLocals); - secondaries = new ArrayList(); - } - - /** - * Constructs an instance with the specified primary and secondaries set. - * - * @param primary non-null; primary locals to use - * @param secondaries non-null; secondaries set, indexed by subroutine - * caller label. - */ - public LocalsArraySet(OneLocalsArray primary, - ArrayList secondaries) { - super(primary.getMaxLocals() > 0); - - this.primary = primary; - this.secondaries = secondaries; - } - - /** - * Constructs an instance which is a copy of another. - * - * @param toCopy non-null; instance to copy. - */ - private LocalsArraySet(LocalsArraySet toCopy) { - super(toCopy.getMaxLocals() > 0); - - primary = toCopy.primary.copy(); - secondaries = new ArrayList(toCopy.secondaries.size()); - - int sz = toCopy.secondaries.size(); - for(int i = 0; i < sz; i++) { - LocalsArray la = toCopy.secondaries.get(i); - - if (la == null) { - secondaries.add(null); - } else { - secondaries.add(la.copy()); - } - } - } - - - /** @inheritDoc */ - @Override - public void setImmutable() { - primary.setImmutable(); - - for (LocalsArray la: secondaries) { - if (la != null) { - la.setImmutable(); - } - } - super.setImmutable(); - } - - /** @inheritDoc */ - @Override - public LocalsArray copy() { - return new LocalsArraySet(this); - } - - /** @inheritDoc */ - @Override - public void annotate(ExceptionWithContext ex) { - ex.addContext("(locals array set; primary)"); - primary.annotate(ex); - - int sz = secondaries.size(); - for(int label = 0; label < sz; label++) { - LocalsArray la = secondaries.get(label); - - if (la != null) { - ex.addContext("(locals array set: primary for caller " - + Hex.u2(label) + ')'); - - la.getPrimary().annotate(ex); - } - } - } - - /** {@inheritDoc*/ - public String toHuman() { - StringBuilder sb = new StringBuilder(); - - sb.append("(locals array set; primary)\n"); - - sb.append(getPrimary().toHuman()); - sb.append('\n'); - - int sz = secondaries.size(); - for(int label = 0; label < sz; label++) { - LocalsArray la = secondaries.get(label); - - if (la != null) { - sb.append("(locals array set: primary for caller " - + Hex.u2(label) + ")\n"); - - sb.append(la.getPrimary().toHuman()); - sb.append('\n'); - } - } - - return sb.toString(); - } - - /** @inheritDoc */ - @Override - public void makeInitialized(Type type) { - int len = primary.getMaxLocals(); - - if (len == 0) { - // We have to check for this before checking for immutability. - return; - } - - throwIfImmutable(); - - primary.makeInitialized(type); - - for (LocalsArray la: secondaries) { - if (la != null) { - la.makeInitialized(type); - } - } - } - - /** @inheritDoc */ - @Override - public int getMaxLocals() { - return primary.getMaxLocals(); - } - - /** @inheritDoc */ - @Override - public void set(int idx, TypeBearer type) { - throwIfImmutable(); - - primary.set(idx, type); - - for (LocalsArray la: secondaries) { - if (la != null) { - la.set(idx, type); - } - } - } - - /** @inheritDoc */ - @Override - public void set(RegisterSpec spec) { - set(spec.getReg(), spec); - } - - /** @inheritDoc */ - @Override - public void invalidate(int idx) { - throwIfImmutable(); - - primary.invalidate(idx); - - for (LocalsArray la: secondaries) { - if (la != null) { - la.invalidate(idx); - } - } - } - - /** @inheritDoc */ - @Override - public TypeBearer getOrNull(int idx) { - return primary.getOrNull(idx); - } - - /** @inheritDoc */ - @Override - public TypeBearer get(int idx) { - return primary.get(idx); - } - - /** @inheritDoc */ - @Override - public TypeBearer getCategory1(int idx) { - return primary.getCategory1(idx); - } - - /** @inheritDoc */ - @Override - public TypeBearer getCategory2(int idx) { - return primary.getCategory2(idx); - } - - /** - * Merges this set with another LocalsArraySet instance. - * - * @param other non-null; to merge - * @return non-null; this instance if merge was a no-op, or - * new merged instance. - */ - private LocalsArraySet mergeWithSet(LocalsArraySet other) { - OneLocalsArray newPrimary; - ArrayList newSecondaries; - boolean secondariesChanged = false; - - newPrimary = primary.merge(other.getPrimary()); - - int sz1 = secondaries.size(); - int sz2 = other.secondaries.size(); - int sz = Math.max(sz1, sz2); - newSecondaries = new ArrayList(sz); - - for (int i = 0; i < sz; i++) { - LocalsArray la1 = (i < sz1 ? secondaries.get(i) : null); - LocalsArray la2 = (i < sz2 ? other.secondaries.get(i) : null); - LocalsArray resultla = null; - - if (la1 == la2) { - resultla = la1; - } else if (la1 == null) { - resultla = la2; - } else if (la2 == null) { - resultla = la1; - } else { - try { - resultla = la1.merge(la2); - } catch (SimException ex) { - ex.addContext( - "Merging locals set for caller block " + Hex.u2(i)); - } - } - - secondariesChanged = secondariesChanged || (la1 != resultla); - - newSecondaries.add(resultla); - } - - if ((primary == newPrimary) && ! secondariesChanged ) { - return this; - } - - return new LocalsArraySet(newPrimary, newSecondaries); - } - - /** - * Merges this set with a OneLocalsArray instance. - * - * @param other non-null; to merge - * @return non-null; this instance if merge was a no-op, or - * new merged instance. - */ - private LocalsArraySet mergeWithOne(OneLocalsArray other) { - OneLocalsArray newPrimary; - ArrayList newSecondaries; - boolean secondariesChanged = false; - - newPrimary = primary.merge(other.getPrimary()); - newSecondaries = new ArrayList(secondaries.size()); - - int sz = secondaries.size(); - for (int i = 0; i < sz; i++) { - LocalsArray la = secondaries.get(i); - LocalsArray resultla = null; - - if (la != null) { - try { - resultla = la.merge(other); - } catch (SimException ex) { - ex.addContext("Merging one locals against caller block " - + Hex.u2(i)); - } - } - - secondariesChanged = secondariesChanged || (la != resultla); - - newSecondaries.add(resultla); - } - - if ((primary == newPrimary) && ! secondariesChanged ) { - return this; - } - - return new LocalsArraySet(newPrimary, newSecondaries); - } - - /** @inheritDoc */ - @Override - public LocalsArraySet merge(LocalsArray other) { - LocalsArraySet result; - - try { - if (other instanceof LocalsArraySet) { - result = mergeWithSet((LocalsArraySet) other); - } else { - result = mergeWithOne((OneLocalsArray) other); - } - } catch (SimException ex) { - ex.addContext("underlay locals:"); - annotate(ex); - ex.addContext("overlay locals:"); - other.annotate(ex); - throw ex; - } - - result.setImmutable(); - return result; - } - - /** - * Gets the LocalsArray instance for a specified subroutine - * caller label, or null if label has no locals associated with it. - * - * @param label >=0 subroutine caller label - * @return null-ok; locals if available. - */ - private LocalsArray getSecondaryForLabel(int label) { - if (label >= secondaries.size()) { - return null; - } - - return secondaries.get(label); - } - - /** {@inheritDoc} */ - @Override - public LocalsArraySet mergeWithSubroutineCaller - (LocalsArray other, int predLabel) { - - LocalsArray mine = getSecondaryForLabel(predLabel); - LocalsArray newSecondary; - OneLocalsArray newPrimary; - - newPrimary = primary.merge(other.getPrimary()); - - if (mine == other) { - newSecondary = mine; - } else if (mine == null) { - newSecondary = other; - } else { - newSecondary = mine.merge(other); - } - - if ((newSecondary == mine) && (newPrimary == primary)) { - return this; - } else { - /* - * We're going to re-build a primary as a merge of all the - * secondaries. - */ - newPrimary = null; - - int szSecondaries = secondaries.size(); - int sz = Math.max(predLabel + 1, szSecondaries); - ArrayList newSecondaries = new ArrayList(sz); - for (int i = 0; i < sz; i++) { - LocalsArray la = null; - - if (i == predLabel) { - /* - * This LocalsArray always replaces any existing one, - * since this is the result of a refined iteration. - */ - la = newSecondary; - } else if (i < szSecondaries) { - la = secondaries.get(i); - } - - if (la != null) { - if (newPrimary == null) { - newPrimary = la.getPrimary(); - } else { - newPrimary = newPrimary.merge(la.getPrimary()); - } - } - - newSecondaries.add(la); - } - - LocalsArraySet result - = new LocalsArraySet(newPrimary, newSecondaries); - result.setImmutable(); - return result; - } - } - - /** - * Returns a LocalsArray instance representing the locals state that should - * be used when returning to a subroutine caller. - * - * @param subLabel >= 0; A calling label of a subroutine - * @return null-ok; an instance for this subroutine, or null if subroutine - * is not in this set. - */ - public LocalsArray subArrayForLabel(int subLabel) { - LocalsArray result = getSecondaryForLabel(subLabel); - return result; - } - - /**{@inheritDoc}*/ - @Override - protected OneLocalsArray getPrimary() { - return primary; - } -} diff --git a/dx/src/com/android/dx/cf/code/Machine.java b/dx/src/com/android/dx/cf/code/Machine.java deleted file mode 100644 index 517a10d6a..000000000 --- a/dx/src/com/android/dx/cf/code/Machine.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.type.Prototype; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.code.LocalItem; -import java.util.ArrayList; - -/** - * Interface for machines capable of executing bytecode by acting - * upon a {@link Frame}. A machine conceptually contains four arbitrary-value - * argument slots, slots for several literal-value arguments, and slots for - * branch target information. - */ -public interface Machine { - /** - * Gets the effective prototype of the method that this instance is - * being used for. The effective prototype includes an initial - * this argument for instance methods. - * - * @return non-null; the method prototype - */ - public Prototype getPrototype(); - - /** - * Clears the regular and auxiliary arguments area. - */ - public void clearArgs(); - - /** - * Pops the given number of values from the stack (of either category), - * and store them in the arguments area, indicating that there are now - * that many arguments. Also, clear the auxiliary arguments. - * - * @param frame non-null; frame to operate on - * @param count >= 0; number of values to pop - */ - public void popArgs(Frame frame, int count); - - /** - * Pops values from the stack of the types indicated by the given - * Prototype (popped in reverse of the argument - * order, so the first prototype argument type is for the deepest - * element of the stack), and store them in the arguments area, - * indicating that there are now that many arguments. Also, clear - * the auxiliary arguments. - * - * @param frame non-null; frame to operate on - * @param prototype non-null; prototype indicating arguments to pop - */ - public void popArgs(Frame frame, Prototype prototype); - - /** - * Pops a value from the stack of the indicated type, and store it - * in the arguments area, indicating that there are now that many - * arguments. Also, clear the auxiliary arguments. - * - * @param frame non-null; frame to operate on - * @param type non-null; type of the argument - */ - public void popArgs(Frame frame, Type type); - - /** - * Pops values from the stack of the indicated types (popped in - * reverse argument order, so the first indicated type is for the - * deepest element of the stack), and store them in the arguments - * area, indicating that there are now that many arguments. Also, - * clear the auxiliary arguments. - * - * @param frame non-null; frame to operate on - * @param type1 non-null; type of the first argument - * @param type2 non-null; type of the second argument - */ - public void popArgs(Frame frame, Type type1, Type type2); - - /** - * Pops values from the stack of the indicated types (popped in - * reverse argument order, so the first indicated type is for the - * deepest element of the stack), and store them in the arguments - * area, indicating that there are now that many arguments. Also, - * clear the auxiliary arguments. - * - * @param frame non-null; frame to operate on - * @param type1 non-null; type of the first argument - * @param type2 non-null; type of the second argument - * @param type3 non-null; type of the third argument - */ - public void popArgs(Frame frame, Type type1, Type type2, Type type3); - - /** - * Loads the local variable with the given index as the sole argument in - * the arguments area. Also, clear the auxiliary arguments. - * - * @param frame non-null; frame to operate on - * @param idx >= 0; the local variable index - */ - public void localArg(Frame frame, int idx); - - /** - * Indicates that the salient type of this operation is as - * given. This differentiates between, for example, the various - * arithmetic opcodes, which, by the time they hit a - * Machine are collapsed to the int - * variant. (See {@link BytecodeArray#parseInstruction} for - * details.) - * - * @param type non-null; the salient type of the upcoming operation - */ - public void auxType(Type type); - - /** - * Indicates that there is an auxiliary (inline, not stack) - * argument of type int, with the given value. - * - *

Note: Perhaps unintuitively, the stack manipulation - * ops (e.g., dup and swap) use this to - * indicate the result stack pattern with a straightforward hex - * encoding of the push order starting with least-significant - * nibbles getting pushed first). For example, an all-category-1 - * dup2_x1 sets this to 0x12312, and the - * other form of that op sets this to - * 0x121.

- * - *

Also Note: For switch* instructions, this is - * used to indicate the padding value (which is only useful for - * verification).

- * - * @param value the argument value - */ - public void auxIntArg(int value); - - /** - * Indicates that there is an auxiliary (inline, not stack) object - * argument, with the value based on the given constant. - * - *

Note: Some opcodes use both int and - * constant auxiliary arguments.

- * - * @param cst non-null; the constant containing / referencing - * the value - */ - public void auxCstArg(Constant cst); - - /** - * Indicates that there is an auxiliary (inline, not stack) argument - * indicating a branch target. - * - * @param target the argument value - */ - public void auxTargetArg(int target); - - /** - * Indicates that there is an auxiliary (inline, not stack) argument - * consisting of a switch* table. - * - *

Note: This is generally used in conjunction with - * {@link #auxIntArg} (which holds the padding).

- * - * @param cases non-null; the list of key-target pairs, plus the default - * target - */ - public void auxSwitchArg(SwitchList cases); - - /** - * Indicates that there is an auxiliary (inline, not stack) argument - * consisting of a list of initial values for a newly created array. - * - * @param initValues non-null; the list of constant values to initialize - * the array - */ - public void auxInitValues(ArrayList initValues); - - /** - * Indicates that the target of this operation is the given local. - * - * @param idx >= 0; the local variable index - * @param type non-null; the type of the local - * @param local null-ok; the name and signature of the local, if known - */ - public void localTarget(int idx, Type type, LocalItem local); - - /** - * "Runs" the indicated opcode in an appropriate way, using the arguments - * area as appropriate, and modifying the given frame in response. - * - * @param frame non-null; frame to operate on - * @param offset >= 0; byte offset in the method to the opcode being - * run - * @param opcode >= 0; the opcode to run - */ - public void run(Frame frame, int offset, int opcode); -} diff --git a/dx/src/com/android/dx/cf/code/Merger.java b/dx/src/com/android/dx/cf/code/Merger.java deleted file mode 100644 index adeaab225..000000000 --- a/dx/src/com/android/dx/cf/code/Merger.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.util.Hex; - -/** - * Utility methods to merge various frame information. - */ -public final class Merger { - /** - * This class is uninstantiable. - */ - private Merger() { - // This space intentionally left blank. - } - - /** - * Merges two locals arrays. If the merged result is the same as the first - * argument, then return the first argument (not a copy). - * - * @param locals1 non-null; a locals array - * @param locals2 non-null; another locals array - * @return non-null; the result of merging the two locals arrays - */ - public static OneLocalsArray mergeLocals(OneLocalsArray locals1, - OneLocalsArray locals2) { - if (locals1 == locals2) { - // Easy out. - return locals1; - } - - int sz = locals1.getMaxLocals(); - OneLocalsArray result = null; - - if (locals2.getMaxLocals() != sz) { - throw new SimException("mismatched maxLocals values"); - } - - for (int i = 0; i < sz; i++) { - TypeBearer tb1 = locals1.getOrNull(i); - TypeBearer tb2 = locals2.getOrNull(i); - TypeBearer resultType = mergeType(tb1, tb2); - if (resultType != tb1) { - /* - * We only need to do anything when the result differs - * from what is in the first array, since that's what the - * result gets initialized to. - */ - if (result == null) { - result = locals1.copy(); - } - - if (resultType == null) { - result.invalidate(i); - } else { - result.set(i, resultType); - } - } - } - - if (result == null) { - return locals1; - } - - result.setImmutable(); - return result; - } - - /** - * Merges two stacks. If the merged result is the same as the first - * argument, then return the first argument (not a copy). - * - * @param stack1 non-null; a stack - * @param stack2 non-null; another stack - * @return non-null; the result of merging the two stacks - */ - public static ExecutionStack mergeStack(ExecutionStack stack1, - ExecutionStack stack2) { - if (stack1 == stack2) { - // Easy out. - return stack1; - } - - int sz = stack1.size(); - ExecutionStack result = null; - - if (stack2.size() != sz) { - throw new SimException("mismatched stack depths"); - } - - for (int i = 0; i < sz; i++) { - TypeBearer tb1 = stack1.peek(i); - TypeBearer tb2 = stack2.peek(i); - TypeBearer resultType = mergeType(tb1, tb2); - if (resultType != tb1) { - /* - * We only need to do anything when the result differs - * from what is in the first stack, since that's what the - * result gets initialized to. - */ - if (result == null) { - result = stack1.copy(); - } - - try { - if (resultType == null) { - throw new SimException("incompatible: " + tb1 + ", " + - tb2); - } else { - result.change(i, resultType); - } - } catch (SimException ex) { - ex.addContext("...while merging stack[" + Hex.u2(i) + "]"); - throw ex; - } - } - } - - if (result == null) { - return stack1; - } - - result.setImmutable(); - return result; - } - - /** - * Merges two frame types. - * - * @param ft1 non-null; a frame type - * @param ft2 non-null; another frame type - * @return non-null; the result of merging the two types - */ - public static TypeBearer mergeType(TypeBearer ft1, TypeBearer ft2) { - if ((ft1 == null) || ft1.equals(ft2)) { - return ft1; - } else if (ft2 == null) { - return null; - } else { - Type type1 = ft1.getType(); - Type type2 = ft2.getType(); - - if (type1 == type2) { - return type1; - } else if (type1.isReference() && type2.isReference()) { - if (type1 == Type.KNOWN_NULL) { - /* - * A known-null merges with any other reference type to - * be that reference type. - */ - return type2; - } else if (type2 == Type.KNOWN_NULL) { - /* - * The same as above, but this time it's type2 that's - * the known-null. - */ - return type1; - } else if (type1.isArray() && type2.isArray()) { - TypeBearer componentUnion = - mergeType(type1.getComponentType(), - type2.getComponentType()); - if (componentUnion == null) { - /* - * At least one of the types is a primitive type, - * so the merged result is just Object. - */ - return Type.OBJECT; - } - return ((Type) componentUnion).getArrayType(); - } else { - /* - * All other unequal reference types get merged to be - * Object in this phase. This is fine here, but it - * won't be the right thing to do in the verifier. - */ - return Type.OBJECT; - } - } else if (type1.isIntlike() && type2.isIntlike()) { - /* - * Merging two non-identical int-like types results in - * the type int. - */ - return Type.INT; - } else { - return null; - } - } - } - - /** - * Returns whether the given supertype is possibly assignable from - * the given subtype. This takes into account primitiveness, - * int-likeness, known-nullness, and array dimensions, but does - * not assume anything about class hierarchy other than that the - * type Object is the supertype of all reference - * types and all arrays are assignable to - * Serializable and Cloneable. - * - * @param supertypeBearer non-null; the supertype - * @param subtypeBearer non-null; the subtype - */ - public static boolean isPossiblyAssignableFrom(TypeBearer supertypeBearer, - TypeBearer subtypeBearer) { - Type supertype = supertypeBearer.getType(); - Type subtype = subtypeBearer.getType(); - - if (supertype.equals(subtype)) { - // Easy out. - return true; - } - - int superBt = supertype.getBasicType(); - int subBt = subtype.getBasicType(); - - // Treat return types as Object for the purposes of this method. - - if (superBt == Type.BT_ADDR) { - supertype = Type.OBJECT; - superBt = Type.BT_OBJECT; - } - - if (subBt == Type.BT_ADDR) { - subtype = Type.OBJECT; - subBt = Type.BT_OBJECT; - } - - if ((superBt != Type.BT_OBJECT) || (subBt != Type.BT_OBJECT)) { - /* - * No two distinct primitive types are assignable in this sense, - * unless they are both int-like. - */ - return supertype.isIntlike() && subtype.isIntlike(); - } - - // At this point, we know both types are reference types. - - if (supertype == Type.KNOWN_NULL) { - /* - * A known-null supertype is only assignable from another - * known-null (handled in the easy out at the top of the - * method). - */ - return false; - } else if (subtype == Type.KNOWN_NULL) { - /* - * A known-null subtype is in fact assignable to any - * reference type. - */ - return true; - } else if (supertype == Type.OBJECT) { - /* - * Object is assignable from any reference type. - */ - return true; - } else if (supertype.isArray()) { - // The supertype is an array type. - if (! subtype.isArray()) { - // The subtype isn't an array, and so can't be assignable. - return false; - } - - /* - * Strip off as many matched component types from both - * types as possible, and check the assignability of the - * results. - */ - do { - supertype = supertype.getComponentType(); - subtype = subtype.getComponentType(); - } while (supertype.isArray() && subtype.isArray()); - - return isPossiblyAssignableFrom(supertype, subtype); - } else if (subtype.isArray()) { - /* - * Other than Object (handled above), array types are - * assignable only to Serializable and Cloneable. - */ - return (supertype == Type.SERIALIZABLE) || - (supertype == Type.CLONEABLE); - } else { - /* - * All other unequal reference types are considered at - * least possibly assignable. - */ - return true; - } - } -} diff --git a/dx/src/com/android/dx/cf/code/OneLocalsArray.java b/dx/src/com/android/dx/cf/code/OneLocalsArray.java deleted file mode 100644 index 3a590a105..000000000 --- a/dx/src/com/android/dx/cf/code/OneLocalsArray.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.code.RegisterSpec; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.util.ExceptionWithContext; -import com.android.dx.util.Hex; -import com.android.dx.util.MutabilityControl; - -/** - * Representation of an array of local variables, with Java semantics. - * - *

Note: For the most part, the documentation for this class - * ignores the distinction between {@link com.android.dx.rop.type.Type} and {@link - * com.android.dx.rop.type.TypeBearer}.

- */ -public class OneLocalsArray extends LocalsArray { - /** non-null; actual array */ - private final TypeBearer[] locals; - - /** - * Constructs an instance. The locals array initially consists of - * all-uninitialized values (represented as nulls). - * - * @param maxLocals >= 0; the maximum number of locals this instance - * can refer to - */ - public OneLocalsArray(int maxLocals) { - super(maxLocals != 0); - locals = new TypeBearer[maxLocals]; - } - - /** @inheritDoc */ - public OneLocalsArray copy() { - OneLocalsArray result = new OneLocalsArray(locals.length); - - System.arraycopy(locals, 0, result.locals, 0, locals.length); - - return result; - } - - /** @inheritDoc */ - public void annotate(ExceptionWithContext ex) { - for (int i = 0; i < locals.length; i++) { - TypeBearer type = locals[i]; - String s = (type == null) ? "" : type.toString(); - ex.addContext("locals[" + Hex.u2(i) + "]: " + s); - } - } - - /** {@inheritDoc*/ - public String toHuman() { - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < locals.length; i++) { - TypeBearer type = locals[i]; - String s = (type == null) ? "" : type.toString(); - sb.append("locals[" + Hex.u2(i) + "]: " + s + "\n"); - } - - return sb.toString(); - } - - /** @inheritDoc */ - public void makeInitialized(Type type) { - int len = locals.length; - - if (len == 0) { - // We have to check for this before checking for immutability. - return; - } - - throwIfImmutable(); - - Type initializedType = type.getInitializedType(); - - for (int i = 0; i < len; i++) { - if (locals[i] == type) { - locals[i] = initializedType; - } - } - } - - /** @inheritDoc */ - public int getMaxLocals() { - return locals.length; - } - - /** @inheritDoc */ - public void set(int idx, TypeBearer type) { - throwIfImmutable(); - - try { - type = type.getFrameType(); - } catch (NullPointerException ex) { - // Elucidate the exception - throw new NullPointerException("type == null"); - } - - if (idx < 0) { - throw new IndexOutOfBoundsException("idx < 0"); - } - - // Make highest possible out-of-bounds check happen first. - if (type.getType().isCategory2()) { - locals[idx + 1] = null; - } - - locals[idx] = type; - - if (idx != 0) { - TypeBearer prev = locals[idx - 1]; - if ((prev != null) && prev.getType().isCategory2()) { - locals[idx - 1] = null; - } - } - } - - /** @inheritDoc */ - public void set(RegisterSpec spec) { - set(spec.getReg(), spec); - } - - /** @inheritDoc */ - public void invalidate(int idx) { - throwIfImmutable(); - locals[idx] = null; - } - - /** @inheritDoc */ - public TypeBearer getOrNull(int idx) { - return locals[idx]; - } - - /** @inheritDoc */ - public TypeBearer get(int idx) { - TypeBearer result = locals[idx]; - - if (result == null) { - return throwSimException(idx, "invalid"); - } - - return result; - } - - /** @inheritDoc */ - public TypeBearer getCategory1(int idx) { - TypeBearer result = get(idx); - Type type = result.getType(); - - if (type.isUninitialized()) { - return throwSimException(idx, "uninitialized instance"); - } - - if (type.isCategory2()) { - return throwSimException(idx, "category-2"); - } - - return result; - } - - /** @inheritDoc */ - public TypeBearer getCategory2(int idx) { - TypeBearer result = get(idx); - - if (result.getType().isCategory1()) { - return throwSimException(idx, "category-1"); - } - - return result; - } - - /** @inheritDoc */ - @Override - public LocalsArray merge(LocalsArray other) { - if (other instanceof OneLocalsArray) { - return merge((OneLocalsArray)other); - } else { //LocalsArraySet - // LocalsArraySet knows how to merge me. - return other.merge(this); - } - } - - /** - * Merges this OneLocalsArray instance with another OneLocalsArray - * instance. A more-refined version of {@link #merge(LocalsArray) merge} - * which is called by that method when appropriate. - * - * @param other locals array with which to merge - * @return this instance if merge was a no-op, or a new instance if - * the merge resulted in a change. - */ - public OneLocalsArray merge(OneLocalsArray other) { - try { - return Merger.mergeLocals(this, other); - } catch (SimException ex) { - ex.addContext("underlay locals:"); - annotate(ex); - ex.addContext("overlay locals:"); - other.annotate(ex); - throw ex; - } - } - - /** @inheritDoc */ - @Override - public LocalsArraySet mergeWithSubroutineCaller - (LocalsArray other, int predLabel) { - - LocalsArraySet result = new LocalsArraySet(getMaxLocals()); - return result.mergeWithSubroutineCaller(other, predLabel); - } - - /**{@inheritDoc}*/ - @Override - protected OneLocalsArray getPrimary() { - return this; - } - - /** - * Throws a properly-formatted exception. - * - * @param idx the salient local index - * @param msg non-null; useful message - * @return never (keeps compiler happy) - */ - private static TypeBearer throwSimException(int idx, String msg) { - throw new SimException("local " + Hex.u2(idx) + ": " + msg); - } -} diff --git a/dx/src/com/android/dx/cf/code/ReturnAddress.java b/dx/src/com/android/dx/cf/code/ReturnAddress.java deleted file mode 100644 index c69253c95..000000000 --- a/dx/src/com/android/dx/cf/code/ReturnAddress.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.util.Hex; - -/** - * Representation of a subroutine return address. In Java verification, - * somewhat counterintuitively, the salient bit of information you need to - * know about a return address is the start address of the subroutine - * being returned from, not the address being returned to, so that's - * what instances of this class hang onto. - */ -public final class ReturnAddress implements TypeBearer { - /** >= 0; the start address of the subroutine being returned from */ - private final int subroutineAddress; - - /** - * Constructs an instance. - * - * @param subroutineAddress >= 0; the start address of the - * subroutine being returned from - */ - public ReturnAddress(int subroutineAddress) { - if (subroutineAddress < 0) { - throw new IllegalArgumentException("subroutineAddress < 0"); - } - - this.subroutineAddress = subroutineAddress; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return (""); - } - - /** {@inheritDoc} */ - public String toHuman() { - return toString(); - } - - /** {@inheritDoc} */ - public Type getType() { - return Type.RETURN_ADDRESS; - } - - /** {@inheritDoc} */ - public TypeBearer getFrameType() { - return this; - } - - /** {@inheritDoc} */ - public int getBasicType() { - return Type.RETURN_ADDRESS.getBasicType(); - } - - /** {@inheritDoc} */ - public int getBasicFrameType() { - return Type.RETURN_ADDRESS.getBasicFrameType(); - } - - /** {@inheritDoc} */ - public boolean isConstant() { - return false; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object other) { - if (!(other instanceof ReturnAddress)) { - return false; - } - - return subroutineAddress == ((ReturnAddress) other).subroutineAddress; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return subroutineAddress; - } - - /** - * Gets the subroutine address. - * - * @return >= 0; the subroutine address - */ - public int getSubroutineAddress() { - return subroutineAddress; - } -} diff --git a/dx/src/com/android/dx/cf/code/Ropper.java b/dx/src/com/android/dx/cf/code/Ropper.java deleted file mode 100644 index f3eecab53..000000000 --- a/dx/src/com/android/dx/cf/code/Ropper.java +++ /dev/null @@ -1,1667 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.code.*; -import com.android.dx.rop.cst.CstInteger; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.Prototype; -import com.android.dx.rop.type.StdTypeList; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeList; -import com.android.dx.util.Bits; -import com.android.dx.util.Hex; -import com.android.dx.util.IntList; - -import java.util.ArrayList; -import java.util.BitSet; -import java.util.HashMap; - -/** - * Utility that converts a basic block list into a list of register-oriented - * blocks. - */ -public final class Ropper { - /** label offset for the parameter assignment block */ - private static final int PARAM_ASSIGNMENT = -1; - - /** label offset for the return block */ - private static final int RETURN = -2; - - /** label offset for the synchronized method final return block */ - private static final int SYNCH_RETURN = -3; - - /** label offset for the first synchronized method setup block */ - private static final int SYNCH_SETUP_1 = -4; - - /** label offset for the second synchronized method setup block */ - private static final int SYNCH_SETUP_2 = -5; - - /** - * label offset for the first synchronized method exception - * handler block - */ - private static final int SYNCH_CATCH_1 = -6; - - /** - * label offset for the second synchronized method exception - * handler block - */ - private static final int SYNCH_CATCH_2 = -7; - - /** number of special label offsets */ - private static final int SPECIAL_LABEL_COUNT = 7; - - /** non-null; method being converted */ - private final ConcreteMethod method; - - /** non-null; original block list */ - private final ByteBlockList blocks; - - /** max locals of the method */ - private final int maxLocals; - - /** max label (exclusive) of any original bytecode block */ - private final int maxLabel; - - /** non-null; simulation machine to use */ - private final RopperMachine machine; - - /** non-null; simulator to use */ - private final Simulator sim; - - /** - * non-null; sparse array mapping block labels to initial frame contents, - * if known - */ - private final Frame[] startFrames; - - /** non-null; output block list in-progress */ - private final ArrayList result; - - /** - * non-null; list of subroutine-nest labels - * (See {@link Frame#getSubroutines} associated with each result block. - * Parallel to {@link Ropper#result}. - */ - private final ArrayList resultSubroutines; - - /** - * non-null; for each block (by label) that is used as an exception - * handler, the type of exception it catches - */ - private final Type[] catchTypes; - - /** - * whether an exception-handler block for a synchronized method was - * ever required - */ - private boolean synchNeedsExceptionHandler; - - /** non-null; list of subroutines indexed by label of start address */ - private final Subroutine subroutines[]; - - /** true if subroutines is non-empty */ - private boolean hasSubroutines; - - /** - * Keeps track of subroutines that exist in java form and are inlined in - * Rop form. - */ - private class Subroutine { - /** list of all blocks that jsr to this subroutine */ - private BitSet callerBlocks; - /** List of all blocks that return from this subroutine */ - private BitSet retBlocks; - /** first block in this subroutine */ - private int startBlock; - - /** - * Constructs instance. - * - * @param startBlock First block of the subroutine. - */ - Subroutine(int startBlock) { - this.startBlock = startBlock; - retBlocks = new BitSet(maxLabel); - callerBlocks = new BitSet(maxLabel); - hasSubroutines = true; - } - - /** - * Constructs instance. - * - * @param startBlock First block of the subroutine. - * @param retBlock one of the ret blocks (final blocks) of this - * subroutine. - */ - Subroutine(int startBlock, int retBlock) { - this(startBlock); - addRetBlock(retBlock); - } - - /** - * @return >= 0; the label of the subroutine's start block. - */ - int getStartBlock() { - return startBlock; - } - - /** - * Adds a label to the list of ret blocks (final blocks) for this - * subroutine. - * - * @param retBlock ret block label - */ - void addRetBlock(int retBlock) { - retBlocks.set(retBlock); - } - - /** - * Adds a label to the list of caller blocks for this subroutine. - * - * @param label a block that invokes this subroutine. - */ - void addCallerBlock(int label) { - callerBlocks.set(label); - } - - /** - * Generates a list of subroutine successors. Note: successor blocks - * could be listed more than once. This is ok, because this successor - * list (and the block it's associated with) will be copied and inlined - * before we leave the ropper. Redundent successors will result in - * redundent (no-op) merges. - * - * @return all currently known successors - * (return destinations) for that subroutine - */ - IntList getSuccessors() { - IntList successors = new IntList(callerBlocks.size()); - - /* - * For each subroutine caller, get it's target. If the target is us, - * add the ret target (subroutine successor) to our list - */ - - for(int label = callerBlocks.nextSetBit(0); label >= 0 - ; label = callerBlocks.nextSetBit(label+1)) { - - BasicBlock subCaller = labelToBlock(label); - successors.add(subCaller.getSuccessors().get(0)); - } - - successors.setImmutable(); - - return successors; - } - - /** - * Merges the specified frame into this subroutine's successors, - * setting workSet as appropriate. To be called with - * the frame of a subroutine ret block. - * - * @param frame non-null; frame from ret block to merge - * @param workSet non-null; workset to update - */ - void mergeToSuccessors(Frame frame, int[] workSet) { - int sz = callerBlocks.size(); - - for(int label = callerBlocks.nextSetBit(0); label >= 0 - ; label = callerBlocks.nextSetBit(label+1)) { - - BasicBlock subCaller = labelToBlock(label); - int succLabel = subCaller.getSuccessors().get(0); - - Frame subFrame = frame.subFrameForLabel(startBlock, label); - - if (subFrame != null) { - mergeAndWorkAsNecessary(succLabel, -1, null, - subFrame, workSet); - } else { - Bits.set(workSet, label); - } - } - } - } - - /** - * Converts a {@link ConcreteMethod} to a {@link RopMethod}. - * - * @param method non-null; method to convert - * @param advice non-null; translation advice to use - * @return non-null; the converted instance - */ - public static RopMethod convert(ConcreteMethod method, - TranslationAdvice advice) { - try { - Ropper r = new Ropper(method, advice); - r.doit(); - return r.getRopMethod(); - } catch (SimException ex) { - ex.addContext("...while working on method " + - method.getNat().toHuman()); - throw ex; - } - } - - /** - * Constructs an instance. This class is not publicly instantiable; use - * {@link #convert}. - * - * @param method non-null; method to convert - * @param advice non-null; translation advice to use - */ - private Ropper(ConcreteMethod method, TranslationAdvice advice) { - if (method == null) { - throw new NullPointerException("method == null"); - } - - if (advice == null) { - throw new NullPointerException("advice == null"); - } - - this.method = method; - this.blocks = BasicBlocker.identifyBlocks(method); - this.maxLabel = blocks.getMaxLabel(); - this.maxLocals = method.getMaxLocals(); - this.machine = new RopperMachine(this, method, advice); - this.sim = new Simulator(machine, method); - this.startFrames = new Frame[maxLabel]; - this.subroutines = new Subroutine[maxLabel]; - - /* - * The "* 2 + 10" below is to conservatively believe that every - * block is an exception handler target and should also - * take care of enough other possible extra overhead such that - * the underlying array is unlikely to need resizing. - */ - this.result = new ArrayList(blocks.size() * 2 + 10); - this.resultSubroutines = new ArrayList(blocks.size() * 2 + 10); - - this.catchTypes = new Type[maxLabel]; - this.synchNeedsExceptionHandler = false; - - /* - * Set up the first stack frame with the right limits, but leave it - * empty here (to be filled in outside of the constructor). - */ - startFrames[0] = new Frame(maxLocals, method.getMaxStack()); - } - - /** - * Gets the first (lowest) register number to use as the temporary - * area when unwinding stack manipulation ops. - * - * @return >= 0; the first register to use - */ - /*package*/ int getFirstTempStackReg() { - /* - * We use the register that is just past the deepest possible - * stack element, plus one if the method is synchronized to - * avoid overlapping with the synch register. We don't need to - * do anything else special at this level, since later passes - * will merely notice the highest register used by explicit - * inspection. - */ - int regCount = getNormalRegCount(); - return isSynchronized() ? regCount + 1 : regCount; - } - - /** - * Gets the label for the exception handler setup block corresponding - * to the given label. - * - * @param label >= 0; the original label - * @return >= 0; the corresponding exception handler setup label - */ - private int getExceptionSetupLabel(int label) { - return maxLabel + label; - } - - /** - * Gets the label for the given special-purpose block. The given label - * should be one of the static constants defined by this class. - * - * @param label < 0; the special label constant - * @return >= 0; the actual label value to use - */ - private int getSpecialLabel(int label) { - /* - * The label is bitwise-complemented so that mistakes where - * LABEL is used instead of getSpecialLabel(LABEL) cause a - * failure at block construction time, since negative labels - * are illegal. We multiply maxLabel by 2 since 0..maxLabel - * (exclusive) are the original blocks and - * maxLabel..(maxLabel*2) are reserved for exception handler - * setup blocks (see getExceptionSetupLabel(), above). - */ - return (maxLabel * 2) + ~label; - } - - /** - * Gets the minimum label for unreserved use. - * - * @return >= 0; the minimum label - */ - private int getMinimumUnreservedLabel() { - /* - * The labels below ((maxLabel * 2) + SPECIAL_LABEL_COUNT) are - * reserved for particular uses. - */ - - return (maxLabel * 2) + SPECIAL_LABEL_COUNT; - } - - /** - * Gets an arbitrary unreserved and available label. - * - * @return >= 0; the label - */ - private int getAvailableLabel() { - int candidate = getMinimumUnreservedLabel(); - - for (BasicBlock bb : result) { - int label = bb.getLabel(); - if (label >= candidate) { - candidate = label + 1; - } - } - - return candidate; - } - - /** - * Gets whether the method being translated is synchronized. - * - * @return whether the method being translated is synchronized - */ - private boolean isSynchronized() { - int accessFlags = method.getAccessFlags(); - return (accessFlags & AccessFlags.ACC_SYNCHRONIZED) != 0; - } - - /** - * Gets whether the method being translated is static. - * - * @return whether the method being translated is static - */ - private boolean isStatic() { - int accessFlags = method.getAccessFlags(); - return (accessFlags & AccessFlags.ACC_STATIC) != 0; - } - - /** - * Gets the total number of registers used for "normal" purposes (i.e., - * for the straightforward translation from the original Java). - * - * @return >= 0; the total number of registers used - */ - private int getNormalRegCount() { - return maxLocals + method.getMaxStack(); - } - - /** - * Gets the register spec to use to hold the object to synchronize on, - * for a synchronized method. - * - * @return non-null; the register spec - */ - private RegisterSpec getSynchReg() { - /* - * We use the register that is just past the deepest possible - * stack element. We don't need to do anything else special at - * this level, since later passes will merely notice the - * highest register used by explicit inspection. - */ - return RegisterSpec.make(getNormalRegCount(), Type.OBJECT); - } - - /** - * Searches {@link #result} for a block with the given label. Return its - * index if found, or return -1 if there is no such block. - * - * @param label the label to look for - * @return >= -1; the index for the block with the given label or - * -1 if there is no such block - */ - private int labelToResultIndex(int label) { - int sz = result.size(); - for (int i = 0; i < sz; i++) { - BasicBlock one = result.get(i); - if (one.getLabel() == label) { - return i; - } - } - - return -1; - } - - /** - * Searches {@link #result} for a block with the given label. Return it if - * found, or throw an exception if there is no such block. - * - * @param label the label to look for - * @return non-null; the block with the given label - */ - private BasicBlock labelToBlock(int label) { - int idx = labelToResultIndex(label); - - if (idx < 0) { - throw new IllegalArgumentException("no such label " + - Hex.u2(label)); - } - - return result.get(idx); - } - - /** - * Adds a block to the output result. - * - * @param block non-null; the block to add - * @param subroutines non-null; subroutine label list as described in - * {@link Frame#getSubroutines} - */ - private void addBlock(BasicBlock block, IntList subroutines) { - if (block == null) { - throw new NullPointerException("block == null"); - } - - result.add(block); - subroutines.throwIfMutable(); - resultSubroutines.add(subroutines); - } - - /** - * Adds or replace a block in the output result. If this is a - * replacement, then any extra blocks that got added with the - * original get removed as a result of calling this method. - * - * @param block non-null; the block to add or replace - * @param subroutines non-null; subroutine label list as described in - * {@link Frame#getSubroutines} - * @return true if the block was replaced or - * false if it was added for the first time - */ - private boolean addOrReplaceBlock(BasicBlock block, IntList subroutines) { - if (block == null) { - throw new NullPointerException("block == null"); - } - - int idx = labelToResultIndex(block.getLabel()); - boolean ret; - - if (idx < 0) { - ret = false; - } else { - /* - * We are replacing a pre-existing block, so find any - * blocks that got added as part of the original and - * remove those too. Such blocks are (possibly indirect) - * successors of this block which are out of the range of - * normally-translated blocks. - */ - removeBlockAndSpecialSuccessors(idx); - ret = true; - } - - result.add(block); - subroutines.throwIfMutable(); - resultSubroutines.add(subroutines); - return ret; - } - - /** - * Adds or replaces a block in the output result. Do not delete - * any successors. - * - * @param block non-null; the block to add or replace - * @param subroutines non-null; subroutine label list as described in - * {@link Frame#getSubroutines} - * @return true if the block was replaced or - * false if it was added for the first time - */ - private boolean addOrReplaceBlockNoDelete(BasicBlock block, - IntList subroutines) { - if (block == null) { - throw new NullPointerException("block == null"); - } - - int idx = labelToResultIndex(block.getLabel()); - boolean ret; - - if (idx < 0) { - ret = false; - } else { - result.remove(idx); - resultSubroutines.remove(idx); - ret = true; - } - - result.add(block); - subroutines.throwIfMutable(); - resultSubroutines.add(subroutines); - return ret; - } - - /** - * Helper for {@link #addOrReplaceBlock} which recursively removes - * the given block and all blocks that are (direct and indirect) - * successors of it whose labels indicate that they are not in the - * normally-translated range. - * - * @param idx non-null; block to remove (etc.) - */ - private void removeBlockAndSpecialSuccessors(int idx) { - int minLabel = getMinimumUnreservedLabel(); - BasicBlock block = result.get(idx); - IntList successors = block.getSuccessors(); - int sz = successors.size(); - - result.remove(idx); - resultSubroutines.remove(idx); - - for (int i = 0; i < sz; i++) { - int label = successors.get(i); - if (label >= minLabel) { - idx = labelToResultIndex(label); - if (idx < 0) { - throw new RuntimeException("Invalid label " - + Hex.u2(label)); - } - removeBlockAndSpecialSuccessors(idx); - } - } - } - - /** - * Extracts the resulting {@link RopMethod} from the instance. - * - * @return non-null; the method object - */ - private RopMethod getRopMethod() { - - // Construct the final list of blocks. - - int sz = result.size(); - BasicBlockList bbl = new BasicBlockList(sz); - for (int i = 0; i < sz; i++) { - bbl.set(i, result.get(i)); - } - bbl.setImmutable(); - - // Construct the method object to wrap it all up. - - /* - * Note: The parameter assignment block is always the first - * that should be executed, hence the second argument to the - * constructor. - */ - return new RopMethod(bbl, getSpecialLabel(PARAM_ASSIGNMENT)); - } - - /** - * Does the conversion. - */ - private void doit() { - int[] workSet = Bits.makeBitSet(maxLabel); - - Bits.set(workSet, 0); - addSetupBlocks(); - setFirstFrame(); - - for (;;) { - int offset = Bits.findFirst(workSet, 0); - if (offset < 0) { - break; - } - Bits.clear(workSet, offset); - ByteBlock block = blocks.labelToBlock(offset); - Frame frame = startFrames[offset]; - try { - processBlock(block, frame, workSet); - } catch (SimException ex) { - ex.addContext("...while working on block " + Hex.u2(offset)); - throw ex; - } - } - - addReturnBlock(); - addSynchExceptionHandlerBlock(); - addExceptionSetupBlocks(); - - if (hasSubroutines) { - // Subroutines are very rare, so skip this step if it's n/a - inlineSubroutines(); - } - } - - /** - * Sets up the first frame to contain all the incoming parameters in - * locals. - */ - private void setFirstFrame() { - Prototype desc = method.getEffectiveDescriptor(); - startFrames[0].initializeWithParameters(desc.getParameterTypes()); - startFrames[0].setImmutable(); - } - - /** - * Processes the given block. - * - * @param block non-null; block to process - * @param frame non-null; start frame for the block - * @param workSet non-null; bits representing work to do, which this - * method may add to - */ - private void processBlock(ByteBlock block, Frame frame, int[] workSet) { - // Prepare the list of caught exceptions for this block. - ByteCatchList catches = block.getCatches(); - machine.startBlock(catches.toRopCatchList()); - - /* - * Using a copy of the given frame, simulate each instruction, - * calling into machine for each. - */ - frame = frame.copy(); - sim.simulate(block, frame); - frame.setImmutable(); - - int extraBlockCount = machine.getExtraBlockCount(); - ArrayList insns = machine.getInsns(); - int insnSz = insns.size(); - - /* - * Merge the frame into each possible non-exceptional - * successor. - */ - - int catchSz = catches.size(); - IntList successors = block.getSuccessors(); - - int startSuccessorIndex; - - Subroutine calledSubroutine = null; - if (machine.hasJsr()) { - /* - * If this frame ends in a JSR, only merge our frame with - * the subroutine start, not the subroutine's return target. - */ - startSuccessorIndex = 1; - - int subroutineLabel = successors.get(1); - - if (subroutines[subroutineLabel] == null) { - subroutines[subroutineLabel] = new Subroutine (subroutineLabel); - } - - subroutines[subroutineLabel].addCallerBlock(block.getLabel()); - - calledSubroutine = subroutines[subroutineLabel]; - } else if (machine.hasRet()) { - /* - * This block ends in a ret, which means it's the final block - * in some subroutine. Ultimately, this block will be copied - * and inlined for each call and then disposed of. - */ - - ReturnAddress ra = machine.getReturnAddress(); - int subroutineLabel = ra.getSubroutineAddress(); - - if (subroutines[subroutineLabel] == null) { - subroutines[subroutineLabel] - = new Subroutine (subroutineLabel, block.getLabel()); - } else { - subroutines[subroutineLabel].addRetBlock(block.getLabel()); - } - - successors = subroutines[subroutineLabel].getSuccessors(); - subroutines[subroutineLabel] - .mergeToSuccessors(frame, workSet); - // Skip processing below since we just did it. - startSuccessorIndex = successors.size(); - } else if (machine.wereCatchesUsed()) { - /* - * If there are catches, then the first successors - * (which will either be all of them or all but the last one) - * are catch targets. - */ - startSuccessorIndex = catchSz; - } else { - startSuccessorIndex = 0; - } - - int succSz = successors.size(); - for (int i = startSuccessorIndex; i < succSz; - i++) { - int succ = successors.get(i); - try { - mergeAndWorkAsNecessary(succ, block.getLabel(), - calledSubroutine, frame, workSet); - } catch (SimException ex) { - ex.addContext("...while merging to block " + Hex.u2(succ)); - throw ex; - } - } - - if ((succSz == 0) && machine.returns()) { - /* - * The block originally contained a return, but it has - * been made to instead end with a goto, and we need to - * tell it at this point that its sole successor is the - * return block. This has to happen after the merge loop - * above, since, at this point, the return block doesn't - * actually exist; it gets synthesized at the end of - * processing the original blocks. - */ - successors = IntList.makeImmutable(getSpecialLabel(RETURN)); - succSz = 1; - } - - int primarySucc; - - if (succSz == 0) { - primarySucc = -1; - } else { - primarySucc = machine.getPrimarySuccessorIndex(); - if (primarySucc >= 0) { - primarySucc = successors.get(primarySucc); - } - } - - /* - * This variable is true only when the method is synchronized and - * the block being processed can possibly throw an exception. - */ - boolean synch = isSynchronized() && machine.canThrow(); - - if (synch || (catchSz != 0)) { - /* - * Deal with exception handlers: Merge an exception-catch - * frame into each possible exception handler, and - * construct a new set of successors to point at the - * exception handler setup blocks (which get synthesized - * at the very end of processing). - */ - boolean catchesAny = false; - IntList newSucc = new IntList(succSz); - for (int i = 0; i < catchSz; i++) { - ByteCatchList.Item one = catches.get(i); - CstType exceptionClass = one.getExceptionClass(); - int targ = one.getHandlerPc(); - - catchesAny |= (exceptionClass == CstType.OBJECT); - - Frame f = frame.makeExceptionHandlerStartFrame(exceptionClass); - - try { - mergeAndWorkAsNecessary(targ, block.getLabel(), - null, f, workSet); - } catch (SimException ex) { - ex.addContext("...while merging exception to block " + - Hex.u2(targ)); - throw ex; - } - - /* - * Set up the exception handler type, by setting it if - * the given handler has yet to be encountered, or by - * conservatively unioning if it has. - */ - Type already = catchTypes[targ]; - if (already == null) { - catchTypes[targ] = exceptionClass.getClassType(); - } else if (already != exceptionClass.getClassType()) { - catchTypes[targ] = Type.OBJECT; - } - - /* - * The synthesized exception setup block will have the - * label getExceptionSetupLabel(targ). - */ - newSucc.add(getExceptionSetupLabel(targ)); - } - - if (synch && !catchesAny) { - /* - * The method is synchronized and this block doesn't - * already have a catch-all handler, so add one to the - * end, both in the successors and in the throwing - * instruction(s) at the end of the block (which is where - * the caught classes live). - */ - newSucc.add(getSpecialLabel(SYNCH_CATCH_1)); - synchNeedsExceptionHandler = true; - - for (int i = insnSz - extraBlockCount - 1; i < insnSz; i++) { - Insn insn = insns.get(i); - if (insn.canThrow()) { - insn = insn.withAddedCatch(Type.OBJECT); - insns.set(i, insn); - } - } - } - - if (primarySucc >= 0) { - newSucc.add(primarySucc); - } - - newSucc.setImmutable(); - successors = newSucc; - } - - // Construct the final resulting block(s), and store it (them). - - int primarySuccListIndex = successors.indexOf(primarySucc); - - /* - * If there are any extra blocks, work backwards through the - * list of instructions, adding single-instruction blocks, and - * resetting the successors variables as appropriate. - */ - for (/*extraBlockCount*/; extraBlockCount > 0; extraBlockCount--) { - /* - * Some of the blocks that the RopperMachine wants added - * are for move-result insns, and these need goto insns as well. - */ - Insn extraInsn = insns.get(--insnSz); - boolean needsGoto - = extraInsn.getOpcode().getBranchingness() - == Rop.BRANCH_NONE; - InsnList il = new InsnList(needsGoto ? 2 : 1); - IntList extraBlockSuccessors = successors; - - il.set(0, extraInsn); - - if (needsGoto) { - il.set(1, new PlainInsn(Rops.GOTO, - extraInsn.getPosition(), null, - RegisterSpecList.EMPTY)); - /* - * Obviously, this block won't be throwing an exception - * so it should only have one successor. - */ - extraBlockSuccessors = IntList.makeImmutable(primarySucc); - } - il.setImmutable(); - - int label = getAvailableLabel(); - BasicBlock bb = new BasicBlock(label, il, extraBlockSuccessors, - primarySucc); - // All of these extra blocks will be in the same subroutine - addBlock(bb, frame.getSubroutines()); - - successors = successors.mutableCopy(); - successors.set(primarySuccListIndex, label); - successors.setImmutable(); - primarySucc = label; - } - - Insn lastInsn = (insnSz == 0) ? null : insns.get(insnSz - 1); - - /* - * Add a goto to the end of the block if it doesn't already - * end with a branch, to maintain the invariant that all - * blocks end with a branch of some sort or other. Note that - * it is possible for there to be blocks for which no - * instructions were ever output (e.g., only consist of pop* - * in the original Java bytecode). - */ - if ((lastInsn == null) || - (lastInsn.getOpcode().getBranchingness() == Rop.BRANCH_NONE)) { - SourcePosition pos = (lastInsn == null) ? SourcePosition.NO_INFO : - lastInsn.getPosition(); - insns.add(new PlainInsn(Rops.GOTO, pos, null, - RegisterSpecList.EMPTY)); - insnSz++; - } - - /* - * Construct a block for the remaining instructions (which in - * the usual case is all of them). - */ - - InsnList il = new InsnList(insnSz); - for (int i = 0; i < insnSz; i++) { - il.set(i, insns.get(i)); - } - il.setImmutable(); - - BasicBlock bb = - new BasicBlock(block.getLabel(), il, successors, primarySucc); - addOrReplaceBlock(bb, frame.getSubroutines()); - } - - /** - * Helper for {@link #processBlock}, which merges frames and - * adds to the work set, as necessary. - * - * @param label >= 0; label to work on - * @param pred predecessor label. Must be >= 0 when - * label is a subroutine start block and calledSubroutine - * is non-null. Otherwise, may be -1. - * @param calledSubroutine null-ok; a Subroutine instance if - * label is the first block in a subroutine. - * @param frame non-null; new frame for the labelled block - * @param workSet non-null; bits representing work to do, which this - * method may add to - */ - private void mergeAndWorkAsNecessary(int label, int pred, - Subroutine calledSubroutine, Frame frame, int[] workSet) { - Frame existing = startFrames[label]; - Frame merged; - - if (existing != null) { - /* - * Some other block also continues at this label. Merge - * the frames, and re-set the bit in the work set if there - * was a change. - */ - if (calledSubroutine != null) { - merged = existing.mergeWithSubroutineCaller(frame, - calledSubroutine.getStartBlock(), pred); - } else { - merged = existing.mergeWith(frame); - } - if (merged != existing) { - startFrames[label] = merged; - Bits.set(workSet, label); - } - } else { - // This is the first time this label has been encountered. - if (calledSubroutine != null) { - startFrames[label] - = frame.makeNewSubroutineStartFrame(label, pred); - } else { - startFrames[label] = frame; - } - Bits.set(workSet, label); - } - } - - /** - * Constructs and adds the blocks that perform setup for the rest of - * the method. This includes a first block which merely contains - * assignments from parameters to the same-numbered registers and - * a possible second block which deals with synchronization. - */ - private void addSetupBlocks() { - LocalVariableList localVariables = method.getLocalVariables(); - SourcePosition pos = method.makeSourcePosistion(0); - Prototype desc = method.getEffectiveDescriptor(); - StdTypeList params = desc.getParameterTypes(); - int sz = params.size(); - InsnList insns = new InsnList(sz + 1); - int at = 0; - - for (int i = 0; i < sz; i++) { - Type one = params.get(i); - LocalVariableList.Item local = localVariables.pcAndIndexToLocal(0, at); - RegisterSpec result = (local == null) ? - RegisterSpec.make(at, one) : - RegisterSpec.makeLocalOptional(at, one, local.getLocalItem()); - - Insn insn = new PlainCstInsn(Rops.opMoveParam(one), pos, result, - RegisterSpecList.EMPTY, - CstInteger.make(at)); - insns.set(i, insn); - at += one.getCategory(); - } - - insns.set(sz, new PlainInsn(Rops.GOTO, pos, null, - RegisterSpecList.EMPTY)); - insns.setImmutable(); - - boolean synch = isSynchronized(); - int label = synch ? getSpecialLabel(SYNCH_SETUP_1) : 0; - BasicBlock bb = - new BasicBlock(getSpecialLabel(PARAM_ASSIGNMENT), insns, - IntList.makeImmutable(label), label); - addBlock(bb, IntList.EMPTY); - - if (synch) { - RegisterSpec synchReg = getSynchReg(); - Insn insn; - if (isStatic()) { - insn = new ThrowingCstInsn(Rops.CONST_OBJECT, pos, - RegisterSpecList.EMPTY, - StdTypeList.EMPTY, - method.getDefiningClass()); - insns = new InsnList(1); - insns.set(0, insn); - } else { - insns = new InsnList(2); - insn = new PlainCstInsn(Rops.MOVE_PARAM_OBJECT, pos, - synchReg, RegisterSpecList.EMPTY, - CstInteger.VALUE_0); - insns.set(0, insn); - insns.set(1, new PlainInsn(Rops.GOTO, pos, null, - RegisterSpecList.EMPTY)); - } - - int label2 = getSpecialLabel(SYNCH_SETUP_2); - insns.setImmutable(); - bb = new BasicBlock(label, insns, - IntList.makeImmutable(label2), label2); - addBlock(bb, IntList.EMPTY); - - insns = new InsnList(isStatic() ? 2 : 1); - - if (isStatic()) { - insns.set(0, new PlainInsn(Rops.opMoveResultPseudo(synchReg), - pos, synchReg, RegisterSpecList.EMPTY)); - } - - insn = new ThrowingInsn(Rops.MONITOR_ENTER, pos, - RegisterSpecList.make(synchReg), - StdTypeList.EMPTY); - insns.set(isStatic() ? 1 :0, insn); - insns.setImmutable(); - bb = new BasicBlock(label2, insns, IntList.makeImmutable(0), 0); - addBlock(bb, IntList.EMPTY); - } - } - - /** - * Constructs and adds the return block, if necessary. The return - * block merely contains an appropriate return - * instruction. - */ - private void addReturnBlock() { - Rop returnOp = machine.getReturnOp(); - - if (returnOp == null) { - /* - * The method being converted never returns normally, so there's - * no need for a return block. - */ - return; - } - - SourcePosition returnPos = machine.getReturnPosition(); - int label = getSpecialLabel(RETURN); - - if (isSynchronized()) { - InsnList insns = new InsnList(1); - Insn insn = new ThrowingInsn(Rops.MONITOR_EXIT, returnPos, - RegisterSpecList.make(getSynchReg()), - StdTypeList.EMPTY); - insns.set(0, insn); - insns.setImmutable(); - - int nextLabel = getSpecialLabel(SYNCH_RETURN); - BasicBlock bb = - new BasicBlock(label, insns, - IntList.makeImmutable(nextLabel), nextLabel); - addBlock(bb, IntList.EMPTY); - - label = nextLabel; - } - - InsnList insns = new InsnList(1); - TypeList sourceTypes = returnOp.getSources(); - RegisterSpecList sources; - - if (sourceTypes.size() == 0) { - sources = RegisterSpecList.EMPTY; - } else { - RegisterSpec source = RegisterSpec.make(0, sourceTypes.getType(0)); - sources = RegisterSpecList.make(source); - } - - Insn insn = new PlainInsn(returnOp, returnPos, null, sources); - insns.set(0, insn); - insns.setImmutable(); - - BasicBlock bb = new BasicBlock(label, insns, IntList.EMPTY, -1); - addBlock(bb, IntList.EMPTY); - } - - /** - * Constructs and adds, if necessary, the catch-all exception handler - * block to deal with unwinding the lock taken on entry to a synchronized - * method. - */ - private void addSynchExceptionHandlerBlock() { - if (!synchNeedsExceptionHandler) { - /* - * The method being converted either isn't synchronized or - * can't possibly throw exceptions in its main body, so - * there's no need for a synchronized method exception - * handler. - */ - return; - } - - SourcePosition pos = method.makeSourcePosistion(0); - RegisterSpec exReg = RegisterSpec.make(0, Type.THROWABLE); - BasicBlock bb; - Insn insn; - - InsnList insns = new InsnList(2); - insn = new PlainInsn(Rops.opMoveException(Type.THROWABLE), pos, - exReg, RegisterSpecList.EMPTY); - insns.set(0, insn); - insn = new ThrowingInsn(Rops.MONITOR_EXIT, pos, - RegisterSpecList.make(getSynchReg()), - StdTypeList.EMPTY); - insns.set(1, insn); - insns.setImmutable(); - - int label2 = getSpecialLabel(SYNCH_CATCH_2); - bb = new BasicBlock(getSpecialLabel(SYNCH_CATCH_1), insns, - IntList.makeImmutable(label2), label2); - addBlock(bb, IntList.EMPTY); - - insns = new InsnList(1); - insn = new ThrowingInsn(Rops.THROW, pos, - RegisterSpecList.make(exReg), - StdTypeList.EMPTY); - insns.set(0, insn); - insns.setImmutable(); - - bb = new BasicBlock(label2, insns, IntList.EMPTY, -1); - addBlock(bb, IntList.EMPTY); - } - - /** - * Creates the exception handler setup blocks. "maxLocals" - * below is because that's the register number corresponding - * to the sole element on a one-deep stack (which is the - * situation at the start of an exception handler block). - */ - private void addExceptionSetupBlocks() { - - int len = catchTypes.length; - for (int i = 0; i < len; i++) { - Type one = catchTypes[i]; - if (one != null) { - Insn proto = labelToBlock(i).getFirstInsn(); - SourcePosition pos = proto.getPosition(); - InsnList il = new InsnList(2); - - Insn insn = new PlainInsn(Rops.opMoveException(one), - pos, - RegisterSpec.make(maxLocals, one), - RegisterSpecList.EMPTY); - il.set(0, insn); - - insn = new PlainInsn(Rops.GOTO, pos, null, - RegisterSpecList.EMPTY); - il.set(1, insn); - il.setImmutable(); - - BasicBlock bb = new BasicBlock(getExceptionSetupLabel(i), - il, - IntList.makeImmutable(i), - i); - addBlock(bb, startFrames[i].getSubroutines()); - } - } - } - - /** - * Checks to see if the basic block is a subroutine caller block. - * - * @param bb non-null; the basic block in question - * @return true if this block calls a subroutine - */ - private boolean isSubroutineCaller(BasicBlock bb) { - IntList successors = bb.getSuccessors(); - if (successors.size() < 2) return false; - - int subLabel = successors.get(1); - - return (subLabel < subroutines.length) - && (subroutines[subLabel] != null); - } - - /** - * Inlines any subroutine calls - */ - private void inlineSubroutines() { - final IntList reachableSubroutineCallerLabels = new IntList(4); - - /* - * Compile a list of all subroutine calls reachable - * through the normal (non-subroutine) flow. We do this first, since - * we'll be affecting the call flow as we go. - * - * Start at label 0 -- the param assignment block has nothing for us - */ - forEachNonSubBlockDepthFirst(0, new BasicBlock.Visitor() { - public void visitBlock(BasicBlock b) { - if (isSubroutineCaller(b)) { - reachableSubroutineCallerLabels.add(b.getLabel()); - } - } - }); - - /* - * Convert the resultSubroutines list, indexed by block index, - * to a label-to-subroutines mapping used by the inliner. - */ - int largestAllocedLabel = getAvailableLabel(); - ArrayList labelToSubroutines - = new ArrayList(largestAllocedLabel); - for (int i = 0; i < largestAllocedLabel; i++) { - labelToSubroutines.add(null); - } - - for (int i = 0; i < result.size(); i++) { - BasicBlock b = result.get(i); - if (b == null) { - continue; - } - IntList subroutineList = resultSubroutines.get(i); - labelToSubroutines.set(b.getLabel(), subroutineList); - } - - /* - * Inline all reachable subroutines. - * Inner subroutines will be inlined as they are encountered. - */ - int sz = reachableSubroutineCallerLabels.size(); - for (int i = 0 ; i < sz ; i++) { - int label = reachableSubroutineCallerLabels.get(i); - new SubroutineInliner( - new LabelAllocator(getAvailableLabel()), labelToSubroutines) - .inlineSubroutineCalledFrom(labelToBlock(label)); - } - - // Now find the blocks that aren't reachable and remove them - deleteUnreachableBlocks(); - } - - /** - * Deletes all blocks that cannot be reached. This is run to delete - * original subroutine blocks after subroutine inlining. - */ - private void deleteUnreachableBlocks() { - final IntList reachableLabels = new IntList(result.size()); - - // subroutine inlining is done now and we won't update this list here - resultSubroutines.clear(); - - forEachNonSubBlockDepthFirst(getSpecialLabel(PARAM_ASSIGNMENT), - new BasicBlock.Visitor() { - - public void visitBlock(BasicBlock b) { - reachableLabels.add(b.getLabel()); - } - }); - - reachableLabels.sort(); - - for (int i = result.size() - 1 ; i >= 0 ; i--) { - if (reachableLabels.indexOf(result.get(i).getLabel()) < 0) { - result.remove(i); - // unnecessary here really, since subroutine inlining is done - //resultSubroutines.remove(i); - } - } - } - - /** - * Allocates labels, without requiring previously allocated labels - * to have been added to the blocks list. - */ - private static class LabelAllocator { - int nextAvailableLabel; - - /** - * @param startLabel available label to start allocating from - */ - LabelAllocator(int startLabel) { - nextAvailableLabel = startLabel; - } - - /** - * @return next available label - */ - int getNextLabel() { - return nextAvailableLabel++; - } - } - - /** - * Inlines a subroutine. Start by calling - * inlineSubroutineCalledFrom. - */ - private class SubroutineInliner { - /** - * maps original label to the label - * that will be used by the inlined version - */ - private final HashMap origLabelToCopiedLabel; - - /** Set of original labels that need to be copied. */ - private final BitSet workList; - - /** The label of the original start block for this subroutine. */ - private int subroutineStart; - - /** The label of the ultimate return block. */ - private int subroutineSuccessor; - - /** Used for generating new labels for copied blocks. */ - private final LabelAllocator labelAllocator; - - /** - * A mapping, indexed by label, to subroutine nesting list. - * The subroutine nest list is as returned by - * {@link Frame#getSubroutines}. - */ - private final ArrayList labelToSubroutines; - - SubroutineInliner(final LabelAllocator labelAllocator, - ArrayList labelToSubroutines) { - origLabelToCopiedLabel = new HashMap(); - - workList = new BitSet(maxLabel); - - this.labelAllocator = labelAllocator; - this.labelToSubroutines = labelToSubroutines; - } - - /** - * Inlines a subroutine. - * - * @param b block where jsr occurred in the original bytecode - */ - void inlineSubroutineCalledFrom(final BasicBlock b) { - - /* - * The 0th successor of a subroutine caller block is where - * the subroutine should return to. The 1st successor is - * the start block of the subroutine. - */ - subroutineSuccessor = b.getSuccessors().get(0); - subroutineStart = b.getSuccessors().get(1); - - /* - * This allocates an initial label and adds the first - * block to the worklist. - */ - int newSubStartLabel = mapOrAllocateLabel(subroutineStart); - - for(int label = workList.nextSetBit(0); label >= 0 - ; label = workList.nextSetBit(0)) { - - workList.clear(label); - int newLabel = origLabelToCopiedLabel.get(label); - - copyBlock(label, newLabel); - - if (isSubroutineCaller(labelToBlock(label))) { - new SubroutineInliner(labelAllocator, labelToSubroutines) - .inlineSubroutineCalledFrom(labelToBlock(newLabel)); - } - } - - /* - * Replace the original caller block, since we now have a - * new successor - */ - - addOrReplaceBlockNoDelete( - new BasicBlock(b.getLabel(), b.getInsns(), - IntList.makeImmutable (newSubStartLabel), - newSubStartLabel), labelToSubroutines.get(b.getLabel())); - } - - /** - * Copies a basic block, mapping its successors along the way. - * @param origLabel original block label - * @param newLabel label that the new block should have - */ - private void copyBlock(int origLabel, int newLabel) { - - BasicBlock origBlock = labelToBlock(origLabel); - - final IntList origSuccessors = origBlock.getSuccessors(); - IntList successors; - int primarySuccessor = -1; - Subroutine subroutine; - - if (isSubroutineCaller(origBlock)) { - /* - * A subroutine call inside a subroutine call. - * Set up so we can recurse. The caller block should have - * it's first successor be a copied block that will be - * the subroutine's return point. It's second successor will - * be copied when we recurse, and remains as the original - * label of the start of the inner subroutine. - */ - - successors = IntList.makeImmutable( - mapOrAllocateLabel(origSuccessors.get(0)), - origSuccessors.get(1)); - // primary successor will be set when this block is replaced - } else if (null - != (subroutine = subroutineFromRetBlock(origLabel))) { - /* - * this is a ret block -- its successor - * should be subroutineSuccessor - */ - - // Sanity check - if (subroutine.startBlock != subroutineStart) { - throw new RuntimeException ( - "ret instruction returns to label " - + Hex.u2 (subroutine.startBlock) - + " expected: " + Hex.u2(subroutineStart)); - } - - successors = IntList.makeImmutable(subroutineSuccessor); - primarySuccessor = subroutineSuccessor; - } else { - // Map all the successor labels - - int origPrimary = origBlock.getPrimarySuccessor(); - int sz = origSuccessors.size(); - - successors = new IntList(sz); - - for (int i = 0 ; i < sz ; i++) { - int origSuccLabel = origSuccessors.get(i); - int newSuccLabel = mapOrAllocateLabel(origSuccLabel); - - successors.add(newSuccLabel); - - if (origPrimary == origSuccLabel) { - primarySuccessor = newSuccLabel; - } - } - - successors.setImmutable(); - } - - addBlock ( - new BasicBlock(newLabel, - filterMoveReturnAddressInsns(origBlock.getInsns()), - successors, primarySuccessor), - labelToSubroutines.get(newLabel)); - } - - /** - * Checks to see if a specified label is involved in a specified - * subroutine. - * - * @param label >=0 a basic block label - * @param subroutineStart >=0 a subroutine as identified by the - * label of its start block. - * @return true if the block is dominated by the subroutine call. - */ - private boolean involvedInSubroutine(int label, int subroutineStart) { - IntList subroutinesList = labelToSubroutines.get(label); - return (subroutinesList.size() > 0 - && subroutinesList.top() == subroutineStart); - } - - /** - * Maps the label of a pre-copied block to the label of the inlined - * block, allocating a new label and adding it to the worklist - * if necessary. If the origLabel is a "special" label, it - * is returned exactly and not scheduled for duplication: copying - * never proceeds past a special label, which likely is the function - * return block or an immediate predecessor. - * - * @param origLabel label of original, pre-copied block - * @return label for new, inlined block - */ - private int mapOrAllocateLabel(int origLabel) { - int resultLabel; - Integer mappedLabel = origLabelToCopiedLabel.get(origLabel); - - if (mappedLabel != null) { - resultLabel = mappedLabel; - } else if (!involvedInSubroutine(origLabel,subroutineStart)) { - /* - * A subroutine has ended by some means other than a "ret" - * (which really means a throw caught later). - */ - resultLabel = origLabel; - } else { - resultLabel = labelAllocator.getNextLabel(); - workList.set(origLabel); - origLabelToCopiedLabel.put(origLabel, resultLabel); - - // The new label has the same frame as the original label - while (labelToSubroutines.size() <= resultLabel) { - labelToSubroutines.add(null); - } - labelToSubroutines.set(resultLabel, - labelToSubroutines.get(origLabel)); - } - - return resultLabel; - } - } - - /** - * Finds a Subroutine that is returned from by a ret in - * a given block. - * @param label A block that originally contained a ret instruction - * @return null-ok; Subroutine or null if none was found. - */ - private Subroutine subroutineFromRetBlock(int label) { - for (int i = subroutines.length - 1 ; i >= 0 ; i--) { - if (subroutines[i] != null) { - Subroutine subroutine = subroutines[i]; - - if (subroutine.retBlocks.get(label)) { - return subroutine; - } - } - } - - return null; - } - - - /** - * Removes all move-return-address instructions, returning a new InsnList - * if necessary. The move-return-address insns are dead code after - * subroutines have been inlined. - * - * @param insns InsnList that may contain move-return-address insns - * @return InsnList with move-return-address removed. - */ - private InsnList filterMoveReturnAddressInsns(InsnList insns) { - int sz; - int newSz = 0; - - // First see if we need to filter, and if so what the new size will be - sz = insns.size(); - for (int i = 0; i < sz; i++) { - if (insns.get(i).getOpcode() != Rops.MOVE_RETURN_ADDRESS) { - newSz++; - } - } - - if (newSz == sz) { - return insns; - } - - // Make a new list without the MOVE_RETURN_ADDRESS insns - InsnList newInsns = new InsnList(newSz); - - int newIndex = 0; - for (int i = 0; i < sz; i++) { - Insn insn = insns.get(i); - if (insn.getOpcode() != Rops.MOVE_RETURN_ADDRESS) { - newInsns.set(newIndex++, insn); - } - } - - newInsns.setImmutable(); - return newInsns; - } - - /** - * Visits each non-subroutine block once in depth-first successor order. - * @param firstLabel label of start block - * @param v callback interface - */ - private void forEachNonSubBlockDepthFirst( - int firstLabel, BasicBlock.Visitor v) { - - forEachNonSubBlockDepthFirst0(labelToBlock(firstLabel), - v, new BitSet(maxLabel)); - } - - /** - * Visits each block once in depth-first successor order, ignoring jsr - * targets. Worker for forEachNonSubBlockDepthFirst(). - * @param next next block to visit - * @param v callback interface - * @param visited set of blocks already visited - */ - private void forEachNonSubBlockDepthFirst0( - BasicBlock next, BasicBlock.Visitor v, BitSet visited) { - - v.visitBlock(next); - visited.set(next.getLabel()); - - IntList successors = next.getSuccessors(); - - int sz = successors.size(); - - for (int i = 0 ; i < sz ; i++) { - int succ = successors.get(i); - - if (visited.get(succ)) { - continue; - } - - if (isSubroutineCaller(next) && i > 0) { - // ignore jsr targets - continue; - } - - /* - * Ignore missing labels: they're successors of - * subroutines that never invoke a ret. - */ - int idx = labelToResultIndex(succ); - if (idx >= 0) { - forEachNonSubBlockDepthFirst0(result.get(idx), v, visited); - } - } - } -} diff --git a/dx/src/com/android/dx/cf/code/RopperMachine.java b/dx/src/com/android/dx/cf/code/RopperMachine.java deleted file mode 100644 index 6d05b382e..000000000 --- a/dx/src/com/android/dx/cf/code/RopperMachine.java +++ /dev/null @@ -1,936 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.code.FillArrayDataInsn; -import com.android.dx.rop.code.Insn; -import com.android.dx.rop.code.PlainCstInsn; -import com.android.dx.rop.code.PlainInsn; -import com.android.dx.rop.code.RegOps; -import com.android.dx.rop.code.RegisterSpec; -import com.android.dx.rop.code.RegisterSpecList; -import com.android.dx.rop.code.Rop; -import com.android.dx.rop.code.Rops; -import com.android.dx.rop.code.SourcePosition; -import com.android.dx.rop.code.SwitchInsn; -import com.android.dx.rop.code.ThrowingCstInsn; -import com.android.dx.rop.code.ThrowingInsn; -import com.android.dx.rop.code.TranslationAdvice; -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.CstFieldRef; -import com.android.dx.rop.cst.CstMethodRef; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.rop.type.TypeList; -import com.android.dx.util.IntList; - -import java.util.ArrayList; - -/** - * Machine implementation for use by {@link Ropper}. - */ -/*package*/ final class RopperMachine extends ValueAwareMachine { - /** non-null; array reflection class */ - private static final CstType ARRAY_REFLECT_TYPE = - new CstType(Type.internClassName("java/lang/reflect/Array")); - - /** - * non-null; method constant for use in converting - * multianewarray instructions - */ - private static final CstMethodRef MULTIANEWARRAY_METHOD = - new CstMethodRef(ARRAY_REFLECT_TYPE, - new CstNat(new CstUtf8("newInstance"), - new CstUtf8("(Ljava/lang/Class;[I)" + - "Ljava/lang/Object;"))); - - /** non-null; {@link Ropper} controlling this instance */ - private final Ropper ropper; - - /** non-null; method being converted */ - private final ConcreteMethod method; - - /** non-null; translation advice */ - private final TranslationAdvice advice; - - /** max locals of the method */ - private final int maxLocals; - - /** non-null; instructions for the rop basic block in-progress */ - private final ArrayList insns; - - /** non-null; catches for the block currently being processed */ - private TypeList catches; - - /** whether the catches have been used in an instruction */ - private boolean catchesUsed; - - /** whether the block contains a return */ - private boolean returns; - - /** primary successor index */ - private int primarySuccessorIndex; - - /** >= 0; number of extra basic blocks required */ - private int extraBlockCount; - - /** true if last processed block ends with a jsr or jsr_W*/ - private boolean hasJsr; - - /** true if an exception can be thrown by the last block processed */ - private boolean blockCanThrow; - - /** - * If non-null, the ReturnAddress that was used by the terminating ret - * instruction. If null, there was no ret instruction encountered. - */ - - private ReturnAddress returnAddress; - - /** - * null-ok; the appropriate return op or null - * if it is not yet known - */ - private Rop returnOp; - - /** - * null-ok; the source position for the return block or null - * if it is not yet known - */ - private SourcePosition returnPosition; - - /** - * Constructs an instance. - * - * @param ropper non-null; ropper controlling this instance - * @param method non-null; method being converted - * @param advice non-null; translation advice to use - */ - public RopperMachine(Ropper ropper, ConcreteMethod method, - TranslationAdvice advice) { - super(method.getEffectiveDescriptor()); - - if (ropper == null) { - throw new NullPointerException("ropper == null"); - } - - if (advice == null) { - throw new NullPointerException("advice == null"); - } - - this.ropper = ropper; - this.method = method; - this.advice = advice; - this.maxLocals = method.getMaxLocals(); - this.insns = new ArrayList(25); - this.catches = null; - this.catchesUsed = false; - this.returns = false; - this.primarySuccessorIndex = -1; - this.extraBlockCount = 0; - this.blockCanThrow = false; - this.returnOp = null; - this.returnPosition = null; - } - - /** - * Gets the instructions array. It is shared and gets modified by - * subsequent calls to this instance. - * - * @return non-null; the instructions array - */ - public ArrayList getInsns() { - return insns; - } - - /** - * Gets the return opcode encountered, if any. - * - * @return null-ok; the return opcode - */ - public Rop getReturnOp() { - return returnOp; - } - - /** - * Gets the return position, if known. - * - * @return null-ok; the return position - */ - public SourcePosition getReturnPosition() { - return returnPosition; - } - - /** - * Gets ready to start working on a new block. This will clear the - * {@link #insns} list, set {@link #catches}, reset whether it has - * been used, reset whether the block contains a - * return, and reset {@link #primarySuccessorIndex}. - */ - public void startBlock(TypeList catches) { - this.catches = catches; - - insns.clear(); - catchesUsed = false; - returns = false; - primarySuccessorIndex = 0; - extraBlockCount = 0; - blockCanThrow = false; - hasJsr = false; - returnAddress = null; - } - - /** - * Gets whether {@link #catches} was used. This indicates that the - * last instruction in the block is one of the ones that can throw. - * - * @return whether catches has been used - */ - public boolean wereCatchesUsed() { - return catchesUsed; - } - - /** - * Gets whether the block just processed ended with a - * return. - * - * @return whether the block returns - */ - public boolean returns() { - return returns; - } - - /** - * Gets the primary successor index. This is the index into the - * successors list where the primary may be found or - * -1 if there are successors but no primary - * successor. This may return something other than - * -1 in the case of an instruction with no - * successors at all (primary or otherwise). - * - * @return >= -1; the primary successor index - */ - public int getPrimarySuccessorIndex() { - return primarySuccessorIndex; - } - - /** - * Gets how many extra blocks will be needed to represent the - * block currently being translated. Each extra block should consist - * of one instruction from the end of the original block. - * - * @return >= 0; the number of extra blocks needed - */ - public int getExtraBlockCount() { - return extraBlockCount; - } - - /** - * @return true if at least one of the insn processed since the last - * call to startBlock() can throw. - */ - public boolean canThrow() { - return blockCanThrow; - } - - /** - * @return true if a JSR has ben encountered since the last call to - * startBlock() - */ - public boolean hasJsr() { - return hasJsr; - } - - /** - * @return true if a RET has ben encountered since the last call to - * startBlock() - */ - public boolean hasRet() { - return returnAddress != null; - } - - /** - * @return null-ok; return address of a ret instruction if encountered - * since last call to startBlock(). null if no ret instruction encountered. - */ - public ReturnAddress getReturnAddress() { - return returnAddress; - } - - /** {@inheritDoc} */ - @Override - public void run(Frame frame, int offset, int opcode) { - /* - * This is the stack pointer after the opcode's arguments have been - * popped. - */ - int stackPointer = maxLocals + frame.getStack().size(); - - // The sources have to be retrieved before super.run() gets called. - RegisterSpecList sources = getSources(opcode, stackPointer); - int sourceCount = sources.size(); - - super.run(frame, offset, opcode); - - SourcePosition pos = method.makeSourcePosistion(offset); - RegisterSpec localTarget = getLocalTarget(); - int destCount = resultCount(); - RegisterSpec dest; - - if (destCount == 0) { - dest = null; - switch (opcode) { - case ByteOps.POP: - case ByteOps.POP2: { - // These simply don't appear in the rop form. - return; - } - } - } else if (localTarget != null) { - dest = localTarget; - } else if (destCount == 1) { - dest = RegisterSpec.make(stackPointer, result(0)); - } else { - /* - * This clause only ever applies to the stack manipulation - * ops that have results (that is, dup* and swap but not - * pop*). - * - * What we do is first move all the source registers into - * the "temporary stack" area defined for the method, and - * then move stuff back down onto the main "stack" in the - * arrangement specified by the stack op pattern. - * - * Note: This code ends up emitting a lot of what will - * turn out to be superfluous moves (e.g., moving back and - * forth to the same local when doing a dup); however, - * that makes this code a bit easier (and goodness knows - * it doesn't need any extra complexity), and all the SSA - * stuff is going to want to deal with this sort of - * superfluous assignment anyway, so it should be a wash - * in the end. - */ - int scratchAt = ropper.getFirstTempStackReg(); - RegisterSpec[] scratchRegs = new RegisterSpec[sourceCount]; - - for (int i = 0; i < sourceCount; i++) { - RegisterSpec src = sources.get(i); - TypeBearer type = src.getTypeBearer(); - RegisterSpec scratch = src.withReg(scratchAt); - insns.add(new PlainInsn(Rops.opMove(type), pos, scratch, src)); - scratchRegs[i] = scratch; - scratchAt += src.getCategory(); - } - - for (int pattern = getAuxInt(); pattern != 0; pattern >>= 4) { - int which = (pattern & 0x0f) - 1; - RegisterSpec scratch = scratchRegs[which]; - TypeBearer type = scratch.getTypeBearer(); - insns.add(new PlainInsn(Rops.opMove(type), pos, - scratch.withReg(stackPointer), - scratch)); - stackPointer += type.getType().getCategory(); - } - return; - } - - TypeBearer destType = (dest != null) ? dest : Type.VOID; - Constant cst = getAuxCst(); - int ropOpcode; - Rop rop; - Insn insn; - - if (opcode == ByteOps.MULTIANEWARRAY) { - blockCanThrow = true; - - // Add the extra instructions for handling multianewarray. - - extraBlockCount = 6; - - /* - * Add an array constructor for the int[] containing all the - * dimensions. - */ - RegisterSpec dimsReg = - RegisterSpec.make(dest.getNextReg(), Type.INT_ARRAY); - rop = Rops.opFilledNewArray(Type.INT_ARRAY, sourceCount); - insn = new ThrowingCstInsn(rop, pos, sources, catches, - CstType.INT_ARRAY); - insns.add(insn); - - // Add a move-result for the new-filled-array - rop = Rops.opMoveResult(Type.INT_ARRAY); - insn = new PlainInsn(rop, pos, dimsReg, RegisterSpecList.EMPTY); - insns.add(insn); - - /* - * Add a const-class instruction for the specified array - * class. - */ - - /* - * Remove as many dimensions from the originally specified - * class as are given in the explicit list of dimensions, - * so as to pass the right component class to the standard - * Java library array constructor. - */ - Type componentType = ((CstType) cst).getClassType(); - for (int i = 0; i < sourceCount; i++) { - componentType = componentType.getComponentType(); - } - - RegisterSpec classReg = - RegisterSpec.make(dest.getReg(), Type.CLASS); - - if (componentType.isPrimitive()) { - /* - * The component type is primitive (e.g., int as opposed - * to Integer), so we have to fetch the corresponding - * TYPE class. - */ - CstFieldRef typeField = - CstFieldRef.forPrimitiveType(componentType); - insn = new ThrowingCstInsn(Rops.GET_STATIC_OBJECT, pos, - RegisterSpecList.EMPTY, - catches, typeField); - } else { - /* - * The component type is an object type, so just make a - * normal class reference. - */ - insn = new ThrowingCstInsn(Rops.CONST_OBJECT, pos, - RegisterSpecList.EMPTY, catches, - new CstType(componentType)); - } - - insns.add(insn); - - // Add a move-result-pseudo for the get-static or const - rop = Rops.opMoveResultPseudo(classReg.getType()); - insn = new PlainInsn(rop, pos, classReg, RegisterSpecList.EMPTY); - insns.add(insn); - - /* - * Add a call to the "multianewarray method," that is, - * Array.newInstance(class, dims). Note: The result type - * of newInstance() is Object, which is why the last - * instruction in this sequence is a cast to the right - * type for the original instruction. - */ - - RegisterSpec objectReg = - RegisterSpec.make(dest.getReg(), Type.OBJECT); - - insn = new ThrowingCstInsn( - Rops.opInvokeStatic(MULTIANEWARRAY_METHOD.getPrototype()), - pos, RegisterSpecList.make(classReg, dimsReg), - catches, MULTIANEWARRAY_METHOD); - insns.add(insn); - - // Add a move-result - rop = Rops.opMoveResult(MULTIANEWARRAY_METHOD.getPrototype() - .getReturnType()); - insn = new PlainInsn(rop, pos, objectReg, RegisterSpecList.EMPTY); - insns.add(insn); - - /* - * And finally, set up for the remainder of this method to - * add an appropriate cast. - */ - - opcode = ByteOps.CHECKCAST; - sources = RegisterSpecList.make(objectReg); - - } else if (opcode == ByteOps.JSR) { - // JSR has no Rop instruction - hasJsr = true; - return; - } else if (opcode == ByteOps.RET) { - try { - returnAddress = (ReturnAddress)arg(0); - } catch (ClassCastException ex) { - throw new RuntimeException( - "Argument to RET was not a ReturnAddress", ex); - } - // RET has no Rop instruction. - return; - } - - ropOpcode = jopToRopOpcode(opcode, cst); - - rop = Rops.ropFor(ropOpcode, destType, sources, cst); - - Insn moveResult = null; - if (dest != null && rop.isCallLike()) { - // We're going to want to have a move-result in the next basic block - extraBlockCount++; - - moveResult = new PlainInsn( - Rops.opMoveResult(((CstMethodRef) cst).getPrototype() - .getReturnType()), pos, dest, RegisterSpecList.EMPTY); - - dest = null; - } else if (dest != null && rop.canThrow()) { - // We're going to want to have a move-result-pseudo - // in the next basic block - extraBlockCount++; - - moveResult = new PlainInsn( - Rops.opMoveResultPseudo(dest.getTypeBearer()), - pos, dest, RegisterSpecList.EMPTY); - - dest = null; - } - if (ropOpcode == RegOps.NEW_ARRAY) { - /* - * In the original bytecode, this was either a primitive - * array constructor "newarray" or an object array - * constructor "anewarray". In the former case, there is - * no explicit constant, and in the latter, the constant - * is for the element type and not the array type. The rop - * instruction form for both of these is supposed to be - * the resulting array type, so we initialize / alter - * "cst" here, accordingly. Conveniently enough, the rop - * opcode already gets constructed with the proper array - * type. - */ - cst = CstType.intern(rop.getResult()); - } else if ((cst == null) && (sourceCount == 2)) { - TypeBearer lastType = sources.get(1).getTypeBearer(); - - if (lastType.isConstant() - && advice.hasConstantOperation(rop, - sources.get(0), sources.get(1))) { - /* - * The target architecture has an instruction that can - * build in the constant found in the second argument, - * so pull it out of the sources and just use it as a - * constant here. - */ - cst = (Constant) lastType; - sources = sources.withoutLast(); - rop = Rops.ropFor(ropOpcode, destType, sources, cst); - } - } - - SwitchList cases = getAuxCases(); - ArrayList initValues = getInitValues(); - boolean canThrow = rop.canThrow(); - - blockCanThrow |= canThrow; - - if (cases != null) { - if (cases.size() == 0) { - // It's a default-only switch statement. It can happen! - insn = new PlainInsn(Rops.GOTO, pos, null, - RegisterSpecList.EMPTY); - primarySuccessorIndex = 0; - } else { - IntList values = cases.getValues(); - insn = new SwitchInsn(rop, pos, dest, sources, values); - primarySuccessorIndex = values.size(); - } - } else if (ropOpcode == RegOps.RETURN) { - /* - * Returns get turned into the combination of a move (if - * non-void and if the return doesn't already mention - * register 0) and a goto (to the return block). - */ - if (sources.size() != 0) { - RegisterSpec source = sources.get(0); - TypeBearer type = source.getTypeBearer(); - if (source.getReg() != 0) { - insns.add(new PlainInsn(Rops.opMove(type), pos, - RegisterSpec.make(0, type), - source)); - } - } - insn = new PlainInsn(Rops.GOTO, pos, null, RegisterSpecList.EMPTY); - primarySuccessorIndex = 0; - updateReturnOp(rop, pos); - returns = true; - } else if (cst != null) { - if (canThrow) { - insn = - new ThrowingCstInsn(rop, pos, sources, catches, cst); - catchesUsed = true; - primarySuccessorIndex = catches.size(); - } else { - insn = new PlainCstInsn(rop, pos, dest, sources, cst); - } - } else if (canThrow) { - insn = new ThrowingInsn(rop, pos, sources, catches); - catchesUsed = true; - if (opcode == ByteOps.ATHROW) { - /* - * The op athrow is the only one where it's possible - * to have non-empty successors and yet not have a - * primary successor. - */ - primarySuccessorIndex = -1; - } else { - primarySuccessorIndex = catches.size(); - } - } else { - insn = new PlainInsn(rop, pos, dest, sources); - } - - insns.add(insn); - - if (moveResult != null) { - insns.add(moveResult); - } - - /* - * If initValues is non-null, it means that the parser has seen a group - * of compatible constant initialization bytecodes that are applied to - * the current newarray. The action we take here is to convert these - * initialization bytecodes into a single fill-array-data ROP which lays - * out all the constant values in a table. - */ - if (initValues != null) { - extraBlockCount++; - insn = new FillArrayDataInsn(Rops.FILL_ARRAY_DATA, pos, - RegisterSpecList.make(moveResult.getResult()), initValues, - cst); - insns.add(insn); - } - } - - /** - * Helper for {@link #run}, which gets the list of sources for the. - * instruction. - * - * @param opcode the opcode being translated - * @param stackPointer >= 0; the stack pointer after the instruction's - * arguments have been popped - * @return non-null; the sources - */ - private RegisterSpecList getSources(int opcode, int stackPointer) { - int count = argCount(); - - if (count == 0) { - // We get an easy out if there aren't any sources. - return RegisterSpecList.EMPTY; - } - - int localIndex = getLocalIndex(); - RegisterSpecList sources; - - if (localIndex >= 0) { - // The instruction is operating on a local variable. - sources = new RegisterSpecList(1); - sources.set(0, RegisterSpec.make(localIndex, arg(0))); - } else { - sources = new RegisterSpecList(count); - int regAt = stackPointer; - for (int i = 0; i < count; i++) { - RegisterSpec spec = RegisterSpec.make(regAt, arg(i)); - sources.set(i, spec); - regAt += spec.getCategory(); - } - - switch (opcode) { - case ByteOps.IASTORE: { - /* - * The Java argument order for array stores is - * (array, index, value), but the rop argument - * order is (value, array, index). The following - * code gets the right arguments in the right - * places. - */ - if (count != 3) { - throw new RuntimeException("shouldn't happen"); - } - RegisterSpec array = sources.get(0); - RegisterSpec index = sources.get(1); - RegisterSpec value = sources.get(2); - sources.set(0, value); - sources.set(1, array); - sources.set(2, index); - break; - } - case ByteOps.PUTFIELD: { - /* - * Similar to above: The Java argument order for - * putfield is (object, value), but the rop - * argument order is (value, object). - */ - if (count != 2) { - throw new RuntimeException("shouldn't happen"); - } - RegisterSpec obj = sources.get(0); - RegisterSpec value = sources.get(1); - sources.set(0, value); - sources.set(1, obj); - break; - } - } - } - - sources.setImmutable(); - return sources; - } - - /** - * Sets or updates the information about the return block. - * - * @param op non-null; the opcode to use - * @param pos non-null; the position to use - */ - private void updateReturnOp(Rop op, SourcePosition pos) { - if (op == null) { - throw new NullPointerException("op == null"); - } - - if (pos == null) { - throw new NullPointerException("pos == null"); - } - - if (returnOp == null) { - returnOp = op; - returnPosition = pos; - } else { - if (returnOp != op) { - throw new SimException("return op mismatch: " + op + ", " + - returnOp); - } - - if (pos.getLine() > returnPosition.getLine()) { - // Pick the largest line number to be the "canonical" return. - returnPosition = pos; - } - } - } - - /** - * Gets the register opcode for the given Java opcode. - * - * @param jop >= 0; the Java opcode - * @param cst null-ok; the constant argument, if any - * @return >= 0; the corresponding register opcode - */ - private int jopToRopOpcode(int jop, Constant cst) { - switch (jop) { - case ByteOps.POP: - case ByteOps.POP2: - case ByteOps.DUP: - case ByteOps.DUP_X1: - case ByteOps.DUP_X2: - case ByteOps.DUP2: - case ByteOps.DUP2_X1: - case ByteOps.DUP2_X2: - case ByteOps.SWAP: - case ByteOps.JSR: - case ByteOps.RET: - case ByteOps.MULTIANEWARRAY: { - // These need to be taken care of specially. - break; - } - case ByteOps.NOP: { - return RegOps.NOP; - } - case ByteOps.LDC: - case ByteOps.LDC2_W: { - return RegOps.CONST; - } - case ByteOps.ILOAD: - case ByteOps.ISTORE: { - return RegOps.MOVE; - } - case ByteOps.IALOAD: { - return RegOps.AGET; - } - case ByteOps.IASTORE: { - return RegOps.APUT; - } - case ByteOps.IADD: - case ByteOps.IINC: { - return RegOps.ADD; - } - case ByteOps.ISUB: { - return RegOps.SUB; - } - case ByteOps.IMUL: { - return RegOps.MUL; - } - case ByteOps.IDIV: { - return RegOps.DIV; - } - case ByteOps.IREM: { - return RegOps.REM; - } - case ByteOps.INEG: { - return RegOps.NEG; - } - case ByteOps.ISHL: { - return RegOps.SHL; - } - case ByteOps.ISHR: { - return RegOps.SHR; - } - case ByteOps.IUSHR: { - return RegOps.USHR; - } - case ByteOps.IAND: { - return RegOps.AND; - } - case ByteOps.IOR: { - return RegOps.OR; - } - case ByteOps.IXOR: { - return RegOps.XOR; - } - case ByteOps.I2L: - case ByteOps.I2F: - case ByteOps.I2D: - case ByteOps.L2I: - case ByteOps.L2F: - case ByteOps.L2D: - case ByteOps.F2I: - case ByteOps.F2L: - case ByteOps.F2D: - case ByteOps.D2I: - case ByteOps.D2L: - case ByteOps.D2F: { - return RegOps.CONV; - } - case ByteOps.I2B: { - return RegOps.TO_BYTE; - } - case ByteOps.I2C: { - return RegOps.TO_CHAR; - } - case ByteOps.I2S: { - return RegOps.TO_SHORT; - } - case ByteOps.LCMP: - case ByteOps.FCMPL: - case ByteOps.DCMPL: { - return RegOps.CMPL; - } - case ByteOps.FCMPG: - case ByteOps.DCMPG: { - return RegOps.CMPG; - } - case ByteOps.IFEQ: - case ByteOps.IF_ICMPEQ: - case ByteOps.IF_ACMPEQ: - case ByteOps.IFNULL: { - return RegOps.IF_EQ; - } - case ByteOps.IFNE: - case ByteOps.IF_ICMPNE: - case ByteOps.IF_ACMPNE: - case ByteOps.IFNONNULL: { - return RegOps.IF_NE; - } - case ByteOps.IFLT: - case ByteOps.IF_ICMPLT: { - return RegOps.IF_LT; - } - case ByteOps.IFGE: - case ByteOps.IF_ICMPGE: { - return RegOps.IF_GE; - } - case ByteOps.IFGT: - case ByteOps.IF_ICMPGT: { - return RegOps.IF_GT; - } - case ByteOps.IFLE: - case ByteOps.IF_ICMPLE: { - return RegOps.IF_LE; - } - case ByteOps.GOTO: { - return RegOps.GOTO; - } - case ByteOps.LOOKUPSWITCH: { - return RegOps.SWITCH; - } - case ByteOps.IRETURN: - case ByteOps.RETURN: { - return RegOps.RETURN; - } - case ByteOps.GETSTATIC: { - return RegOps.GET_STATIC; - } - case ByteOps.PUTSTATIC: { - return RegOps.PUT_STATIC; - } - case ByteOps.GETFIELD: { - return RegOps.GET_FIELD; - } - case ByteOps.PUTFIELD: { - return RegOps.PUT_FIELD; - } - case ByteOps.INVOKEVIRTUAL: { - return RegOps.INVOKE_VIRTUAL; - } - case ByteOps.INVOKESPECIAL: { - /* - * Determine whether the opcode should be - * INVOKE_DIRECT or INVOKE_SUPER. See vmspec-2 section 6 - * on "invokespecial" as well as section 4.8.2 (7th - * bullet point) for the gory details. - */ - CstMethodRef ref = (CstMethodRef) cst; - if (ref.isInstanceInit() || - (ref.getDefiningClass() == method.getDefiningClass()) || - !method.getAccSuper()) { - return RegOps.INVOKE_DIRECT; - } - return RegOps.INVOKE_SUPER; - } - case ByteOps.INVOKESTATIC: { - return RegOps.INVOKE_STATIC; - } - case ByteOps.INVOKEINTERFACE: { - return RegOps.INVOKE_INTERFACE; - } - case ByteOps.NEW: { - return RegOps.NEW_INSTANCE; - } - case ByteOps.NEWARRAY: - case ByteOps.ANEWARRAY: { - return RegOps.NEW_ARRAY; - } - case ByteOps.ARRAYLENGTH: { - return RegOps.ARRAY_LENGTH; - } - case ByteOps.ATHROW: { - return RegOps.THROW; - } - case ByteOps.CHECKCAST: { - return RegOps.CHECK_CAST; - } - case ByteOps.INSTANCEOF: { - return RegOps.INSTANCE_OF; - } - case ByteOps.MONITORENTER: { - return RegOps.MONITOR_ENTER; - } - case ByteOps.MONITOREXIT: { - return RegOps.MONITOR_EXIT; - } - } - - throw new RuntimeException("shouldn't happen"); - } -} diff --git a/dx/src/com/android/dx/cf/code/SimException.java b/dx/src/com/android/dx/cf/code/SimException.java deleted file mode 100644 index 220f2818a..000000000 --- a/dx/src/com/android/dx/cf/code/SimException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.util.ExceptionWithContext; - -/** - * Exception from simulation. - */ -public class SimException - extends ExceptionWithContext { - public SimException(String message) { - super(message); - } - - public SimException(Throwable cause) { - super(cause); - } - - public SimException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/dx/src/com/android/dx/cf/code/Simulator.java b/dx/src/com/android/dx/cf/code/Simulator.java deleted file mode 100644 index 3c90ee593..000000000 --- a/dx/src/com/android/dx/cf/code/Simulator.java +++ /dev/null @@ -1,701 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.CstFieldRef; -import com.android.dx.rop.cst.CstInteger; -import com.android.dx.rop.cst.CstInterfaceMethodRef; -import com.android.dx.rop.cst.CstMethodRef; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.type.Prototype; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.rop.code.LocalItem; -import com.android.dx.util.Hex; -import com.android.dx.util.IntList; - -import java.util.List; -import java.util.ArrayList; - -/** - * Class which knows how to simulate the effects of executing bytecode. - * - *

Note: This class is not thread-safe. If multiple threads - * need to use a single instance, they must synchronize access explicitly - * between themselves.

- */ -public class Simulator { - /** non-null; canned error message for local variable table mismatches */ - private static final String LOCAL_MISMATCH_ERROR = - "This is symptomatic of .class transformation tools that ignore " + - "local variable information."; - - /** non-null; machine to use when simulating */ - private final Machine machine; - - /** non-null; array of bytecode */ - private final BytecodeArray code; - - /** non-null; local variable information */ - private final LocalVariableList localVariables; - - /** non-null; visitor instance to use */ - private final SimVisitor visitor; - - /** - * Constructs an instance. - * - * @param machine non-null; machine to use when simulating - * @param method non-null; method data to use - */ - public Simulator(Machine machine, ConcreteMethod method) { - if (machine == null) { - throw new NullPointerException("machine == null"); - } - - if (method == null) { - throw new NullPointerException("method == null"); - } - - this.machine = machine; - this.code = method.getCode(); - this.localVariables = method.getLocalVariables(); - this.visitor = new SimVisitor(); - } - - /** - * Simulates the effect of executing the given basic block. This modifies - * the passed-in frame to represent the end result. - * - * @param bb non-null; the basic block - * @param frame non-null; frame to operate on - */ - public void simulate(ByteBlock bb, Frame frame) { - int end = bb.getEnd(); - - visitor.setFrame(frame); - - try { - for (int off = bb.getStart(); off < end; /*off*/) { - int length = code.parseInstruction(off, visitor); - visitor.setPreviousOffset(off); - off += length; - } - } catch (SimException ex) { - frame.annotate(ex); - throw ex; - } - } - - /** - * Simulates the effect of the instruction at the given offset, by - * making appropriate calls on the given frame. - * - * @param offset >= 0; offset of the instruction to simulate - * @param frame non-null; frame to operate on - * @return the length of the instruction, in bytes - */ - public int simulate(int offset, Frame frame) { - visitor.setFrame(frame); - return code.parseInstruction(offset, visitor); - } - - /** - * Constructs an "illegal top-of-stack" exception, for the stack - * manipulation opcodes. - */ - private static SimException illegalTos() { - return new SimException("stack mismatch: illegal " + - "top-of-stack for opcode"); - } - - /** - * Bytecode visitor used during simulation. - */ - private class SimVisitor implements BytecodeArray.Visitor { - /** - * non-null; machine instance to use (just to avoid excessive - * cross-object field access) - */ - private final Machine machine; - - /** - * null-ok; frame to use; set with each call to - * {@link Simulator#simulate} - */ - private Frame frame; - - /** offset of the previous bytecode */ - private int previousOffset; - - /** - * Constructs an instance. - */ - public SimVisitor() { - this.machine = Simulator.this.machine; - this.frame = null; - } - - /** - * Sets the frame to act on. - * - * @param frame non-null; the frame - */ - public void setFrame(Frame frame) { - if (frame == null) { - throw new NullPointerException("frame == null"); - } - - this.frame = frame; - } - - /** {@inheritDoc} */ - public void visitInvalid(int opcode, int offset, int length) { - throw new SimException("invalid opcode " + Hex.u1(opcode)); - } - - /** {@inheritDoc} */ - public void visitNoArgs(int opcode, int offset, int length, - Type type) { - switch (opcode) { - case ByteOps.NOP: { - machine.clearArgs(); - break; - } - case ByteOps.INEG: { - machine.popArgs(frame, type); - break; - } - case ByteOps.I2L: - case ByteOps.I2F: - case ByteOps.I2D: - case ByteOps.I2B: - case ByteOps.I2C: - case ByteOps.I2S: { - machine.popArgs(frame, Type.INT); - break; - } - case ByteOps.L2I: - case ByteOps.L2F: - case ByteOps.L2D: { - machine.popArgs(frame, Type.LONG); - break; - } - case ByteOps.F2I: - case ByteOps.F2L: - case ByteOps.F2D: { - machine.popArgs(frame, Type.FLOAT); - break; - } - case ByteOps.D2I: - case ByteOps.D2L: - case ByteOps.D2F: { - machine.popArgs(frame, Type.DOUBLE); - break; - } - case ByteOps.RETURN: { - machine.clearArgs(); - checkReturnType(Type.VOID); - break; - } - case ByteOps.IRETURN: { - Type checkType = type; - if (type == Type.OBJECT) { - /* - * For an object return, use the best-known - * type of the popped value. - */ - checkType = frame.getStack().peekType(0); - } - machine.popArgs(frame, type); - checkReturnType(checkType); - break; - } - case ByteOps.POP: { - Type peekType = frame.getStack().peekType(0); - if (peekType.isCategory2()) { - throw illegalTos(); - } - machine.popArgs(frame, 1); - break; - } - case ByteOps.ARRAYLENGTH: { - Type arrayType = frame.getStack().peekType(0); - if (!arrayType.isArrayOrKnownNull()) { - throw new SimException("type mismatch: expected " + - "array type but encountered " + - arrayType.toHuman()); - } - machine.popArgs(frame, Type.OBJECT); - break; - } - case ByteOps.ATHROW: - case ByteOps.MONITORENTER: - case ByteOps.MONITOREXIT: { - machine.popArgs(frame, Type.OBJECT); - break; - } - case ByteOps.IALOAD: { - /* - * Change the type (which is to be pushed) to - * reflect the actual component type of the array - * being popped. - */ - Type requireType = type.getArrayType(); - type = frame.getStack().peekType(1); - if (type == Type.KNOWN_NULL) { - /* - * The type is a known-null: Just treat the - * popped type as whatever is expected. In - * reality, unless this frame is revisited - * (due to a branch merge), execution will - * result in the throwing of a - * NullPointerException, but claiming the - * expected type at here should be good enough - * for the purposes at this level. - */ - type = requireType; - } - type = type.getComponentType(); - machine.popArgs(frame, requireType, Type.INT); - break; - } - case ByteOps.IADD: - case ByteOps.ISUB: - case ByteOps.IMUL: - case ByteOps.IDIV: - case ByteOps.IREM: - case ByteOps.IAND: - case ByteOps.IOR: - case ByteOps.IXOR: { - machine.popArgs(frame, type, type); - break; - } - case ByteOps.ISHL: - case ByteOps.ISHR: - case ByteOps.IUSHR: { - machine.popArgs(frame, type, Type.INT); - break; - } - case ByteOps.LCMP: { - machine.popArgs(frame, Type.LONG, Type.LONG); - break; - } - case ByteOps.FCMPL: - case ByteOps.FCMPG: { - machine.popArgs(frame, Type.FLOAT, Type.FLOAT); - break; - } - case ByteOps.DCMPL: - case ByteOps.DCMPG: { - machine.popArgs(frame, Type.DOUBLE, Type.DOUBLE); - break; - } - case ByteOps.IASTORE: { - Type arrayType = type.getArrayType(); - machine.popArgs(frame, arrayType, Type.INT, type); - break; - } - case ByteOps.POP2: - case ByteOps.DUP2: { - ExecutionStack stack = frame.getStack(); - int pattern; - - if (stack.peekType(0).isCategory2()) { - // "form 2" in vmspec-2 - machine.popArgs(frame, 1); - pattern = 0x11; - } else if (stack.peekType(1).isCategory1()) { - // "form 1" - machine.popArgs(frame, 2); - pattern = 0x2121; - } else { - throw illegalTos(); - } - - if (opcode == ByteOps.DUP2) { - machine.auxIntArg(pattern); - } - break; - } - case ByteOps.DUP: { - Type peekType = frame.getStack().peekType(0); - - if (peekType.isCategory2()) { - throw illegalTos(); - } - - machine.popArgs(frame, 1); - machine.auxIntArg(0x11); - break; - } - case ByteOps.DUP_X1: { - ExecutionStack stack = frame.getStack(); - - if (! (stack.peekType(0).isCategory1() && - stack.peekType(1).isCategory1())) { - throw illegalTos(); - } - - machine.popArgs(frame, 2); - machine.auxIntArg(0x212); - break; - } - case ByteOps.DUP_X2: { - ExecutionStack stack = frame.getStack(); - - if (stack.peekType(0).isCategory2()) { - throw illegalTos(); - } - - if (stack.peekType(1).isCategory2()) { - // "form 2" in vmspec-2 - machine.popArgs(frame, 2); - machine.auxIntArg(0x212); - } else if (stack.peekType(2).isCategory1()) { - // "form 1" - machine.popArgs(frame, 3); - machine.auxIntArg(0x3213); - } else { - throw illegalTos(); - } - break; - } - case ByteOps.DUP2_X1: { - ExecutionStack stack = frame.getStack(); - - if (stack.peekType(0).isCategory2()) { - // "form 2" in vmspec-2 - if (stack.peekType(2).isCategory2()) { - throw illegalTos(); - } - machine.popArgs(frame, 2); - machine.auxIntArg(0x212); - } else { - // "form 1" - if (stack.peekType(1).isCategory2() || - stack.peekType(2).isCategory2()) { - throw illegalTos(); - } - machine.popArgs(frame, 3); - machine.auxIntArg(0x32132); - } - break; - } - case ByteOps.DUP2_X2: { - ExecutionStack stack = frame.getStack(); - - if (stack.peekType(0).isCategory2()) { - if (stack.peekType(2).isCategory2()) { - // "form 4" in vmspec-2 - machine.popArgs(frame, 2); - machine.auxIntArg(0x212); - } else if (stack.peekType(3).isCategory1()) { - // "form 2" - machine.popArgs(frame, 3); - machine.auxIntArg(0x3213); - } else { - throw illegalTos(); - } - } else if (stack.peekType(1).isCategory1()) { - if (stack.peekType(2).isCategory2()) { - // "form 3" - machine.popArgs(frame, 3); - machine.auxIntArg(0x32132); - } else if (stack.peekType(3).isCategory1()) { - // "form 1" - machine.popArgs(frame, 4); - machine.auxIntArg(0x432143); - } else { - throw illegalTos(); - } - } else { - throw illegalTos(); - } - break; - } - case ByteOps.SWAP: { - ExecutionStack stack = frame.getStack(); - - if (! (stack.peekType(0).isCategory1() && - stack.peekType(1).isCategory1())) { - throw illegalTos(); - } - - machine.popArgs(frame, 2); - machine.auxIntArg(0x12); - break; - } - default: { - visitInvalid(opcode, offset, length); - return; - } - } - - machine.auxType(type); - machine.run(frame, offset, opcode); - } - - /** - * Checks whether the prototype is compatible with returning the - * given type, and throws if not. - * - * @param encountered non-null; the encountered return type - */ - private void checkReturnType(Type encountered) { - Type returnType = machine.getPrototype().getReturnType(); - - /* - * Check to see if the prototype's return type is - * possibly assignable from the type we encountered. This - * takes care of all the salient cases (types are the same, - * they're compatible primitive types, etc.). - */ - if (! Merger.isPossiblyAssignableFrom(returnType, encountered)) { - throw new SimException("return type mismatch: prototype " + - "indicates " + returnType.toHuman() + - ", but encountered type " + encountered.toHuman()); - } - } - - /** {@inheritDoc} */ - public void visitLocal(int opcode, int offset, int length, - int idx, Type type, int value) { - /* - * Note that the "type" parameter is always the simplest - * type based on the original opcode, e.g., "int" for - * "iload" (per se) and "Object" for "aload". So, when - * possible, we replace the type with the one indicated in - * the local variable table, though we still need to check - * to make sure it's valid for the opcode. - * - * The reason we use (offset + length) for the localOffset - * for a store is because it is only after the store that - * the local type becomes valid. On the other hand, the - * type associated with a load is valid at the start of - * the instruction. - */ - int localOffset = - (opcode == ByteOps.ISTORE) ? (offset + length) : offset; - LocalVariableList.Item local = - localVariables.pcAndIndexToLocal(localOffset, idx); - Type localType; - - if (local != null) { - localType = local.getType(); - if (localType.getBasicFrameType() != - type.getBasicFrameType()) { - BaseMachine.throwLocalMismatch(type, localType); - return; - } - } else { - localType = type; - } - - switch (opcode) { - case ByteOps.ILOAD: - case ByteOps.RET: { - machine.localArg(frame, idx); - machine.auxType(type); - break; - } - case ByteOps.ISTORE: { - LocalItem item - = (local == null) ? null : local.getLocalItem(); - machine.popArgs(frame, type); - machine.auxType(type); - machine.localTarget(idx, localType, item); - break; - } - case ByteOps.IINC: { - LocalItem item - = (local == null) ? null : local.getLocalItem(); - machine.localArg(frame, idx); - machine.localTarget(idx, localType, item); - machine.auxType(type); - machine.auxIntArg(value); - machine.auxCstArg(CstInteger.make(value)); - break; - } - default: { - visitInvalid(opcode, offset, length); - return; - } - } - - machine.run(frame, offset, opcode); - } - - /** {@inheritDoc} */ - public void visitConstant(int opcode, int offset, int length, - Constant cst, int value) { - switch (opcode) { - case ByteOps.ANEWARRAY: { - machine.popArgs(frame, Type.INT); - break; - } - case ByteOps.PUTSTATIC: { - Type fieldType = ((CstFieldRef) cst).getType(); - machine.popArgs(frame, fieldType); - break; - } - case ByteOps.GETFIELD: - case ByteOps.CHECKCAST: - case ByteOps.INSTANCEOF: { - machine.popArgs(frame, Type.OBJECT); - break; - } - case ByteOps.PUTFIELD: { - Type fieldType = ((CstFieldRef) cst).getType(); - machine.popArgs(frame, Type.OBJECT, fieldType); - break; - } - case ByteOps.INVOKEINTERFACE: { - /* - * Convert the interface method ref into a normal - * method ref. - */ - cst = ((CstInterfaceMethodRef) cst).toMethodRef(); - // and fall through... - } - case ByteOps.INVOKEVIRTUAL: - case ByteOps.INVOKESPECIAL: { - /* - * Get the instance prototype, and use it to direct - * the machine. - */ - Prototype prototype = - ((CstMethodRef) cst).getPrototype(false); - machine.popArgs(frame, prototype); - break; - } - case ByteOps.INVOKESTATIC: { - /* - * Get the static prototype, and use it to direct - * the machine. - */ - Prototype prototype = - ((CstMethodRef) cst).getPrototype(true); - machine.popArgs(frame, prototype); - break; - } - case ByteOps.MULTIANEWARRAY: { - /* - * The "value" here is the count of dimensions to - * create. Make a prototype of that many "int" - * types, and tell the machine to pop them. This - * isn't the most efficient way in the world to do - * this, but then again, multianewarray is pretty - * darn rare and so not worth much effort - * optimizing for. - */ - Prototype prototype = - Prototype.internInts(Type.VOID, value); - machine.popArgs(frame, prototype); - break; - } - default: { - machine.clearArgs(); - break; - } - } - - machine.auxIntArg(value); - machine.auxCstArg(cst); - machine.run(frame, offset, opcode); - } - - /** {@inheritDoc} */ - public void visitBranch(int opcode, int offset, int length, - int target) { - switch (opcode) { - case ByteOps.IFEQ: - case ByteOps.IFNE: - case ByteOps.IFLT: - case ByteOps.IFGE: - case ByteOps.IFGT: - case ByteOps.IFLE: { - machine.popArgs(frame, Type.INT); - break; - } - case ByteOps.IFNULL: - case ByteOps.IFNONNULL: { - machine.popArgs(frame, Type.OBJECT); - break; - } - case ByteOps.IF_ICMPEQ: - case ByteOps.IF_ICMPNE: - case ByteOps.IF_ICMPLT: - case ByteOps.IF_ICMPGE: - case ByteOps.IF_ICMPGT: - case ByteOps.IF_ICMPLE: { - machine.popArgs(frame, Type.INT, Type.INT); - break; - } - case ByteOps.IF_ACMPEQ: - case ByteOps.IF_ACMPNE: { - machine.popArgs(frame, Type.OBJECT, Type.OBJECT); - break; - } - case ByteOps.GOTO: - case ByteOps.JSR: - case ByteOps.GOTO_W: - case ByteOps.JSR_W: { - machine.clearArgs(); - break; - } - default: { - visitInvalid(opcode, offset, length); - return; - } - } - - machine.auxTargetArg(target); - machine.run(frame, offset, opcode); - } - - /** {@inheritDoc} */ - public void visitSwitch(int opcode, int offset, int length, - SwitchList cases, int padding) { - machine.popArgs(frame, Type.INT); - machine.auxIntArg(padding); - machine.auxSwitchArg(cases); - machine.run(frame, offset, opcode); - } - - /** {@inheritDoc} */ - public void visitNewarray(int offset, int length, CstType type, - ArrayList initValues) { - machine.popArgs(frame, Type.INT); - machine.auxInitValues(initValues); - machine.auxCstArg(type); - machine.run(frame, offset, ByteOps.NEWARRAY); - } - - /** {@inheritDoc} */ - public void setPreviousOffset(int offset) { - previousOffset = offset; - } - - /** {@inheritDoc} */ - public int getPreviousOffset() { - return previousOffset; - } - } -} diff --git a/dx/src/com/android/dx/cf/code/SwitchList.java b/dx/src/com/android/dx/cf/code/SwitchList.java deleted file mode 100644 index dc04137fb..000000000 --- a/dx/src/com/android/dx/cf/code/SwitchList.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.util.IntList; -import com.android.dx.util.MutabilityControl; - -/** - * List of (value, target) mappings representing the choices of a - * tableswitch or lookupswitch instruction. It - * also holds the default target for the switch. - */ -public final class SwitchList extends MutabilityControl { - /** non-null; list of test values */ - private final IntList values; - - /** - * non-null; list of targets corresponding to the test values; there - * is always one extra element in the target list, to hold the - * default target - */ - private final IntList targets; - - /** ultimate size of the list */ - private int size; - - /** - * Constructs an instance. - * - * @param size >= 0; the number of elements to be in the table - */ - public SwitchList(int size) { - super(true); - this.values = new IntList(size); - this.targets = new IntList(size + 1); - this.size = size; - } - - /** {@inheritDoc} */ - @Override - public void setImmutable() { - values.setImmutable(); - targets.setImmutable(); - super.setImmutable(); - } - - /** - * Gets the size of the list. - * - * @return >= 0; the list size - */ - public int size() { - return size; - } - - /** - * Gets the indicated test value. - * - * @param n >= 0;, < size(); which index - * @return the test value - */ - public int getValue(int n) { - return values.get(n); - } - - /** - * Gets the indicated target. Asking for the target at size() - * returns the default target. - * - * @param n >= 0, <= size(); which index - * @return >= 0; the target - */ - public int getTarget(int n) { - return targets.get(n); - } - - /** - * Gets the default target. This is just a shorthand for - * getTarget(size()). - * - * @return >= 0; the default target - */ - public int getDefaultTarget() { - return targets.get(size); - } - - /** - * Gets the list of all targets. This includes one extra element at the - * end of the list, which holds the default target. - * - * @return non-null; the target list - */ - public IntList getTargets() { - return targets; - } - - /** - * Gets the list of all case values. - * - * @return non-null; the case value list - */ - public IntList getValues() { - return values; - } - - /** - * Sets the default target. It is only valid to call this method - * when all the non-default elements have been set. - * - * @param target >= 0; the absolute (not relative) default target - * address - */ - public void setDefaultTarget(int target) { - throwIfImmutable(); - - if (target < 0) { - throw new IllegalArgumentException("target < 0"); - } - - if (targets.size() != size) { - throw new RuntimeException("non-default elements not all set"); - } - - targets.add(target); - } - - /** - * Adds the given item. - * - * @param value the test value - * @param target >= 0; the absolute (not relative) target address - */ - public void add(int value, int target) { - throwIfImmutable(); - - if (target < 0) { - throw new IllegalArgumentException("target < 0"); - } - - values.add(value); - targets.add(target); - } - - /** - * Shrinks this instance if possible, removing test elements that - * refer to the default target. This is only valid after the instance - * is fully populated, including the default target (naturally). - */ - public void removeSuperfluousDefaults() { - throwIfImmutable(); - - int sz = size; - - if (sz != (targets.size() - 1)) { - throw new IllegalArgumentException("incomplete instance"); - } - - int defaultTarget = targets.get(sz); - int at = 0; - - for (int i = 0; i < sz; i++) { - int target = targets.get(i); - if (target != defaultTarget) { - if (i != at) { - targets.set(at, target); - values.set(at, values.get(i)); - } - at++; - } - } - - if (at != sz) { - values.shrink(at); - targets.set(at, defaultTarget); - targets.shrink(at + 1); - size = at; - } - } -} diff --git a/dx/src/com/android/dx/cf/code/ValueAwareMachine.java b/dx/src/com/android/dx/cf/code/ValueAwareMachine.java deleted file mode 100644 index 4062c3b94..000000000 --- a/dx/src/com/android/dx/cf/code/ValueAwareMachine.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.code; - -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.Prototype; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeBearer; -import com.android.dx.util.Hex; - -/** - * {@link Machine} which keeps track of known values but does not do - * smart/realistic reference type calculations. - */ -public class ValueAwareMachine extends BaseMachine { - /** - * Constructs an instance. - * - * @param prototype non-null; the prototype for the associated method - */ - public ValueAwareMachine(Prototype prototype) { - super(prototype); - } - - /** {@inheritDoc} */ - public void run(Frame frame, int offset, int opcode) { - switch (opcode) { - case ByteOps.NOP: - case ByteOps.IASTORE: - case ByteOps.POP: - case ByteOps.POP2: - case ByteOps.IFEQ: - case ByteOps.IFNE: - case ByteOps.IFLT: - case ByteOps.IFGE: - case ByteOps.IFGT: - case ByteOps.IFLE: - case ByteOps.IF_ICMPEQ: - case ByteOps.IF_ICMPNE: - case ByteOps.IF_ICMPLT: - case ByteOps.IF_ICMPGE: - case ByteOps.IF_ICMPGT: - case ByteOps.IF_ICMPLE: - case ByteOps.IF_ACMPEQ: - case ByteOps.IF_ACMPNE: - case ByteOps.GOTO: - case ByteOps.RET: - case ByteOps.LOOKUPSWITCH: - case ByteOps.IRETURN: - case ByteOps.RETURN: - case ByteOps.PUTSTATIC: - case ByteOps.PUTFIELD: - case ByteOps.ATHROW: - case ByteOps.MONITORENTER: - case ByteOps.MONITOREXIT: - case ByteOps.IFNULL: - case ByteOps.IFNONNULL: { - // Nothing to do for these ops in this class. - clearResult(); - break; - } - case ByteOps.LDC: - case ByteOps.LDC2_W: { - setResult((TypeBearer) getAuxCst()); - break; - } - case ByteOps.ILOAD: - case ByteOps.ISTORE: { - setResult(arg(0)); - break; - } - case ByteOps.IALOAD: - case ByteOps.IADD: - case ByteOps.ISUB: - case ByteOps.IMUL: - case ByteOps.IDIV: - case ByteOps.IREM: - case ByteOps.INEG: - case ByteOps.ISHL: - case ByteOps.ISHR: - case ByteOps.IUSHR: - case ByteOps.IAND: - case ByteOps.IOR: - case ByteOps.IXOR: - case ByteOps.IINC: - case ByteOps.I2L: - case ByteOps.I2F: - case ByteOps.I2D: - case ByteOps.L2I: - case ByteOps.L2F: - case ByteOps.L2D: - case ByteOps.F2I: - case ByteOps.F2L: - case ByteOps.F2D: - case ByteOps.D2I: - case ByteOps.D2L: - case ByteOps.D2F: - case ByteOps.I2B: - case ByteOps.I2C: - case ByteOps.I2S: - case ByteOps.LCMP: - case ByteOps.FCMPL: - case ByteOps.FCMPG: - case ByteOps.DCMPL: - case ByteOps.DCMPG: - case ByteOps.ARRAYLENGTH: { - setResult(getAuxType()); - break; - } - case ByteOps.DUP: - case ByteOps.DUP_X1: - case ByteOps.DUP_X2: - case ByteOps.DUP2: - case ByteOps.DUP2_X1: - case ByteOps.DUP2_X2: - case ByteOps.SWAP: { - clearResult(); - for (int pattern = getAuxInt(); pattern != 0; pattern >>= 4) { - int which = (pattern & 0x0f) - 1; - addResult(arg(which)); - } - break; - } - - case ByteOps.JSR: { - setResult(new ReturnAddress(getAuxTarget())); - break; - } - case ByteOps.GETSTATIC: - case ByteOps.GETFIELD: - case ByteOps.INVOKEVIRTUAL: - case ByteOps.INVOKESTATIC: - case ByteOps.INVOKEINTERFACE: { - Type type = ((TypeBearer) getAuxCst()).getType(); - if (type == Type.VOID) { - clearResult(); - } else { - setResult(type); - } - break; - } - case ByteOps.INVOKESPECIAL: { - Type thisType = arg(0).getType(); - if (thisType.isUninitialized()) { - frame.makeInitialized(thisType); - } - Type type = ((TypeBearer) getAuxCst()).getType(); - if (type == Type.VOID) { - clearResult(); - } else { - setResult(type); - } - break; - } - case ByteOps.NEW: { - Type type = ((CstType) getAuxCst()).getClassType(); - setResult(type.asUninitialized(offset)); - break; - } - case ByteOps.NEWARRAY: - case ByteOps.CHECKCAST: - case ByteOps.MULTIANEWARRAY: { - Type type = ((CstType) getAuxCst()).getClassType(); - setResult(type); - break; - } - case ByteOps.ANEWARRAY: { - Type type = ((CstType) getAuxCst()).getClassType(); - setResult(type.getArrayType()); - break; - } - case ByteOps.INSTANCEOF: { - setResult(Type.INT); - break; - } - default: { - throw new RuntimeException("shouldn't happen: " + - Hex.u1(opcode)); - } - } - - storeResults(frame); - } -} diff --git a/dx/src/com/android/dx/cf/code/package.html b/dx/src/com/android/dx/cf/code/package.html deleted file mode 100644 index abd4e9bec..000000000 --- a/dx/src/com/android/dx/cf/code/package.html +++ /dev/null @@ -1,10 +0,0 @@ - -

Implementation of classes having to do with Java simulation, such as -is needed for verification or stack-to-register conversion.

- -

PACKAGES USED: -

    -
  • com.android.dx.rop.pool
  • -
  • com.android.dx.util
  • -
- diff --git a/dx/src/com/android/dx/cf/cst/ConstantPoolParser.java b/dx/src/com/android/dx/cf/cst/ConstantPoolParser.java deleted file mode 100644 index 953981c90..000000000 --- a/dx/src/com/android/dx/cf/cst/ConstantPoolParser.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.cst; - -import com.android.dx.cf.iface.ParseException; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.CstDouble; -import com.android.dx.rop.cst.CstFieldRef; -import com.android.dx.rop.cst.CstFloat; -import com.android.dx.rop.cst.CstInteger; -import com.android.dx.rop.cst.CstInterfaceMethodRef; -import com.android.dx.rop.cst.CstLong; -import com.android.dx.rop.cst.CstMethodRef; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstString; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.cst.StdConstantPool; -import com.android.dx.rop.type.Type; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; - -import static com.android.dx.cf.cst.ConstantTags.*; - -/** - * Parser for a constant pool embedded in a class file. - */ -public final class ConstantPoolParser { - /** non-null; the bytes of the constant pool */ - private final ByteArray bytes; - - /** non-null; actual parsed constant pool contents */ - private final StdConstantPool pool; - - /** non-null; byte offsets to each cst */ - private final int[] offsets; - - /** - * -1 || >= 10; the end offset of this constant pool in the - * byte[] which it came from or -1 if not - * yet parsed - */ - private int endOffset; - - /** null-ok; parse observer, if any */ - private ParseObserver observer; - - /** - * Constructs an instance. - * - * @param bytes non-null; the bytes of the file - */ - public ConstantPoolParser(ByteArray bytes) { - int size = bytes.getUnsignedShort(8); // constant_pool_count - - this.bytes = bytes; - this.pool = new StdConstantPool(size); - this.offsets = new int[size]; - this.endOffset = -1; - } - - /** - * Sets the parse observer for this instance. - * - * @param observer null-ok; the observer - */ - public void setObserver(ParseObserver observer) { - this.observer = observer; - } - - /** - * Gets the end offset of this constant pool in the byte[] - * which it came from. - * - * @return >= 10; the end offset - */ - public int getEndOffset() { - parseIfNecessary(); - return endOffset; - } - - /** - * Gets the actual constant pool. - * - * @return non-null; the constant pool - */ - public StdConstantPool getPool() { - parseIfNecessary(); - return pool; - } - - /** - * Runs {@link #parse} if it has not yet been run successfully. - */ - private void parseIfNecessary() { - if (endOffset < 0) { - parse(); - } - } - - /** - * Does the actual parsing. - */ - private void parse() { - determineOffsets(); - - if (observer != null) { - observer.parsed(bytes, 8, 2, - "constant_pool_count: " + Hex.u2(offsets.length)); - observer.parsed(bytes, 10, 0, "\nconstant_pool:"); - observer.changeIndent(1); - } - - for (int i = 1; i < offsets.length; i++) { - int offset = offsets[i]; - if ((offset != 0) && (pool.getOrNull(i) == null)) { - parse0(i); - } - } - - if (observer != null) { - for (int i = 1; i < offsets.length; i++) { - Constant cst = pool.getOrNull(i); - if (cst == null) { - continue; - } - int offset = offsets[i]; - int nextOffset = endOffset; - for (int j = i + 1; j < offsets.length; j++) { - int off = offsets[j]; - if (off != 0) { - nextOffset = off; - break; - } - } - observer.parsed(bytes, offset, nextOffset - offset, - Hex.u2(i) + ": " + cst.toString()); - } - - observer.changeIndent(-1); - observer.parsed(bytes, endOffset, 0, "end constant_pool"); - } - } - - /** - * Populates {@link #offsets} and also completely parse utf8 constants. - */ - private void determineOffsets() { - int at = 10; // offset from the start of the file to the first cst - int lastCategory; - - for (int i = 1; i < offsets.length; i += lastCategory) { - offsets[i] = at; - int tag = bytes.getUnsignedByte(at); - switch (tag) { - case CONSTANT_Integer: - case CONSTANT_Float: - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - case CONSTANT_NameAndType: { - lastCategory = 1; - at += 5; - break; - } - case CONSTANT_Long: - case CONSTANT_Double: { - lastCategory = 2; - at += 9; - break; - } - case CONSTANT_Class: - case CONSTANT_String: { - lastCategory = 1; - at += 3; - break; - } - case CONSTANT_Utf8: { - lastCategory = 1; - at += bytes.getUnsignedShort(at + 1) + 3; - break; - } - default: { - ParseException ex = - new ParseException("unknown tag byte: " + Hex.u1(tag)); - ex.addContext("...while preparsing cst " + Hex.u2(i) + - " at offset " + Hex.u4(at)); - throw ex; - } - } - } - - endOffset = at; - } - - /** - * Parses the constant for the given index if it hasn't already been - * parsed, also storing it in the constant pool. This will also - * have the side effect of parsing any entries the indicated one - * depends on. - * - * @param idx which constant - * @return non-null; the parsed constant - */ - private Constant parse0(int idx) { - Constant cst = pool.getOrNull(idx); - if (cst != null) { - return cst; - } - - int at = offsets[idx]; - - try { - int tag = bytes.getUnsignedByte(at); - switch (tag) { - case CONSTANT_Utf8: { - cst = parseUtf8(at); - break; - } - case CONSTANT_Integer: { - int value = bytes.getInt(at + 1); - cst = CstInteger.make(value); - break; - } - case CONSTANT_Float: { - int bits = bytes.getInt(at + 1); - cst = CstFloat.make(bits); - break; - } - case CONSTANT_Long: { - long value = bytes.getLong(at + 1); - cst = CstLong.make(value); - break; - } - case CONSTANT_Double: { - long bits = bytes.getLong(at + 1); - cst = CstDouble.make(bits); - break; - } - case CONSTANT_Class: { - int nameIndex = bytes.getUnsignedShort(at + 1); - CstUtf8 name = (CstUtf8) parse0(nameIndex); - cst = new CstType(Type.internClassName(name.getString())); - break; - } - case CONSTANT_String: { - int stringIndex = bytes.getUnsignedShort(at + 1); - CstUtf8 string = (CstUtf8) parse0(stringIndex); - cst = new CstString(string); - break; - } - case CONSTANT_Fieldref: { - int classIndex = bytes.getUnsignedShort(at + 1); - CstType type = (CstType) parse0(classIndex); - int natIndex = bytes.getUnsignedShort(at + 3); - CstNat nat = (CstNat) parse0(natIndex); - cst = new CstFieldRef(type, nat); - break; - } - case CONSTANT_Methodref: { - int classIndex = bytes.getUnsignedShort(at + 1); - CstType type = (CstType) parse0(classIndex); - int natIndex = bytes.getUnsignedShort(at + 3); - CstNat nat = (CstNat) parse0(natIndex); - cst = new CstMethodRef(type, nat); - break; - } - case CONSTANT_InterfaceMethodref: { - int classIndex = bytes.getUnsignedShort(at + 1); - CstType type = (CstType) parse0(classIndex); - int natIndex = bytes.getUnsignedShort(at + 3); - CstNat nat = (CstNat) parse0(natIndex); - cst = new CstInterfaceMethodRef(type, nat); - break; - } - case CONSTANT_NameAndType: { - int nameIndex = bytes.getUnsignedShort(at + 1); - CstUtf8 name = (CstUtf8) parse0(nameIndex); - int descriptorIndex = bytes.getUnsignedShort(at + 3); - CstUtf8 descriptor = (CstUtf8) parse0(descriptorIndex); - cst = new CstNat(name, descriptor); - break; - } - } - } catch (ParseException ex) { - ex.addContext("...while parsing cst " + Hex.u2(idx) + - " at offset " + Hex.u4(at)); - throw ex; - } catch (RuntimeException ex) { - ParseException pe = new ParseException(ex); - pe.addContext("...while parsing cst " + Hex.u2(idx) + - " at offset " + Hex.u4(at)); - throw pe; - } - - pool.set(idx, cst); - return cst; - } - - /** - * Parses a utf8 constant. - * - * @param at offset to the start of the constant (where the tag byte is) - * @return non-null; the parsed value - */ - private CstUtf8 parseUtf8(int at) { - int length = bytes.getUnsignedShort(at + 1); - - at += 3; // Skip to the data. - - ByteArray ubytes = bytes.slice(at, at + length); - - try { - return new CstUtf8(ubytes); - } catch (IllegalArgumentException ex) { - // Translate the exception - throw new ParseException(ex); - } - } -} diff --git a/dx/src/com/android/dx/cf/cst/ConstantTags.java b/dx/src/com/android/dx/cf/cst/ConstantTags.java deleted file mode 100644 index 64bc8d874..000000000 --- a/dx/src/com/android/dx/cf/cst/ConstantTags.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.cst; - -/** - * Tags for constant pool constants. - */ -public interface ConstantTags { - /** tag for a CONSTANT_Utf8_info */ - int CONSTANT_Utf8 = 1; - - /** tag for a CONSTANT_Integer_info */ - int CONSTANT_Integer = 3; - - /** tag for a CONSTANT_Float_info */ - int CONSTANT_Float = 4; - - /** tag for a CONSTANT_Long_info */ - int CONSTANT_Long = 5; - - /** tag for a CONSTANT_Double_info */ - int CONSTANT_Double = 6; - - /** tag for a CONSTANT_Class_info */ - int CONSTANT_Class = 7; - - /** tag for a CONSTANT_String_info */ - int CONSTANT_String = 8; - - /** tag for a CONSTANT_Fieldref_info */ - int CONSTANT_Fieldref = 9; - - /** tag for a CONSTANT_Methodref_info */ - int CONSTANT_Methodref = 10; - - /** tag for a CONSTANT_InterfaceMethodref_info */ - int CONSTANT_InterfaceMethodref = 11; - - /** tag for a CONSTANT_NameAndType_info */ - int CONSTANT_NameAndType = 12; -} diff --git a/dx/src/com/android/dx/cf/direct/AnnotationParser.java b/dx/src/com/android/dx/cf/direct/AnnotationParser.java deleted file mode 100644 index 5d800869b..000000000 --- a/dx/src/com/android/dx/cf/direct/AnnotationParser.java +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.iface.ParseException; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.rop.annotation.Annotation; -import com.android.dx.rop.annotation.AnnotationVisibility; -import com.android.dx.rop.annotation.Annotations; -import com.android.dx.rop.annotation.AnnotationsList; -import com.android.dx.rop.annotation.NameValuePair; -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.rop.cst.CstAnnotation; -import com.android.dx.rop.cst.CstArray; -import com.android.dx.rop.cst.CstBoolean; -import com.android.dx.rop.cst.CstByte; -import com.android.dx.rop.cst.CstChar; -import com.android.dx.rop.cst.CstDouble; -import com.android.dx.rop.cst.CstEnumRef; -import com.android.dx.rop.cst.CstFieldRef; -import com.android.dx.rop.cst.CstFloat; -import com.android.dx.rop.cst.CstInteger; -import com.android.dx.rop.cst.CstLong; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstShort; -import com.android.dx.rop.cst.CstString; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.type.Type; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; - -import java.io.IOException; - -/** - * Parser for annotations. - */ -public final class AnnotationParser { - /** non-null; class file being parsed */ - private final DirectClassFile cf; - - /** non-null; constant pool to use */ - private final ConstantPool pool; - - /** non-null; bytes of the attribute data */ - private final ByteArray bytes; - - /** null-ok; parse observer, if any */ - private final ParseObserver observer; - - /** non-null; input stream to parse from */ - private final ByteArray.MyDataInputStream input; - - /** - * non-null; cursor for use when informing the observer of what - * was parsed - */ - private int parseCursor; - - /** - * Constructs an instance. - * - * @param cf non-null; class file to parse from - * @param offset >= 0; offset into the class file data to parse at - * @param length >= 0; number of bytes left in the attribute data - * @param observer null-ok; parse observer to notify, if any - */ - public AnnotationParser(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (cf == null) { - throw new NullPointerException("cf == null"); - } - - this.cf = cf; - this.pool = cf.getConstantPool(); - this.observer = observer; - this.bytes = cf.getBytes().slice(offset, offset + length); - this.input = bytes.makeDataInputStream(); - this.parseCursor = 0; - } - - /** - * Parses an annotation value (element_value) attribute. - * - * @return non-null; the parsed constant value - */ - public Constant parseValueAttribute() { - Constant result; - - try { - result = parseValue(); - - if (input.available() != 0) { - throw new ParseException("extra data in attribute"); - } - } catch (IOException ex) { - // ByteArray.MyDataInputStream should never throw. - throw new RuntimeException("shouldn't happen", ex); - } - - return result; - } - - /** - * Parses a parameter annotation attribute. - * - * @param visibility non-null; visibility of the parsed annotations - * @return non-null; the parsed list of lists of annotations - */ - public AnnotationsList parseParameterAttribute( - AnnotationVisibility visibility) { - AnnotationsList result; - - try { - result = parseAnnotationsList(visibility); - - if (input.available() != 0) { - throw new ParseException("extra data in attribute"); - } - } catch (IOException ex) { - // ByteArray.MyDataInputStream should never throw. - throw new RuntimeException("shouldn't happen", ex); - } - - return result; - } - - /** - * Parses an annotation attribute, per se. - * - * @param visibility non-null; visibility of the parsed annotations - * @return non-null; the list of annotations read from the attribute - * data - */ - public Annotations parseAnnotationAttribute( - AnnotationVisibility visibility) { - Annotations result; - - try { - result = parseAnnotations(visibility); - - if (input.available() != 0) { - throw new ParseException("extra data in attribute"); - } - } catch (IOException ex) { - // ByteArray.MyDataInputStream should never throw. - throw new RuntimeException("shouldn't happen", ex); - } - - return result; - } - - /** - * Parses a list of annotation lists. - * - * @param visibility non-null; visibility of the parsed annotations - * @return non-null; the list of annotation lists read from the attribute - * data - */ - private AnnotationsList parseAnnotationsList( - AnnotationVisibility visibility) throws IOException { - int count = input.readUnsignedByte(); - - if (observer != null) { - parsed(1, "num_parameters: " + Hex.u1(count)); - } - - AnnotationsList outerList = new AnnotationsList(count); - - for (int i = 0; i < count; i++) { - if (observer != null) { - parsed(0, "parameter_annotations[" + i + "]:"); - changeIndent(1); - } - - Annotations annotations = parseAnnotations(visibility); - outerList.set(i, annotations); - - if (observer != null) { - observer.changeIndent(-1); - } - } - - outerList.setImmutable(); - return outerList; - } - - /** - * Parses an annotation list. - * - * @param visibility non-null; visibility of the parsed annotations - * @return non-null; the list of annotations read from the attribute - * data - */ - private Annotations parseAnnotations(AnnotationVisibility visibility) - throws IOException { - int count = input.readUnsignedShort(); - - if (observer != null) { - parsed(2, "num_annotations: " + Hex.u2(count)); - } - - Annotations annotations = new Annotations(); - - for (int i = 0; i < count; i++) { - if (observer != null) { - parsed(0, "annotations[" + i + "]:"); - changeIndent(1); - } - - Annotation annotation = parseAnnotation(visibility); - annotations.add(annotation); - - if (observer != null) { - observer.changeIndent(-1); - } - } - - annotations.setImmutable(); - return annotations; - } - - /** - * Parses a single annotation. - * - * @param visibility non-null; visibility of the parsed annotation - * @return non-null; the parsed annotation - */ - private Annotation parseAnnotation(AnnotationVisibility visibility) - throws IOException { - requireLength(4); - - int typeIndex = input.readUnsignedShort(); - int numElements = input.readUnsignedShort(); - CstUtf8 typeUtf8 = (CstUtf8) pool.get(typeIndex); - CstType type = new CstType(Type.intern(typeUtf8.getString())); - - if (observer != null) { - parsed(2, "type: " + type.toHuman()); - parsed(2, "num_elements: " + numElements); - } - - Annotation annotation = new Annotation(type, visibility); - - for (int i = 0; i < numElements; i++) { - if (observer != null) { - parsed(0, "elements[" + i + "]:"); - changeIndent(1); - } - - NameValuePair element = parseElement(); - annotation.add(element); - - if (observer != null) { - changeIndent(-1); - } - } - - annotation.setImmutable(); - return annotation; - } - - /** - * Parses a {@link NameValuePair}. - * - * @return non-null; the parsed element - */ - private NameValuePair parseElement() throws IOException { - requireLength(5); - - int elementNameIndex = input.readUnsignedShort(); - CstUtf8 elementName = (CstUtf8) pool.get(elementNameIndex); - - if (observer != null) { - parsed(2, "element_name: " + elementName.toHuman()); - parsed(0, "value: "); - changeIndent(1); - } - - Constant value = parseValue(); - - if (observer != null) { - changeIndent(-1); - } - - return new NameValuePair(elementName, value); - } - - /** - * Parses an annotation value. - * - * @return non-null; the parsed value - */ - private Constant parseValue() throws IOException { - int tag = input.readUnsignedByte(); - - if (observer != null) { - CstUtf8 humanTag = new CstUtf8(Character.toString((char) tag)); - parsed(1, "tag: " + humanTag.toQuoted()); - } - - switch (tag) { - case 'B': { - CstInteger value = (CstInteger) parseConstant(); - return CstByte.make(value.getValue()); - } - case 'C': { - CstInteger value = (CstInteger) parseConstant(); - int intValue = value.getValue(); - return CstChar.make(value.getValue()); - } - case 'D': { - CstDouble value = (CstDouble) parseConstant(); - return value; - } - case 'F': { - CstFloat value = (CstFloat) parseConstant(); - return value; - } - case 'I': { - CstInteger value = (CstInteger) parseConstant(); - return value; - } - case 'J': { - CstLong value = (CstLong) parseConstant(); - return value; - } - case 'S': { - CstInteger value = (CstInteger) parseConstant(); - return CstShort.make(value.getValue()); - } - case 'Z': { - CstInteger value = (CstInteger) parseConstant(); - return CstBoolean.make(value.getValue()); - } - case 'c': { - int classInfoIndex = input.readUnsignedShort(); - CstUtf8 value = (CstUtf8) pool.get(classInfoIndex); - Type type = Type.internReturnType(value.getString()); - - if (observer != null) { - parsed(2, "class_info: " + type.toHuman()); - } - - return new CstType(type); - } - case 's': { - CstString value = new CstString((CstUtf8) parseConstant()); - return value; - } - case 'e': { - requireLength(4); - - int typeNameIndex = input.readUnsignedShort(); - int constNameIndex = input.readUnsignedShort(); - CstUtf8 typeName = (CstUtf8) pool.get(typeNameIndex); - CstUtf8 constName = (CstUtf8) pool.get(constNameIndex); - - if (observer != null) { - parsed(2, "type_name: " + typeName.toHuman()); - parsed(2, "const_name: " + constName.toHuman()); - } - - return new CstEnumRef(new CstNat(constName, typeName)); - } - case '@': { - Annotation annotation = - parseAnnotation(AnnotationVisibility.EMBEDDED); - return new CstAnnotation(annotation); - } - case '[': { - requireLength(2); - - int numValues = input.readUnsignedShort(); - CstArray.List list = new CstArray.List(numValues); - - if (observer != null) { - parsed(2, "num_values: " + numValues); - changeIndent(1); - } - - for (int i = 0; i < numValues; i++) { - if (observer != null) { - changeIndent(-1); - parsed(0, "element_value[" + i + "]:"); - changeIndent(1); - } - list.set(i, parseValue()); - } - - if (observer != null) { - changeIndent(-1); - } - - list.setImmutable(); - return new CstArray(list); - } - default: { - throw new ParseException("unknown annotation tag: " + - Hex.u1(tag)); - } - } - } - - /** - * Helper for {@link #parseValue}, which parses a constant reference - * and returns the referred-to constant value. - * - * @return non-null; the parsed value - */ - private Constant parseConstant() throws IOException { - int constValueIndex = input.readUnsignedShort(); - Constant value = (Constant) pool.get(constValueIndex); - - if (observer != null) { - String human = (value instanceof CstUtf8) - ? ((CstUtf8) value).toQuoted() - : value.toHuman(); - parsed(2, "constant_value: " + human); - } - - return value; - } - - /** - * Helper which will throw an exception if the given number of bytes - * is not available to be read. - * - * @param requiredLength the number of required bytes - */ - private void requireLength(int requiredLength) throws IOException { - if (input.available() < requiredLength) { - throw new ParseException("truncated annotation attribute"); - } - } - - /** - * Helper which indicates that some bytes were just parsed. This should - * only be used (for efficiency sake) if the parse is known to be - * observed. - * - * @param length >= 0; number of bytes parsed - * @param message non-null; associated message - */ - private void parsed(int length, String message) { - observer.parsed(bytes, parseCursor, length, message); - parseCursor += length; - } - - /** - * Convenience wrapper that simply calls through to - * observer.changeIndent(). - * - * @param indent the amount to change the indent by - */ - private void changeIndent(int indent) { - observer.changeIndent(indent); - } -} diff --git a/dx/src/com/android/dx/cf/direct/AttributeFactory.java b/dx/src/com/android/dx/cf/direct/AttributeFactory.java deleted file mode 100644 index 420d74175..000000000 --- a/dx/src/com/android/dx/cf/direct/AttributeFactory.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.attrib.RawAttribute; -import com.android.dx.cf.iface.Attribute; -import com.android.dx.cf.iface.ParseException; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; - -/** - * Factory capable of instantiating various {@link Attribute} subclasses - * depending on the context and name. - */ -public class AttributeFactory { - /** context for attributes on class files */ - public static final int CTX_CLASS = 0; - - /** context for attributes on fields */ - public static final int CTX_FIELD = 1; - - /** context for attributes on methods */ - public static final int CTX_METHOD = 2; - - /** context for attributes on code attributes */ - public static final int CTX_CODE = 3; - - /** number of contexts */ - public static final int CTX_COUNT = 4; - - /** - * Constructs an instance. - */ - public AttributeFactory() { - // This space intentionally left blank. - } - - /** - * Parses and makes an attribute based on the bytes at the - * indicated position in the given array. This method figures out - * the name, and then does all the setup to call on to {@link #parse0}, - * which does the actual construction. - * - * @param cf non-null; class file to parse from - * @param context context to parse in; one of the CTX_* - * constants - * @param offset offset into dcf's bytes - * to start parsing at - * @param observer null-ok; parse observer to report to, if any - * @return non-null; an appropriately-constructed {@link Attribute} - */ - public final Attribute parse(DirectClassFile cf, int context, int offset, - ParseObserver observer) { - if (cf == null) { - throw new NullPointerException("cf == null"); - } - - if ((context < 0) || (context >= CTX_COUNT)) { - throw new IllegalArgumentException("bad context"); - } - - CstUtf8 name = null; - - try { - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - int nameIdx = bytes.getUnsignedShort(offset); - int length = bytes.getInt(offset + 2); - - name = (CstUtf8) pool.get(nameIdx); - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "name: " + name.toHuman()); - observer.parsed(bytes, offset + 2, 4, - "length: " + Hex.u4(length)); - } - - return parse0(cf, context, name.getString(), offset + 6, length, - observer); - } catch (ParseException ex) { - ex.addContext("...while parsing " + - ((name != null) ? (name.toHuman() + " ") : "") + - "attribute at offset " + Hex.u4(offset)); - throw ex; - } - } - - /** - * Parses attribute content. The base class implements this by constructing - * an instance of {@link RawAttribute}. Subclasses are expected to - * override this to do something better in most cases. - * - * @param cf non-null; class file to parse from - * @param context context to parse in; one of the CTX_* - * constants - * @param name non-null; the attribute name - * @param offset offset into bytes to start parsing at; this - * is the offset to the start of attribute data, not to the header - * @param length the length of the attribute data - * @param observer null-ok; parse observer to report to, if any - * @return non-null; an appropriately-constructed {@link Attribute} - */ - protected Attribute parse0(DirectClassFile cf, int context, String name, - int offset, int length, - ParseObserver observer) { - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - Attribute result = new RawAttribute(name, bytes, offset, length, pool); - - if (observer != null) { - observer.parsed(bytes, offset, length, "attribute data"); - } - - return result; - } -} diff --git a/dx/src/com/android/dx/cf/direct/AttributeListParser.java b/dx/src/com/android/dx/cf/direct/AttributeListParser.java deleted file mode 100644 index 765226565..000000000 --- a/dx/src/com/android/dx/cf/direct/AttributeListParser.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.iface.Attribute; -import com.android.dx.cf.iface.ParseException; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.cf.iface.StdAttributeList; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; - -/** - * Parser for lists of attributes. - */ -final /*package*/ class AttributeListParser { - /** non-null; the class file to parse from */ - private final DirectClassFile cf; - - /** attribute parsing context */ - private final int context; - - /** offset in the byte array of the classfile to the start of the list */ - private final int offset; - - /** non-null; attribute factory to use */ - private final AttributeFactory attributeFactory; - - /** non-null; list of parsed attributes */ - private final StdAttributeList list; - - /** >= -1; the end offset of this list in the byte array of the - * classfile, or -1 if not yet parsed */ - private int endOffset; - - /** null-ok; parse observer, if any */ - private ParseObserver observer; - - /** - * Constructs an instance. - * - * @param cf non-null; class file to parse from - * @param context attribute parsing context (see {@link AttributeFactory}) - * @param offset offset in bytes to the start of the list - * @param attributeFactory non-null; attribute factory to use - */ - public AttributeListParser(DirectClassFile cf, int context, int offset, - AttributeFactory attributeFactory) { - if (cf == null) { - throw new NullPointerException("cf == null"); - } - - if (attributeFactory == null) { - throw new NullPointerException("attributeFactory == null"); - } - - int size = cf.getBytes().getUnsignedShort(offset); - - this.cf = cf; - this.context = context; - this.offset = offset; - this.attributeFactory = attributeFactory; - this.list = new StdAttributeList(size); - this.endOffset = -1; - } - - /** - * Sets the parse observer for this instance. - * - * @param observer null-ok; the observer - */ - public void setObserver(ParseObserver observer) { - this.observer = observer; - } - - /** - * Gets the end offset of this constant pool in the byte[] - * which it came from. - * - * @return >= 0; the end offset - */ - public int getEndOffset() { - parseIfNecessary(); - return endOffset; - } - - /** - * Gets the parsed list. - * - * @return non-null; the list - */ - public StdAttributeList getList() { - parseIfNecessary(); - return list; - } - - /** - * Runs {@link #parse} if it has not yet been run successfully. - */ - private void parseIfNecessary() { - if (endOffset < 0) { - parse(); - } - } - - /** - * Does the actual parsing. - */ - private void parse() { - int sz = list.size(); - int at = offset + 2; // Skip the count. - - ByteArray bytes = cf.getBytes(); - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "attributes_count: " + Hex.u2(sz)); - } - - for (int i = 0; i < sz; i++) { - try { - if (observer != null) { - observer.parsed(bytes, at, 0, - "\nattributes[" + i + "]:\n"); - observer.changeIndent(1); - } - - Attribute attrib = - attributeFactory.parse(cf, context, at, observer); - - at += attrib.byteLength(); - list.set(i, attrib); - - if (observer != null) { - observer.changeIndent(-1); - observer.parsed(bytes, at, 0, - "end attributes[" + i + "]\n"); - } - } catch (ParseException ex) { - ex.addContext("...while parsing attributes[" + i + "]"); - throw ex; - } catch (RuntimeException ex) { - ParseException pe = new ParseException(ex); - pe.addContext("...while parsing attributes[" + i + "]"); - throw pe; - } - } - - endOffset = at; - } -} diff --git a/dx/src/com/android/dx/cf/direct/ClassPathOpener.java b/dx/src/com/android/dx/cf/direct/ClassPathOpener.java deleted file mode 100644 index d30234990..000000000 --- a/dx/src/com/android/dx/cf/direct/ClassPathOpener.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; -import java.util.Arrays; -import java.util.Comparator; -import java.util.ArrayList; -import java.util.Collections; - -/** - * Opens all the class files found in a class path element. Path elements - * can point to class files, {jar,zip,apk} files, or directories containing - * class files. - */ -public class ClassPathOpener { - - /** non-null; pathname to start with */ - private final String pathname; - /** non-null; callback interface */ - private final Consumer consumer; - /** - * If true, sort such that classes appear before their inner - * classes and "package-info" occurs before all other classes in that - * package. - */ - private final boolean sort; - - /** - * Callback interface for ClassOpener. - */ - public interface Consumer { - - /** - * Provides the file name and byte array for a class path element. - * - * @param name non-null; filename of element. May not be a valid - * filesystem path. - * - * @param bytes non-null; file data - * @return true on success. Result is or'd with all other results - * from processFileBytes and returned to the caller - * of process(). - */ - boolean processFileBytes(String name, byte[] bytes); - - /** - * Informs consumer that an exception occurred while processing - * this path element. Processing will continue if possible. - * - * @param ex non-null; exception - */ - void onException(Exception ex); - - /** - * Informs consumer that processing of an archive file has begun. - * - * @param file non-null; archive file being processed - */ - void onProcessArchiveStart(File file); - } - - /** - * Constructs an instance. - * - * @param pathname non-null; path element to process - * @param sort if true, sort such that classes appear before their inner - * classes and "package-info" occurs before all other classes in that - * package. - * @param consumer non-null; callback interface - */ - public ClassPathOpener(String pathname, boolean sort, Consumer consumer) { - this.pathname = pathname; - this.sort = sort; - this.consumer = consumer; - } - - /** - * Processes a path element. - * - * @return the OR of all return values - * from Consumer.processFileBytes(). - */ - public boolean process() { - File file = new File(pathname); - - return processOne(file, true); - } - - /** - * Processes one file. - * - * @param file non-null; the file to process - * @param topLevel whether this is a top-level file (that is, - * specified directly on the commandline) - * @return whether any processing actually happened - */ - private boolean processOne(File file, boolean topLevel) { - try { - if (file.isDirectory()) { - return processDirectory(file, topLevel); - } - - String path = file.getPath(); - - if (path.endsWith(".zip") || - path.endsWith(".jar") || - path.endsWith(".apk")) { - return processArchive(file); - } - - byte[] bytes = FileUtils.readFile(file); - return consumer.processFileBytes(path, bytes); - } catch (Exception ex) { - consumer.onException(ex); - return false; - } - } - - /** - * Sorts java class names such that outer classes preceed their inner - * classes and "package-info" preceeds all other classes in its package. - * - * @param a non-null; first class name - * @param b non-null; second class name - * @return compareTo()-style result - */ - private static int compareClassNames(String a, String b) { - // Ensure inner classes sort second - a = a.replace('$','0'); - b = b.replace('$','0'); - - /* - * Assuming "package-info" only occurs at the end, ensures package-info - * sorts first. - */ - a = a.replace("package-info", ""); - b = b.replace("package-info", ""); - - return a.compareTo(b); - } - - /** - * Processes a directory recursively. - * - * @param dir non-null; file representing the directory - * @param topLevel whether this is a top-level directory (that is, - * specified directly on the commandline) - * @return whether any processing actually happened - */ - private boolean processDirectory(File dir, boolean topLevel) { - if (topLevel) { - dir = new File(dir, "."); - } - - File[] files = dir.listFiles(); - int len = files.length; - boolean any = false; - - if (sort) { - Arrays.sort(files, new Comparator() { - public int compare(File a, File b) { - return compareClassNames(a.getName(), b.getName()); - } - }); - } - - for (int i = 0; i < len; i++) { - any |= processOne(files[i], false); - } - - return any; - } - - /** - * Processes the contents of an archive (.zip, - * .jar, or .apk). - * - * @param file non-null; archive file to process - * @return whether any processing actually happened - * @throws IOException on i/o problem - */ - private boolean processArchive(File file) throws IOException { - ZipFile zip = new ZipFile(file); - ByteArrayOutputStream baos = new ByteArrayOutputStream(40000); - byte[] buf = new byte[20000]; - boolean any = false; - - ArrayList entriesList - = Collections.list(zip.entries()); - - if (sort) { - Collections.sort(entriesList, new Comparator() { - public int compare (ZipEntry a, ZipEntry b) { - return compareClassNames(a.getName(), b.getName()); - } - }); - } - - consumer.onProcessArchiveStart(file); - - for (ZipEntry one: entriesList) { - - if (one.isDirectory()) { - continue; - } - - String path = one.getName(); - InputStream in = zip.getInputStream(one); - - baos.reset(); - for (;;) { - int amt = in.read(buf); - if (amt < 0) { - break; - } - - baos.write(buf, 0, amt); - } - - in.close(); - - byte[] bytes = baos.toByteArray(); - any |= consumer.processFileBytes(path, bytes); - } - - zip.close(); - return any; - } -} diff --git a/dx/src/com/android/dx/cf/direct/CodeObserver.java b/dx/src/com/android/dx/cf/direct/CodeObserver.java deleted file mode 100644 index 950147fdb..000000000 --- a/dx/src/com/android/dx/cf/direct/CodeObserver.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.code.ByteOps; -import com.android.dx.cf.code.BytecodeArray; -import com.android.dx.cf.code.SwitchList; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.CstDouble; -import com.android.dx.rop.cst.CstFloat; -import com.android.dx.rop.cst.CstInteger; -import com.android.dx.rop.cst.CstKnownNull; -import com.android.dx.rop.cst.CstLong; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.Type; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; -import com.android.dx.util.IntList; - -import java.util.List; -import java.util.ArrayList; - -/** - * Bytecode visitor to use when "observing" bytecode getting parsed. - */ -public class CodeObserver implements BytecodeArray.Visitor { - /** non-null; actual array of bytecode */ - private final ByteArray bytes; - - /** non-null; observer to inform of parsing */ - private final ParseObserver observer; - - /** - * Constructs an instance. - * - * @param bytes non-null; actual array of bytecode - * @param observer non-null; observer to inform of parsing - */ - public CodeObserver(ByteArray bytes, ParseObserver observer) { - if (bytes == null) { - throw new NullPointerException("bytes == null"); - } - - if (observer == null) { - throw new NullPointerException("observer == null"); - } - - this.bytes = bytes; - this.observer = observer; - } - - /** {@inheritDoc} */ - public void visitInvalid(int opcode, int offset, int length) { - observer.parsed(bytes, offset, length, header(offset)); - } - - /** {@inheritDoc} */ - public void visitNoArgs(int opcode, int offset, int length, Type type) { - observer.parsed(bytes, offset, length, header(offset)); - } - - /** {@inheritDoc} */ - public void visitLocal(int opcode, int offset, int length, - int idx, Type type, int value) { - String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx); - boolean argComment = (length == 1); - String valueStr = ""; - - if (opcode == ByteOps.IINC) { - valueStr = ", #" + - ((length <= 3) ? Hex.s1(value) : Hex.s2(value)); - } - - String catStr = ""; - if (type.isCategory2()) { - catStr = (argComment ? "," : " //") + " category-2"; - } - - observer.parsed(bytes, offset, length, - header(offset) + (argComment ? " // " : " ") + - idxStr + valueStr + catStr); - } - - /** {@inheritDoc} */ - public void visitConstant(int opcode, int offset, int length, - Constant cst, int value) { - if (cst instanceof CstKnownNull) { - // This is aconst_null. - visitNoArgs(opcode, offset, length, null); - return; - } - - if (cst instanceof CstInteger) { - visitLiteralInt(opcode, offset, length, value); - return; - } - - if (cst instanceof CstLong) { - visitLiteralLong(opcode, offset, length, - ((CstLong) cst).getValue()); - return; - } - - if (cst instanceof CstFloat) { - visitLiteralFloat(opcode, offset, length, - ((CstFloat) cst).getIntBits()); - return; - } - - if (cst instanceof CstDouble) { - visitLiteralDouble(opcode, offset, length, - ((CstDouble) cst).getLongBits()); - return; - } - - String valueStr = ""; - if (value != 0) { - valueStr = ", "; - if (opcode == ByteOps.MULTIANEWARRAY) { - valueStr += Hex.u1(value); - } else { - valueStr += Hex.u2(value); - } - } - - observer.parsed(bytes, offset, length, - header(offset) + " " + cst + valueStr); - } - - /** {@inheritDoc} */ - public void visitBranch(int opcode, int offset, int length, - int target) { - String targetStr = (length <= 3) ? Hex.u2(target) : Hex.u4(target); - observer.parsed(bytes, offset, length, - header(offset) + " " + targetStr); - } - - /** {@inheritDoc} */ - public void visitSwitch(int opcode, int offset, int length, - SwitchList cases, int padding) { - int sz = cases.size(); - StringBuffer sb = new StringBuffer(sz * 20 + 100); - - sb.append(header(offset)); - if (padding != 0) { - sb.append(" // padding: " + Hex.u4(padding)); - } - sb.append('\n'); - - for (int i = 0; i < sz; i++) { - sb.append(" "); - sb.append(Hex.s4(cases.getValue(i))); - sb.append(": "); - sb.append(Hex.u2(cases.getTarget(i))); - sb.append('\n'); - } - - sb.append(" default: "); - sb.append(Hex.u2(cases.getDefaultTarget())); - - observer.parsed(bytes, offset, length, sb.toString()); - } - - /** {@inheritDoc} */ - public void visitNewarray(int offset, int length, CstType cst, - ArrayList intVals) { - String commentOrSpace = (length == 1) ? " // " : " "; - String typeName = cst.getClassType().getComponentType().toHuman(); - - observer.parsed(bytes, offset, length, - header(offset) + commentOrSpace + typeName); - } - - /** {@inheritDoc} */ - public void setPreviousOffset(int offset) { - // Do nothing - } - - /** {@inheritDoc} */ - public int getPreviousOffset() { - return -1; - } - - /** - * Helper to produce the first bit of output for each instruction. - * - * @param offset the offset to the start of the instruction - */ - private String header(int offset) { - /* - * Note: This uses the original bytecode, not the - * possibly-transformed one. - */ - int opcode = bytes.getUnsignedByte(offset); - String name = ByteOps.opName(opcode); - - if (opcode == ByteOps.WIDE) { - opcode = bytes.getUnsignedByte(offset + 1); - name += " " + ByteOps.opName(opcode); - } - - return Hex.u2(offset) + ": " + name; - } - - /** - * Helper for {code #visitConstant} where the constant is an - * int. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length instruction length - * @param value constant value - */ - private void visitLiteralInt(int opcode, int offset, int length, - int value) { - String commentOrSpace = (length == 1) ? " // " : " "; - String valueStr; - - opcode = bytes.getUnsignedByte(offset); // Compare with orig op below. - if ((length == 1) || (opcode == ByteOps.BIPUSH)) { - valueStr = "#" + Hex.s1(value); - } else if (opcode == ByteOps.SIPUSH) { - valueStr = "#" + Hex.s2(value); - } else { - valueStr = "#" + Hex.s4(value); - } - - observer.parsed(bytes, offset, length, - header(offset) + commentOrSpace + valueStr); - } - - /** - * Helper for {code #visitConstant} where the constant is a - * long. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length instruction length - * @param value constant value - */ - private void visitLiteralLong(int opcode, int offset, int length, - long value) { - String commentOrLit = (length == 1) ? " // " : " #"; - String valueStr; - - if (length == 1) { - valueStr = Hex.s1((int) value); - } else { - valueStr = Hex.s8(value); - } - - observer.parsed(bytes, offset, length, - header(offset) + commentOrLit + valueStr); - } - - /** - * Helper for {code #visitConstant} where the constant is a - * float. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length instruction length - * @param bits constant value, as float-bits - */ - private void visitLiteralFloat(int opcode, int offset, int length, - int bits) { - String optArg = (length != 1) ? " #" + Hex.u4(bits) : ""; - - observer.parsed(bytes, offset, length, - header(offset) + optArg + " // " + - Float.intBitsToFloat(bits)); - } - - /** - * Helper for {code #visitConstant} where the constant is a - * double. - * - * @param opcode the opcode - * @param offset offset to the instruction - * @param length instruction length - * @param bits constant value, as double-bits - */ - private void visitLiteralDouble(int opcode, int offset, int length, - long bits) { - String optArg = (length != 1) ? " #" + Hex.u8(bits) : ""; - - observer.parsed(bytes, offset, length, - header(offset) + optArg + " // " + - Double.longBitsToDouble(bits)); - } -} diff --git a/dx/src/com/android/dx/cf/direct/DirectClassFile.java b/dx/src/com/android/dx/cf/direct/DirectClassFile.java deleted file mode 100644 index e4751a4cc..000000000 --- a/dx/src/com/android/dx/cf/direct/DirectClassFile.java +++ /dev/null @@ -1,633 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.attrib.AttSourceFile; -import com.android.dx.cf.cst.ConstantPoolParser; -import com.android.dx.cf.iface.Attribute; -import com.android.dx.cf.iface.AttributeList; -import com.android.dx.cf.iface.ClassFile; -import com.android.dx.cf.iface.FieldList; -import com.android.dx.cf.iface.MethodList; -import com.android.dx.cf.iface.ParseException; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.cf.iface.StdAttributeList; -import com.android.dx.rop.code.AccessFlags; -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.cst.StdConstantPool; -import com.android.dx.rop.type.StdTypeList; -import com.android.dx.rop.type.Type; -import com.android.dx.rop.type.TypeList; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; - -/** - * Class file with info taken from a byte[] or slice thereof. - */ -public class DirectClassFile implements ClassFile { - /** the expected value of the ClassFile.magic field */ - private static final int CLASS_FILE_MAGIC = 0xcafebabe; - - /** - * minimum .class file major version - * - * The class file definition (vmspec/2nd-edition) says: - * - * "Implementations of version 1.2 of the - * Java 2 platform can support class file - * formats of versions in the range 45.0 - * through 46.0 inclusive." - * - * The class files generated by the build are currently - * (as of 11/2006) reporting version 49.0 (0x31.0x00), - * however, so we use that as our upper bound. - * - * Valid ranges are typically of the form - * "A.0 through B.C inclusive" where A <= B and C >= 0, - * which is why we don't have a CLASS_FILE_MIN_MINOR_VERSION. - */ - private static final int CLASS_FILE_MIN_MAJOR_VERSION = 45; - - /** maximum .class file major version */ - private static final int CLASS_FILE_MAX_MAJOR_VERSION = 50; - - /** maximum .class file minor version */ - private static final int CLASS_FILE_MAX_MINOR_VERSION = 0; - - /** - * non-null; the file path for the class, excluding any base directory - * specification - */ - private final String filePath; - - /** non-null; the bytes of the file */ - private final ByteArray bytes; - - /** - * whether to be strict about parsing; if - * false, this avoids doing checks that only exist - * for purposes of verification (such as magic number matching and - * path-package consistency checking) - */ - private final boolean strictParse; - - /** - * null-ok; the constant pool; only ever null - * before the constant pool is successfully parsed - */ - private StdConstantPool pool; - - /** - * the class file field access_flags; will be -1 - * before the file is successfully parsed - */ - private int accessFlags; - - /** - * null-ok; the class file field this_class, - * interpreted as a type constant; only ever null - * before the file is successfully parsed - */ - private CstType thisClass; - - /** - * null-ok; the class file field super_class, interpreted - * as a type constant if non-zero - */ - private CstType superClass; - - /** - * null-ok; the class file field interfaces; only - * ever null before the file is successfully - * parsed - */ - private TypeList interfaces; - - /** - * null-ok; the class file field fields; only ever - * null before the file is successfully parsed - */ - private FieldList fields; - - /** - * null-ok; the class file field methods; only ever - * null before the file is successfully parsed - */ - private MethodList methods; - - /** - * null-ok; the class file field attributes; only - * ever null before the file is successfully - * parsed - */ - private StdAttributeList attributes; - - /** null-ok; attribute factory, if any */ - private AttributeFactory attributeFactory; - - /** null-ok; parse observer, if any */ - private ParseObserver observer; - - /** - * Returns the string form of an object or "(none)" - * (rather than "null") for null. - * - * @param obj null-ok; the object to stringify - * @return non-null; the appropriate string form - */ - public static String stringOrNone(Object obj) { - if (obj == null) { - return "(none)"; - } - - return obj.toString(); - } - - /** - * Constructs an instance. - * - * @param bytes non-null; the bytes of the file - * @param filePath non-null; the file path for the class, - * excluding any base directory specification - * @param strictParse whether to be strict about parsing; if - * false, this avoids doing checks that only exist - * for purposes of verification (such as magic number matching and - * path-package consistency checking) - */ - public DirectClassFile(ByteArray bytes, String filePath, - boolean strictParse) { - if (bytes == null) { - throw new NullPointerException("bytes == null"); - } - - if (filePath == null) { - throw new NullPointerException("filePath == null"); - } - - this.filePath = filePath; - this.bytes = bytes; - this.strictParse = strictParse; - this.accessFlags = -1; - } - - /** - * Constructs an instance. - * - * @param bytes non-null; the bytes of the file - * @param filePath non-null; the file path for the class, - * excluding any base directory specification - * @param strictParse whether to be strict about parsing; if - * false, this avoids doing checks that only exist - * for purposes of verification (such as magic number matching and - * path-package consistency checking) - */ - public DirectClassFile(byte[] bytes, String filePath, - boolean strictParse) { - this(new ByteArray(bytes), filePath, strictParse); - } - - /** - * Sets the parse observer for this instance. - * - * @param observer null-ok; the observer - */ - public void setObserver(ParseObserver observer) { - this.observer = observer; - } - - /** - * Sets the attribute factory to use. - * - * @param attributeFactory non-null; the attribute factory - */ - public void setAttributeFactory(AttributeFactory attributeFactory) { - if (attributeFactory == null) { - throw new NullPointerException("attributeFactory == null"); - } - - this.attributeFactory = attributeFactory; - } - - /** - * Gets the {@link ByteArray} that this instance's data comes from. - * - * @return non-null; the bytes - */ - public ByteArray getBytes() { - return bytes; - } - - /** {@inheritDoc} */ - public int getMagic() { - parseToInterfacesIfNecessary(); - return getMagic0(); - } - - /** {@inheritDoc} */ - public int getMinorVersion() { - parseToInterfacesIfNecessary(); - return getMinorVersion0(); - } - - /** {@inheritDoc} */ - public int getMajorVersion() { - parseToInterfacesIfNecessary(); - return getMajorVersion0(); - } - - /** {@inheritDoc} */ - public int getAccessFlags() { - parseToInterfacesIfNecessary(); - return accessFlags; - } - - /** {@inheritDoc} */ - public CstType getThisClass() { - parseToInterfacesIfNecessary(); - return thisClass; - } - - /** {@inheritDoc} */ - public CstType getSuperclass() { - parseToInterfacesIfNecessary(); - return superClass; - } - - /** {@inheritDoc} */ - public ConstantPool getConstantPool() { - parseToInterfacesIfNecessary(); - return pool; - } - - /** {@inheritDoc} */ - public TypeList getInterfaces() { - parseToInterfacesIfNecessary(); - return interfaces; - } - - /** {@inheritDoc} */ - public FieldList getFields() { - parseToEndIfNecessary(); - return fields; - } - - /** {@inheritDoc} */ - public MethodList getMethods() { - parseToEndIfNecessary(); - return methods; - } - - /** {@inheritDoc} */ - public AttributeList getAttributes() { - parseToEndIfNecessary(); - return attributes; - } - - /** {@inheritDoc} */ - public CstUtf8 getSourceFile() { - AttributeList attribs = getAttributes(); - Attribute attSf = attribs.findFirst(AttSourceFile.ATTRIBUTE_NAME); - - if (attSf instanceof AttSourceFile) { - return ((AttSourceFile) attSf).getSourceFile(); - } - - return null; - } - - /** - * Constructs and returns an instance of {@link TypeList} whose - * data comes from the bytes of this instance, interpreted as a - * list of constant pool indices for classes, which are in turn - * translated to type constants. Instance construction will fail - * if any of the (alleged) indices turn out not to refer to - * constant pool entries of type Class. - * - * @param offset offset into {@link #bytes} for the start of the - * data - * @param size number of elements in the list (not number of bytes) - * @return non-null; an appropriately-constructed class list - */ - public TypeList makeTypeList(int offset, int size) { - if (size == 0) { - return StdTypeList.EMPTY; - } - - if (pool == null) { - throw new IllegalStateException("pool not yet initialized"); - } - - return new DcfTypeList(bytes, offset, size, pool, observer); - } - - /** - * Gets the class file field magic, but without doing any - * checks or parsing first. - * - * @return the magic value - */ - public int getMagic0() { - return bytes.getInt(0); - } - - /** - * Gets the class file field minor_version, but - * without doing any checks or parsing first. - * - * @return the minor version - */ - public int getMinorVersion0() { - return bytes.getUnsignedShort(4); - } - - /** - * Gets the class file field major_version, but - * without doing any checks or parsing first. - * - * @return the major version - */ - public int getMajorVersion0() { - return bytes.getUnsignedShort(6); - } - - /** - * Runs {@link #parse} if it has not yet been run to cover up to - * the interfaces list. - */ - private void parseToInterfacesIfNecessary() { - if (accessFlags == -1) { - parse(); - } - } - - /** - * Runs {@link #parse} if it has not yet been run successfully. - */ - private void parseToEndIfNecessary() { - if (attributes == null) { - parse(); - } - } - - /** - * Does the parsing, handing exceptions. - */ - private void parse() { - try { - parse0(); - } catch (ParseException ex) { - ex.addContext("...while parsing " + filePath); - throw ex; - } catch (RuntimeException ex) { - ParseException pe = new ParseException(ex); - pe.addContext("...while parsing " + filePath); - throw pe; - } - } - - /** - * Sees if the .class file header magic/version are within - * range. - * - * @param magic the value of a classfile "magic" field - * @param minorVersion the value of a classfile "minor_version" field - * @param majorVersion the value of a classfile "major_version" field - * @return true iff the parameters are valid and within range - */ - private boolean isGoodVersion(int magic, int minorVersion, - int majorVersion) { - /* Valid version ranges are typically of the form - * "A.0 through B.C inclusive" where A <= B and C >= 0, - * which is why we don't have a CLASS_FILE_MIN_MINOR_VERSION. - */ - if (magic == CLASS_FILE_MAGIC && minorVersion >= 0) { - /* Check against max first to handle the case where - * MIN_MAJOR == MAX_MAJOR. - */ - if (majorVersion == CLASS_FILE_MAX_MAJOR_VERSION) { - if (minorVersion <= CLASS_FILE_MAX_MINOR_VERSION) { - return true; - } - } else if (majorVersion < CLASS_FILE_MAX_MAJOR_VERSION && - majorVersion >= CLASS_FILE_MIN_MAJOR_VERSION) { - return true; - } - } - - return false; - } - - /** - * Does the actual parsing. - */ - private void parse0() { - if (bytes.size() < 10) { - throw new ParseException("severely truncated class file"); - } - - if (observer != null) { - observer.parsed(bytes, 0, 0, "begin classfile"); - observer.parsed(bytes, 0, 4, "magic: " + Hex.u4(getMagic0())); - observer.parsed(bytes, 4, 2, - "minor_version: " + Hex.u2(getMinorVersion0())); - observer.parsed(bytes, 6, 2, - "major_version: " + Hex.u2(getMajorVersion0())); - } - - if (strictParse) { - /* Make sure that this looks like a valid class file with a - * version that we can handle. - */ - if (!isGoodVersion(getMagic0(), getMinorVersion0(), - getMajorVersion0())) { - throw new ParseException("bad class file magic (" + - Hex.u4(getMagic0()) + - ") or version (" + - Hex.u2(getMajorVersion0()) + "." + - Hex.u2(getMinorVersion0()) + ")"); - } - } - - ConstantPoolParser cpParser = new ConstantPoolParser(bytes); - cpParser.setObserver(observer); - pool = cpParser.getPool(); - pool.setImmutable(); - - int at = cpParser.getEndOffset(); - int accessFlags = bytes.getUnsignedShort(at); // u2 access_flags; - int cpi = bytes.getUnsignedShort(at + 2); // u2 this_class; - thisClass = (CstType) pool.get(cpi); - cpi = bytes.getUnsignedShort(at + 4); // u2 super_class; - superClass = (CstType) pool.get0Ok(cpi); - int count = bytes.getUnsignedShort(at + 6); // u2 interfaces_count - - if (observer != null) { - observer.parsed(bytes, at, 2, - "access_flags: " + - AccessFlags.classString(accessFlags)); - observer.parsed(bytes, at + 2, 2, "this_class: " + thisClass); - observer.parsed(bytes, at + 4, 2, "super_class: " + - stringOrNone(superClass)); - observer.parsed(bytes, at + 6, 2, - "interfaces_count: " + Hex.u2(count)); - if (count != 0) { - observer.parsed(bytes, at + 8, 0, "interfaces:"); - } - } - - at += 8; - interfaces = makeTypeList(at, count); - at += count * 2; - - if (strictParse) { - /* - * Make sure that the file/jar path matches the declared - * package/class name. - */ - String thisClassName = thisClass.getClassType().getClassName(); - if (!(filePath.endsWith(".class") && - filePath.startsWith(thisClassName) && - (filePath.length() == (thisClassName.length() + 6)))) { - throw new ParseException("class name (" + thisClassName + - ") does not match path (" + - filePath + ")"); - } - } - - /* - * Only set the instance variable accessFlags here, since - * that's what signals a successful parse of the first part of - * the file (through the interfaces list). - */ - this.accessFlags = accessFlags; - - FieldListParser flParser = - new FieldListParser(this, thisClass, at, attributeFactory); - flParser.setObserver(observer); - fields = flParser.getList(); - at = flParser.getEndOffset(); - - MethodListParser mlParser = - new MethodListParser(this, thisClass, at, attributeFactory); - mlParser.setObserver(observer); - methods = mlParser.getList(); - at = mlParser.getEndOffset(); - - AttributeListParser alParser = - new AttributeListParser(this, AttributeFactory.CTX_CLASS, at, - attributeFactory); - alParser.setObserver(observer); - attributes = alParser.getList(); - attributes.setImmutable(); - at = alParser.getEndOffset(); - - if (at != bytes.size()) { - throw new ParseException("extra bytes at end of class file, " + - "at offset " + Hex.u4(at)); - } - - if (observer != null) { - observer.parsed(bytes, at, 0, "end classfile"); - } - } - - /** - * Implementation of {@link TypeList} whose data comes directly - * from the bytes of an instance of this (outer) class, - * interpreted as a list of constant pool indices for classes - * which are in turn returned as type constants. Instance - * construction will fail if any of the (alleged) indices turn out - * not to refer to constant pool entries of type - * Class. - */ - private static class DcfTypeList implements TypeList { - /** non-null; array containing the data */ - private final ByteArray bytes; - - /** number of elements in the list (not number of bytes) */ - private final int size; - - /** non-null; the constant pool */ - private final StdConstantPool pool; - - /** - * Constructs an instance. - * - * @param bytes non-null; original classfile's bytes - * @param offset offset into {@link #bytes} for the start of the - * data - * @param size number of elements in the list (not number of bytes) - * @param pool non-null; the constant pool to use - * @param observer null-ok; parse observer to use, if any - */ - public DcfTypeList(ByteArray bytes, int offset, int size, - StdConstantPool pool, ParseObserver observer) { - if (size < 0) { - throw new IllegalArgumentException("size < 0"); - } - - bytes = bytes.slice(offset, offset + size * 2); - this.bytes = bytes; - this.size = size; - this.pool = pool; - - for (int i = 0; i < size; i++) { - offset = i * 2; - int idx = bytes.getUnsignedShort(offset); - CstType type; - try { - type = (CstType) pool.get(idx); - } catch (ClassCastException ex) { - // Translate the exception. - throw new RuntimeException("bogus class cpi", ex); - } - if (observer != null) { - observer.parsed(bytes, offset, 2, " " + type); - } - } - } - - /** {@inheritDoc} */ - public boolean isMutable() { - return false; - } - - /** {@inheritDoc} */ - public int size() { - return size; - } - - /** {@inheritDoc} */ - public int getWordCount() { - // It is the same as size because all elements are classes. - return size; - } - - /** {@inheritDoc} */ - public Type getType(int n) { - int idx = bytes.getUnsignedShort(n * 2); - return ((CstType) pool.get(idx)).getClassType(); - } - - /** {@inheritDoc} */ - public TypeList withAddedType(Type type) { - throw new UnsupportedOperationException("unsupported"); - } - } -} diff --git a/dx/src/com/android/dx/cf/direct/FieldListParser.java b/dx/src/com/android/dx/cf/direct/FieldListParser.java deleted file mode 100644 index 06dcc4127..000000000 --- a/dx/src/com/android/dx/cf/direct/FieldListParser.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.iface.AttributeList; -import com.android.dx.cf.iface.Member; -import com.android.dx.cf.iface.StdField; -import com.android.dx.cf.iface.StdFieldList; -import com.android.dx.rop.code.AccessFlags; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; - -/** - * Parser for lists of fields in a class file. - */ -final /*package*/ class FieldListParser extends MemberListParser { - /** non-null; list in progress */ - private final StdFieldList fields; - - /** - * Constructs an instance. - * - * @param cf non-null; the class file to parse from - * @param definer non-null; class being defined - * @param offset offset in bytes to the start of the list - * @param attributeFactory non-null; attribute factory to use - */ - public FieldListParser(DirectClassFile cf, CstType definer, int offset, - AttributeFactory attributeFactory) { - super(cf, definer, offset, attributeFactory); - fields = new StdFieldList(getCount()); - } - - /** - * Gets the parsed list. - * - * @return non-null; the parsed list - */ - public StdFieldList getList() { - parseIfNecessary(); - return fields; - } - - /** {@inheritDoc} */ - @Override - protected String humanName() { - return "field"; - } - - /** {@inheritDoc} */ - @Override - protected String humanAccessFlags(int accessFlags) { - return AccessFlags.fieldString(accessFlags); - } - - /** {@inheritDoc} */ - @Override - protected int getAttributeContext() { - return AttributeFactory.CTX_FIELD; - } - - /** {@inheritDoc} */ - @Override - protected Member set(int n, int accessFlags, CstNat nat, - AttributeList attributes) { - StdField field = - new StdField(getDefiner(), accessFlags, nat, attributes); - - fields.set(n, field); - return field; - } -} diff --git a/dx/src/com/android/dx/cf/direct/MemberListParser.java b/dx/src/com/android/dx/cf/direct/MemberListParser.java deleted file mode 100644 index 3c0bfa837..000000000 --- a/dx/src/com/android/dx/cf/direct/MemberListParser.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.iface.AttributeList; -import com.android.dx.cf.iface.Member; -import com.android.dx.cf.iface.ParseException; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.cf.iface.StdAttributeList; -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; - -/** - * Parser for lists of class file members (that is, fields and methods). - */ -abstract /*package*/ class MemberListParser { - /** non-null; the class file to parse from */ - private final DirectClassFile cf; - - /** non-null; class being defined */ - private final CstType definer; - - /** offset in the byte array of the classfile to the start of the list */ - private final int offset; - - /** non-null; attribute factory to use */ - private final AttributeFactory attributeFactory; - - /** >= -1; the end offset of this list in the byte array of the - * classfile, or -1 if not yet parsed */ - private int endOffset; - - /** null-ok; parse observer, if any */ - private ParseObserver observer; - - /** - * Constructs an instance. - * - * @param cf non-null; the class file to parse from - * @param definer non-null; class being defined - * @param offset offset in bytes to the start of the list - * @param attributeFactory non-null; attribute factory to use - */ - public MemberListParser(DirectClassFile cf, CstType definer, - int offset, AttributeFactory attributeFactory) { - if (cf == null) { - throw new NullPointerException("cf == null"); - } - - if (offset < 0) { - throw new IllegalArgumentException("offset < 0"); - } - - if (attributeFactory == null) { - throw new NullPointerException("attributeFactory == null"); - } - - this.cf = cf; - this.definer = definer; - this.offset = offset; - this.attributeFactory = attributeFactory; - this.endOffset = -1; - } - - /** - * Gets the end offset of this constant pool in the byte[] - * which it came from. - * - * @return >= 0; the end offset - */ - public int getEndOffset() { - parseIfNecessary(); - return endOffset; - } - - /** - * Sets the parse observer for this instance. - * - * @param observer null-ok; the observer - */ - public final void setObserver(ParseObserver observer) { - this.observer = observer; - } - - /** - * Runs {@link #parse} if it has not yet been run successfully. - */ - protected final void parseIfNecessary() { - if (endOffset < 0) { - parse(); - } - } - - /** - * Gets the count of elements in the list. - * - * @return the count - */ - protected final int getCount() { - ByteArray bytes = cf.getBytes(); - return bytes.getUnsignedShort(offset); - } - - /** - * Gets the class file being defined. - * - * @return non-null; the class - */ - protected final CstType getDefiner() { - return definer; - } - - /** - * Gets the human-oriented name for what this instance is parsing. - * Subclasses must override this method. - * - * @return non-null; the human oriented name - */ - protected abstract String humanName(); - - /** - * Gets the human-oriented string for the given access flags. - * Subclasses must override this method. - * - * @param accessFlags the flags - * @return non-null; the string form - */ - protected abstract String humanAccessFlags(int accessFlags); - - /** - * Gets the CTX_* constant to use when parsing attributes. - * Subclasses must override this method. - * - * @return non-null; the human oriented name - */ - protected abstract int getAttributeContext(); - - /** - * Sets an element in the list. Subclasses must override this method. - * - * @param n which element - * @param accessFlags the access_flags - * @param nat the interpreted name and type (based on the two - * *_index fields) - * @param attributes list of parsed attributes - * @return non-null; the constructed member - */ - protected abstract Member set(int n, int accessFlags, CstNat nat, - AttributeList attributes); - - /** - * Does the actual parsing. - */ - private void parse() { - int attributeContext = getAttributeContext(); - int count = getCount(); - int at = offset + 2; // Skip the count. - - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - - if (observer != null) { - observer.parsed(bytes, offset, 2, - humanName() + "s_count: " + Hex.u2(count)); - } - - for (int i = 0; i < count; i++) { - try { - int accessFlags = bytes.getUnsignedShort(at); - int nameIdx = bytes.getUnsignedShort(at + 2); - int descIdx = bytes.getUnsignedShort(at + 4); - CstUtf8 name = (CstUtf8) pool.get(nameIdx); - CstUtf8 desc = (CstUtf8) pool.get(descIdx); - - if (observer != null) { - observer.startParsingMember(bytes, at, name.getString(), - desc.getString()); - observer.parsed(bytes, at, 0, "\n" + humanName() + - "s[" + i + "]:\n"); - observer.changeIndent(1); - observer.parsed(bytes, at, 2, - "access_flags: " + - humanAccessFlags(accessFlags)); - observer.parsed(bytes, at + 2, 2, - "name: " + name.toHuman()); - observer.parsed(bytes, at + 4, 2, - "descriptor: " + desc.toHuman()); - } - - at += 6; - AttributeListParser parser = - new AttributeListParser(cf, attributeContext, at, - attributeFactory); - parser.setObserver(observer); - at = parser.getEndOffset(); - StdAttributeList attributes = parser.getList(); - attributes.setImmutable(); - CstNat nat = new CstNat(name, desc); - Member member = set(i, accessFlags, nat, attributes); - - if (observer != null) { - observer.changeIndent(-1); - observer.parsed(bytes, at, 0, "end " + humanName() + - "s[" + i + "]\n"); - observer.endParsingMember(bytes, at, name.getString(), - desc.getString(), member); - } - } catch (ParseException ex) { - ex.addContext("...while parsing " + humanName() + "s[" + i + - "]"); - throw ex; - } catch (RuntimeException ex) { - ParseException pe = new ParseException(ex); - pe.addContext("...while parsing " + humanName() + "s[" + i + - "]"); - throw pe; - } - } - - endOffset = at; - } -} diff --git a/dx/src/com/android/dx/cf/direct/MethodListParser.java b/dx/src/com/android/dx/cf/direct/MethodListParser.java deleted file mode 100644 index 9ca8ba6b8..000000000 --- a/dx/src/com/android/dx/cf/direct/MethodListParser.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.iface.AttributeList; -import com.android.dx.cf.iface.Member; -import com.android.dx.cf.iface.StdMethod; -import com.android.dx.cf.iface.StdMethodList; -import com.android.dx.rop.code.AccessFlags; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; - -/** - * Parser for lists of methods in a class file. - */ -final /*package*/ class MethodListParser extends MemberListParser { - /** non-null; list in progress */ - final private StdMethodList methods; - - /** - * Constructs an instance. - * - * @param cf non-null; the class file to parse from - * @param definer non-null; class being defined - * @param offset offset in bytes to the start of the list - * @param attributeFactory non-null; attribute factory to use - */ - public MethodListParser(DirectClassFile cf, CstType definer, - int offset, AttributeFactory attributeFactory) { - super(cf, definer, offset, attributeFactory); - methods = new StdMethodList(getCount()); - } - - /** - * Gets the parsed list. - * - * @return non-null; the parsed list - */ - public StdMethodList getList() { - parseIfNecessary(); - return methods; - } - - /** {@inheritDoc} */ - @Override - protected String humanName() { - return "method"; - } - - /** {@inheritDoc} */ - @Override - protected String humanAccessFlags(int accessFlags) { - return AccessFlags.methodString(accessFlags); - } - - /** {@inheritDoc} */ - @Override - protected int getAttributeContext() { - return AttributeFactory.CTX_METHOD; - } - - /** {@inheritDoc} */ - @Override - protected Member set(int n, int accessFlags, CstNat nat, - AttributeList attributes) { - StdMethod meth = - new StdMethod(getDefiner(), accessFlags, nat, attributes); - - methods.set(n, meth); - return meth; - } -} diff --git a/dx/src/com/android/dx/cf/direct/StdAttributeFactory.java b/dx/src/com/android/dx/cf/direct/StdAttributeFactory.java deleted file mode 100644 index ab0e2f7fd..000000000 --- a/dx/src/com/android/dx/cf/direct/StdAttributeFactory.java +++ /dev/null @@ -1,764 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.direct; - -import com.android.dx.cf.attrib.AttAnnotationDefault; -import com.android.dx.cf.attrib.AttCode; -import com.android.dx.cf.attrib.AttConstantValue; -import com.android.dx.cf.attrib.AttDeprecated; -import com.android.dx.cf.attrib.AttEnclosingMethod; -import com.android.dx.cf.attrib.AttExceptions; -import com.android.dx.cf.attrib.AttInnerClasses; -import com.android.dx.cf.attrib.AttLineNumberTable; -import com.android.dx.cf.attrib.AttLocalVariableTable; -import com.android.dx.cf.attrib.AttLocalVariableTypeTable; -import com.android.dx.cf.attrib.AttRuntimeInvisibleAnnotations; -import com.android.dx.cf.attrib.AttRuntimeInvisibleParameterAnnotations; -import com.android.dx.cf.attrib.AttRuntimeVisibleAnnotations; -import com.android.dx.cf.attrib.AttRuntimeVisibleParameterAnnotations; -import com.android.dx.cf.attrib.AttSignature; -import com.android.dx.cf.attrib.AttSourceFile; -import com.android.dx.cf.attrib.AttSynthetic; -import com.android.dx.cf.attrib.InnerClassList; -import com.android.dx.cf.code.ByteCatchList; -import com.android.dx.cf.code.BytecodeArray; -import com.android.dx.cf.code.LineNumberList; -import com.android.dx.cf.code.LocalVariableList; -import com.android.dx.cf.iface.Attribute; -import com.android.dx.cf.iface.ParseException; -import com.android.dx.cf.iface.ParseObserver; -import com.android.dx.cf.iface.StdAttributeList; -import com.android.dx.rop.annotation.Annotation; -import com.android.dx.rop.annotation.AnnotationVisibility; -import com.android.dx.rop.annotation.Annotations; -import com.android.dx.rop.annotation.AnnotationsList; -import com.android.dx.rop.code.AccessFlags; -import com.android.dx.rop.cst.Constant; -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.cst.TypedConstant; -import com.android.dx.rop.type.TypeList; -import com.android.dx.util.ByteArray; -import com.android.dx.util.Hex; - -import java.io.IOException; - -/** - * Standard subclass of {@link AttributeFactory}, which knows how to parse - * all the standard attribute types. - */ -public class StdAttributeFactory - extends AttributeFactory { - /** non-null; shared instance of this class */ - public static final StdAttributeFactory THE_ONE = - new StdAttributeFactory(); - - /** - * Constructs an instance. - */ - public StdAttributeFactory() { - // This space intentionally left blank. - } - - /** {@inheritDoc} */ - @Override - protected Attribute parse0(DirectClassFile cf, int context, String name, - int offset, int length, ParseObserver observer) { - switch (context) { - case CTX_CLASS: { - if (name == AttDeprecated.ATTRIBUTE_NAME) { - return deprecated(cf, offset, length, observer); - } - if (name == AttEnclosingMethod.ATTRIBUTE_NAME) { - return enclosingMethod(cf, offset, length, observer); - } - if (name == AttInnerClasses.ATTRIBUTE_NAME) { - return innerClasses(cf, offset, length, observer); - } - if (name == AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME) { - return runtimeInvisibleAnnotations(cf, offset, length, - observer); - } - if (name == AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME) { - return runtimeVisibleAnnotations(cf, offset, length, - observer); - } - if (name == AttSynthetic.ATTRIBUTE_NAME) { - return synthetic(cf, offset, length, observer); - } - if (name == AttSignature.ATTRIBUTE_NAME) { - return signature(cf, offset, length, observer); - } - if (name == AttSourceFile.ATTRIBUTE_NAME) { - return sourceFile(cf, offset, length, observer); - } - break; - } - case CTX_FIELD: { - if (name == AttConstantValue.ATTRIBUTE_NAME) { - return constantValue(cf, offset, length, observer); - } - if (name == AttDeprecated.ATTRIBUTE_NAME) { - return deprecated(cf, offset, length, observer); - } - if (name == AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME) { - return runtimeInvisibleAnnotations(cf, offset, length, - observer); - } - if (name == AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME) { - return runtimeVisibleAnnotations(cf, offset, length, - observer); - } - if (name == AttSignature.ATTRIBUTE_NAME) { - return signature(cf, offset, length, observer); - } - if (name == AttSynthetic.ATTRIBUTE_NAME) { - return synthetic(cf, offset, length, observer); - } - break; - } - case CTX_METHOD: { - if (name == AttAnnotationDefault.ATTRIBUTE_NAME) { - return annotationDefault(cf, offset, length, observer); - } - if (name == AttCode.ATTRIBUTE_NAME) { - return code(cf, offset, length, observer); - } - if (name == AttDeprecated.ATTRIBUTE_NAME) { - return deprecated(cf, offset, length, observer); - } - if (name == AttExceptions.ATTRIBUTE_NAME) { - return exceptions(cf, offset, length, observer); - } - if (name == AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME) { - return runtimeInvisibleAnnotations(cf, offset, length, - observer); - } - if (name == AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME) { - return runtimeVisibleAnnotations(cf, offset, length, - observer); - } - if (name == AttRuntimeInvisibleParameterAnnotations. - ATTRIBUTE_NAME) { - return runtimeInvisibleParameterAnnotations( - cf, offset, length, observer); - } - if (name == AttRuntimeVisibleParameterAnnotations. - ATTRIBUTE_NAME) { - return runtimeVisibleParameterAnnotations( - cf, offset, length, observer); - } - if (name == AttSignature.ATTRIBUTE_NAME) { - return signature(cf, offset, length, observer); - } - if (name == AttSynthetic.ATTRIBUTE_NAME) { - return synthetic(cf, offset, length, observer); - } - break; - } - case CTX_CODE: { - if (name == AttLineNumberTable.ATTRIBUTE_NAME) { - return lineNumberTable(cf, offset, length, observer); - } - if (name == AttLocalVariableTable.ATTRIBUTE_NAME) { - return localVariableTable(cf, offset, length, observer); - } - if (name == AttLocalVariableTypeTable.ATTRIBUTE_NAME) { - return localVariableTypeTable(cf, offset, length, - observer); - } - break; - } - } - - return super.parse0(cf, context, name, offset, length, observer); - } - - /** - * Parses an AnnotationDefault attribute. - */ - private Attribute annotationDefault(DirectClassFile cf, - int offset, int length, ParseObserver observer) { - if (length < 2) { - throwSeverelyTruncated(); - } - - AnnotationParser ap = - new AnnotationParser(cf, offset, length, observer); - Constant cst = ap.parseValueAttribute(); - - return new AttAnnotationDefault(cst, length); - } - - /** - * Parses a Code attribute. - */ - private Attribute code(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length < 12) { - return throwSeverelyTruncated(); - } - - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - int maxStack = bytes.getUnsignedShort(offset); // u2 max_stack - int maxLocals = bytes.getUnsignedShort(offset + 2); // u2 max_locals - int codeLength = bytes.getInt(offset + 4); // u4 code_length - int origOffset = offset; - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "max_stack: " + Hex.u2(maxStack)); - observer.parsed(bytes, offset + 2, 2, - "max_locals: " + Hex.u2(maxLocals)); - observer.parsed(bytes, offset + 4, 4, - "code_length: " + Hex.u4(codeLength)); - } - - offset += 8; - length -= 8; - - if (length < (codeLength + 4)) { - return throwTruncated(); - } - - int codeOffset = offset; - offset += codeLength; - length -= codeLength; - BytecodeArray code = - new BytecodeArray(bytes.slice(codeOffset, codeOffset + codeLength), - pool); - if (observer != null) { - code.forEach(new CodeObserver(code.getBytes(), observer)); - } - - // u2 exception_table_length - int exceptionTableLength = bytes.getUnsignedShort(offset); - ByteCatchList catches = (exceptionTableLength == 0) ? - ByteCatchList.EMPTY : - new ByteCatchList(exceptionTableLength); - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "exception_table_length: " + - Hex.u2(exceptionTableLength)); - } - - offset += 2; - length -= 2; - - if (length < (exceptionTableLength * 8 + 2)) { - return throwTruncated(); - } - - for (int i = 0; i < exceptionTableLength; i++) { - if (observer != null) { - observer.changeIndent(1); - } - - int startPc = bytes.getUnsignedShort(offset); - int endPc = bytes.getUnsignedShort(offset + 2); - int handlerPc = bytes.getUnsignedShort(offset + 4); - int catchTypeIdx = bytes.getUnsignedShort(offset + 6); - CstType catchType = (CstType) pool.get0Ok(catchTypeIdx); - catches.set(i, startPc, endPc, handlerPc, catchType); - if (observer != null) { - observer.parsed(bytes, offset, 8, - Hex.u2(startPc) + ".." + Hex.u2(endPc) + - " -> " + Hex.u2(handlerPc) + " " + - ((catchType == null) ? "" : - catchType.toHuman())); - } - offset += 8; - length -= 8; - - if (observer != null) { - observer.changeIndent(-1); - } - } - - catches.setImmutable(); - - AttributeListParser parser = - new AttributeListParser(cf, CTX_CODE, offset, this); - parser.setObserver(observer); - - StdAttributeList attributes = parser.getList(); - attributes.setImmutable(); - - int attributeByteCount = parser.getEndOffset() - offset; - if (attributeByteCount != length) { - return throwBadLength(attributeByteCount + (offset - origOffset)); - } - - return new AttCode(maxStack, maxLocals, code, catches, attributes); - } - - /** - * Parses a ConstantValue attribute. - */ - private Attribute constantValue(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length != 2) { - return throwBadLength(2); - } - - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - int idx = bytes.getUnsignedShort(offset); - TypedConstant cst = (TypedConstant) pool.get(idx); - Attribute result = new AttConstantValue(cst); - - if (observer != null) { - observer.parsed(bytes, offset, 2, "value: " + cst); - } - - return result; - } - - /** - * Parses a Deprecated attribute. - */ - private Attribute deprecated(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length != 0) { - return throwBadLength(0); - } - - return new AttDeprecated(); - } - - /** - * Parses an EnclosingMethod attribute. - */ - private Attribute enclosingMethod(DirectClassFile cf, int offset, - int length, ParseObserver observer) { - if (length != 4) { - throwBadLength(4); - } - - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - - int idx = bytes.getUnsignedShort(offset); - CstType type = (CstType) pool.get(idx); - - idx = bytes.getUnsignedShort(offset + 2); - CstNat method = (CstNat) pool.get0Ok(idx); - - Attribute result = new AttEnclosingMethod(type, method); - - if (observer != null) { - observer.parsed(bytes, offset, 2, "class: " + type); - observer.parsed(bytes, offset + 2, 2, "method: " + - DirectClassFile.stringOrNone(method)); - } - - return result; - } - - /** - * Parses an Exceptions attribute. - */ - private Attribute exceptions(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length < 2) { - return throwSeverelyTruncated(); - } - - ByteArray bytes = cf.getBytes(); - int count = bytes.getUnsignedShort(offset); // number_of_exceptions - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "number_of_exceptions: " + Hex.u2(count)); - } - - offset += 2; - length -= 2; - - if (length != (count * 2)) { - throwBadLength((count * 2) + 2); - } - - TypeList list = cf.makeTypeList(offset, count); - return new AttExceptions(list); - } - - /** - * Parses an InnerClasses attribute. - */ - private Attribute innerClasses(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length < 2) { - return throwSeverelyTruncated(); - } - - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - int count = bytes.getUnsignedShort(offset); // number_of_classes - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "number_of_classes: " + Hex.u2(count)); - } - - offset += 2; - length -= 2; - - if (length != (count * 8)) { - throwBadLength((count * 8) + 2); - } - - InnerClassList list = new InnerClassList(count); - - for (int i = 0; i < count; i++) { - int innerClassIdx = bytes.getUnsignedShort(offset); - int outerClassIdx = bytes.getUnsignedShort(offset + 2); - int nameIdx = bytes.getUnsignedShort(offset + 4); - int accessFlags = bytes.getUnsignedShort(offset + 6); - CstType innerClass = (CstType) pool.get(innerClassIdx); - CstType outerClass = (CstType) pool.get0Ok(outerClassIdx); - CstUtf8 name = (CstUtf8) pool.get0Ok(nameIdx); - list.set(i, innerClass, outerClass, name, accessFlags); - if (observer != null) { - observer.parsed(bytes, offset, 2, - "inner_class: " + - DirectClassFile.stringOrNone(innerClass)); - observer.parsed(bytes, offset + 2, 2, - " outer_class: " + - DirectClassFile.stringOrNone(outerClass)); - observer.parsed(bytes, offset + 4, 2, - " name: " + - DirectClassFile.stringOrNone(name)); - observer.parsed(bytes, offset + 6, 2, - " access_flags: " + - AccessFlags.innerClassString(accessFlags)); - } - offset += 8; - } - - list.setImmutable(); - return new AttInnerClasses(list); - } - - /** - * Parses a LineNumberTable attribute. - */ - private Attribute lineNumberTable(DirectClassFile cf, int offset, - int length, ParseObserver observer) { - if (length < 2) { - return throwSeverelyTruncated(); - } - - ByteArray bytes = cf.getBytes(); - int count = bytes.getUnsignedShort(offset); // line_number_table_length - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "line_number_table_length: " + Hex.u2(count)); - } - - offset += 2; - length -= 2; - - if (length != (count * 4)) { - throwBadLength((count * 4) + 2); - } - - LineNumberList list = new LineNumberList(count); - - for (int i = 0; i < count; i++) { - int startPc = bytes.getUnsignedShort(offset); - int lineNumber = bytes.getUnsignedShort(offset + 2); - list.set(i, startPc, lineNumber); - if (observer != null) { - observer.parsed(bytes, offset, 4, - Hex.u2(startPc) + " " + lineNumber); - } - offset += 4; - } - - list.setImmutable(); - return new AttLineNumberTable(list); - } - - /** - * Parses a LocalVariableTable attribute. - */ - private Attribute localVariableTable(DirectClassFile cf, int offset, - int length, ParseObserver observer) { - if (length < 2) { - return throwSeverelyTruncated(); - } - - ByteArray bytes = cf.getBytes(); - int count = bytes.getUnsignedShort(offset); - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "local_variable_table_length: " + Hex.u2(count)); - } - - LocalVariableList list = parseLocalVariables( - bytes.slice(offset + 2, offset + length), cf.getConstantPool(), - observer, count, false); - return new AttLocalVariableTable(list); - } - - /** - * Parses a LocalVariableTypeTable attribute. - */ - private Attribute localVariableTypeTable(DirectClassFile cf, int offset, - int length, ParseObserver observer) { - if (length < 2) { - return throwSeverelyTruncated(); - } - - ByteArray bytes = cf.getBytes(); - int count = bytes.getUnsignedShort(offset); - - if (observer != null) { - observer.parsed(bytes, offset, 2, - "local_variable_type_table_length: " + Hex.u2(count)); - } - - LocalVariableList list = parseLocalVariables( - bytes.slice(offset + 2, offset + length), cf.getConstantPool(), - observer, count, true); - return new AttLocalVariableTypeTable(list); - } - - /** - * Parse the table part of either a LocalVariableTable - * or a LocalVariableTypeTable. - * - * @param bytes non-null; bytes to parse, which should only - * contain the table data (no header) - * @param pool non-null; constant pool to use - * @param count >= 0; the number of entries - * @param typeTable true iff this is for a type table - * @return non-null; the constructed list - */ - private LocalVariableList parseLocalVariables(ByteArray bytes, - ConstantPool pool, ParseObserver observer, int count, - boolean typeTable) { - if (bytes.size() != (count * 10)) { - // "+ 2" is for the count. - throwBadLength((count * 10) + 2); - } - - ByteArray.MyDataInputStream in = bytes.makeDataInputStream(); - LocalVariableList list = new LocalVariableList(count); - - try { - for (int i = 0; i < count; i++) { - int startPc = in.readUnsignedShort(); - int length = in.readUnsignedShort(); - int nameIdx = in.readUnsignedShort(); - int typeIdx = in.readUnsignedShort(); - int index = in.readUnsignedShort(); - CstUtf8 name = (CstUtf8) pool.get(nameIdx); - CstUtf8 type = (CstUtf8) pool.get(typeIdx); - CstUtf8 descriptor = null; - CstUtf8 signature = null; - - if (typeTable) { - signature = type; - } else { - descriptor = type; - } - - list.set(i, startPc, length, name, - descriptor, signature, index); - - if (observer != null) { - observer.parsed(bytes, i * 10, 10, Hex.u2(startPc) + - ".." + Hex.u2(startPc + length) + " " + - Hex.u2(index) + " " + name.toHuman() + " " + - type.toHuman()); - } - } - } catch (IOException ex) { - throw new RuntimeException("shouldn't happen", ex); - } - - list.setImmutable(); - return list; - } - - /** - * Parses a RuntimeInvisibleAnnotations attribute. - */ - private Attribute runtimeInvisibleAnnotations(DirectClassFile cf, - int offset, int length, ParseObserver observer) { - if (length < 2) { - throwSeverelyTruncated(); - } - - AnnotationParser ap = - new AnnotationParser(cf, offset, length, observer); - Annotations annotations = - ap.parseAnnotationAttribute(AnnotationVisibility.BUILD); - - return new AttRuntimeInvisibleAnnotations(annotations, length); - } - - /** - * Parses a RuntimeVisibleAnnotations attribute. - */ - private Attribute runtimeVisibleAnnotations(DirectClassFile cf, - int offset, int length, ParseObserver observer) { - if (length < 2) { - throwSeverelyTruncated(); - } - - AnnotationParser ap = - new AnnotationParser(cf, offset, length, observer); - Annotations annotations = - ap.parseAnnotationAttribute(AnnotationVisibility.RUNTIME); - - return new AttRuntimeVisibleAnnotations(annotations, length); - } - - /** - * Parses a RuntimeInvisibleParameterAnnotations attribute. - */ - private Attribute runtimeInvisibleParameterAnnotations(DirectClassFile cf, - int offset, int length, ParseObserver observer) { - if (length < 2) { - throwSeverelyTruncated(); - } - - AnnotationParser ap = - new AnnotationParser(cf, offset, length, observer); - AnnotationsList list = - ap.parseParameterAttribute(AnnotationVisibility.BUILD); - - return new AttRuntimeInvisibleParameterAnnotations(list, length); - } - - /** - * Parses a RuntimeVisibleParameterAnnotations attribute. - */ - private Attribute runtimeVisibleParameterAnnotations(DirectClassFile cf, - int offset, int length, ParseObserver observer) { - if (length < 2) { - throwSeverelyTruncated(); - } - - AnnotationParser ap = - new AnnotationParser(cf, offset, length, observer); - AnnotationsList list = - ap.parseParameterAttribute(AnnotationVisibility.RUNTIME); - - return new AttRuntimeVisibleParameterAnnotations(list, length); - } - - /** - * Parses a Signature attribute. - */ - private Attribute signature(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length != 2) { - throwBadLength(2); - } - - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - int idx = bytes.getUnsignedShort(offset); - CstUtf8 cst = (CstUtf8) pool.get(idx); - Attribute result = new AttSignature(cst); - - if (observer != null) { - observer.parsed(bytes, offset, 2, "signature: " + cst); - } - - return result; - } - - /** - * Parses a SourceFile attribute. - */ - private Attribute sourceFile(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length != 2) { - throwBadLength(2); - } - - ByteArray bytes = cf.getBytes(); - ConstantPool pool = cf.getConstantPool(); - int idx = bytes.getUnsignedShort(offset); - CstUtf8 cst = (CstUtf8) pool.get(idx); - Attribute result = new AttSourceFile(cst); - - if (observer != null) { - observer.parsed(bytes, offset, 2, "source: " + cst); - } - - return result; - } - - /** - * Parses a Synthetic attribute. - */ - private Attribute synthetic(DirectClassFile cf, int offset, int length, - ParseObserver observer) { - if (length != 0) { - return throwBadLength(0); - } - - return new AttSynthetic(); - } - - /** - * Throws the right exception when a known attribute has a way too short - * length. - * - * @return never - * @throws ParseException always thrown - */ - private static Attribute throwSeverelyTruncated() { - throw new ParseException("severely truncated attribute"); - } - - /** - * Throws the right exception when a known attribute has a too short - * length. - * - * @return never - * @throws ParseException always thrown - */ - private static Attribute throwTruncated() { - throw new ParseException("truncated attribute"); - } - - /** - * Throws the right exception when an attribute has an unexpected length - * (given its contents). - * - * @param expected expected length - * @return never - * @throws ParseException always thrown - */ - private static Attribute throwBadLength(int expected) { - throw new ParseException("bad attribute length; expected length " + - Hex.u4(expected)); - } -} diff --git a/dx/src/com/android/dx/cf/direct/package.html b/dx/src/com/android/dx/cf/direct/package.html deleted file mode 100644 index 2a4619843..000000000 --- a/dx/src/com/android/dx/cf/direct/package.html +++ /dev/null @@ -1,12 +0,0 @@ - -

Implementation of cf.iface.* based on a direct representation -of class files as byte[]s.

- -

PACKAGES USED: -

    -
  • com.android.dx.cf.attrib
  • -
  • com.android.dx.cf.iface
  • -
  • com.android.dx.rop.pool
  • -
  • com.android.dx.util
  • -
- diff --git a/dx/src/com/android/dx/cf/iface/Attribute.java b/dx/src/com/android/dx/cf/iface/Attribute.java deleted file mode 100644 index f28f51e24..000000000 --- a/dx/src/com/android/dx/cf/iface/Attribute.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -/** - * Interface representing attributes of class files (directly or indirectly). - */ -public interface Attribute { - /** - * Get the name of the attribute. - * - * @return non-null; the name - */ - public String getName(); - - /** - * Get the total length of the attribute in bytes, including the - * header. Since the header is always six bytes, the result of - * this method is always at least 6. - * - * @return >= 6; the total length, in bytes - */ - public int byteLength(); -} diff --git a/dx/src/com/android/dx/cf/iface/AttributeList.java b/dx/src/com/android/dx/cf/iface/AttributeList.java deleted file mode 100644 index a72965abd..000000000 --- a/dx/src/com/android/dx/cf/iface/AttributeList.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -/** - * Interface for lists of attributes. - */ -public interface AttributeList { - /** - * Get whether this instance is mutable. Note that the - * AttributeList interface itself doesn't provide any means - * of mutation, but that doesn't mean that there isn't a non-interface - * way of mutating an instance. - * - * @return true iff this instance is somehow mutable - */ - public boolean isMutable(); - - /** - * Get the number of attributes in the list. - * - * @return the size - */ - public int size(); - - /** - * Get the nth attribute. - * - * @param n n >= 0, n < size(); which attribute - * @return non-null; the attribute in question - */ - public Attribute get(int n); - - /** - * Get the total length of this list in bytes, when part of a - * class file. The returned value includes the two bytes for the - * attributes_count length indicator. - * - * @return >= 2; the total length, in bytes - */ - public int byteLength(); - - /** - * Get the first attribute in the list with the given name, if any. - * - * @param name non-null; attribute name - * @return null-ok; first attribute in the list with the given name, - * or null if there is none - */ - public Attribute findFirst(String name); - - /** - * Get the next attribute in the list after the given one, with the same - * name, if any. - * - * @param attrib non-null; attribute to start looking after - * @return null-ok; next attribute after attrib with the - * same name as attrib - */ - public Attribute findNext(Attribute attrib); -} diff --git a/dx/src/com/android/dx/cf/iface/ClassFile.java b/dx/src/com/android/dx/cf/iface/ClassFile.java deleted file mode 100644 index 36a5f7415..000000000 --- a/dx/src/com/android/dx/cf/iface/ClassFile.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.rop.cst.ConstantPool; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; -import com.android.dx.rop.type.TypeList; - -/** - * Interface for things which purport to be class files or reasonable - * facsimiles thereof. - * - *

Note: The fields referred to in this documentation are of the - * ClassFile structure defined in vmspec-2 sec4.1. - */ -public interface ClassFile { - /** - * Gets the field magic. - * - * @return the value in question - */ - public int getMagic(); - - /** - * Gets the field minor_version. - * - * @return the value in question - */ - public int getMinorVersion(); - - /** - * Gets the field major_version. - * - * @return the value in question - */ - public int getMajorVersion(); - - /** - * Gets the field access_flags. - * - * @return the value in question - */ - public int getAccessFlags(); - - /** - * Gets the field this_class, interpreted as a type constant. - * - * @return non-null; the value in question - */ - public CstType getThisClass(); - - /** - * Gets the field super_class, interpreted as a type constant - * if non-zero. - * - * @return null-ok; the value in question - */ - public CstType getSuperclass(); - - /** - * Gets the field constant_pool (along with - * constant_pool_count). - * - * @return non-null; the constant pool - */ - public ConstantPool getConstantPool(); - - /** - * Gets the field interfaces (along with - * interfaces_count). - * - * @return non-null; the list of interfaces - */ - public TypeList getInterfaces(); - - /** - * Gets the field fields (along with - * fields_count). - * - * @return non-null; the list of fields - */ - public FieldList getFields(); - - /** - * Gets the field methods (along with - * methods_count). - * - * @return non-null; the list of fields - */ - public MethodList getMethods(); - - /** - * Gets the field attributes (along with - * attributes_count). - * - * @return non-null; the list of attributes - */ - public AttributeList getAttributes(); - - /** - * Gets the name out of the SourceFile attribute of this - * file, if any. This is a convenient shorthand for scrounging around - * the class's attributes. - * - * @return non-null; the constant pool - */ - public CstUtf8 getSourceFile(); -} diff --git a/dx/src/com/android/dx/cf/iface/Field.java b/dx/src/com/android/dx/cf/iface/Field.java deleted file mode 100644 index d1694fc32..000000000 --- a/dx/src/com/android/dx/cf/iface/Field.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.rop.cst.TypedConstant; - -/** - * Interface representing fields of class files. - */ -public interface Field - extends Member { - /** - * Get the constant value for this field, if any. This only returns - * non-null for a static final field which - * includes a ConstantValue attribute. - * - * @return null-ok; the constant value, or null if this - * field isn't a constant - */ - public TypedConstant getConstantValue(); -} diff --git a/dx/src/com/android/dx/cf/iface/FieldList.java b/dx/src/com/android/dx/cf/iface/FieldList.java deleted file mode 100644 index 80a794fdb..000000000 --- a/dx/src/com/android/dx/cf/iface/FieldList.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -/** - * Interface for lists of fields. - */ -public interface FieldList -{ - /** - * Get whether this instance is mutable. Note that the - * FieldList interface itself doesn't provide any means - * of mutation, but that doesn't mean that there isn't a non-interface - * way of mutating an instance. - * - * @return true iff this instance is somehow mutable - */ - public boolean isMutable(); - - /** - * Get the number of fields in the list. - * - * @return the size - */ - public int size(); - - /** - * Get the nth field. - * - * @param n n >= 0, n < size(); which field - * @return non-null; the field in question - */ - public Field get(int n); -} diff --git a/dx/src/com/android/dx/cf/iface/Member.java b/dx/src/com/android/dx/cf/iface/Member.java deleted file mode 100644 index b305e09b6..000000000 --- a/dx/src/com/android/dx/cf/iface/Member.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; - -/** - * Interface representing members of class files (that is, fields and methods). - */ -public interface Member { - /** - * Get the defining class. - * - * @return non-null; the defining class - */ - public CstType getDefiningClass(); - - /** - * Get the field access_flags. - * - * @return the access flags - */ - public int getAccessFlags(); - - /** - * Get the field name_index of the member. This is - * just a convenient shorthand for getNat().getName(). - * - * @return non-null; the name - */ - public CstUtf8 getName(); - - /** - * Get the field descriptor_index of the member. This is - * just a convenient shorthand for getNat().getDescriptor(). - * - * @return non-null; the descriptor - */ - public CstUtf8 getDescriptor(); - - /** - * Get the name and type associated with this member. This is a - * combination of the fields name_index and - * descriptor_index in the original classfile, interpreted - * via the constant pool. - * - * @return non-null; the name and type - */ - public CstNat getNat(); - - /** - * Get the field attributes (along with - * attributes_count). - * - * @return non-null; the constant pool - */ - public AttributeList getAttributes(); -} diff --git a/dx/src/com/android/dx/cf/iface/Method.java b/dx/src/com/android/dx/cf/iface/Method.java deleted file mode 100644 index 424400a2b..000000000 --- a/dx/src/com/android/dx/cf/iface/Method.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.rop.type.Prototype; - -/** - * Interface representing methods of class files. - */ -public interface Method - extends Member -{ - /** - * Get the effective method descriptor, which includes, if - * necessary, a first this parameter. - * - * @return non-null; the effective method descriptor - */ - public Prototype getEffectiveDescriptor(); -} diff --git a/dx/src/com/android/dx/cf/iface/MethodList.java b/dx/src/com/android/dx/cf/iface/MethodList.java deleted file mode 100644 index a7a395cbe..000000000 --- a/dx/src/com/android/dx/cf/iface/MethodList.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -/** - * Interface for lists of methods. - */ -public interface MethodList { - /** - * Get whether this instance is mutable. Note that the - * MethodList interface itself doesn't provide any means - * of mutation, but that doesn't mean that there isn't a non-interface - * way of mutating an instance. - * - * @return true iff this instance is somehow mutable - */ - public boolean isMutable(); - - /** - * Get the number of methods in the list. - * - * @return the size - */ - public int size(); - - /** - * Get the nth method. - * - * @param n n >= 0, n < size(); which method - * @return non-null; the method in question - */ - public Method get(int n); -} diff --git a/dx/src/com/android/dx/cf/iface/ParseException.java b/dx/src/com/android/dx/cf/iface/ParseException.java deleted file mode 100644 index 18a9d0e24..000000000 --- a/dx/src/com/android/dx/cf/iface/ParseException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.util.ExceptionWithContext; - -/** - * Exception from parsing. - */ -public class ParseException - extends ExceptionWithContext { - public ParseException(String message) { - super(message); - } - - public ParseException(Throwable cause) { - super(cause); - } - - public ParseException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/dx/src/com/android/dx/cf/iface/ParseObserver.java b/dx/src/com/android/dx/cf/iface/ParseObserver.java deleted file mode 100644 index 2ad3493c6..000000000 --- a/dx/src/com/android/dx/cf/iface/ParseObserver.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.util.ByteArray; - -/** - * Observer of parsing in action. This is used to supply feedback from - * the various things that parse particularly to the dumping utilities. - */ -public interface ParseObserver { - /** - * Indicate that the level of indentation for a dump should increase - * or decrease (positive or negative argument, respectively). - * - * @param indentDelta the amount to change indentation - */ - public void changeIndent(int indentDelta); - - /** - * Indicate that a particular member is now being parsed. - * - * @param bytes non-null; the source that is being parsed - * @param offset offset into bytes for the start of the - * member - * @param name non-null; name of the member - * @param descriptor non-null; descriptor of the member - */ - public void startParsingMember(ByteArray bytes, int offset, String name, - String descriptor); - - /** - * Indicate that a particular member is no longer being parsed. - * - * @param bytes non-null; the source that was parsed - * @param offset offset into bytes for the end of the - * member - * @param name non-null; name of the member - * @param descriptor non-null; descriptor of the member - * @param member non-null; the actual member that was parsed - */ - public void endParsingMember(ByteArray bytes, int offset, String name, - String descriptor, Member member); - - /** - * Indicate that some parsing happened. - * - * @param bytes non-null; the source that was parsed - * @param offset offset into bytes for what was parsed - * @param len number of bytes parsed - * @param human non-null; human form for what was parsed - */ - public void parsed(ByteArray bytes, int offset, int len, String human); -} diff --git a/dx/src/com/android/dx/cf/iface/StdAttributeList.java b/dx/src/com/android/dx/cf/iface/StdAttributeList.java deleted file mode 100644 index c29bb08d0..000000000 --- a/dx/src/com/android/dx/cf/iface/StdAttributeList.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.util.FixedSizeList; - -/** - * Standard implementation of {@link AttributeList}, which directly stores - * an array of {@link Attribute} objects and can be made immutable. - */ -public final class StdAttributeList extends FixedSizeList - implements AttributeList { - /** - * Constructs an instance. All indices initially contain null. - * - * @param size the size of the list - */ - public StdAttributeList(int size) { - super(size); - } - - /** {@inheritDoc} */ - public Attribute get(int n) { - return (Attribute) get0(n); - } - - /** {@inheritDoc} */ - public int byteLength() { - int sz = size(); - int result = 2; // u2 attributes_count - - for (int i = 0; i < sz; i++) { - result += get(i).byteLength(); - } - - return result; - } - - /** {@inheritDoc} */ - public Attribute findFirst(String name) { - int sz = size(); - - for (int i = 0; i < sz; i++) { - Attribute att = get(i); - if (att.getName().equals(name)) { - return att; - } - } - - return null; - } - - /** {@inheritDoc} */ - public Attribute findNext(Attribute attrib) { - int sz = size(); - int at; - - outer: { - for (at = 0; at < sz; at++) { - Attribute att = get(at); - if (att == attrib) { - break outer; - } - } - - return null; - } - - String name = attrib.getName(); - - for (at++; at < sz; at++) { - Attribute att = get(at); - if (att.getName().equals(name)) { - return att; - } - } - - return null; - } - - /** - * Sets the attribute at the given index. - * - * @param n >= 0, < size(); which attribute - * @param attribute null-ok; the attribute object - */ - public void set(int n, Attribute attribute) { - set0(n, attribute); - } -} diff --git a/dx/src/com/android/dx/cf/iface/StdField.java b/dx/src/com/android/dx/cf/iface/StdField.java deleted file mode 100644 index 3551aee69..000000000 --- a/dx/src/com/android/dx/cf/iface/StdField.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.cf.attrib.AttConstantValue; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.TypedConstant; - -/** - * Standard implementation of {@link Field}, which directly stores - * all the associated data. - */ -public final class StdField extends StdMember implements Field { - /** - * Constructs an instance. - * - * @param definingClass non-null; the defining class - * @param accessFlags access flags - * @param nat non-null; member name and type (descriptor) - * @param attributes non-null; list of associated attributes - */ - public StdField(CstType definingClass, int accessFlags, CstNat nat, - AttributeList attributes) { - super(definingClass, accessFlags, nat, attributes); - } - - /** {@inheritDoc} */ - public TypedConstant getConstantValue() { - AttributeList attribs = getAttributes(); - AttConstantValue cval = (AttConstantValue) - attribs.findFirst(AttConstantValue.ATTRIBUTE_NAME); - - if (cval == null) { - return null; - } - - return cval.getConstantValue(); - } -} diff --git a/dx/src/com/android/dx/cf/iface/StdFieldList.java b/dx/src/com/android/dx/cf/iface/StdFieldList.java deleted file mode 100644 index 0f8654b20..000000000 --- a/dx/src/com/android/dx/cf/iface/StdFieldList.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.util.FixedSizeList; - -/** - * Standard implementation of {@link FieldList}, which directly stores - * an array of {@link Field} objects and can be made immutable. - */ -public final class StdFieldList extends FixedSizeList implements FieldList { - /** - * Constructs an instance. All indices initially contain null. - * - * @param size the size of the list - */ - public StdFieldList(int size) { - super(size); - } - - /** {@inheritDoc} */ - public Field get(int n) { - return (Field) get0(n); - } - - /** - * Sets the field at the given index. - * - * @param n >= 0, < size(); which field - * @param field null-ok; the field object - */ - public void set(int n, Field field) { - set0(n, field); - } -} diff --git a/dx/src/com/android/dx/cf/iface/StdMember.java b/dx/src/com/android/dx/cf/iface/StdMember.java deleted file mode 100644 index eaf949ef0..000000000 --- a/dx/src/com/android/dx/cf/iface/StdMember.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.cst.CstUtf8; - -/** - * Standard implementation of {@link Member}, which directly stores - * all the associated data. - */ -public abstract class StdMember implements Member { - /** non-null; the defining class */ - private final CstType definingClass; - - /** access flags */ - private final int accessFlags; - - /** non-null; member name and type */ - private final CstNat nat; - - /** non-null; list of associated attributes */ - private final AttributeList attributes; - - /** - * Constructs an instance. - * - * @param definingClass non-null; the defining class - * @param accessFlags access flags - * @param nat non-null; member name and type (descriptor) - * @param attributes non-null; list of associated attributes - */ - public StdMember(CstType definingClass, int accessFlags, CstNat nat, - AttributeList attributes) { - if (definingClass == null) { - throw new NullPointerException("definingClass == null"); - } - - if (nat == null) { - throw new NullPointerException("nat == null"); - } - - if (attributes == null) { - throw new NullPointerException("attributes == null"); - } - - this.definingClass = definingClass; - this.accessFlags = accessFlags; - this.nat = nat; - this.attributes = attributes; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - StringBuffer sb = new StringBuffer(100); - - sb.append(getClass().getName()); - sb.append('{'); - sb.append(nat.toHuman()); - sb.append('}'); - - return sb.toString(); - } - - /** {@inheritDoc} */ - public final CstType getDefiningClass() { - return definingClass; - } - - /** {@inheritDoc} */ - public final int getAccessFlags() { - return accessFlags; - } - - /** {@inheritDoc} */ - public final CstNat getNat() { - return nat; - } - - /** {@inheritDoc} */ - public final CstUtf8 getName() { - return nat.getName(); - } - - /** {@inheritDoc} */ - public final CstUtf8 getDescriptor() { - return nat.getDescriptor(); - } - - /** {@inheritDoc} */ - public final AttributeList getAttributes() { - return attributes; - } -} diff --git a/dx/src/com/android/dx/cf/iface/StdMethod.java b/dx/src/com/android/dx/cf/iface/StdMethod.java deleted file mode 100644 index a4acbaa7f..000000000 --- a/dx/src/com/android/dx/cf/iface/StdMethod.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.rop.code.AccessFlags; -import com.android.dx.rop.cst.CstNat; -import com.android.dx.rop.cst.CstType; -import com.android.dx.rop.type.Prototype; - -/** - * Standard implementation of {@link Method}, which directly stores - * all the associated data. - */ -public final class StdMethod extends StdMember implements Method { - /** non-null; the effective method descriptor */ - private final Prototype effectiveDescriptor; - - /** - * Constructs an instance. - * - * @param definingClass non-null; the defining class - * @param accessFlags access flags - * @param nat non-null; member name and type (descriptor) - * @param attributes non-null; list of associated attributes - */ - public StdMethod(CstType definingClass, int accessFlags, CstNat nat, - AttributeList attributes) { - super(definingClass, accessFlags, nat, attributes); - - String descStr = getDescriptor().getString(); - effectiveDescriptor = - Prototype.intern(descStr, definingClass.getClassType(), - AccessFlags.isStatic(accessFlags), - nat.isInstanceInit()); - } - - /** {@inheritDoc} */ - public Prototype getEffectiveDescriptor() { - return effectiveDescriptor; - } -} diff --git a/dx/src/com/android/dx/cf/iface/StdMethodList.java b/dx/src/com/android/dx/cf/iface/StdMethodList.java deleted file mode 100644 index ef0ff3153..000000000 --- a/dx/src/com/android/dx/cf/iface/StdMethodList.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.cf.iface; - -import com.android.dx.util.FixedSizeList; - -/** - * Standard implementation of {@link MethodList}, which directly stores - * an array of {@link Method} objects and can be made immutable. - */ -public final class StdMethodList extends FixedSizeList implements MethodList { - /** - * Constructs an instance. All indices initially contain null. - * - * @param size the size of the list - */ - public StdMethodList(int size) { - super(size); - } - - /** {@inheritDoc} */ - public Method get(int n) { - return (Method) get0(n); - } - - /** - * Sets the method at the given index. - * - * @param n >= 0, < size(); which method - * @param method null-ok; the method object - */ - public void set(int n, Method method) { - set0(n, method); - } -} diff --git a/dx/src/com/android/dx/cf/iface/package.html b/dx/src/com/android/dx/cf/iface/package.html deleted file mode 100644 index c7345527d..000000000 --- a/dx/src/com/android/dx/cf/iface/package.html +++ /dev/null @@ -1,10 +0,0 @@ - -

Interfaces and base classes for dealing with class files. This package -doesn't have any parsing but does have basic container implementations.

- -

PACKAGES USED: -

    -
  • com.android.dx.rop.pool
  • -
  • com.android.dx.util
  • -
- diff --git a/dx/src/com/android/dx/command/DxConsole.java b/dx/src/com/android/dx/command/DxConsole.java deleted file mode 100644 index 982e6593c..000000000 --- a/dx/src/com/android/dx/command/DxConsole.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.command; - -import java.io.PrintStream; - -/** - * Provides standard and error PrintStream object to output information.
- * By default the PrintStream objects link to System.out and - * System.err but they can be changed to link to other - * PrintStream. - */ -public class DxConsole { - /** - * Standard output stream. Links to System.out by default. - */ - public static PrintStream out = System.out; - - /** - * Error output stream. Links to System.err by default. - */ - public static PrintStream err = System.err; -} diff --git a/dx/src/com/android/dx/command/Main.java b/dx/src/com/android/dx/command/Main.java deleted file mode 100644 index 17f5db386..000000000 --- a/dx/src/com/android/dx/command/Main.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dx.command; - -import com.android.dx.Version; - -import junit.textui.TestRunner; - -/** - * Main class for dx. It recognizes enough options to be able to dispatch - * to the right "actual" main. - */ -public class Main { - private static String USAGE_MESSAGE = - "usage:\n" + - " dx --dex [--debug] [--verbose] [--positions=