com.twitter.util

Eval

class Eval extends AnyRef

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()

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Eval
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Eval()

    empty constructor for backwards compatibility

  2. new Eval(target: Option[File])

Type Members

  1. class ClassScopedResolver extends Resolver

  2. class CompilerException extends Exception

  3. class FilesystemResolver extends Resolver

  4. class IncludePreprocessor extends Preprocessor

  5. trait Preprocessor extends AnyRef

  6. class ResolutionFailedException extends Exception

  7. trait Resolver extends AnyRef

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def apply[T](stream: InputStream): T

    val i: Int = new Eval()(getClass.

    val i: Int = new Eval()(getClass.getResourceAsStream("..."))

  7. def apply[T](files: File*): T

    val i: Int = new Eval()(new File(".

    val i: Int = new Eval()(new File("..."))

  8. def apply[T](code: String, resetState: Boolean = true): T

    val i: Int = new Eval()("1 + 1") // => 2

  9. def applyProcessed[T](className: String, code: String, resetState: Boolean): T

    same as apply[T], but does not run preprocessors.

  10. def applyProcessed[T](code: String, resetState: Boolean): T

    same as apply[T], but does not run preprocessors.

    same as apply[T], but does not run preprocessors. Will generate a classname of the form Evaluater<unique>, where unique is computed from the jvmID (a random number) and a digest of code

  11. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  12. def check(stream: InputStream): Unit

    Check if stream is Eval-able.

    Check if stream is Eval-able.

    Exceptions thrown
    CompilerException

    if not Eval-able.

  13. def check(files: File*): Unit

    Check if files are Eval-able.

    Check if files are Eval-able.

    Exceptions thrown
    CompilerException

    if not Eval-able.

  14. def check(code: String): Unit

    Check if code is Eval-able.

    Check if code is Eval-able.

    Exceptions thrown
    CompilerException

    if not Eval-able.

  15. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  16. def compile(code: String): Unit

    Compile an entire source file into the virtual classloader.

  17. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  19. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  20. def findClass(className: String): Class[_]

  21. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  23. lazy val impliedClassPath: List[String]

  24. def inPlace[T](code: String): T

    Like Eval(), but doesn't reset the virtual classloader before evaluating.

    Like Eval(), but doesn't reset the virtual classloader before evaluating. So if you've loaded classes with compile, they can be referenced/imported in code run by inPlace.

  25. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  26. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  29. lazy val preprocessors: Seq[Preprocessor]

    Preprocessors to run the code through before it is passed to the Scala compiler.

    Preprocessors to run the code through before it is passed to the Scala compiler. if you want to add new resolvers, you can do so with new Eval(...) { lazy val preprocessors = {...} }

    Attributes
    protected
  30. def sourceForString(code: String): String

    run preprocessors on our string, returning a String that is the processed source

  31. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  32. def toSource(code: String): String

    converts the given file to evaluable source.

  33. def toSource(file: File): String

    converts the given file to evaluable source.

    converts the given file to evaluable source. delegates to toSource(code: String)

  34. def toString(): String

    Definition Classes
    AnyRef → Any
  35. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  36. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  37. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  38. def writeChecksum(checksum: String, file: File): Unit

    write the current checksum to a file

Inherited from AnyRef

Inherited from Any

Ungrouped