public class FregeCompiler
extends java.lang.Object
implements java.util.concurrent.Callable<java.lang.invoke.MethodHandle>
Interface to compiler from Java. This is used by the frege/maven plugin.
Constructor and Description |
---|
FregeCompiler() |
Modifier and Type | Method and Description |
---|---|
java.lang.invoke.MethodHandle |
call()
obtain a MethodHandle that calls the compile(...) method.
|
static boolean |
compile(java.lang.String compiler,
java.lang.String[] modules,
java.lang.String[] sourcePath,
int flags,
java.lang.String target,
java.lang.String[] fregePath,
java.lang.String prefix,
java.io.PrintWriter compilerMessages)
Run the compiler.
|
static void |
main(java.lang.String[] argv) |
public static final boolean compile(java.lang.String compiler, java.lang.String[] modules, java.lang.String[] sourcePath, int flags, java.lang.String target, java.lang.String[] fregePath, java.lang.String prefix, java.io.PrintWriter compilerMessages) throws java.lang.Exception
Run the compiler.
Whenever an array parameter is null, it will be seen as empty list by the frege compiler. A null for a string parameter will be replaced with a sensible value.
compiler
- the compiler's class, usually "frege.compiler.Main"modules
- array of file names to compile.
If the make flag is set, also names of classes that must be made are allowed.sourcePath
- array of directory names where source files can be found. Makes sense only with "make"flags
- compiler flags, use either "stdopts" or "bootstrapopts" and possibly add "make"target
- directory name of the target directory, will be the javac -d option. defaults to "."fregePath
- Array of directory names, jar/zip file names and URLs. Compiler uses this to
construct an URLCLassLoader needed to import frege classes.prefix
- Prefix for modifying class names. Used in compiler bootstrap only. default ""compilerMessages
- a PrintWriter for compiler error messages and warningsjava.lang.Compiler
- bugs and reflective activities done here can lead to various exceptions.java.lang.Exception
public java.lang.invoke.MethodHandle call() throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException
Use like this:
@SuppressWarnings("unchecked") Callable<MethodHandle> fc = (Callable<MethodHandle>) Class.forName("frege.rt.FregeCompiler").newInstance(); boolean result = fc.call().invoke("frege.compiler.Main", new String[] {"foo.fr"}, null, flags, "build", new String[] {"fregec1.jar"}, "", new PrintWriter (new StringBuffer()));
call
in interface java.util.concurrent.Callable<java.lang.invoke.MethodHandle>
java.lang.Error
- if MH cannot be madejava.lang.NoSuchMethodException
java.lang.IllegalAccessException
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception