< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java

Print this page




2199         result = genExpr(tree.expr, tree.clazz.type).load();
2200         setTypeAnnotationPositions(tree.pos);
2201         // Additional code is only needed if we cast to a reference type
2202         // which is not statically a supertype of the expression's type.
2203         // For basic types, the coerce(...) in genExpr(...) will do
2204         // the conversion.
2205         if (!tree.clazz.type.isPrimitive() &&
2206            !types.isSameType(tree.expr.type, tree.clazz.type) &&
2207            types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) {
2208             code.emitop2(checkcast, checkDimension(tree.pos(), tree.clazz.type), PoolWriter::putClass);
2209         }
2210     }
2211 
2212     public void visitWildcard(JCWildcard tree) {
2213         throw new AssertionError(this.getClass().getName());
2214     }
2215 
2216     public void visitTypeTest(JCInstanceOf tree) {
2217         genExpr(tree.expr, tree.expr.type).load();
2218         setTypeAnnotationPositions(tree.pos);
2219         code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
2220         result = items.makeStackItem(syms.booleanType);
2221     }
2222 
2223     public void visitIndexed(JCArrayAccess tree) {
2224         genExpr(tree.indexed, tree.indexed.type).load();
2225         genExpr(tree.index, syms.intType).load();
2226         result = items.makeIndexedItem(tree.type);
2227     }
2228 
2229     public void visitIdent(JCIdent tree) {
2230         Symbol sym = tree.sym;
2231         if (tree.name == names._this || tree.name == names._super) {
2232             Item res = tree.name == names._this
2233                 ? items.makeThisItem()
2234                 : items.makeSuperItem();
2235             if (sym.kind == MTH) {
2236                 // Generate code to address the constructor.
2237                 res.load();
2238                 res = items.makeMemberItem(sym, true);
2239             }




2199         result = genExpr(tree.expr, tree.clazz.type).load();
2200         setTypeAnnotationPositions(tree.pos);
2201         // Additional code is only needed if we cast to a reference type
2202         // which is not statically a supertype of the expression's type.
2203         // For basic types, the coerce(...) in genExpr(...) will do
2204         // the conversion.
2205         if (!tree.clazz.type.isPrimitive() &&
2206            !types.isSameType(tree.expr.type, tree.clazz.type) &&
2207            types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) {
2208             code.emitop2(checkcast, checkDimension(tree.pos(), tree.clazz.type), PoolWriter::putClass);
2209         }
2210     }
2211 
2212     public void visitWildcard(JCWildcard tree) {
2213         throw new AssertionError(this.getClass().getName());
2214     }
2215 
2216     public void visitTypeTest(JCInstanceOf tree) {
2217         genExpr(tree.expr, tree.expr.type).load();
2218         setTypeAnnotationPositions(tree.pos);
2219         code.emitop2(instanceof_, makeRef(tree.pos(), tree.pattern.type));
2220         result = items.makeStackItem(syms.booleanType);
2221     }
2222 
2223     public void visitIndexed(JCArrayAccess tree) {
2224         genExpr(tree.indexed, tree.indexed.type).load();
2225         genExpr(tree.index, syms.intType).load();
2226         result = items.makeIndexedItem(tree.type);
2227     }
2228 
2229     public void visitIdent(JCIdent tree) {
2230         Symbol sym = tree.sym;
2231         if (tree.name == names._this || tree.name == names._super) {
2232             Item res = tree.name == names._this
2233                 ? items.makeThisItem()
2234                 : items.makeSuperItem();
2235             if (sym.kind == MTH) {
2236                 // Generate code to address the constructor.
2237                 res.load();
2238                 res = items.makeMemberItem(sym, true);
2239             }


< prev index next >