本文整理汇总了Java中com.android.dx.rop.cst.TypedConstant类的典型用法代码示例。如果您正苦于以下问题:Java TypedConstant类的具体用法?Java TypedConstant怎么用?Java TypedConstant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypedConstant类属于com.android.dx.rop.cst包,在下文中一共展示了TypedConstant类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: AttConstantValue
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Constructs an instance.
*
* @param constantValue {@code non-null;} the constant value, which must
* be an instance of one of: {@code CstString},
* {@code CstInteger}, {@code CstLong},
* {@code CstFloat}, or {@code 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;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:25,代码来源:AttConstantValue.java
示例2: constantValue
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Parses a {@code 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;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:22,代码来源:StdAttributeFactory.java
示例3: replaceDef
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Replaces the instructions that define an array with equivalent registers.
* For each entry in the array, a register is created, initialized to zero.
* A mapping between this register and the corresponding array index is
* added.
*
* @param def {@code non-null;} move result instruction for array
* @param prev {@code non-null;} instruction for instantiating new array
* @param length size of the new array
* @param newRegs {@code non-null;} mapping of array indices to new
* registers to be populated
*/
private void replaceDef(SsaInsn def, SsaInsn prev, int length,
ArrayList<RegisterSpec> newRegs) {
Type resultType = def.getResult().getType();
// Create new zeroed out registers for each element in the array
for (int i = 0; i < length; i++) {
Constant newZero = Zeroes.zeroFor(resultType.getComponentType());
TypedConstant typedZero = (TypedConstant) newZero;
RegisterSpec newReg =
RegisterSpec.make(ssaMeth.makeNewSsaReg(), typedZero);
newRegs.add(newReg);
insertPlainInsnBefore(def, RegisterSpecList.EMPTY, newReg,
RegOps.CONST, newZero);
}
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:28,代码来源:EscapeAnalysis.java
示例4: coerceConstant
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Helper for {@link #processFields}, which translates constants into
* more specific types if necessary.
*
* @param constant {@code non-null;} the constant in question
* @param type {@code non-null;} the desired type
*/
private static TypedConstant coerceConstant(TypedConstant constant,
Type type) {
Type constantType = constant.getType();
if (constantType.equals(type)) {
return constant;
}
switch (type.getBasicType()) {
case Type.BT_BOOLEAN: {
return CstBoolean.make(((CstInteger) constant).getValue());
}
case Type.BT_BYTE: {
return CstByte.make(((CstInteger) constant).getValue());
}
case Type.BT_CHAR: {
return CstChar.make(((CstInteger) constant).getValue());
}
case Type.BT_SHORT: {
return CstShort.make(((CstInteger) constant).getValue());
}
default: {
throw new UnsupportedOperationException("can't coerce " +
constant + " to " + type);
}
}
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:35,代码来源:CfTranslator.java
示例5: getConstantValue
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/** {@inheritDoc} */
public TypedConstant getConstantValue() {
AttributeList attribs = getAttributes();
AttConstantValue cval = (AttConstantValue)
attribs.findFirst(AttConstantValue.ATTRIBUTE_NAME);
if (cval == null) {
return null;
}
return cval.getConstantValue();
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:13,代码来源:StdField.java
示例6: getConstant
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Returns a rop constant for the specified value.
*
* @param value null, a boxed primitive, String, Class, or TypeId.
*/
static TypedConstant getConstant(Object value) {
if (value == null) {
return CstKnownNull.THE_ONE;
} else if (value instanceof Boolean) {
return CstBoolean.make((Boolean) value);
} else if (value instanceof Byte) {
return CstByte.make((Byte) value);
} else if (value instanceof Character) {
return CstChar.make((Character) value);
} else if (value instanceof Double) {
return CstDouble.make(Double.doubleToLongBits((Double) value));
} else if (value instanceof Float) {
return CstFloat.make(Float.floatToIntBits((Float) value));
} else if (value instanceof Integer) {
return CstInteger.make((Integer) value);
} else if (value instanceof Long) {
return CstLong.make((Long) value);
} else if (value instanceof Short) {
return CstShort.make((Short) value);
} else if (value instanceof String) {
return new CstString((String) value);
} else if (value instanceof Class) {
return new CstType(TypeId.get((Class<?>) value).ropType);
} else if (value instanceof TypeId) {
return new CstType(((TypeId) value).ropType);
} else {
throw new UnsupportedOperationException("Not a constant: " + value);
}
}
开发者ID:linkedin,项目名称:dexmaker,代码行数:35,代码来源:Constants.java
示例7: replaceConstants
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Replaces TypeBearers in source register specs with constant type
* bearers if possible. These are then referenced in later optimization
* steps.
*/
private void replaceConstants() {
for (int reg = 0; reg < regCount; reg++) {
if (latticeValues[reg] != CONSTANT) {
continue;
}
if (!(latticeConstants[reg] instanceof TypedConstant)) {
// We can't do much with these
continue;
}
SsaInsn defn = ssaMeth.getDefinitionForRegister(reg);
TypeBearer typeBearer = defn.getResult().getTypeBearer();
if (typeBearer.isConstant()) {
/*
* The definition was a constant already.
* The uses should be as well.
*/
continue;
}
// Update the destination RegisterSpec with the constant value
RegisterSpec dest = defn.getResult();
RegisterSpec newDest
= dest.withType((TypedConstant)latticeConstants[reg]);
defn.setResult(newDest);
/*
* Update the sources RegisterSpec's of all non-move uses.
* These will be used in later steps.
*/
for (SsaInsn insn : ssaMeth.getUseListForRegister(reg)) {
if (insn.isPhiOrMove()) {
continue;
}
NormalSsaInsn nInsn = (NormalSsaInsn) insn;
RegisterSpecList sources = insn.getSources();
int index = sources.indexOfRegister(reg);
RegisterSpec spec = sources.get(index);
RegisterSpec newSpec
= spec.withType((TypedConstant)latticeConstants[reg]);
nInsn.changeOneSource(index, newSpec);
}
}
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:55,代码来源:SCCP.java
示例8: run
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Applies the optimization.
*/
private void run() {
int regSz = ssaMeth.getRegCount();
ArrayList<TypedConstant> constantList
= getConstsSortedByCountUse();
int toCollect = Math.min(constantList.size(), MAX_COLLECTED_CONSTANTS);
SsaBasicBlock start = ssaMeth.getEntryBlock();
// Constant to new register containing the constant
HashMap<TypedConstant, RegisterSpec> newRegs
= new HashMap<TypedConstant, RegisterSpec> (toCollect);
for (int i = 0; i < toCollect; i++) {
TypedConstant cst = constantList.get(i);
RegisterSpec result
= RegisterSpec.make(ssaMeth.makeNewSsaReg(), cst);
Rop constRop = Rops.opConst(cst);
if (constRop.getBranchingness() == Rop.BRANCH_NONE) {
start.addInsnToHead(
new PlainCstInsn(Rops.opConst(cst),
SourcePosition.NO_INFO, result,
RegisterSpecList.EMPTY, cst));
} else {
// We need two new basic blocks along with the new insn
SsaBasicBlock entryBlock = ssaMeth.getEntryBlock();
SsaBasicBlock successorBlock
= entryBlock.getPrimarySuccessor();
// Insert a block containing the const insn.
SsaBasicBlock constBlock
= entryBlock.insertNewSuccessor(successorBlock);
constBlock.replaceLastInsn(
new ThrowingCstInsn(constRop, SourcePosition.NO_INFO,
RegisterSpecList.EMPTY,
StdTypeList.EMPTY, cst));
// Insert a block containing the move-result-pseudo insn.
SsaBasicBlock resultBlock
= constBlock.insertNewSuccessor(successorBlock);
PlainInsn insn
= new PlainInsn(
Rops.opMoveResultPseudo(result.getTypeBearer()),
SourcePosition.NO_INFO,
result, RegisterSpecList.EMPTY);
resultBlock.addInsnToHead(insn);
}
newRegs.put(cst, result);
}
updateConstUses(newRegs, regSz);
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:63,代码来源:ConstCollector.java
示例9: processFields
import com.android.dx.rop.cst.TypedConstant; //导入依赖的package包/类
/**
* Processes the fields and adds corresponding elements to the class
* element.
*
* @param skeletonOnly
*/
private void processFields(FieldList fieldList, Element classElement,
Map<String, ReferenceKind> referencedTypes, boolean skeletonOnly) {
for (int i = 0; i < fieldList.size(); ++i) {
Field field = fieldList.get(i);
if (hasIgnoreAnnotation(field.getAttributes())) {
// If this field has the @XMLVMIgnore annotation, we just
// simply ignore it.
continue;
}
if (skeletonOnly
&& (field.getAccessFlags() & (AccessFlags.ACC_PRIVATE | AccessFlags.ACC_SYNTHETIC)) != 0) {
// This field is private or synthetic and we want to generate
// only a skeleton, so we just simply ignore it.
continue;
}
Element fieldElement = new Element("field", NS_XMLVM);
fieldElement.setAttribute("name", field.getName().toHuman());
String fieldType = field.getNat().getFieldType().toHuman();
if (isRedType(fieldType)) {
fieldType = JLO;
} else {
addReference(referencedTypes, fieldType, ReferenceKind.USAGE);
}
fieldElement.setAttribute("type", fieldType);
TypedConstant value = field.getConstantValue();
if (value != null) {
String constValue = null;
if (fieldType.equals("java.lang.String")) {
constValue = ((CstString) value).getString().getString();
encodeString(fieldElement, constValue);
} else {
constValue = value.toHuman();
fieldElement.setAttribute("value", constValue);
}
}
processAccessFlags(field.getAccessFlags(), fieldElement);
classElement.addContent(fieldElement);
}
}
开发者ID:shannah,项目名称:cn1,代码行数:47,代码来源:DEXmlvmOutputProcess.java
注:本文中的com.android.dx.rop.cst.TypedConstant类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论