Package railo.transformer.bytecode.statement.java

Source Code of railo.transformer.bytecode.statement.java.VariableDecl

package railo.transformer.bytecode.statement.java;

import org.objectweb.asm.Type;

import railo.transformer.bytecode.BytecodeContext;
import railo.transformer.bytecode.BytecodeException;
import railo.transformer.bytecode.expression.ExpressionBase;
import railo.transformer.bytecode.util.Types;

public class VariableDecl extends ExpressionBase {

  private Class type;
  private String name;
  private Object value;
  private DataBag db;

  public VariableDecl(int line,Class type,String name,Object value, DataBag db) {
    super(line);
    this.type=type;
    this.name=name;
    this.value=value;
    this.db = db;
   
  }

  public Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException {
    Integer oLocal=db.locals.get(name);
    int local;
    Type t = null;
    if(oLocal==null){
     
        t = Type.getType(type);
        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){
      Type rtn = Assign.writeOut(db, bc, t,mode, value, getLine(),false);
     
      bc.getAdapter().storeLocal(local,t);
      return rtn;
    }
   
    return Types.VOID;
  }

 
 
}
TOP

Related Classes of railo.transformer.bytecode.statement.java.VariableDecl

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.