本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCAssignOp类的典型用法代码示例。如果您正苦于以下问题:Java JCAssignOp类的具体用法?Java JCAssignOp怎么用?Java JCAssignOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JCAssignOp类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCAssignOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
protected int diffAssignop(JCAssignOp oldT, JCAssignOp newT, int[] bounds) {
int localPointer = bounds[0];
// lhs
int[] lhsBounds = getBounds(oldT.lhs);
copyTo(localPointer, lhsBounds[0]);
localPointer = diffTree(oldT.lhs, newT.lhs, lhsBounds);
if (oldT.getTag() != newT.getTag()) { // todo (#pf): operatorName() does not work
copyTo(localPointer, oldT.pos);
printer.print(getAssignementOperator(newT));
localPointer = oldT.pos + getAssignementOperator(oldT).length();
}
// rhs
int[] rhsBounds = getBounds(oldT.rhs);
copyTo(localPointer, rhsBounds[0]);
localPointer = diffTree(oldT.rhs, newT.rhs, rhsBounds);
copyTo(localPointer, bounds[1]);
return bounds[1];
}
示例2: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
public void visitAssignop(JCAssignOp tree) {
// Attribute arguments.
Type owntype = attribTree(tree.lhs, env, VAR, Type.noType);
Type operand = attribExpr(tree.rhs, env);
// Find operator.
Symbol operator = tree.operator = rs.resolveBinaryOperator(
tree.pos(), tree.getTag() - JCTree.ASGOffset, env,
owntype, operand);
if (operator.kind == MTH &&
!owntype.isErroneous() &&
!operand.isErroneous()) {
chk.checkOperator(tree.pos(),
(OperatorSymbol)operator,
tree.getTag() - JCTree.ASGOffset,
owntype,
operand);
chk.checkDivZero(tree.rhs.pos(), operator, operand);
chk.checkCastable(tree.rhs.pos(),
operator.type.getReturnType(),
owntype);
}
result = check(tree, owntype, VAL, pkind, pt);
}
示例3: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
public void visitAssignop(JCAssignOp that) {
try {
print("JCAssignOp:");
} catch (Exception e) {
}
super.visitAssignop(that);
}
示例4: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
public void visitAssignop(JCAssignOp tree) {
try {
open(prec, TreeInfo.assignopPrec);
printExpr(tree.lhs, TreeInfo.assignopPrec + 1);
String opname = operatorName(treeTag(tree));
print(" " + opname + " ");
printExpr(tree.rhs, TreeInfo.assignopPrec);
close(prec, TreeInfo.assignopPrec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
@Override public void visitAssignop(JCAssignOp tree) {
printNode(tree);
child("lhs", tree.lhs);
property("(operator)", operatorName(getTag(tree) - JCTree.ASGOffset) + "=");
child("rhs", tree.rhs);
indent--;
}
示例6: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
@Override public void visitAssignop(JCAssignOp node) {
BinaryExpression expr = new BinaryExpression();
expr.rawRight(toTree(node.getExpression()));
expr.rawLeft(toTree(node.getVariable()));
expr.astOperator(JcTreeBuilder.BINARY_OPERATORS.inverse().get(getTag(node)));
set(node, expr);
}
示例7: visitCompoundAssignment
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
@Override
public Choice<State<JCAssignOp>> visitCompoundAssignment(
final CompoundAssignmentTree node, State<?> state) {
return chooseSubtrees(
state,
s -> unifyExpression(node.getVariable(), s),
s -> unifyExpression(node.getExpression(), s),
(var, expr) -> maker().Assignop(((JCAssignOp) node).getTag(), var, expr))
.condition(assignOp -> !(assignOp.result().getVariable() instanceof PlaceholderParamIdent));
}
示例8: inline
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
@Override
public JCAssignOp inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner
.maker()
.Assignop(
TAG.get(getKind()), getVariable().inline(inliner), getExpression().inline(inliner));
}
示例9: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
public void visitAssignop(JCAssignOp tree) {
try {
open(prec, TreeInfo.assignopPrec);
printExpr(tree.lhs, TreeInfo.assignopPrec + 1);
print(" " + operatorName(tree.getTag() - JCTree.ASGOffset) + "= ");
printExpr(tree.rhs, TreeInfo.assignopPrec);
close(prec, TreeInfo.assignopPrec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例10: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
public void visitAssignop(JCAssignOp tree) {
try {
open(prec, TreeInfo.assignopPrec);
printExpr(tree.lhs, TreeInfo.assignopPrec + 1);
print(" " + operatorName(getTag(tree) - JCTree.ASGOffset) + "= ");
printExpr(tree.rhs, TreeInfo.assignopPrec);
close(prec, TreeInfo.assignopPrec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例11: matchAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
private boolean matchAssignop(JCAssignOp t1, JCAssignOp t2) {
return t1.operator == t2.operator &&
treesMatch(t1.lhs, t2.lhs) && treesMatch(t1.rhs, t2.rhs);
}
示例12: Assignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
public JCAssignOp Assignop(TreeTag opcode, JCTree lhs, JCTree rhs) {
return invoke(Assignop, opcode.value, lhs, rhs);
}
示例13: visitAssignop
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
@Override public void visitAssignop(JCAssignOp tree) {
print(tree.lhs);
String opname = operator(treeTag(tree));
print(" " + opname + " ");
print(tree.rhs);
}
示例14: AJCAssignOp
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的package包/类
public AJCAssignOp(JCAssignOp ltree) {
super(ltree.getTag(), ltree.lhs, ltree.rhs, ltree.operator);
}
示例15: getPrecedence
import com.sun.tools.javac.tree.JCTree.JCAssignOp; //导入依赖的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;
}
}