class
IMain extends Imports
Instance Constructors
-
new
IMain()
-
new
IMain(settings: Settings)
-
Type Members
-
case class
ComputedImports(prepend: String, append: String, access: String) extends Product with Serializable
-
-
-
Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
def
+(other: String): String
-
def
->[B](y: B): (IMain, B)
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
def
addImports(ids: String*): Result
-
def
aliasForType(path: String): Option[String]
-
def
allDefHandlers: collection.immutable.List[(memberHandlers)#MemberDefHandler]
-
def
allDefSymbols: collection.immutable.List[Global.Symbol]
-
def
allDefinedNames: collection.immutable.List[Global.Name]
-
def
allHandlers: collection.immutable.List[(memberHandlers)#MemberHandler]
-
def
allImplicits: collection.immutable.List[Global.Name { ... /* 5 definitions in type refinement */ }]
-
def
allImportedNames: collection.immutable.List[Global.Name]
-
def
allSeenTypes: collection.immutable.List[String]
-
def
apply[T](implicit arg0: ClassTag[T]): Global.Symbol
-
-
final
def
asInstanceOf[T0]: T0
-
def
beQuietDuring[T](body: ⇒ T): T
-
def
beSilentDuring[T](operation: ⇒ T): T
-
def
bind[T](name: String, value: T)(implicit arg0: reflect.api.JavaUniverse.TypeTag[T], arg1: ClassTag[T]): Result
-
-
def
bind(name: String, boundType: String, value: Any, modifiers: List[String] = Nil): Result
-
def
bindSyntheticValue(x: Any): Result
-
def
bindValue(name: String, x: Any): Result
-
def
bindValue(x: Any): Result
-
-
def
classOfTerm(id: String): Option[JClass]
-
def
classSymbols: collection.immutable.List[Global.ClassSymbol]
-
-
def
clearExecutionWrapper(): Unit
-
def
clone(): AnyRef
-
def
close(): Unit
-
def
compileSources(sources: SourceFile*): Boolean
-
def
compileSourcesKeepingRun(sources: SourceFile*): (Boolean, Run)
-
def
compileString(code: String): Boolean
-
def
compilerClasspath: Seq[URL]
-
def
debugging[T](msg: String)(res: T): T
-
-
def
definedSymbolList: collection.immutable.List[Global.Symbol]
-
-
def
definedTerms: collection.immutable.List[Global.TermName]
-
def
definedTypes: collection.immutable.List[Global.TypeName]
-
def
definitionForName(name: Global.Name): Option[(memberHandlers)#MemberHandler]
-
def
directBind[T](name: String, value: T)(implicit arg0: reflect.api.JavaUniverse.TypeTag[T], arg1: ClassTag[T]): Result
-
-
def
directBind(name: String, boundType: String, value: Any): Result
-
final
def
ensureClassLoader(): Unit
-
def
ensuring(cond: (IMain) ⇒ Boolean, msg: ⇒ Any): IMain
-
def
ensuring(cond: (IMain) ⇒ Boolean): IMain
-
def
ensuring(cond: Boolean, msg: ⇒ Any): IMain
-
def
ensuring(cond: Boolean): IMain
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
executionWrapper: String
-
-
def
finalize(): Unit
-
def
flatName(id: String): String
-
def
formatted(fmtstr: String): String
-
lazy val
formatting: Formatting
-
def
generatedName(simpleName: String): Option[String]
-
final
def
getClass(): Class[_]
-
-
lazy val
global: Global
-
-
-
def
hashCode(): Int
-
def
implicitSymbols: collection.immutable.List[Global.Symbol]
-
-
def
importHandlers: collection.immutable.List[(memberHandlers)#ImportHandler]
-
def
importedSymbols: collection.immutable.List[Global.Symbol]
-
-
def
importedTermNamed(name: String): Global.Symbol
-
def
importedTermSymbols: collection.immutable.List[Global.TermSymbol]
-
def
importedTerms: collection.immutable.List[Global.TermName]
-
def
importedTypeSymbols: collection.immutable.List[Global.TypeSymbol]
-
def
importedTypes: collection.immutable.List[Global.TypeName]
-
-
def
initialize(postInitSignal: ⇒ Unit): Unit
-
def
initializeSynchronous(): Unit
-
def
interpret(line: String, synthetic: Boolean): Result
-
def
interpret(line: String): Result
-
def
interpretSynthetic(line: String): Result
-
def
isInitializeComplete: Boolean
-
final
def
isInstanceOf[T0]: Boolean
-
def
isNoImports: Boolean
-
def
isNoPredef: Boolean
-
def
isParseable(line: String): Boolean
-
lazy val
isettings: ISettings
-
def
languageSymbols: collection.immutable.List[Global.Symbol]
-
def
languageWildcardHandlers: collection.immutable.List[(memberHandlers)#ImportHandler]
-
-
-
def
lastRequest: Request
-
-
lazy val
memberHandlers: MemberHandlers { val intp: IMain.this.type }
-
def
methodSymbols: collection.immutable.List[Global.MethodSymbol]
-
def
mostRecentLine: String
-
def
mostRecentVar: String
-
def
namedDefinedTerms: collection.immutable.List[Global.TermName]
-
-
final
def
ne(arg0: AnyRef): Boolean
-
-
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
-
-
def
optFlatName(id: String): Option[String]
-
-
def
parentClassLoader: ClassLoader
-
def
parse(line: String): Option[List[Global.Tree]]
-
def
pathToName(name: Global.Name): String
-
def
pathToTerm(id: String): String
-
def
pathToType(id: String): String
-
def
prevRequestList: collection.immutable.List[Request]
-
-
def
quietImport(ids: String*): Result
-
def
quietRun[T](code: String): Result
-
-
def
recordRequest(req: Request): Unit
-
lazy val
repllog: Logger
-
-
def
requestForIdent(line: String): Option[Request]
-
-
def
requestForReqId(id: Int): Option[Request]
-
-
def
reset(): Unit
-
def
resetClassLoader(): Unit
-
def
runtimeClassAndTypeOfTerm(id: String): Option[(JClass, Global.Type)]
-
def
runtimeTypeOfTerm(id: String): Global.Type
-
def
sessionImportedSymbols: collection.immutable.List[Global.Symbol]
-
-
def
setContextClassLoader(): Unit
-
def
setExecutionWrapper(code: String): Unit
-
-
def
showCodeIfDebugging(code: String): Unit
-
def
symbolDefString(sym: Global.Symbol): String
-
def
symbolOfLine(code: String): Global.Symbol
-
def
symbolOfTerm(id: String): Global.Symbol
-
def
symbolOfType(id: String): Global.Symbol
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
terms[T](implicit arg0: ClassTag[T]): Global.Symbol
-
-
def
toString(): String
-
def
treesForRequestId(id: Int): List[Global.Tree]
-
def
typeOfExpression(expr: String, silent: Boolean = true): Global.Type
-
def
typeOfTerm(id: String): Global.Type
-
def
types[T](implicit arg0: ClassTag[T]): Global.Symbol
-
-
def
unqualifiedIds: collection.immutable.List[String]
-
def
valueOfTerm(id: String): Option[AnyRef]
-
-
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
-
def
wildcardTypes: collection.immutable.List[Global.Type]
-
def
withoutUnwrapping(op: ⇒ Unit): Unit
-
def
withoutWarnings[T](body: ⇒ T): T
-
def
→[B](y: B): (IMain, B)
Shadowed Implicit Value Members
-
val
self: Any
-
val
self: Any
Deprecated Value Members
-
lazy val
compiler: global.type
-
-
Inherited from Any
Inherited by implicit conversion any2stringadd from
IMain to StringAdd
Inherited by implicit conversion any2stringfmt from
IMain to StringFormat
Inherited by implicit conversion any2ArrowAssoc from
IMain to ArrowAssoc[IMain]
Inherited by implicit conversion any2Ensuring from
IMain to Ensuring[IMain]
An interpreter for Scala code.
The main public entry points are compile(), interpret(), and bind(). The compile() method loads a complete Scala file. The interpret() method executes one line of Scala code at the request of the user. The bind() method binds an object to a variable that can then be used by later interpreted code.
The overall approach is based on compiling the requested code and then using a Java classloader and Java reflection to run the code and access its results.
In more detail, a single compiler instance is used to accumulate all successfully compiled or interpreted Scala code. To "interpret" a line of code, the compiler generates a fresh object that includes the line of code and which has public member(s) to export all variables defined by that code. To extract the result of an interpreted line to show the user, a second "result object" is created which imports the variables exported by the above object and then exports members called "$eval" and "$print". To accomodate user expressions that read from variables or methods defined in previous statements, "import" statements are used.
This interpreter shares the strengths and weaknesses of using the full compiler-to-Java. The main strength is that interpreted code behaves exactly as does compiled code, including running at full speed. The main weakness is that redefining classes and methods is not handled properly, because rebinding at the Java level is technically difficult.