1 /* 2 * Javassist, a Java-bytecode translator toolkit. 3 * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved. 4 * 5 * The contents of this file are subject to the Mozilla Public License Version 6 * 1.1 (the "License"); you may not use this file except in compliance with 7 * the License. Alternatively, the contents of this file may be used under 8 * the terms of the GNU Lesser General Public License Version 2.1 or later, 9 * or the Apache License Version 2.0. 10 * 11 * Software distributed under the License is distributed on an "AS IS" basis, 12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 * for the specific language governing rights and limitations under the 14 * License. 15 */ 16 17 package javassist.compiler.ast; 18 19 import javassist.compiler.CompileError; 20 import javassist.compiler.TokenId; 21 22 /** 23 * Cast expression. 24 */ 25 public class CastExpr extends ASTList implements TokenId { 26 /** default serialVersionUID */ 27 private static final long serialVersionUID = 1L; 28 protected int castType; 29 protected int arrayDim; 30 CastExpr(ASTList className, int dim, ASTree expr)31 public CastExpr(ASTList className, int dim, ASTree expr) { 32 super(className, new ASTList(expr)); 33 castType = CLASS; 34 arrayDim = dim; 35 } 36 CastExpr(int type, int dim, ASTree expr)37 public CastExpr(int type, int dim, ASTree expr) { 38 super(null, new ASTList(expr)); 39 castType = type; 40 arrayDim = dim; 41 } 42 43 /* Returns CLASS, BOOLEAN, INT, or ... 44 */ getType()45 public int getType() { return castType; } 46 getArrayDim()47 public int getArrayDim() { return arrayDim; } 48 getClassName()49 public ASTList getClassName() { return (ASTList)getLeft(); } 50 getOprand()51 public ASTree getOprand() { return getRight().getLeft(); } 52 setOprand(ASTree t)53 public void setOprand(ASTree t) { getRight().setLeft(t); } 54 55 @Override getTag()56 public String getTag() { return "cast:" + castType + ":" + arrayDim; } 57 58 @Override accept(Visitor v)59 public void accept(Visitor v) throws CompileError { v.atCastExpr(this); } 60 } 61