Evaluates files, strings, or input streams as Scala code, and returns the result.
Evaluates files, strings, or input streams as Scala code, and returns the result.
If target
is None
, the results are compiled to memory (and are therefore ephemeral). If
target
is Some(path)
, the path must point to a directory, and classes will be saved into
that directory.
Eval also supports a limited set of preprocessors. Currently, "limited" means "exactly one":
directives of the form #include <file>
.
The flow of evaluation is:
- extract a string of code from the file, string, or input stream
- run preprocessors on that string
- wrap processed code in an apply
method in a generated class
- compile the class
- contruct an instance of that class
- return the result of apply()
The type of threading model to use for compilation within the com.eharmony.aloha.semantics.compiled.compiler.TwitterEvalCompiler.
Compiles code using Twitter's Eval class from util-eval, wrapping the attempt in a Try.
Compiles code using Twitter's Eval class from util-eval, wrapping the attempt in a Try.
NOTE: while thread local is a good idea for multi-threading purposes (creates one compiler per thread), one needs to be careful about the number of threads interacting with the compiler. This is true for two reasons: 1 Creation time for compiler instance takes a while. 1 compiler instances are big (translation, many threads + thread local == java.lang.OutOfMemoryError).
Because the critical sections of the compile function of the StringCompiler.apply(*,*,*) function called by Eval.applyProcessed(*,*,*) are synchronized, we shouldn't need to worry about thread-safety. For more information, see Eval on github.
a threading model used for compilation.
Directory where generated class files should be stored.
import statements.
Creates a single instance of com.twitter.util.Eval within the com.eharmony.aloha.semantics.compiled.compiler.TwitterEvalCompiler instance.
Creates an instance of com.twitter.util.Eval per calling thread to the com.eharmony.aloha.semantics.compiled.compiler.TwitterEvalCompiler instance.