本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop类的典型用法代码示例。如果您正苦于以下问题:Java JCEnhancedForLoop类的具体用法?Java JCEnhancedForLoop怎么用?Java JCEnhancedForLoop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCEnhancedForLoop类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCEnhancedForLoop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
protected int diffForeachLoop(JCEnhancedForLoop oldT, JCEnhancedForLoop newT, int[] bounds) {
int localPointer = bounds[0];
// variable
int[] varBounds = getBounds(oldT.var);
copyTo(localPointer, varBounds[0]);
localPointer = diffTree(oldT.var, newT.var, varBounds);
// expression
int[] exprBounds = getBounds(oldT.expr);
copyTo(localPointer, exprBounds[0]);
localPointer = diffTree(oldT.expr, newT.expr, exprBounds);
// body
int[] bodyBounds = new int[] { localPointer, endPos(oldT.body) };
int oldIndent = newT.body.hasTag(Tag.BLOCK) ? -1 : printer.indent();
localPointer = diffTree(oldT.body, newT.body, bodyBounds, oldT.getKind());
if (!newT.body.hasTag(Tag.BLOCK))
printer.undent(oldIndent);
copyTo(localPointer, bounds[1]);
return bounds[1];
}
示例2: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override public void visitForeachLoop(JCEnhancedForLoop tree) {
aPrint("for (");
printVarDefInline(tree.var);
print(" : ");
print(tree.expr);
print(") ");
print(tree.body);
}
示例3: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
public void visitForeachLoop(JCEnhancedForLoop that) {
try {
print("JCEnhancedForLoop:");
} catch (Exception e) {
}
super.visitForeachLoop(that);
}
示例4: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
public void visitForeachLoop(JCEnhancedForLoop tree) {
try {
print("for (");
printExpr(tree.var);
print(" : ");
printExpr(tree.expr);
print(") ");
printStat(tree.body);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: inline
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override
public JCEnhancedForLoop inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner.maker().ForeachLoop(
getVariable().inline(inliner),
getExpression().inline(inliner),
getStatement().inline(inliner));
}
示例6: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override public void visitForeachLoop(JCEnhancedForLoop tree) {
printNode(tree);
child("var", tree.var);
child("expr", tree.expr);
child("body", tree.body);
indent--;
}
示例7: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override public void visitForeachLoop(JCEnhancedForLoop node) {
ForEach fe = new ForEach();
fe.rawIterable(toTree(node.getExpression()));
fe.rawStatement(toTree(node.getStatement()));
fe.rawVariable(toTree(node.getVariable(), FlagKey.VARDEF_IS_DEFINITION));
set(node, fe);
}
示例8: inline
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override
public JCEnhancedForLoop inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner
.maker()
.ForeachLoop(
getVariable().inline(inliner),
getExpression().inline(inliner),
getStatement().inline(inliner));
}
示例9: visitEnhancedForLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override
public Choice<State<JCEnhancedForLoop>> visitEnhancedForLoop(
final EnhancedForLoopTree node, State<?> state) {
return chooseSubtrees(
state,
s -> unifyExpression(node.getExpression(), s),
s -> unifyStatement(node.getStatement(), s),
(expr, stmt) -> maker().ForeachLoop((JCVariableDecl) node.getVariable(), expr, stmt));
}
示例10: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
public void visitForeachLoop(JCEnhancedForLoop tree) {
try {
print("for (");
printExpr(tree.var);
print(" : ");
printExpr(tree.expr);
print(") ");
printStat(tree.body);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例11: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
public void visitForeachLoop(JCEnhancedForLoop tree) {
Env<AttrContext> loopEnv =
env.dup(env.tree, env.info.dup(env.info.scope.dup()));
attribStat(tree.var, loopEnv);
Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv));
chk.checkNonVoid(tree.pos(), exprType);
Type elemtype = types.elemtype(exprType); // perhaps expr is an array?
if (elemtype == null) {
// or perhaps expr implements Iterable<T>?
Type base = types.asSuper(exprType, syms.iterableType.tsym);
if (base == null) {
log.error(tree.expr.pos(),
"foreach.not.applicable.to.type",
exprType,
diags.fragment("type.req.array.or.iterable"));
elemtype = types.createErrorType(exprType);
} else {
List<Type> iterableParams = base.allparams();
elemtype = iterableParams.isEmpty()
? syms.objectType
: types.upperBound(iterableParams.head);
}
}
chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type);
loopEnv.tree = tree; // before, we were not in loop!
attribStat(tree.body, loopEnv);
loopEnv.info.scope.leave();
result = null;
}
示例12: matchForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
private boolean matchForeachLoop(JCEnhancedForLoop t1, JCEnhancedForLoop t2) {
return treesMatch(t1.var, t2.var) && treesMatch(t1.expr, t2.expr) &&
treesMatch(t1.body, t2.body);
}
示例13: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override
public void visitForeachLoop(JCEnhancedForLoop tree) {
//skip body (to prevents same statements to be analyzed twice)
scan(tree.getExpression());
}
示例14: visitForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
@Override
public void visitForeachLoop(JCEnhancedForLoop tree) {
scan(tree.getExpression());
}
示例15: ForeachLoop
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop; //导入依赖的package包/类
public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
return invoke(ForeachLoop, var, expr, body);
}