Examples of BytecodeException


Examples of railo.transformer.bytecode.BytecodeException

  public Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException {
   
    Integer local=db.locals.get(name);
    if(local==null){
      throw new BytecodeException("there is no variable declaration for ["+name+"]", getLine());
    }
    Type t = bc.getAdapter().getLocalType(local.intValue());
    if("assign".equals(operator))writeOut(db,bc,t,mode,value,getLine(),false);
    else{
      new Operation(getLine(), name, value, operator, db).writeOut(bc, mode);
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

    if(value instanceof Expression)
      from=((Expression)value).writeOut(bc, mode);
    else {
      Integer var=db.locals.get(value);
      if(var==null)
        throw new BytecodeException("there is no variable with name ["+value+"] in the enviroment", line);
      from=bc.getAdapter().getLocalType(var.intValue());
      bc.getAdapter().loadLocal(var.intValue(),from);
     
    }
    if(to!=null && !from.equals(to)){
      boolean isRefFrom = ASMUtil.isRefType(from);
      boolean isRefTo = ASMUtil.isRefType(to);
     
      if(castExplicit) {
        Class fc=null,tc=null;
     
        if(!isRefFrom && !isRefTo){
          fc = ASMUtil.getValueTypeClass(from,null);
          tc = ASMUtil.getValueTypeClass(to,null);
        }
        else {
          try {
            fc = ClassUtil.loadClass(from.getClassName());
            tc = ClassUtil.loadClass(to.getClassName());
          }
          catch (ClassException e) {
            throw new BytecodeException(e, line);
          }
        }
        if(((tc==boolean.class && fc!=boolean.class))||(fc==boolean.class && tc!=boolean.class))
          throw new BytecodeException("cannot cast from ["+fc.getName()+"] to ["+tc.getName()+"]", line);
        bc.getAdapter().cast(from, to);
      }
      else {
       
        // unbox
        if(isRefFrom && !isRefTo){
          bc.getAdapter().unbox(to);
          from=ASMUtil.toValueType(from);
          isRefFrom=false;
        }
        // box
        else if(!isRefFrom && isRefTo){
          bc.getAdapter().box(from);
          from=ASMUtil.toRefType(from);
          isRefFrom=true;
        }
       
       
       
       
        // value types
        if(!isRefFrom && !isRefTo){
          Class fc = ASMUtil.getValueTypeClass(from,null);
          Class tc = ASMUtil.getValueTypeClass(to,null);
          if(Reflector.canConvert(fc, tc))
            bc.getAdapter().cast(from, to);
          else {
            boolean doThrow=true;
            if(value instanceof LitDouble){
              double d=((LitDouble)value).getDoubleValue();
              if(canConvert(d, tc)){
                bc.getAdapter().cast(from, to);
                doThrow=false;
              }
            }
            if(value instanceof LitFloat){
              float f=((LitFloat)value).getFloatValue();
              if(canConvert(f, tc)){
                bc.getAdapter().cast(from, to);
                doThrow=false;
              }
            }
            if(value instanceof LitInteger){
              int i=((LitInteger)value).geIntValue();
              if(canConvert(i, tc)){
                bc.getAdapter().cast(from, to);
                doThrow=false;
              }
            }
           
            if(doThrow)throw new BytecodeException("cannot convert from ["+fc.getName()+"] to ["+tc.getName()+"]", line);
          }
        }
       
        // ref types
        else {
         
          try {
            Class fc = ClassUtil.loadClass(from.getClassName());
            Class tc = ClassUtil.loadClass(to.getClassName());
            if(value instanceof NullExpression || Reflector.isInstaneOf(fc, tc))
              bc.getAdapter().cast(from, to);
            else
              throw new BytecodeException("cannot convert from ["+fc.getName()+"] to ["+tc.getName()+"]", line);
          }
          catch (ClassException e) {
            throw new BytecodeException(e, line);
          }
        }
      }
    }
    return from;
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

            rtn=Types.OBJECT;
      }
     
      // UDF
      else if(member instanceof UDF) {
        if(last)throw new BytecodeException("can't asign value to a user defined function",getStart());
        UDF udf=(UDF) member;
        boolean isKey=Variable.registerKey(bc, udf.getName());
        //udf.getName().writeOut(bc, MODE_REF);
        ExpressionUtil.writeOutExpressionArray(bc, Types.OBJECT, udf.getArguments());
       
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

    if(member instanceof DataMember) {
      return _writeOutOneDataMember(bc,(DataMember)member,last,doOnlyScope);
      //return Variable._writeOutFirstDataMember(adapter,(DataMember)member,variable.scope, last);
    }
      else if(member instanceof UDF) {
        if(last)throw new BytecodeException("can't assign value to a user defined function",getStart());
        return Variable._writeOutFirstUDF(bc,(UDF)member,variable.scope,doOnlyScope);
      }
      else {
        if(last)throw new BytecodeException("can't assign value to a built in function",getStart());
        return Variable._writeOutFirstBIF(bc,(BIF)member,mode,last,getStart());
      }
  }
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

    if(expr instanceof ExprString) return (ExprString) expr;
    return LitString.toExprString(translateVariableToString(expr,rawIfPossible), expr.getStart(),expr.getEnd());
  }
 
  private static String translateVariableToString(Expression expr, boolean rawIfPossible) throws BytecodeException {
    if(!(expr instanceof Variable)) throw new BytecodeException("can't translate value to a string",expr.getStart());
    return variableToString((Variable) expr,rawIfPossible);
  }
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

    Iterator it = members.iterator();
    DataMember dm;
    Expression n;
    while(it.hasNext()) {
      Object o = it.next();
      if(!(o instanceof DataMember)) throw new BytecodeException("can't translate Variable to a String",var.getStart());
      dm=(DataMember) o;
      n=dm.getName();
      if(n instanceof Literal) {
        if(rawIfPossible && n instanceof Identifier) {
          arr.add(((Identifier) n).getRaw());
        }
        else {
          arr.add(((Literal) n).getString());
        }
      }
      else throw new BytecodeException("argument name must be a constant value",var.getStart());
    }
    return arr.toArray(new String[arr.size()]);
  }
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

          else vt.value.writeOut(bc, Types.isPrimitiveType(argTypes[index])?MODE_VALUE:MODE_REF);
        }
       
        for(int y=0;y<names.length;y++){
          if(names[y]!=null) {
            BytecodeException bce = new BytecodeException("argument ["+names[y]+"] is not allowed for function ["+bif.getFlf().getName()+"]", args[y].getStart());
            UDFUtil.addFunctionDoc(bce, bif.getFlf());
            throw bce;
          }
        }
       
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

   
    // if not required return the default value
    if(!flfa.getRequired()) {
      return getDefaultValue(flfa);
    }
    BytecodeException be = new BytecodeException("missing required argument ["+flfan+"] for function ["+flfa.getFunction().getName()+"]",line);
    UDFUtil.addFunctionDoc(be, flfa.getFunction());
    throw be;
  }
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

    return new VT(CastOther.toExpression(LitString.toExprString(defaultValue), type),type,-1);
  }

  private static String getName(Expression expr) throws BytecodeException {
    String name = ASMUtil.toString(expr);
    if(name==null) throw new BytecodeException("cannot extract a string from a object of type ["+expr.getClass().getName()+"]",null);
    return name;
  }
View Full Code Here

Examples of railo.transformer.bytecode.BytecodeException

    if(ArrayUtil.isEmpty(args)) return false;
    boolean named=false;
    for(int i=0;i<args.length;i++){
      if(args[i] instanceof NamedArgument)named=true;
      else if(named)
        throw new BytecodeException("invalid argument for function "+funcName+", you can not mix named and unnamed arguments", args[i].getStart());
    }
   
   
    return named;
  }
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.