use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class Enter method visitTopLevel.
@Override
public void visitTopLevel(JCCompilationUnit tree) {
JavaFileObject prev = log.useSource(tree.sourcefile);
boolean addEnv = false;
boolean isPkgInfo = tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
if (tree.pid != null) {
tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid));
if (tree.packageAnnotations.nonEmpty() || pkginfoOpt == PkgInfo.ALWAYS) {
if (isPkgInfo) {
addEnv = true;
} else {
log.error(tree.packageAnnotations.head.pos(), "pkg.annotations.sb.in.package-info.java");
}
}
} else {
tree.packge = syms.unnamedPackage;
}
// Find all classes in package.
tree.packge.complete();
Env<AttrContext> topEnv = topLevelEnv(tree);
// Save environment of package-info.java file.
if (isPkgInfo) {
Env<AttrContext> env0 = typeEnvs.get(tree.packge);
if (env0 == null) {
typeEnvs.put(tree.packge, topEnv);
} else {
JCCompilationUnit tree0 = env0.toplevel;
if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
log.warning(tree.pid != null ? tree.pid.pos() : null, "pkg-info.already.seen", tree.packge);
if (addEnv || (tree0.packageAnnotations.isEmpty() && tree.docComments != null && tree.docComments.get(tree) != null)) {
typeEnvs.put(tree.packge, topEnv);
}
}
}
for (Symbol q = tree.packge; q != null && q.kind == PCK; q = q.owner) q.flags_field |= EXISTS;
Name name = names.package_info;
ClassSymbol c = reader.enterClass(name, tree.packge);
c.flatname = names.fromString(tree.packge + "." + name);
c.sourcefile = tree.sourcefile;
c.completer = null;
c.members_field = new Scope(c);
tree.packge.package_info = c;
}
classEnter(tree.defs, topEnv);
if (addEnv) {
todo.append(topEnv);
}
log.useSource(prev);
result = null;
}
use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class Flow method analyzeTree.
/**************************************************************************
* main method
*************************************************************************/
/** Perform definite assignment/unassignment analysis on a tree.
*/
public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
try {
attrEnv = env;
JCTree tree = env.tree;
this.make = make;
inits = new Bits();
uninits = new Bits();
uninitsTry = new Bits();
initsWhenTrue = initsWhenFalse = uninitsWhenTrue = uninitsWhenFalse = null;
if (vars == null)
vars = new VarSymbol[32];
else
for (int i = 0; i < vars.length; i++) vars[i] = null;
firstadr = 0;
nextadr = 0;
pendingExits = new ListBuffer<PendingExit>();
preciseRethrowTypes = new HashMap<Symbol, List<Type>>();
alive = true;
this.thrown = this.caught = null;
this.classDef = null;
unrefdResources = new Scope(env.enclClass.sym);
scan(tree);
} finally {
// note that recursive invocations of this method fail hard
inits = uninits = uninitsTry = null;
initsWhenTrue = initsWhenFalse = uninitsWhenTrue = uninitsWhenFalse = null;
if (vars != null)
for (int i = 0; i < vars.length; i++) vars[i] = null;
firstadr = 0;
nextadr = 0;
pendingExits = null;
this.make = null;
this.thrown = this.caught = null;
this.classDef = null;
unrefdResources = null;
}
}
use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class Flow method visitThrow.
public void visitThrow(JCThrow tree) {
scanExpr(tree.expr);
Symbol sym = TreeInfo.symbol(tree.expr);
if (sym != null && sym.kind == VAR && (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 && preciseRethrowTypes.get(sym) != null && allowImprovedRethrowAnalysis) {
for (Type t : preciseRethrowTypes.get(sym)) {
markThrown(tree, t);
}
} else {
markThrown(tree, tree.expr.type);
}
markDead();
}
use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class Flow method is292targetTypeCast.
//where
private boolean is292targetTypeCast(JCTypeCast tree) {
boolean is292targetTypeCast = false;
JCExpression expr = TreeInfo.skipParens(tree.expr);
if (expr.getTag() == JCTree.APPLY) {
JCMethodInvocation apply = (JCMethodInvocation) expr;
Symbol sym = TreeInfo.symbol(apply.meth);
is292targetTypeCast = sym != null && sym.kind == MTH && (sym.flags() & POLYMORPHIC_SIGNATURE) != 0;
}
return is292targetTypeCast;
}
use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.
the class Check method firstIncompatibility.
/** Return the first method which is defined with same args
* but different return types in two given interfaces, or null if none
* exists.
* @param t1 The first type.
* @param t2 The second type.
* @param site The most derived type.
* @returns symbol from t2 that conflicts with one in t1.
*/
private Symbol firstIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) {
Map<TypeSymbol, Type> interfaces1 = new HashMap<TypeSymbol, Type>();
closure(t1, interfaces1);
Map<TypeSymbol, Type> interfaces2;
if (t1 == t2)
interfaces2 = interfaces1;
else
closure(t2, interfaces1, interfaces2 = new HashMap<TypeSymbol, Type>());
for (Type t3 : interfaces1.values()) {
for (Type t4 : interfaces2.values()) {
Symbol s = firstDirectIncompatibility(pos, t3, t4, site);
if (s != null)
return s;
}
}
return null;
}
Aggregations