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


Java Bytecode.growStack方法代码示例

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


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

示例1: doit

import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
    throws CompileError
{
    if (args != null && !gen.isParamListName(args))
        throw new CompileError(Javac.proceedName
                + "() cannot take a parameter for field reading");

    int stack;
    if (isStatic(opcode))
        stack = 0;
    else {
        stack = -1;
        bytecode.addAload(targetVar);
    }

    if (fieldType instanceof CtPrimitiveType)
        stack += ((CtPrimitiveType)fieldType).getDataSize();
    else
        ++stack;

    bytecode.add(opcode);
    bytecode.addIndex(index);
    bytecode.growStack(stack);
    gen.setType(fieldType);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:26,代码来源:FieldAccess.java

示例2: doit

import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
    throws CompileError
{
    int num = gen.getMethodArgsLength(args); 
    if (num != dimension)
        throw new CompileError(Javac.proceedName
                + "() with a wrong number of parameters");

    gen.atMethodArgs(args, new int[num],
                     new int[num], new String[num]);
    bytecode.addOpcode(opcode);
    if (opcode == Opcode.ANEWARRAY)
        bytecode.addIndex(index);
    else if (opcode == Opcode.NEWARRAY)
        bytecode.add(index);
    else /* if (opcode == Opcode.MULTIANEWARRAY) */ {
        bytecode.addIndex(index);
        bytecode.add(dimension);
        bytecode.growStack(1 - dimension);
    }

    gen.setType(arrayType);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:24,代码来源:NewArray.java

示例3: atTryStmnt

import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
protected void atTryStmnt(Stmnt st) throws CompileError {
    Bytecode bc = bytecode;
    Stmnt body = (Stmnt)st.getLeft();
    if (body == null)
        return;

    ASTList catchList = (ASTList)st.getRight().getLeft();
    Stmnt finallyBlock = (Stmnt)st.getRight().getRight().getLeft();
    ArrayList gotoList = new ArrayList(); 

    JsrHook jsrHook = null;
    if (finallyBlock != null)
        jsrHook = new JsrHook(this);

    int start = bc.currentPc();
    body.accept(this);
    int end = bc.currentPc();
    if (start == end)
        throw new CompileError("empty try block");

    boolean tryNotReturn = !hasReturned;
    if (tryNotReturn) {
        bc.addOpcode(Opcode.GOTO);
        gotoList.add(new Integer(bc.currentPc()));
        bc.addIndex(0);   // correct later
    }

    int var = getMaxLocals();
    incMaxLocals(1);
    while (catchList != null) {
        // catch clause
        Pair p = (Pair)catchList.head();
        catchList = catchList.tail();
        Declarator decl = (Declarator)p.getLeft();
        Stmnt block = (Stmnt)p.getRight();

        decl.setLocalVar(var);

        CtClass type = resolver.lookupClassByJvmName(decl.getClassName());
        decl.setClassName(MemberResolver.javaToJvmName(type.getName()));
        bc.addExceptionHandler(start, end, bc.currentPc(), type);
        bc.growStack(1);
        bc.addAstore(var);
        hasReturned = false;
        if (block != null)
            block.accept(this);

        if (!hasReturned) {
            bc.addOpcode(Opcode.GOTO);
            gotoList.add(new Integer(bc.currentPc()));
            bc.addIndex(0);   // correct later
            tryNotReturn = true;
        }
    }

    if (finallyBlock != null) {
        jsrHook.remove(this);
        // catch (any) clause
        int pcAnyCatch = bc.currentPc();
        bc.addExceptionHandler(start, pcAnyCatch, pcAnyCatch, 0);
        bc.growStack(1);
        bc.addAstore(var);
        hasReturned = false;
        finallyBlock.accept(this);
        if (!hasReturned) {
            bc.addAload(var);
            bc.addOpcode(ATHROW);
        }

        addFinally(jsrHook.jsrList, finallyBlock);
    }

    int pcEnd = bc.currentPc();
    patchGoto(gotoList, pcEnd);
    hasReturned = !tryNotReturn;
    if (finallyBlock != null) {
        if (tryNotReturn)
            finallyBlock.accept(this);
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:81,代码来源:MemberCodeGen.java


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