Java Code Examples for com.sun.tools.javac.tree.TreeInfo#skipParens()
The following examples show how to use
com.sun.tools.javac.tree.TreeInfo#skipParens() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Flow.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SuppressWarnings("fallthrough") void letInit(JCTree tree) { tree = TreeInfo.skipParens(tree); if (tree.hasTag(IDENT) || tree.hasTag(SELECT)) { Symbol sym = TreeInfo.symbol(tree); if (currentTree != null && sym.kind == VAR && sym.owner.kind == MTH && ((VarSymbol)sym).pos < currentTree.getStartPosition()) { switch (currentTree.getTag()) { case CLASSDEF: if (!allowEffectivelyFinalInInnerClasses) { reportInnerClsNeedsFinalError(tree, sym); break; } case LAMBDA: reportEffectivelyFinalError(tree, sym); } } } }
Example 2
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
JCExpression abstractLval(JCExpression lval, final TreeBuilder builder) { lval = TreeInfo.skipParens(lval); switch (lval.getTag()) { case IDENT: return builder.build(lval); case SELECT: { final JCFieldAccess s = (JCFieldAccess)lval; Symbol lid = TreeInfo.symbol(s.selected); if (lid != null && lid.kind == TYP) return builder.build(lval); return abstractRval(s.selected, selected -> builder.build(make.Select(selected, s.sym))); } case INDEXED: { final JCArrayAccess i = (JCArrayAccess)lval; return abstractRval(i.indexed, indexed -> abstractRval(i.index, syms.intType, index -> { JCExpression newLval = make.Indexed(indexed, index); newLval.setType(i.type); return builder.build(newLval); })); } case TYPECAST: { return abstractLval(((JCTypeCast)lval).expr, builder); } } throw new AssertionError(lval); }
Example 3
Source File: StringConcat.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private List<JCTree> collect(JCTree tree, List<JCTree> res) { tree = TreeInfo.skipParens(tree); if (tree.hasTag(PLUS) && tree.type.constValue() == null) { JCTree.JCBinary op = (JCTree.JCBinary) tree; if (op.operator.kind == MTH && op.operator.opcode == string_add) { return res .appendList(collect(op.lhs, res)) .appendList(collect(op.rhs, res)); } } return res.append(tree); }
Example 4
Source File: Flow.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** If tree is either a simple name or of the form this.name or * C.this.name, and tree represents a trackable variable, * record an initialization of the variable. */ void letInit(JCTree tree) { tree = TreeInfo.skipParens(tree); if (tree.hasTag(IDENT) || tree.hasTag(SELECT)) { Symbol sym = TreeInfo.symbol(tree); if (sym.kind == VAR) { letInit(tree.pos(), (VarSymbol)sym); } } }
Example 5
Source File: Flow.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void visitAssign(JCAssign tree) { JCTree lhs = TreeInfo.skipParens(tree.lhs); if (!isIdentOrThisDotIdent(lhs)) scanExpr(lhs); scanExpr(tree.rhs); letInit(lhs); }
Example 6
Source File: Flow.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void visitSelect(JCFieldAccess tree) { super.visitSelect(tree); JCTree sel = TreeInfo.skipParens(tree.selected); if (enforceThisDotInit && sel.hasTag(IDENT) && ((JCIdent)sel).name == names._this && tree.sym.kind == VAR) { checkInit(tree.pos(), (VarSymbol)tree.sym); } }
Example 7
Source File: Flow.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void visitAssign(JCAssign tree) { JCTree lhs = TreeInfo.skipParens(tree.lhs); if (!(lhs instanceof JCIdent)) { scan(lhs); } scan(tree.rhs); letInit(lhs); }
Example 8
Source File: StringConcat.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private List<JCTree> collect(JCTree tree, List<JCTree> res) { tree = TreeInfo.skipParens(tree); if (tree.hasTag(PLUS) && tree.type.constValue() == null) { JCTree.JCBinary op = (JCTree.JCBinary) tree; if (op.operator.kind == MTH && op.operator.opcode == string_add) { return res .appendList(collect(op.lhs, res)) .appendList(collect(op.rhs, res)); } } return res.append(tree); }
Example 9
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** return access code for identifier, * @param tree The tree representing the identifier use. * @param enclOp The closest enclosing operation node of tree, * null if tree is not a subtree of an operation. */ private static int accessCode(JCTree tree, JCTree enclOp) { if (enclOp == null) return AccessCode.DEREF.code; else if (enclOp.hasTag(ASSIGN) && tree == TreeInfo.skipParens(((JCAssign) enclOp).lhs)) return AccessCode.ASSIGN.code; else if ((enclOp.getTag().isIncOrDecUnaryOp() || enclOp.getTag().isAssignop()) && tree == TreeInfo.skipParens(((JCOperatorExpression) enclOp).getOperand(LEFT))) return (((JCOperatorExpression) enclOp).operator).getAccessCode(enclOp.getTag()); else return AccessCode.DEREF.code; }
Example 10
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Construct an expression using the builder, with the given rval * expression as an argument to the builder. However, the rval * expression must be computed only once, even if used multiple * times in the result of the builder. We do that by * constructing a "let" expression that saves the rvalue into a * temporary variable and then uses the temporary variable in * place of the expression built by the builder. The complete * resulting expression is of the form * <pre> * (let <b>TYPE</b> <b>TEMP</b> = <b>RVAL</b>; * in (<b>BUILDER</b>(<b>TEMP</b>))) * </pre> * where <code><b>TEMP</b></code> is a newly declared variable * in the let expression. */ JCExpression abstractRval(JCExpression rval, Type type, TreeBuilder builder) { rval = TreeInfo.skipParens(rval); switch (rval.getTag()) { case LITERAL: return builder.build(rval); case IDENT: JCIdent id = (JCIdent) rval; if ((id.sym.flags() & FINAL) != 0 && id.sym.owner.kind == MTH) return builder.build(rval); } Name name = TreeInfo.name(rval); if (name == names._super || name == names._this) return builder.build(rval); VarSymbol var = new VarSymbol(FINAL|SYNTHETIC, names.fromString( target.syntheticNameChar() + "" + rval.hashCode()), type, currentMethodSym); rval = convert(rval,type); JCVariableDecl def = make.VarDef(var, rval); // XXX cast JCExpression built = builder.build(make.Ident(var)); JCExpression res = make.LetExpr(def, built); res.type = built.type; return res; }
Example 11
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; if (spMethod == null || types.isSameType(spMethod.getReturnType(), syms.objectType, true)) { // The return type of the polymorphic signature is polymorphic, // and is computed from the enclosing tree E, as follows: // if E is a cast, then use the target type of the cast expression // as a return type; if E is an expression statement, the return // type is 'void'; otherwise // the return type is simply 'Object'. A correctness check ensures // that env.next refers to the lexically enclosing environment in // which the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } } else { // The return type of the polymorphic signature is fixed // (not polymorphic) restype = spMethod.getReturnType(); } List<Type> paramtypes = argtypes.map(new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 12
Source File: Infer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 13
Source File: Infer.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 14
Source File: Infer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; if (spMethod == null || types.isSameType(spMethod.getReturnType(), syms.objectType, true)) { // The return type of the polymorphic signature is polymorphic, // and is computed from the enclosing tree E, as follows: // if E is a cast, then use the target type of the cast expression // as a return type; if E is an expression statement, the return // type is 'void'; otherwise // the return type is simply 'Object'. A correctness check ensures // that env.next refers to the lexically enclosing environment in // which the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } } else { // The return type of the polymorphic signature is fixed // (not polymorphic) restype = spMethod.getReturnType(); } List<Type> paramtypes = argtypes.map(new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 15
Source File: Infer.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Type site, Name name, MethodSymbol spMethod, // sig. poly. method or null if none List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case JCTree.TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case JCTree.EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, implicitArgType); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 16
Source File: Infer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 17
Source File: Infer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 18
Source File: Infer.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 19
Source File: Infer.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Type site, Name name, MethodSymbol spMethod, // sig. poly. method or null if none List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case JCTree.TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case JCTree.EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, implicitArgType); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }
Example 20
Source File: Infer.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Compute a synthetic method type corresponding to the requested polymorphic * method signature. The target return type is computed from the immediately * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> argtypes) { final Type restype; //The return type for a polymorphic signature call is computed from //the enclosing tree E, as follows: if E is a cast, then use the //target type of the cast expression as a return type; if E is an //expression statement, the return type is 'void' - otherwise the //return type is simply 'Object'. A correctness check ensures that //env.next refers to the lexically enclosing environment in which //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? syms.voidType : syms.objectType; break; default: restype = syms.objectType; } List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step)); List<Type> exType = spMethod != null ? spMethod.getThrownTypes() : List.of(syms.throwableType); // make it throw all exceptions MethodType mtype = new MethodType(paramtypes, restype, exType, syms.methodClass); return mtype; }