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


Java StackProducer类代码示例

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


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

示例1: push

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Pushes a value to the operand stack.
 *
 * @param producer the instruction producing the value being pushed
 */
public void push(StackProducer producer) {
    Klass type = producer.getType();
    Assert.that(type != Klass.VOID);

    /*
     * Check for overflow and push the producer.
     */
    if (sp == maxStack) {
        throw codeParser.verifyError("operand stack overflow");
    }
    stack[sp++] = producer;

    /*
     * For long and double check for overflow and then add a null word to the stack.
     */
    if (type.isDoubleWord()) {
        if (sp == maxStack) {
            throw codeParser.verifyError("operand stack overflow");
        }
        stack[sp++] = null;
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:28,代码来源:Frame.java

示例2: containsType

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Determines if the operand stack or local variable array currently
 * contains an entry whose type is equal to or a subtype of a given type.
 *
 * @param  type  the type to search for
 * @return true if an entry was found
 */
public boolean containsType(Klass type) {
    for (int i = 0 ; i < localTypes.length ; i++) {
        if (type.isAssignableFrom(localTypes[i])) {
            return true;
        }
    }
    for (int i = 0 ; i < sp ; i++) {
        StackProducer producer = stack[i];
        if (producer != null && type.isAssignableFrom(producer.getType())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:22,代码来源:Frame.java

示例3: replaceTypeWithType

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Changes the type of any object in a local variable or on the operand
 * stack whose current type is matches <code>fromType</code> to be
 * <code>toType</code>.
 */
public void replaceTypeWithType(Klass fromType, Klass toType) {
    for (int i = 0 ; i < localTypes.length ; i++) {
        if (localTypes[i] == fromType) {
            localTypes[i] = toType;
        }
    }
    for (int i = 0 ; i < sp ; i++) {
        StackProducer producer = stack[i];
        if (producer != null && producer.getType() == fromType) {
            producer.updateType(toType);
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:19,代码来源:Frame.java

示例4: getTopOfStack

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Gets the stack producer that wrote the value at the top of the
 * operand stack.
 *
 * @return  the stack producer that wrote the value at index <code>index</code> on the operand stack, or null if stack is empty.
 */
public StackProducer getTopOfStack() {
    if (isTopDoubleWord()) {
        Assert.that(stack[sp-2] != null);
        return stack[sp-2];
    } else if (sp > 0) {
        Assert.that(stack[sp-1] != null);
        return stack[sp-1];
    } else {
        return null;
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:18,代码来源:Frame.java

示例5: resetStack

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
     * Reset the state of the operand stack based on the stack state recorded
     * for a given target.
     *
     * @param target       the target whose recorded state will be used to
     *                     reset the state of this frame's operand stack
     * @param isForCatch   specifies if target corresponds to an exception
     *                     handler entry
     */
    public void resetStack(Target target, boolean isForCatch) {
        Klass[] recordedTypes = target.getStack();
        if (!isForCatch) {
            sp = 0;
            if (recordedTypes.length != 0) {
                StackProducer[] derivedStack = target.getDerivedStack();
                boolean isBackwardBranchTarget = (derivedStack[0] == null);
                if (isBackwardBranchTarget) {
                    for (int i = 0 ; i < recordedTypes.length ; i++) {
                        Klass recordedType = recordedTypes[i];
                        if (recordedType != Klass.LONG2
/*if[FLOATS]*/
                            && recordedType != Klass.DOUBLE2
/*end[FLOATS]*/
                            ) {
                            StackMerge merge = new StackMerge(recordedType);
                            // Sometimes we end up with old derivedStack[0] == a StackMerge with no producers.
                            Assert.that(derivedStack[0] == null || !derivedStack[0].isOnStack());
                            derivedStack[0] = merge;
                            push(merge);
                        }
                    }
                } else {
                    while (sp != derivedStack.length) {
                        StackProducer producer = derivedStack[sp];
                        stack[sp++] = producer;
                    }
                }
            }
        } else {
            //Assert.that(sp == 0);
            sp = 0;
        }
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:44,代码来源:Frame.java

示例6: spillStack

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
     * Spill each item on the operand stack.
     */
    public void spillStack() {
//System.out.println("** spillStack ** --------------------------------------------------------------------------");
        for (int i = 0 ; i < sp ; i++) {
            StackProducer producer = stack[i];
            if (producer != null) {
                spill(producer);
            }
        }
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:13,代码来源:Frame.java

示例7: tosKlassName

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Returns the internal name of the top type on the stack.
 *
 * @return  the name
 */
private String tosKlassName() {
    StackProducer top = stack[sp - (isTopDoubleWord() ? 2 : 1)];
    if (top == null) {
        return "null";
    }
    return top.getType().getInternalName();
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:13,代码来源:Frame.java

示例8: resetStack

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Reset the state of the operand stack based on the stack state recorded
 * for a given target.
 *
 * @param target       the target whose recorded state will be used to
 *                     reset the state of this frame's operand stack
 * @param isForCatch   specifies if target corresponds to an exception
 *                     handler entry
 */
public void resetStack(Target target, boolean isForCatch) {
    Klass[] recordedTypes = target.getStack();
    if (!isForCatch) {
        sp = 0;
        if (recordedTypes.length != 0) {
            StackProducer[] derivedStack = target.getDerivedStack();
            boolean isBackwardBranchTarget = (derivedStack[0] == null);
            if (isBackwardBranchTarget) {
                for (int i = 0 ; i < recordedTypes.length ; i++) {
                    Klass recordedType = recordedTypes[i];
                    if (recordedType != Klass.LONG2

                        && recordedType != Klass.DOUBLE2

                        ) {
                        StackMerge merge = new StackMerge(recordedType);
                        // Sometimes we end up with old derivedStack[0] == a StackMerge with no producers.
                        Assert.that(derivedStack[0] == null || !derivedStack[0].isOnStack());
                        derivedStack[0] = merge;
                        push(merge);
                    }
                }
            } else {
                while (sp != derivedStack.length) {
                    StackProducer producer = derivedStack[sp];
                    stack[sp++] = producer;
                }
            }
        }
    } else {
        //Assert.that(sp == 0);
        sp = 0;
    }
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:44,代码来源:Frame.java

示例9: pop

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
     * Pops a value off the operand stack.
     *
     * @param type the type that the value popped off the operand stack  must be assignable to
     * @return the instruction that produced the popped value
     */
    public StackProducer pop(Klass type) {
        StackProducer producer;
        if (type.isDoubleWord()) {
            if (sp < 2) {
                throw codeParser.verifyError("operand stack underflow");
            }
            if (!isTopDoubleWord()) {
                throw codeParser.verifyError("incompatible type on operand stack "+tosKlassName());
            }
            sp -= 2;
            producer = stack[sp];
        } else {
            if (sp < 1) {
                throw codeParser.verifyError("operand stack underflow");
            }
            if (isTopDoubleWord()) {
                throw codeParser.verifyError("incompatible type on operand stack "+tosKlassName());
            }
            producer = stack[--sp];

            /*
             * The primitive one-word, non-float types are all assignment compatible with each other
             */
            if (type.isPrimitive()
/*if[FLOATS]*/
                && type != Klass.FLOAT
/*end[FLOATS]*/
                ) {
                type = Klass.INT;
            }
        }

        Assert.that(producer != null);

        /*
         * Interfaces are treated as java.lang.Object in the verifier.
         */
        if (type.isInterface()) {
            type = Klass.OBJECT;
        }

        /*
         * Verify that the instruction is producing the correct type.
         */
        if (!type.isAssignableFrom(producer.getType())) {
            throw codeParser.verifyError("incompatible type: '"+type+"' is not assignable from '"+producer.getType() + "'");
        }


        return producer;
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:58,代码来源:Frame.java

示例10: spill

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Spill the result of an instruction.
 *
 * @param producer the instruction producing the value
 */
public void spill(StackProducer producer) {
    if (!producer.isSpilt()) {
        producer.spill(allocateLocalForSpill(producer));
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:11,代码来源:Frame.java

示例11: pop

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Pops a value off the operand stack.
 *
 * @param type the type that the value popped off the operand stack  must be assignable to
 * @return the instruction that produced the popped value
 */
public StackProducer pop(Klass type) {
    StackProducer producer;
    if (type.isDoubleWord()) {
        if (sp < 2) {
            throw codeParser.verifyError("operand stack underflow");
        }
        if (!isTopDoubleWord()) {
            throw codeParser.verifyError("incompatible type on operand stack "+tosKlassName());
        }
        sp -= 2;
        producer = stack[sp];
    } else {
        if (sp < 1) {
            throw codeParser.verifyError("operand stack underflow");
        }
        if (isTopDoubleWord()) {
            throw codeParser.verifyError("incompatible type on operand stack "+tosKlassName());
        }
        producer = stack[--sp];

        /*
         * The primitive one-word, non-float types are all assignment compatible with each other
         */
        if (type.isPrimitive()

            && type != Klass.FLOAT

            ) {
            type = Klass.INT;
        }
    }

    Assert.that(producer != null);

    /*
     * Interfaces are treated as java.lang.Object in the verifier.
     */
    if (type.isInterface()) {
        type = Klass.OBJECT;
    }

    /*
     * Verify that the instruction is producing the correct type.
     */
    if (!type.isAssignableFrom(producer.getType())) {
        throw codeParser.verifyError("incompatible type: '"+type+"' is not assignable from '"+producer.getType() + "'");
    }


    return producer;
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:58,代码来源:Frame.java

示例12: ensureStack

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Ensure that the operand stack is large enough to meet a given limit. The
 * operand stack is expanded if necessary.
 *
 * @param limit  the minimum size of the operand stack to be guaranteed by this method
 */
private void ensureStack(int limit) {
    if (limit > stack.length) {
        stack = (StackProducer[])Arrays.copy(stack, 0, new StackProducer[limit], 0, stack.length);
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:12,代码来源:Frame.java

示例13: getStackAt

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Gets the stack producer that wrote the value at a given index on the
 * operand stack. The <code>index</code> must not indicate a stack slot
 * that corresponds to the second word of a double word value.
 *
 * @param   index  the operand stack index for which the corresponding stack producer is requested
 * @return  the stack producer that wrote the value at index <code>index</code> on the operand stack
 */
public StackProducer getStackAt(int index) {
    Assert.that(index < sp, "index out of bounds");
    Assert.that(stack[index] != null, "cannot index the second word of a double word value");
    return stack[index];
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:14,代码来源:Frame.java

示例14: allocateLocalForSpill

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Allocate local that is used for spilling.
 *
 * @param producer the instruction producing the value that needs to be spilled
 * @return a unique local to be used to hold the value
 */
public Local allocateLocalForSpill(StackProducer producer) {
    Klass type = getLocalTypeFor(producer.getType());
    return new Local(type, --nextSpillLocalId, false);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:11,代码来源:Frame.java

示例15: doOperand

import com.sun.squawk.translator.ir.instr.StackProducer; //导入依赖的package包/类
/**
 * Visits a single given operand of a given instruction.
 *
 * @param   instruction  the instruction being visited
 * @param   operand      an operand of <code>instruction</code>
 * @return  the value of the operand which may be different from the original value
 */
public StackProducer doOperand(Instruction instruction, StackProducer operand);
 
开发者ID:tomatsu,项目名称:squawk,代码行数:9,代码来源:OperandVisitor.java


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