本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCInstanceOf类的典型用法代码示例。如果您正苦于以下问题:Java JCInstanceOf类的具体用法?Java JCInstanceOf怎么用?Java JCInstanceOf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JCInstanceOf类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCInstanceOf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
protected int diffTypeTest(JCInstanceOf oldT, JCInstanceOf newT, int[] bounds) {
int localPointer = bounds[0];
// expr
int[] exprBounds = getBounds(oldT.expr);
copyTo(localPointer, exprBounds[0]);
localPointer = diffTree(oldT.expr, newT.expr, exprBounds);
// clazz
int[] clazzBounds = getBounds(oldT.clazz);
clazzBounds[0] = copyUpTo(localPointer, clazzBounds[0]);
localPointer = diffTree(oldT.clazz, newT.clazz, clazzBounds);
localPointer = copyUpTo(localPointer, bounds[1]);
return localPointer;
}
示例2: visitTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
public void visitTypeTest(JCInstanceOf that) {
try {
print("JCInstanceOf:");
} catch (Exception e) {
}
super.visitTypeTest(that);
}
示例3: visitTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
public void visitTypeTest(JCInstanceOf tree) {
try {
open(prec, TreeInfo.ordPrec);
printExpr(tree.expr, TreeInfo.ordPrec);
print(" instanceof ");
printExpr(tree.clazz, TreeInfo.ordPrec + 1);
close(prec, TreeInfo.ordPrec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例4: visitInstanceOf
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
@Override
public Choice<State<JCInstanceOf>> visitInstanceOf(final InstanceOfTree node, State<?> state) {
return chooseSubtrees(
state,
s -> unifyExpression(node.getExpression(), s),
expr -> maker().TypeTest(expr, (JCTree) node.getType()));
}
示例5: visitTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
public void visitTypeTest(JCInstanceOf tree) {
try {
open(prec, TreeInfo.ordPrec);
printExpr(tree.expr, TreeInfo.ordPrec);
print(" instanceof ");
printExpr(tree.clazz, TreeInfo.ordPrec + 1);
close(prec, TreeInfo.ordPrec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例6: visitTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
public void visitTypeTest(JCInstanceOf tree) {
Type exprtype = chk.checkNullOrRefType(
tree.expr.pos(), attribExpr(tree.expr, env));
Type clazztype = chk.checkReifiableReferenceType(
tree.clazz.pos(), attribType(tree.clazz, env));
chk.validate(tree.clazz, env, false);
chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
result = check(tree, syms.booleanType, VAL, pkind, pt);
}
示例7: matchTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
private boolean matchTypeTest(JCInstanceOf t1, JCInstanceOf t2) {
return treesMatch(t1.clazz, t2.clazz) && treesMatch(t1.expr, t2.expr);
}
示例8: TypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
public JCInstanceOf TypeTest(JCExpression expr, JCTree clazz) {
return invoke(TypeTest, expr, clazz);
}
示例9: visitTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
@Override public void visitTypeTest(JCInstanceOf tree) {
print(tree.expr);
print(" instanceof ");
print(tree.clazz);
}
示例10: AJCInstanceOf
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
public AJCInstanceOf(JCInstanceOf ltree) {
super(ltree.expr, ltree.clazz);
}
示例11: inline
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
@Override
public JCInstanceOf inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner.maker().TypeTest(getExpression().inline(inliner), getType().inline(inliner));
}
示例12: getPrecedence
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
/**
* Returns the precedence level appropriate for unambiguously printing
* leaf as a subexpression of its parent.
*/
private static int getPrecedence(JCTree leaf, Context context) {
JCCompilationUnit comp = context.get(JCCompilationUnit.class);
JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);
// In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
//
// TODO(mdempsky): There are probably cases where we could omit parentheses
// by tweaking the returned precedence, but they need careful review.
// For example, consider a template to replace "add(a, b)" with "a + b",
// which applied to "x + add(y, z)" would result in "x + (y + z)".
// In most cases, we'd likely prefer "x + y + z" instead, but those aren't
// always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
// a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
// to integer promotion rules.
if (parent instanceof JCConditional) {
// This intentionally differs from Pretty, because Pretty appears buggy:
// http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
JCConditional conditional = (JCConditional) parent;
return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
} else if (parent instanceof JCAssign) {
JCAssign assign = (JCAssign) parent;
return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
} else if (parent instanceof JCAssignOp) {
JCAssignOp assignOp = (JCAssignOp) parent;
return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
} else if (parent instanceof JCUnary) {
return TreeInfo.opPrec(parent.getTag());
} else if (parent instanceof JCBinary) {
JCBinary binary = (JCBinary) parent;
return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
} else if (parent instanceof JCTypeCast) {
JCTypeCast typeCast = (JCTypeCast) parent;
return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
} else if (parent instanceof JCInstanceOf) {
JCInstanceOf instanceOf = (JCInstanceOf) parent;
return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
} else if (parent instanceof JCArrayAccess) {
JCArrayAccess arrayAccess = (JCArrayAccess) parent;
return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
} else if (parent instanceof JCFieldAccess) {
JCFieldAccess fieldAccess = (JCFieldAccess) parent;
return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
} else {
return TreeInfo.noPrec;
}
}
示例13: visitTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
@Override public void visitTypeTest(JCInstanceOf tree) {
printNode(tree);
child("expr", tree.expr);
child("clazz", tree.clazz);
indent--;
}
示例14: visitTypeTest
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
@Override public void visitTypeTest(JCInstanceOf node) {
InstanceOf io = new InstanceOf();
io.rawTypeReference(toTree(node.getType(), FlagKey.TYPE_REFERENCE));
io.rawObjectReference(toTree(node.getExpression()));
set(node, io);
}
示例15: getPrecedence
import com.sun.tools.javac.tree.JCTree.JCInstanceOf; //导入依赖的package包/类
/**
* Returns the precedence level appropriate for unambiguously printing leaf as a subexpression of
* its parent.
*/
private static int getPrecedence(JCTree leaf, Context context) {
JCCompilationUnit comp = context.get(JCCompilationUnit.class);
JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);
// In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
//
// TODO(mdempsky): There are probably cases where we could omit parentheses
// by tweaking the returned precedence, but they need careful review.
// For example, consider a template to replace "add(a, b)" with "a + b",
// which applied to "x + add(y, z)" would result in "x + (y + z)".
// In most cases, we'd likely prefer "x + y + z" instead, but those aren't
// always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
// a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
// to integer promotion rules.
if (parent instanceof JCConditional) {
// This intentionally differs from Pretty, because Pretty appears buggy:
// http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
JCConditional conditional = (JCConditional) parent;
return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
} else if (parent instanceof JCAssign) {
JCAssign assign = (JCAssign) parent;
return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
} else if (parent instanceof JCAssignOp) {
JCAssignOp assignOp = (JCAssignOp) parent;
return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
} else if (parent instanceof JCUnary) {
return TreeInfo.opPrec(parent.getTag());
} else if (parent instanceof JCBinary) {
JCBinary binary = (JCBinary) parent;
return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
} else if (parent instanceof JCTypeCast) {
JCTypeCast typeCast = (JCTypeCast) parent;
return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
} else if (parent instanceof JCInstanceOf) {
JCInstanceOf instanceOf = (JCInstanceOf) parent;
return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
} else if (parent instanceof JCArrayAccess) {
JCArrayAccess arrayAccess = (JCArrayAccess) parent;
return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
} else if (parent instanceof JCFieldAccess) {
JCFieldAccess fieldAccess = (JCFieldAccess) parent;
return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
} else {
return TreeInfo.noPrec;
}
}