Examples of CompileException


Examples of org.jboss.byteman.rule.exception.CompileException

            binding.compile(mv, compileContext);
        }

        // check stack heights
        if (compileContext.getStackCount() != currentStack) {
            throw new CompileException("Event.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + currentStack);
        }
    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

            }
        }

        // ensure we have only increased the stack by the return value size
        if (compileContext.getStackCount() != currentStack + expected) {
            throw new CompileException("DollarExpression.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + (currentStack + expected));
        }

    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

        int currentStack = compileContext.getStackCount();
        int size = ((type.getNBytes() > 4) ? 2 : 1);

        if (index == HELPER_IDX) {
            // not allowed to reassign the helper binding
            throw new CompileException("DollarExpression.compileAssign : invalid assignment to helper binding $$");
        } else {
            // value to be assigned is TOS and will already be coerced to the correct value type
            // copy it so we leave it as a a return value on the stack
            if (size == 2) {
                mv.visitInsn(Opcodes.DUP2);
            } else {
                mv.visitInsn(Opcodes.DUP);
            }
            // stack the current helper then insert it below the value
            mv.visitVarInsn(Opcodes.ALOAD, 0);
            if (size == 2) {
                // use a DUP_X2 to push a copy below the value then pop the redundant value
                mv.visitInsn(Opcodes.DUP_X2);
                mv.visitInsn(Opcodes.POP);
            } else {
                // we can just swap the two values
                mv.visitInsn(Opcodes.SWAP);
            }
            // stack the name for the variable and swap below the value
            mv.visitLdcInsn(targetName);
            if (size == 2) {
                // use a DUP_X2 to push a copy below the value then pop the redundant value
                mv.visitInsn(Opcodes.DUP_X2);
                // this is the high water mark
                // at this point the stack has gone from [ .. val1 val2]  to [.. val1 val2 helper name val1 val2 name]
                compileContext.addStackCount(5);
                mv.visitInsn(Opcodes.POP);
                compileContext.addStackCount(-1);
            } else {
                // this is the high water mark
                // at this point the stack has gone from [ .. val]  to [.. val helper val name]
                compileContext.addStackCount(3);
                // we can just swap the two values
                mv.visitInsn(Opcodes.SWAP);
            }
            // ensure we have an object
            compileObjectConversion(type, Type.OBJECT, mv, compileContext);

            // call the setBinding method
            mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, Type.internalName(HelperAdapter.class), "setBinding", "(Ljava/lang/String;Ljava/lang/Object;)V");

            // the call will remove 3 from the stack height
            compileContext.addStackCount(-3);

            // ok, the stack height should be as it was
            if (compileContext.getStackCount() != currentStack) {
                throw new CompileException("variable.compileAssignment : invalid stack height " + compileContext.getStackCount() + " expecting " + currentStack);
            }
        }
    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

            }
        }

        // check original stack height has been restored
        if (compileContext.getStackCount() != currentStack) {
            throw new CompileException("Action.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + currentStack);
        }
    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

        // This is the end, my beau-tiful friend
        mv.visitLabel(endLabel);
        // in either case if we get here we should have one extra value on the stack
        // check stack height
        if (compileContext.getStackCount() != currentStack + 1) {
            throw new CompileException("LogicalExpression.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + (currentStack + 1));
        }
    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

            adapterClass = loadHelperAdapter(loader, externalName, classBytes);
        } catch(CompileException ce) {
            throw ce;
        } catch (Throwable th) {
            if (compileToBytecode) {
                throw new CompileException("Compiler.createHelperAdapter : exception creating compiled helper adapter for " + helperClass.getName(), th);
            } else {
                throw new CompileException("Compiler.createHelperAdapter : exception creating interpreted helper adapter for " + helperClass.getName(), th);
            }
        }

        return adapterClass;
    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

        try {
            superConstructor = helperClass.getDeclaredConstructor(Rule.class);
        } catch (NoSuchMethodException e) {
            // hmm, ok see if there is an empty constructor
        } catch (SecurityException e) {
            throw new CompileException("Compiler.compileBytes : unable to access constructor for helper class " + helperClass.getCanonicalName());
        }
        boolean superWantsRule = (superConstructor != null);
        if (!superWantsRule) {
            try {
                superConstructor = helperClass.getDeclaredConstructor();
            } catch (NoSuchMethodException e) {
                throw new CompileException("Compiler.compileBytes : no valid constructor found for helper class " + helperClass.getCanonicalName());
            } catch (SecurityException e) {
                throw new CompileException("Compiler.compileBytes : unable to access constructor for helper class " + helperClass.getCanonicalName());
            }
        }
        //
        //  public Compiled<helper>_<NNN>()Rule rule)
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Lorg/jboss/byteman/rule/Rule;)V", null, null);
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

            compileUnbox(Type.BOOLEAN, Type.Z, mv, compileContext);
        }

        // check stack heights
        if (compileContext.getStackCount() != currentStack + 1) {
            throw new CompileException("Condition.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + currentStack);
        }
    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

                compileContext.addStackCount(1 - arrayDimDefinedCount);
            }
        }

        if (compileContext.getStackCount() != currentStack + expected) {
            throw new CompileException("NewExpression.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + (currentStack + expected));
        }
    }
View Full Code Here

Examples of org.jboss.byteman.rule.exception.CompileException

                    case MOD:
                        mv.visitInsn(Opcodes.IREM);
                        break;
                    default:
                        // should never happen
                        throw new CompileException("ArithmeticExpression.compile : unexpected operator " + oper);
                }
                // now coerce back to appropriate type
                if (type == type.B) {
                    mv.visitInsn(Opcodes.I2B);
                } else if (type == type.S) {
                    mv.visitInsn(Opcodes.I2S);
                } else if (type == type.C) {
                    mv.visitInsn(Opcodes.I2C);
                } // else if (type == type.I) { do nothing }
                // ok, we popped two bytes but added one
                compileContext.addStackCount(-1);
            else if (type == type.J) {

                expectedStack = 2;

                switch (oper)
                {
                    case MUL:
                        mv.visitInsn(Opcodes.LMUL);
                        break;
                    case DIV:
                        mv.visitInsn(Opcodes.LDIV);
                        break;
                    case PLUS:
                        mv.visitInsn(Opcodes.LADD);
                        break;
                    case MINUS:
                        mv.visitInsn(Opcodes.LSUB);
                        break;
                    case MOD:
                        mv.visitInsn(Opcodes.LREM);
                        break;
                    default:
                        // should never happen
                        throw new CompileException("ArithmeticExpression.compile : unexpected operator " + oper);
                }
                // ok, we popped four bytes but added two
                compileContext.addStackCount(-2);
            else if (type == type.F) {

                expectedStack = 1;

                switch (oper)
                {
                    case MUL:
                        mv.visitInsn(Opcodes.FMUL);
                        break;
                    case DIV:
                        mv.visitInsn(Opcodes.FDIV);
                        break;
                    case PLUS:
                        mv.visitInsn(Opcodes.FADD);
                        break;
                    case MINUS:
                        mv.visitInsn(Opcodes.FSUB);
                        break;
                    case MOD:
                        mv.visitInsn(Opcodes.FREM);
                        break;
                    default:
                        // should never happen
                        throw new CompileException("ArithmeticExpression.compile : unexpected operator " + oper);
                }
                // ok, we popped two bytes but added one
                compileContext.addStackCount(-1);
            else if (type == type.D) {

                expectedStack = 2;

                switch (oper)
                {
                    case MUL:
                        mv.visitInsn(Opcodes.DMUL);
                        break;
                    case DIV:
                        mv.visitInsn(Opcodes.DDIV);
                        break;
                    case PLUS:
                        mv.visitInsn(Opcodes.DADD);
                        break;
                    case MINUS:
                        mv.visitInsn(Opcodes.DSUB);
                        break;
                    case MOD:
                        mv.visitInsn(Opcodes.DREM);
                        break;
                    default:
                        // should never happen
                        throw new CompileException("ArithmeticExpression.compile : unexpected operator " + oper);
                }
                // ok, we popped four bytes but added two
                compileContext.addStackCount(-2);
            } else {
                throw new CompileException("ArithmeticExpression.compile : unexpected result type " + type.getName());
            }
        } catch (CompileException e) {
            throw e;
        } catch (Exception e) {
            throw new CompileException("ArithmeticExpression.compile : unexpected exception for operation " + token + getPos() + " in rule " + rule.getName(), e);
        }

        // check stack heights
        if (compileContext.getStackCount() != currentStack + expectedStack) {
            throw new CompileException("ArithmeticExpression.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + (currentStack + expectedStack));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.