本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCUnary类的典型用法代码示例。如果您正苦于以下问题:Java JCUnary类的具体用法?Java JCUnary怎么用?Java JCUnary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCUnary类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCUnary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
protected int diffUnary(JCUnary oldT, JCUnary newT, int[] bounds) {
int[] argBounds = getBounds(oldT.arg);
boolean newOpOnLeft = newT.getKind() != Kind.POSTFIX_DECREMENT && newT.getKind() != Kind.POSTFIX_INCREMENT;
if (newOpOnLeft) {
if (oldT.getTag() != newT.getTag()) {
printer.print(operatorName(newT.getTag()));
} else {
copyTo(bounds[0], argBounds[0]);
}
}
int localPointer = diffTree(oldT.arg, newT.arg, argBounds);
localPointer = copyUpTo(localPointer, argBounds[1]);
if (!newOpOnLeft) {
if (oldT.getTag() != newT.getTag()) {
printer.print(operatorName(newT.getTag()));
} else {
copyUpTo(localPointer, bounds[1]);
}
}
return bounds[1];
}
示例2: visitUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
public void visitUnary(JCUnary tree) {
try {
int ownprec = isOwnPrec(tree);
String opname = operatorName(treeTag(tree));
open(prec, ownprec);
if (isPrefixUnary(tree)) {
print(opname);
printExpr(tree.arg, ownprec);
} else {
printExpr(tree.arg, ownprec);
print(opname);
}
close(prec, ownprec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例3: visitUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
public void visitUnary(JCUnary tree) {
try {
int ownprec = TreeInfo.opPrec(tree.getTag());
String opname = operatorName(tree.getTag());
open(prec, ownprec);
if (tree.getTag() <= JCTree.PREDEC) {
print(opname);
printExpr(tree.arg, ownprec);
} else {
printExpr(tree.arg, ownprec);
print(opname);
}
close(prec, ownprec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例4: visitUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
public void visitUnary(JCUnary tree) {
try {
int ownprec = TreeInfo.opPrec(getTag(tree));
String opname = operatorName(getTag(tree));
open(prec, ownprec);
if (getTag(tree) <= Javac.getCtcInt(JCTree.class, "PREDEC")) {
print(opname);
printExpr(tree.arg, ownprec);
} else {
printExpr(tree.arg, ownprec);
print(opname);
}
close(prec, ownprec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: visitNewClass
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public JCTree visitNewClass(NewClassTree node, Void aVoid) {
JCNewClass oldNewClazz = (JCNewClass)node;
JCNewClass newNewClazz = (JCNewClass)super.visitNewClass(node, aVoid);
if (!oldNewClazz.args.isEmpty() && oldNewClazz.args.head.hasTag(NULLCHK)) {
//workaround to Attr generating trees
newNewClazz.encl = ((JCUnary)newNewClazz.args.head).arg;
newNewClazz.args = newNewClazz.args.tail;
}
return newNewClazz;
}
示例6: visitUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
@Override public void visitUnary(JCUnary tree) {
String op = operator(treeTag(tree));
if (treeTag(tree).getOperatorPrecedenceLevel() == PREFIX) {
print(op);
print(tree.arg);
} else {
print(tree.arg);
print(op);
}
}
示例7: visitUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
public void visitUnary(JCUnary that) {
try {
print("JCUnary:");
} catch (Exception e) {
}
super.visitUnary(that);
}
示例8: setPos
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
private <N extends Node> N setPos(JCTree node, N astNode) {
if (astNode != null && node != null) {
int start = node.pos;
Integer end_ = endPosTable.get(node);
if (node instanceof JCUnary) end_ = node.getEndPosition(endPosTable);
int end = end_ == null ? node.getEndPosition(endPosTable) : end_;
if (start != com.sun.tools.javac.util.Position.NOPOS && end != com.sun.tools.javac.util.Position.NOPOS) {
astNode.setPosition(new Position(start, end));
}
}
return astNode;
}
示例9: visitUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
@Override
public Choice<State<JCUnary>> visitUnary(UnaryTree node, State<?> state) {
final Tag tag = ((JCUnary) node).getTag();
return chooseSubtrees(
state, s -> unifyExpression(node.getExpression(), s), expr -> maker().Unary(tag, expr))
.condition(
s ->
!MUTATING_UNARY_TAGS.contains(tag)
|| !(s.result().getExpression() instanceof PlaceholderParamIdent));
}
示例10: replaceAssert
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
private static void replaceAssert(
SuggestedFix.Builder fix, AssertTree foundAssert, VisitorState state) {
ExpressionTree expr = foundAssert.getCondition();
expr = (ExpressionTree) TreeInfo.skipParens((JCTree) expr);
// case: "assert !expr"
if (expr.getKind().equals(LOGICAL_COMPLEMENT)) {
addFix(fix, ((JCUnary) expr).getExpression(), foundAssert, state, IS_FALSE);
return;
}
// case: "assert expr1.equals(expr2)"
if (instanceMethod().onClass(Any.INSTANCE).named("equals").matches(expr, state)) {
JCMethodInvocation equalsCall = ((JCMethodInvocation) expr);
JCExpression expr1 = ((JCFieldAccess) ((JCMethodInvocation) expr).meth).selected;
JCExpression expr2 = equalsCall.getArguments().get(0);
addFix(
fix,
expr1,
foundAssert,
state,
String.format(IS_EQUAL_TO, normalizedSourceForExpression(expr2, state)));
return;
}
// case: "assert expr1 == expr2" or "assert expr1 != expr2"
if (expr.getKind().equals(Kind.EQUAL_TO) || expr.getKind().equals(Kind.NOT_EQUAL_TO)) {
suggestFixForSameReference(fix, foundAssert, state, expr.getKind().equals(Kind.EQUAL_TO));
return;
}
// case: "assert expr", which didn't match any of the previous cases.
addFix(fix, (JCExpression) expr, foundAssert, state, IS_TRUE);
}
示例11: makeNullCheck
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
/** Make an attributed null check tree.
*/
public JCExpression makeNullCheck(JCExpression arg) {
// optimization: X.this is never null; skip null check
Name name = TreeInfo.name(arg);
if (name == names._this || name == names._super) return arg;
int optag = JCTree.NULLCHK;
JCUnary tree = make.at(arg.pos).Unary(optag, arg);
tree.operator = syms.nullcheck;
tree.type = arg.type;
return tree;
}
示例12: visitUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
public void visitUnary(JCUnary tree) {
// Attribute arguments.
Type argtype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC)
? attribTree(tree.arg, env, VAR, Type.noType)
: chk.checkNonVoid(tree.arg.pos(), attribExpr(tree.arg, env));
// Find operator.
Symbol operator = tree.operator =
rs.resolveUnaryOperator(tree.pos(), tree.getTag(), env, argtype);
Type owntype = types.createErrorType(tree.type);
if (operator.kind == MTH &&
!argtype.isErroneous()) {
owntype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC)
? tree.arg.type
: operator.type.getReturnType();
int opc = ((OperatorSymbol)operator).opcode;
// If the argument is constant, fold it.
if (argtype.constValue() != null) {
Type ctype = cfolder.fold1(opc, argtype);
if (ctype != null) {
owntype = cfolder.coerce(ctype, owntype);
// Remove constant types from arguments to
// conserve space. The parser will fold concatenations
// of string literals; the code here also
// gets rid of intermediate results when some of the
// operands are constant identifiers.
if (tree.arg.type.tsym == syms.stringType.tsym) {
tree.arg.type = syms.stringType;
}
}
}
}
result = check(tree, owntype, VAL, pkind, pt);
}
示例13: matchUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
private boolean matchUnary(JCUnary t1, JCUnary t2) {
return t1.operator == t2.operator && treesMatch(t1.arg, t2.arg);
}
示例14: Unary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
public JCUnary Unary(TreeTag opcode, JCExpression arg) {
return invoke(Unary, opcode.value, arg);
}
示例15: AJCUnary
import com.sun.tools.javac.tree.JCTree.JCUnary; //导入依赖的package包/类
public AJCUnary(JCUnary ltree) {
super(ltree.getTag(), ltree.arg);
}