use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class ImplementationCacheTest method main.
public static void main(String[] args) throws IOException {
List<? extends JavaFileObject> files = Arrays.asList(new SourceFile());
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTask ct = (JavacTask) tool.getTask(null, null, null, null, null, files);
Context ctx = new Context();
JavacFileManager.preRegister(ctx);
checkImplementationCache(ct.analyze(), Types.instance(ctx));
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class CeylonModuleRunner method compileAndRun.
private void compileAndRun(File srcDir, File resDir, File outRepo, String[] modules, String[] dependencies, String[] options, Set<String> removeAtRuntime, String[] modulesUsingCheckFunction, String[] modulesUsingCheckModule) throws Exception {
// Compile all the .ceylon files into a .car
Context context = new Context();
final ErrorCollector listener = new ErrorCollector();
// can't create it until Log
CeyloncFileManager.preRegister(context);
// has been set up
CeylonLog.preRegister(context);
context.put(DiagnosticListener.class, listener);
com.redhat.ceylon.compiler.java.launcher.Main compiler = new com.redhat.ceylon.compiler.java.launcher.Main("ceylonc");
List<String> args = new ArrayList<>();
// args.add("-verbose:code");
args.add("-g");
args.add("-src");
args.add(srcDir.getCanonicalPath());
args.add("-res");
args.add(resDir.getCanonicalPath());
args.add("-out");
args.add(outRepo.getAbsolutePath());
for (String option : options) {
args.add(option);
}
for (String module : modules) args.add(module);
for (String module : dependencies) args.add(module);
compiler.compile(args.toArray(new String[args.size()]), context);
TreeSet<CompilerError> errors = listener.get(Kind.ERROR);
if (!errors.isEmpty()) {
List<Runner> errorRunners = new LinkedList<Runner>();
for (final CompilerError compileError : errors) {
createFailingTest(errorRunners, compileError.filename, new CompilationException(compileError.toString()));
}
for (Runner errorRunner : errorRunners) {
children.put(errorRunner, errorRunner.getDescription());
}
}
// remove what we need for runtime
for (String module : removeAtRuntime) {
File moduleFolder = new File(outRepo, module.replace('.', File.separatorChar));
FileUtil.delete(moduleFolder);
}
for (String module : modules) {
postCompile(context, listener, module, srcDir, dependencies, removeAtRuntime, modulesUsingCheckFunction, modulesUsingCheckModule);
}
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class ModelLoaderTests method verifyRuntimeClassLoading.
protected void verifyRuntimeClassLoading(RunnableTest test) {
RepositoryManager repoManager = CeylonUtils.repoManager().buildManager();
VFS vfs = new VFS();
com.redhat.ceylon.compiler.typechecker.context.Context context = new com.redhat.ceylon.compiler.typechecker.context.Context(repoManager, vfs);
RuntimeModuleManager moduleManager = new RuntimeModuleManager();
context.setModules(new Modules());
moduleManager.initCoreModules(new Modules());
moduleManager.loadModule(AbstractModelLoader.CEYLON_LANGUAGE, Versions.CEYLON_VERSION_NUMBER, repoManager.getArtifactResult("ceylon.language", Versions.CEYLON_VERSION_NUMBER), getClass().getClassLoader());
RuntimeModelLoader modelLoader = moduleManager.getModelLoader();
modelLoader.setupWithNoStandardModules();
modelLoader.loadStandardModules();
test.test(modelLoader);
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class TestSymtabItems method run.
void run() throws Exception {
Context c = new Context();
JavacFileManager.preRegister(c);
Symtab syms = Symtab.instance(c);
JavacTypes types = JavacTypes.instance(c);
// will init ClassReader.sourceCompleter
JavaCompiler.instance(c);
for (Field f : Symtab.class.getDeclaredFields()) {
// during API evolution
if (f.getName().toLowerCase().contains("methodhandle"))
continue;
Class<?> ft = f.getType();
if (TypeMirror.class.isAssignableFrom(ft))
print(f.getName(), (TypeMirror) f.get(syms), types);
else if (Element.class.isAssignableFrom(ft))
print(f.getName(), (Element) f.get(syms));
}
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
use of com.sun.tools.javac.util.Context in project ceylon-compiler by ceylon.
the class MakeLiteralTest method run.
void run() throws Exception {
Context context = new Context();
JavacFileManager.preRegister(context);
Symtab syms = Symtab.instance(context);
maker = TreeMaker.instance(context);
types = Types.instance(context);
test("abc", CLASS, syms.stringType, "abc");
test(Boolean.FALSE, BOOLEAN, syms.booleanType, Integer.valueOf(0));
test(Boolean.TRUE, BOOLEAN, syms.booleanType, Integer.valueOf(1));
test(Byte.valueOf((byte) 1), BYTE, syms.byteType, Byte.valueOf((byte) 1));
test(Character.valueOf('a'), CHAR, syms.charType, Integer.valueOf('a'));
test(Double.valueOf(1d), DOUBLE, syms.doubleType, Double.valueOf(1d));
test(Float.valueOf(1f), FLOAT, syms.floatType, Float.valueOf(1f));
test(Integer.valueOf(1), INT, syms.intType, Integer.valueOf(1));
test(Long.valueOf(1), LONG, syms.longType, Long.valueOf(1));
test(Short.valueOf((short) 1), SHORT, syms.shortType, Short.valueOf((short) 1));
if (errors > 0)
throw new Exception(errors + " errors found");
}
Aggregations