当前位置: 首页>>代码示例>>Java>>正文


Java Opcode.RETURN属性代码示例

本文整理汇总了Java中scouter.javassist.bytecode.Opcode.RETURN属性的典型用法代码示例。如果您正苦于以下问题:Java Opcode.RETURN属性的具体用法?Java Opcode.RETURN怎么用?Java Opcode.RETURN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在scouter.javassist.bytecode.Opcode的用法示例。


在下文中一共展示了Opcode.RETURN属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isEmpty

/**
 * Returns true if the constructor (or static initializer)
 * is the default one.  This method returns true if the constructor
 * takes some arguments but it does not perform anything except
 * calling <code>super()</code> (the no-argument constructor of
 * the super class).
 */
public boolean isEmpty() {
    CodeAttribute ca = getMethodInfo2().getCodeAttribute();
    if (ca == null)
        return false;       // native or abstract??
                            // they are not allowed, though.

    ConstPool cp = ca.getConstPool();
    CodeIterator it = ca.iterator();
    try {
        int pos, desc;
        int op0 = it.byteAt(it.next());
        return op0 == Opcode.RETURN     // empty static initializer
            || (op0 == Opcode.ALOAD_0
                && it.byteAt(pos = it.next()) == Opcode.INVOKESPECIAL
                && (desc = cp.isConstructor(getSuperclassName(),
                                            it.u16bitAt(pos + 1))) != 0
                && "()V".equals(cp.getUtf8Info(desc))
                && it.byteAt(it.next()) == Opcode.RETURN
                && !it.hasNext());
    }
    catch (BadBytecode e) {}
    return false;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:30,代码来源:CtConstructor.java

示例2: atReturnStmnt2

protected final void atReturnStmnt2(ASTree result) throws CompileError {
    int op;
    if (result == null)
        op = Opcode.RETURN;
    else {
        compileExpr(result);
        if (arrayDim > 0)
            op = ARETURN;
        else {
            int type = exprType;
            if (type == DOUBLE)
                op = DRETURN;
            else if (type == FLOAT)
                op = FRETURN;
            else if (type == LONG)
                op = LRETURN;
            else if (isRefType(type))
                op = ARETURN;
            else
                op = IRETURN;
        }
    }

    for (ReturnHook har = returnHooks; har != null; har = har.next)
        if (har.doit(bytecode, op)) {
            hasReturned = true;
            return;
        }

    bytecode.addOpcode(op);
    hasReturned = true;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:32,代码来源:CodeGen.java

示例3: isEmpty

/**
 * Returns true if the method body is empty, that is, <code>{}</code>.
 * It also returns true if the method is an abstract method.
 */
public boolean isEmpty() {
    CodeAttribute ca = getMethodInfo2().getCodeAttribute();
    if (ca == null)         // abstract or native
        return (getModifiers() & Modifier.ABSTRACT) != 0;

    CodeIterator it = ca.iterator();
    try {
        return it.hasNext() && it.byteAt(it.next()) == Opcode.RETURN
            && !it.hasNext();
    }
    catch (BadBytecode e) {}
    return false;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:17,代码来源:CtMethod.java

示例4: makeDefaultBody

private static void makeDefaultBody(Bytecode b, CtClass type) {
    int op;
    int value;
    if (type instanceof CtPrimitiveType) {
        CtPrimitiveType pt = (CtPrimitiveType)type;
        op = pt.getReturnOp();
        if (op == Opcode.DRETURN)
            value = Opcode.DCONST_0;
        else if (op == Opcode.FRETURN)
            value = Opcode.FCONST_0;
        else if (op == Opcode.LRETURN)
            value = Opcode.LCONST_0;
        else if (op == Opcode.RETURN)
            value = Opcode.NOP;
        else
            value = Opcode.ICONST_0;
    }
    else {
        op = Opcode.ARETURN;
        value = Opcode.ACONST_NULL;
    }

    if (value != Opcode.NOP)
        b.addOpcode(value);

    b.addOpcode(op);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:27,代码来源:Javac.java

示例5: doit

protected boolean doit(Bytecode b, int opcode) {
    switch (opcode) {
    case Opcode.RETURN :
        jsrJmp(b);
        break;
    case ARETURN :
        b.addAstore(getVar(1));
        jsrJmp(b);
        b.addAload(var);
        break;
    case IRETURN :
        b.addIstore(getVar(1));
        jsrJmp(b);
        b.addIload(var);
        break;
    case LRETURN :
        b.addLstore(getVar(2));
        jsrJmp(b);
        b.addLload(var);
        break;
    case DRETURN :
        b.addDstore(getVar(2));
        jsrJmp(b);
        b.addDload(var);
        break;
    case FRETURN :
        b.addFstore(getVar(1));
        jsrJmp(b);
        b.addFload(var);
        break;
    default :
        throw new RuntimeException("fatal");
    }

    return false;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:36,代码来源:MemberCodeGen.java


注:本文中的scouter.javassist.bytecode.Opcode.RETURN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。