use of com.sun.tools.javac.tree.JCTree in project ceylon-compiler by ceylon.
the class Flow method addVars.
// where
/** Add any variables defined in stats to inits and uninits. */
private static void addVars(List<JCStatement> stats, Bits inits, Bits uninits) {
for (; stats.nonEmpty(); stats = stats.tail) {
JCTree stat = stats.head;
if (stat.getTag() == JCTree.VARDEF) {
int adr = ((JCVariableDecl) stat).sym.adr;
inits.excl(adr);
uninits.incl(adr);
}
}
}
use of com.sun.tools.javac.tree.JCTree in project ceylon-compiler by ceylon.
the class Check method checkCyclicConstructors.
/* *************************************************************************
* Check for cycles in the constructor call graph.
**************************************************************************/
/** Check for cycles in the graph of constructors calling other
* constructors.
*/
void checkCyclicConstructors(JCClassDecl tree) {
Map<Symbol, Symbol> callMap = new HashMap<Symbol, Symbol>();
// enter each constructor this-call into the map
for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
JCMethodInvocation app = TreeInfo.firstConstructorCall(l.head);
if (app == null)
continue;
JCMethodDecl meth = (JCMethodDecl) l.head;
if (TreeInfo.name(app.meth) == names._this) {
callMap.put(meth.sym, TreeInfo.symbol(app.meth));
} else {
meth.sym.flags_field |= ACYCLIC;
}
}
// Check for cycles in the map
Symbol[] ctors = new Symbol[0];
ctors = callMap.keySet().toArray(ctors);
for (Symbol caller : ctors) {
checkCyclicConstructor(tree, caller, callMap);
}
}
use of com.sun.tools.javac.tree.JCTree in project ceylon-compiler by ceylon.
the class Check method checkNonCyclicElements.
/* *************************************************************************
* Check for recursive annotation elements.
**************************************************************************/
/** Check for cycles in the graph of annotation elements.
*/
void checkNonCyclicElements(JCClassDecl tree) {
if ((tree.sym.flags_field & ANNOTATION) == 0)
return;
Assert.check((tree.sym.flags_field & LOCKED) == 0);
try {
tree.sym.flags_field |= LOCKED;
for (JCTree def : tree.defs) {
if (def.getTag() != JCTree.METHODDEF)
continue;
JCMethodDecl meth = (JCMethodDecl) def;
checkAnnotationResType(meth.pos(), meth.restype.type);
}
} finally {
tree.sym.flags_field &= ~LOCKED;
tree.sym.flags_field |= ACYCLIC_ANN;
}
}
use of com.sun.tools.javac.tree.JCTree in project ceylon-compiler by ceylon.
the class ClassDocImpl method importedPackages.
/**
* Get the list of packages declared as imported.
* These are called "type-import-on-demand declarations" in the JLS.
* This method is deprecated in the ClassDoc interface.
*
* @return an array of PackageDocImpl representing the imported packages.
*
* ###NOTE: the syntax supports importing all inner classes from a class as well.
* @deprecated Import declarations are implementation details that
* should not be exposed here. In addition, this method's
* return type does not allow for all type-import-on-demand
* declarations to be returned.
*/
@Deprecated
public PackageDoc[] importedPackages() {
// information is not available for binary classfiles
if (tsym.sourcefile == null)
return new PackageDoc[0];
ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<PackageDocImpl>();
//### Add the implicit "import java.lang.*" to the result
Names names = tsym.name.table.names;
importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang)));
Env<AttrContext> compenv = env.enter.getEnv(tsym);
if (compenv == null)
return new PackageDocImpl[0];
for (JCTree t : compenv.toplevel.defs) {
if (t.getTag() == JCTree.IMPORT) {
JCTree imp = ((JCImport) t).qualid;
if (TreeInfo.name(imp) == names.asterisk) {
JCFieldAccess sel = (JCFieldAccess) imp;
Symbol s = sel.selected.type.tsym;
PackageDocImpl pdoc = env.getPackageDoc(s.packge());
if (!importedPackages.contains(pdoc))
importedPackages.append(pdoc);
}
}
}
return importedPackages.toArray(new PackageDocImpl[importedPackages.length()]);
}
use of com.sun.tools.javac.tree.JCTree in project ceylon-compiler by ceylon.
the class JavacTaskImpl method parseType.
/**
* For internal use only. This method will be
* removed without warning.
*/
public Type parseType(String expr, TypeElement scope) {
if (expr == null || expr.equals(""))
throw new IllegalArgumentException();
compiler = JavaCompiler.instance(context);
JavaFileObject prev = compiler.log.useSource(null);
ParserFactory parserFactory = ParserFactory.instance(context);
Attr attr = Attr.instance(context);
try {
CharBuffer buf = CharBuffer.wrap((expr + "