1 package polyglot.ext.pao.extension; 2 3 import polyglot.ast.Instanceof; 4 import polyglot.ast.Node; 5 import polyglot.ext.jl.ast.JL_c; 6 import polyglot.types.SemanticException; 7 import polyglot.types.Type; 8 import polyglot.visit.TypeChecker; 9 10 15 public class PaoInstanceofDel_c extends JL_c { 16 22 public Node typeCheck(TypeChecker tc) throws SemanticException { 23 Instanceof n = (Instanceof) node(); 24 Type rtype = n.compareType().type(); 25 Type ltype = n.expr().type(); 26 27 if (! tc.typeSystem().isCastValid(ltype, rtype)) { 28 throw new SemanticException( 29 "Left operand of \"instanceof\" must be castable to " 30 + "the right operand."); 31 } 32 33 return n.type(tc.typeSystem().Boolean()); 34 } 35 } 36 | Popular Tags |