• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CstString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.dx.rop.cst.CstString的典型用法代码示例。如果您正苦于以下问题:Java CstString类的具体用法?Java CstString怎么用?Java CstString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CstString类属于com.android.dx.rop.cst包,在下文中一共展示了CstString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parseElement

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Parses a {@link NameValuePair}.
 *
 * @return {@code non-null;} the parsed element
 */
private NameValuePair parseElement() throws IOException {
    requireLength(5);

    int elementNameIndex = input.readUnsignedShort();
    CstString elementName = (CstString) 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);
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:26,代码来源:AnnotationParser.java


示例2: signature

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Parses a {@code 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);
    CstString cst = (CstString) pool.get(idx);
    Attribute result = new AttSignature(cst);

    if (observer != null) {
        observer.parsed(bytes, offset, 2, "signature: " + cst);
    }

    return result;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:22,代码来源:StdAttributeFactory.java


示例3: if

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Interns the given constant in the appropriate section of this
 * instance, or do nothing if the given constant isn't the sort
 * that should be interned.
 *
 * @param cst {@code non-null;} constant to possibly intern
 */
/*package*/ void internIfAppropriate(Constant cst) {
    if (cst instanceof CstString) {
        stringIds.intern((CstString) cst);
    } else if (cst instanceof CstType) {
        typeIds.intern((CstType) cst);
    } else if (cst instanceof CstBaseMethodRef) {
        methodIds.intern((CstBaseMethodRef) cst);
    } else if (cst instanceof CstFieldRef) {
        fieldIds.intern((CstFieldRef) cst);
    } else if (cst instanceof CstEnumRef) {
        fieldIds.intern(((CstEnumRef) cst).getFieldRef());
    } else if (cst == null) {
        throw new NullPointerException("cst == null");
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:DexFile.java


示例4: mergeDescriptorsAndSignatures

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * 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 {@code non-null;} list with descriptors
 * @param signatureList {@code non-null;} list with signatures
 * @return {@code non-null;} the merged result
 */
public static LocalVariableList mergeDescriptorsAndSignatures(
        LocalVariableList descriptorList,
        LocalVariableList signatureList) {
    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) {
            CstString signature = signatureItem.getSignature();
            item = item.withSignature(signature);
        }
        result.set(i, item);
    }

    result.setImmutable();
    return result;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:33,代码来源:LocalVariableList.java


示例5: indexOf

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Gets the index of the given string, which must have been added
 * to this instance.
 *
 * @param string {@code non-null;} the string to look up
 * @return {@code >= 0;} the string's index
 */
public int indexOf(CstString string) {
    if (string == null) {
        throw new NullPointerException("string == null");
    }

    throwIfNotPrepared();

    StringIdItem s = strings.get(string);

    if (s == null) {
        throw new IllegalArgumentException("not found");
    }

    return s.getIndex();
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:23,代码来源:StringIdsSection.java


示例6: get

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    throwIfNotPrepared();

    IndexedItem result = strings.get((CstString) cst);

    if (result == null) {
        throw new IllegalArgumentException("not found");
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:18,代码来源:StringIdsSection.java


示例7: AttConstantValue

import com.android.dx.rop.cst.CstString; //导入依赖的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


示例8: visitConstant

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/** {@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);
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:17,代码来源:BasicBlocker.java


示例9: ClassDefItem

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Constructs an instance. Its sets of members and annotations are
 * initially empty.
 *
 * @param thisClass {@code non-null;} type constant for this class
 * @param accessFlags access flags
 * @param superclass {@code null-ok;} superclass or {@code null} if
 * this class is a/the root class
 * @param interfaces {@code non-null;} list of implemented interfaces
 * @param sourceFile {@code null-ok;} source file name or
 * {@code null} if unknown
 */
public ClassDefItem(CstType thisClass, int accessFlags,
        CstType superclass, TypeList interfaces, CstString sourceFile) {
    if (thisClass == null) {
        throw new NullPointerException("thisClass == null");
    }

    /*
     * TODO: Maybe check accessFlags and superclass, at
     * least for easily-checked stuff?
     */

    if (interfaces == null) {
        throw new NullPointerException("interfaces == null");
    }

    this.thisClass = thisClass;
    this.accessFlags = accessFlags;
    this.superclass = superclass;
    this.interfaces =
        (interfaces.size() == 0) ? null :  new TypeListItem(interfaces);
    this.sourceFile = sourceFile;
    this.classData = new ClassDataItem(thisClass);
    this.staticValuesItem = null;
    this.annotationsDirectory = new AnnotationsDirectoryItem();
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:38,代码来源:ClassDefItem.java


示例10: addConstants

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Helper for {@link #getAllConstants} which adds all the info for
 * a single {@code RegisterSpec}.
 *
 * @param result {@code non-null;} result set to add to
 * @param spec {@code null-ok;} register spec to add
 */
private static void addConstants(HashSet<Constant> result,
        RegisterSpec spec) {
    if (spec == null) {
        return;
    }

    LocalItem local = spec.getLocalItem();
    CstString name = local.getName();
    CstString signature = local.getSignature();
    Type type = spec.getType();

    if (type != Type.KNOWN_NULL) {
        result.add(CstType.intern(type));
    }

    if (name != null) {
        result.add(name);
    }

    if (signature != null) {
        result.add(signature);
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:31,代码来源:OutputFinisher.java


示例11: intern

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Interns an element into this instance.
 *
 * @param string {@code non-null;} the string to intern
 * @return {@code non-null;} the interned string
 */
public synchronized StringIdItem intern(StringIdItem string) {
    if (string == null) {
        throw new NullPointerException("string == null");
    }

    throwIfPrepared();

    CstString value = string.getValue();
    StringIdItem already = strings.get(value);

    if (already != null) {
        return already;
    }

    strings.put(value, string);
    return string;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:24,代码来源:StringIdsSection.java


示例12: sourceFile

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Parses a {@code 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);
    CstString cst = (CstString) pool.get(idx);
    Attribute result = new AttSourceFile(cst);

    if (observer != null) {
        observer.parsed(bytes, offset, 2, "source: " + cst);
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:22,代码来源:StdAttributeFactory.java


示例13: add

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Add an element to the set of (name, value) pairs for this instance.
 * It is an error to call this method if there is a preexisting element
 * with the same name.
 *
 * @param pair {@code non-null;} the (name, value) pair to add to this instance
 */
public void add(NameValuePair pair) {
    throwIfImmutable();

    if (pair == null) {
        throw new NullPointerException("pair == null");
    }

    CstString name = pair.getName();

    if (elements.get(name) != null) {
        throw new IllegalArgumentException("name already added: " + name);
    }

    elements.put(name, pair);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:Annotation.java


示例14: entryAnnotationString

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Returns a string representation of this LocalList entry that is
 * appropriate for emitting as an annotation.
 *
 * @param e {@code non-null;} entry
 * @return {@code non-null;} annotation string
 */
private String entryAnnotationString(LocalList.Entry e) {
    StringBuilder sb = new StringBuilder();

    sb.append(RegisterSpec.PREFIX);
    sb.append(e.getRegister());
    sb.append(' ');

    CstString name = e.getName();
    if (name == null) {
        sb.append("null");
    } else {
        sb.append(name.toHuman());
    }
    sb.append(' ');

    CstType type = e.getType();
    if (type == null) {
        sb.append("null");
    } else {
        sb.append(type.toHuman());
    }

    CstString signature = e.getSignature();

    if (signature != null) {
        sb.append(' ');
        sb.append(signature.toHuman());
    }

    return sb.toString();
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:39,代码来源:DebugInfoEncoder.java


示例15: parseAnnotation

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Parses a single annotation.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotation
 * @return {@code non-null;} the parsed annotation
 */
private Annotation parseAnnotation(AnnotationVisibility visibility)
        throws IOException {
    requireLength(4);

    int typeIndex = input.readUnsignedShort();
    int numElements = input.readUnsignedShort();
    CstString typeString = (CstString) pool.get(typeIndex);
    CstType type = new CstType(Type.intern(typeString.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;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:40,代码来源:AnnotationParser.java


示例16: toString0

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Helper for {@link #toString} and {@link #toHuman}.
 *
 * @param human whether to be human-oriented
 * @return {@code non-null;} the string form
 */
private String toString0(boolean human) {
    StringBuffer sb = new StringBuffer(40);

    sb.append(regString());
    sb.append(":");

    if (local != null) {
        sb.append(local.toString());
    }

    Type justType = type.getType();
    sb.append(justType);

    if (justType != type) {
        sb.append("=");
        if (human && (type instanceof CstString)) {
            sb.append(((CstString) type).toQuoted());
        } else if (human && (type instanceof Constant)) {
            sb.append(type.toHuman());
        } else {
            sb.append(type);
        }
    }

    return sb.toString();
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:33,代码来源:RegisterSpec.java


示例17: insertExceptionThrow

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Replaces instructions that trigger an ArrayIndexOutofBounds exception
 * with an actual throw of the exception.
 *
 * @param insn {@code non-null;} instruction causing the exception
 * @param index {@code non-null;} index value that is out of bounds
 * @param deletedInsns {@code non-null;} set of instructions marked for
 * deletion
 */
private void insertExceptionThrow(SsaInsn insn, RegisterSpec index,
                                      HashSet<SsaInsn> deletedInsns) {
    // Create a new ArrayIndexOutOfBoundsException
    CstType exception =
        new CstType(Exceptions.TYPE_ArrayIndexOutOfBoundsException);
    insertThrowingInsnBefore(insn, RegisterSpecList.EMPTY, null,
                                 RegOps.NEW_INSTANCE, exception);

    // Add a successor block with a move result pseudo for the exception
    SsaBasicBlock currBlock = insn.getBlock();
    SsaBasicBlock newBlock =
        currBlock.insertNewSuccessor(currBlock.getPrimarySuccessor());
    SsaInsn newInsn = newBlock.getInsns().get(0);
    RegisterSpec newReg =
        RegisterSpec.make(ssaMeth.makeNewSsaReg(), exception);
    insertPlainInsnBefore(newInsn, RegisterSpecList.EMPTY, newReg,
                              RegOps.MOVE_RESULT_PSEUDO, null);

    // Add another successor block to initialize the exception
    SsaBasicBlock newBlock2 =
        newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor());
    SsaInsn newInsn2 = newBlock2.getInsns().get(0);
    CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V"));
    CstMethodRef newRef = new CstMethodRef(exception, newNat);
    insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index),
                                 null, RegOps.INVOKE_DIRECT, newRef);
    deletedInsns.add(newInsn2);

    // Add another successor block to throw the new exception
    SsaBasicBlock newBlock3 =
        newBlock2.insertNewSuccessor(newBlock2.getPrimarySuccessor());
    SsaInsn newInsn3 = newBlock3.getInsns().get(0);
    insertThrowingInsnBefore(newInsn3, RegisterSpecList.make(newReg), null,
                                 RegOps.THROW, null);
    newBlock3.replaceSuccessor(newBlock3.getPrimarySuccessorIndex(),
                                   ssaMeth.getExitBlock().getIndex());
    deletedInsns.add(newInsn3);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:48,代码来源:EscapeAnalysis.java


示例18: makeShortForm

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Creates the short-form of the given prototype.
 *
 * @param prototype {@code non-null;} the prototype
 * @return {@code non-null;} the short form
 */
private static CstString makeShortForm(Prototype prototype) {
    StdTypeList parameters = prototype.getParameterTypes();
    int size = parameters.size();
    StringBuilder sb = new StringBuilder(size + 1);

    sb.append(shortFormCharFor(prototype.getReturnType()));

    for (int i = 0; i < size; i++) {
        sb.append(shortFormCharFor(parameters.getType(i)));
    }

    return new CstString(sb.toString());
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:20,代码来源:ProtoIdItem.java


示例19: emitStringIndex

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Emits a string index as an unsigned LEB128. The actual value written
 * is shifted by 1, so that the '0' value is reserved for "null". The
 * null symbol is used in some cases by the parameter name list
 * at the beginning of the sequence.
 *
 * @param string {@code null-ok;} string to emit
 * @throws IOException
 */
private void emitStringIndex(CstString string) throws IOException {
    if ((string == null) || (file == null)) {
        output.writeUleb128(0);
    } else {
        output.writeUleb128(
                1 + file.getStringIds().indexOf(string));
    }

    if (DEBUG) {
        System.err.printf("Emit string %s\n",
                string == null ? "<null>" : string.toQuoted());
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:23,代码来源:DebugInfoEncoder.java


示例20: writeSize

import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
 * Gets the write size for a given value.
 *
 * @param value {@code non-null;} the string value
 * @return {@code >= 2}; the write size, in bytes
 */
private static int writeSize(CstString value) {
    int utf16Size = value.getUtf16Size();

    // The +1 is for the '\0' termination byte.
    return Leb128.unsignedLeb128Size(utf16Size)
        + value.getUtf8Size() + 1;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:StringDataItem.java



注:本文中的com.android.dx.rop.cst.CstString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Timestamp类代码示例发布时间:2022-05-23
下一篇:
Java RangeFacet类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap