本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCBinary类的典型用法代码示例。如果您正苦于以下问题:Java JCBinary类的具体用法?Java JCBinary怎么用?Java JCBinary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCBinary类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCBinary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffBinary
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
protected int diffBinary(JCBinary oldT, JCBinary newT, int[] bounds) {
int localPointer = bounds[0];
int[] lhsBounds = getBounds(oldT.lhs);
copyTo(localPointer, lhsBounds[0]);
localPointer = diffTree(oldT.lhs, newT.lhs, lhsBounds);
if (oldT.getTag() != newT.getTag()) {
copyTo(localPointer, oldT.pos);
printer.print(operatorName(newT.getTag()));
localPointer = oldT.pos + operatorName(oldT.getTag()).toString().length();
}
int[] rhsBounds = getCommentCorrectedBounds(oldT.rhs);
rhsBounds[0] = copyUpTo(localPointer, rhsBounds[0]);
localPointer = diffTree(oldT.rhs, newT.rhs, rhsBounds);
return copyUpTo(localPointer, bounds[1]);
}
示例2: translateTopLevelClass
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
@Override
public List<JCTree> translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) {
List<JCTree> result = super.translateTopLevelClass(env, cdef, make);
new TreeScanner() {
@Override
public void visitBinary(JCBinary tree) {
hasNullCheck |= tree.operator.getSimpleName().contentEquals("!=") &&
"resource".equals(String.valueOf(TreeInfo.name(tree.lhs))) &&
TreeInfo.isNull(tree.rhs);
super.visitBinary(tree);
}
}.scan(result);
return result;
}
示例3: isThereInMiniTree
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
/**
* This function walks into a tree with nodes of type JCBinary to search for
* a string as one of the elements of the tree.
* @param toTest The String searched as Element in the tree.
* @param expression The bifurcation tree searched.
* @return True if the string was found, or False.
*/
private boolean isThereInMiniTree(String toTest, JCTree expression) {
if(expression instanceof JCParens){
if(isThereInMiniTree(toTest, ((JCParens) expression).expr))
return true;
} else if(expression instanceof JCIdent){
if(((JCIdent) expression).name.toString().equals(toTest))
return true;
} else if(expression instanceof JCBinary){
if(isThereInMiniTree(toTest, ((JCBinary) expression).rhs))
return true;
if(isThereInMiniTree(toTest, ((JCBinary) expression).lhs))
return true;
}
return false;
}
示例4: hasTrueValue
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
/**
* Verify if the boolean expression have a true value despite of any variable values.
* @param expression The boolean expression examined.
* @return 1 When the expression is always true.
*/
private int hasTrueValue(JCTree expression) {
if(expression instanceof JCParens){
if(hasTrueValue(((JCParens)expression).expr) != 0)
return 1;
}else if(expression instanceof JCLiteral){
if(((JCLiteral) expression).value == null)
return VAR_FALSE_VALUE;
return (int) ((JCLiteral) expression).value;
}else if(expression instanceof JmlSingleton){
return 1;
}else if(expression instanceof JCBinary){
return resolveBooleanOperations(expression);
}
return VAR_FALSE_VALUE;
}
示例5: matchBinary
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
@Override
public Description matchBinary(BinaryTree tree, VisitorState state) {
Tree parent = state.getPath().getParentPath().getLeaf();
if (!(parent instanceof BinaryTree)) {
return NO_MATCH;
}
if (TreeInfo.opPrec(((JCBinary) tree).getTag())
== TreeInfo.opPrec(((JCBinary) parent).getTag())) {
return NO_MATCH;
}
if (!isConfusing(tree.getKind(), parent.getKind())) {
return NO_MATCH;
}
return describeMatch(
tree, SuggestedFix.builder().prefixWith(tree, "(").postfixWith(tree, ")").build());
}
示例6: visitBinary
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
@Override public void visitBinary(JCBinary tree) {
String op = operator(treeTag(tree));
print(tree.lhs);
print(" ");
print(op);
print(" ");
print(tree.rhs);
}
示例7: generateCompareFloatOrDouble
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
public JCStatement generateCompareFloatOrDouble(JCExpression thisDotField, JCExpression otherDotField,
JavacTreeMaker maker, JavacNode node, boolean isDouble) {
/* if (Float.compare(fieldName, other.fieldName) != 0) return false; */
JCExpression clazz = genJavaLangTypeRef(node, isDouble ? "Double" : "Float");
List<JCExpression> args = List.of(thisDotField, otherDotField);
JCBinary compareCallEquals0 = maker.Binary(CTC_NOT_EQUAL, maker.Apply(
List.<JCExpression>nil(), maker.Select(clazz, node.toName("compare")), args), maker.Literal(0));
return maker.If(compareCallEquals0, returnBool(maker, false), null);
}
示例8: returnVarNameIfNullCheck
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
/**
* Checks if the statement is of the form 'if (x == null) {throw WHATEVER;},
* where the block braces are optional. If it is of this form, returns "x".
* If it is not of this form, returns null.
*/
public String returnVarNameIfNullCheck(JCStatement stat) {
if (!(stat instanceof JCIf)) return null;
/* Check that the if's statement is a throw statement, possibly in a block. */ {
JCStatement then = ((JCIf) stat).thenpart;
if (then instanceof JCBlock) {
List<JCStatement> stats = ((JCBlock) then).stats;
if (stats.length() == 0) return null;
then = stats.get(0);
}
if (!(then instanceof JCThrow)) return null;
}
/* Check that the if's conditional is like 'x == null'. Return from this method (don't generate
a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ {
JCExpression cond = ((JCIf) stat).cond;
while (cond instanceof JCParens) cond = ((JCParens) cond).expr;
if (!(cond instanceof JCBinary)) return null;
JCBinary bin = (JCBinary) cond;
if (!CTC_EQUAL.equals(treeTag(bin))) return null;
if (!(bin.lhs instanceof JCIdent)) return null;
if (!(bin.rhs instanceof JCLiteral)) return null;
if (!CTC_BOT.equals(typeTag(bin.rhs))) return null;
return ((JCIdent) bin.lhs).name.toString();
}
}
示例9: visitBinary
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
public void visitBinary(JCBinary that) {
try {
print("JCBinary:");
} catch (Exception e) {
}
super.visitBinary(that);
}
示例10: visitBinary
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
public void visitBinary(JCBinary tree) {
try {
int ownprec = isOwnPrec(tree);
String opname = operatorName(treeTag(tree));
open(prec, ownprec);
printExpr(tree.lhs, ownprec);
print(" " + opname + " ");
printExpr(tree.rhs, ownprec + 1);
close(prec, ownprec);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例11: generateCompareFloatOrDouble
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
public JCStatement generateCompareFloatOrDouble(JCExpression thisDotField, JCExpression otherDotField,
JavacTreeMaker maker, JavacNode node, boolean isDouble) {
/* if (Float.compare(fieldName, other.fieldName) != 0) return false; */
JCExpression clazz = genJavaLangTypeRef(node, isDouble ? "Double" : "Float");
List<JCExpression> args = List.of(thisDotField, otherDotField);
JCBinary compareCallEquals0 = maker.Binary(CTC_NOT_EQUAL, maker.Apply(
List.<JCExpression>nil(), maker.Select(clazz, node.toName("compare")), args), maker.Literal(0));
return maker.If(compareCallEquals0, returnBool(maker, false), null);
}
示例12: inline
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
@Override
public JCBinary inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner.maker().Binary(
OP_CODES.get(getKind()),
getLeftOperand().inline(inliner),
getRightOperand().inline(inliner));
}
示例13: visitBinary
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
@Override public void visitBinary(JCBinary tree) {
printNode(tree);
child("lhs", tree.lhs);
property("(operator)", operatorName(getTag(tree)));
child("rhs", tree.rhs);
indent--;
}
示例14: visitBinary
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
@Override public void visitBinary(JCBinary node) {
BinaryExpression expr = new BinaryExpression();
expr.rawLeft(toTree(node.getLeftOperand()));
expr.rawRight(toTree(node.getRightOperand()));
expr.astOperator(JcTreeBuilder.BINARY_OPERATORS.inverse().get(getTag(node)));
set(node, expr);
}
示例15: inline
import com.sun.tools.javac.tree.JCTree.JCBinary; //导入依赖的package包/类
@Override
public JCBinary inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner
.maker()
.Binary(
OP_CODES.get(getKind()),
getLeftOperand().inline(inliner),
getRightOperand().inline(inliner));
}