001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.transformer.bytecode.expression.var; 020 021import lucee.transformer.bytecode.BytecodeContext; 022import lucee.transformer.bytecode.BytecodeException; 023import lucee.transformer.bytecode.cast.CastOther; 024import lucee.transformer.bytecode.expression.Expression; 025import lucee.transformer.bytecode.expression.ExpressionBase; 026import lucee.transformer.bytecode.util.ExpressionUtil; 027 028import org.objectweb.asm.Type; 029 030 031public class Argument extends ExpressionBase { 032 033 private Expression raw; 034 private String type; 035 036 public Argument(Expression value, String type) { 037 super(value.getStart(),value.getEnd()); 038 this.raw=value;//Cast.toExpression(value,type); 039 this.type=type; 040 } 041 042 /** 043 * @return the value 044 */ 045 public Expression getValue() { 046 return CastOther.toExpression(raw,type); 047 } 048 049 /** 050 * return the uncasted value 051 * @return 052 */ 053 public Expression getRawValue() { 054 return raw; 055 } 056 057 public void setValue(Expression value,String type) { 058 this.raw = value; 059 this.type=type; 060 061 } 062 063 /** 064 * 065 * @see lucee.transformer.bytecode.expression.ExpressionBase#_writeOut(org.objectweb.asm.commons.GeneratorAdapter, int) 066 */ 067 public Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException { 068 return getValue().writeOut(bc, mode); 069 } 070 071 public Type writeOutValue(BytecodeContext bc, int mode) throws BytecodeException { 072 ExpressionUtil.visitLine(bc, getStart()); 073 Type t = getValue().writeOut(bc, mode); 074 ExpressionUtil.visitLine(bc, getEnd()); 075 return t; 076 } 077 078 /** 079 * @return the type 080 */ 081 public String getStringType() { 082 return type; 083 } 084 }