Package railo.transformer.bytecode

Examples of railo.transformer.bytecode.BytecodeException


      fc=ASMUtil.getAncestorRetryFCStatement(stat,finallyLabels,label);
      name="retry";
    }
   
    if(fc==null)
      throw new BytecodeException(name+" must be inside a loop (for,while,do-while,<cfloop>,<cfwhile> ...)",stat.getStart());
   
    GeneratorAdapter adapter = bc.getAdapter();
   
    Label end;
    if(FlowControl.BREAK==flowType) end=((FlowControlBreak)fc).getBreakLabel();
View Full Code Here


  public static Page getAncestorPage(Statement stat) throws BytecodeException {
    Statement parent=stat;
    while(true)  {
      parent=parent.getParent();
      if(parent==null) {
        throw new BytecodeException("missing parent Statement of Statement",stat.getStart());
        //return null;
      }
      if(parent instanceof Pagereturn (Page) parent;
    }
  }
View Full Code Here

    Statement parent=stat;
    while(true)  {
      parent=parent.getParent();
      //print.ln(" - "+parent);
      if(parent==null) {
        throw new BytecodeException("missing parent Statement of Statement",stat.getStart());
        //return null;
      }
      if(parent instanceof TagComponent)
      //if(parent instanceof Tag && "component".equals(((Tag)parent).getTagLibTag().getName())) 
        return (Tag) parent;
View Full Code Here

  }


  public static Boolean toBoolean(Attribute attr, Position start) throws BytecodeException {
    if(attr==null)
      throw new BytecodeException("attribute does not exist",start);
   
    if(attr.getValue() instanceof Literal){
      Boolean b=((Literal)attr.getValue()).getBoolean(null);
      if(b!=null) return b;
    }
    throw new BytecodeException("attribute ["+attr.getName()+"] must be a constant boolean value",start);
   
   
  }
View Full Code Here

        local =bc.getAdapter().newLocal(t);
        db.locals.put(name, Integer.valueOf(local));
     
    }
    else
      throw new BytecodeException("there is already a variable declared with name ["+name+"]", getLine());
   
   
    //bc.getAdapter().visitLocalVariable(name, strType, null, db.start,db.end,x);
   
    if(value!=null){
View Full Code Here

  public Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException {
   
    Integer var=db.locals.get(operant);
    if(var==null)
      throw new BytecodeException("there is no variable with name ["+operation+"] in the enviroment", getLine());
   
    GeneratorAdapter a = bc.getAdapter();
   
    if(operation.startsWith("pos")) a.loadLocal(var.intValue());
    if("preDecrement".equals(operation))a.iinc(var.intValue(), -1);
View Full Code Here

  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

    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

            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

    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

TOP

Related Classes of railo.transformer.bytecode.BytecodeException

Copyright © 2018 www.massapicom. 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.