summaryrefslogtreecommitdiff
path: root/src/repl
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #2736 from som-snytt/issue/7488-chase-delayed-initAdriaan Moors2013-07-251-18/+64
|\ | | | | SI-7488 REPL javap finds new style delayedEndpoint
| * SI-7488 REPL javap finds new style delayedEndpointSom Snytt2013-07-151-18/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The REPL :java -app command is a convenience to locate the body of DelayedInit code. Now it will look for new style delayedEndpoints on the class before it falls back to showing the apply method of the delayedInit$body closure. ``` apm@mara:~/tmp$ skala Welcome to Scala version 2.11.0-20130711-153246-eb1c3137f5 (OpenJDK 64-Bit Server VM, Java 1.7.0_21). Type in expressions to have them evaluated. Type :help for more information. scala> :javap -pv -app delayed.C public final void delayedEndpoint$delayed$C$1(); flags: ACC_PUBLIC, ACC_FINAL Code: stack=2, locals=1, args_size=1 0: getstatic #29 // Field scala/Predef$.MODULE$:Lscala/Predef$; 3: ldc #31 // String this is the initialization code of C 5: invokevirtual #35 // Method scala/Predef$.println:(Ljava/lang/Object;)V 8: return LocalVariableTable: Start Length Slot Name Signature 0 9 0 this Ldelayed/C; LineNumberTable: line 11: 0 scala> :q apm@mara:~/tmp$ rm delayed/*.class apm@mara:~/tmp$ scalac delayed.scala apm@mara:~/tmp$ skala Welcome to Scala version 2.11.0-20130711-153246-eb1c3137f5 (OpenJDK 64-Bit Server VM, Java 1.7.0_21). Type in expressions to have them evaluated. Type :help for more information. scala> :javap -pv -app delayed.C public final java.lang.Object apply(); flags: ACC_PUBLIC, ACC_FINAL Code: stack=2, locals=1, args_size=1 0: getstatic #13 // Field scala/Predef$.MODULE$:Lscala/Predef$; 3: ldc #15 // String this is the initialization code of C 5: invokevirtual #19 // Method scala/Predef$.println:(Ljava/lang/Object;)V 8: getstatic #25 // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit; 11: areturn LocalVariableTable: Start Length Slot Name Signature 0 12 0 this Ldelayed/C$delayedInit$body; LineNumberTable: line 11: 0 line 10: 8 ```
* | SI-7650 No bang expansions in REPL jlineSom Snytt2013-07-151-0/+3
|/ | | | Disable expandEvents at the earliest opportunity.
* SI-4684 Repl supports raw pasteSom Snytt2013-07-111-9/+30
| | | | | | | | By special request, :paste -raw simply compiles the pasted code to the repl output dir. The -raw flag means no wrapping; the pasted code must be ordinary top level Scala code, not script.
* SI-4684 Repl supports whole-file pasteSom Snytt2013-07-111-15/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a file argument to the :paste command which loads the file's contents as though entered in :paste mode. The :paste command is replayable. Samples, including companions defined together: ``` scala> :paste junk.scala File contains no code: junk.scala scala> :paste no-file.scala That file does not exist scala> :paste obj-repl.scala Pasting file obj-repl.scala... <console>:2: error: expected start of definition private foo = 7 ^ scala> :paste hw-repl.scala Pasting file hw-repl.scala... The pasted code is incomplete! <pastie>:5: error: illegal start of simple expression } ^ scala> :replay Replaying: :paste junk.scala File contains no code: junk.scala Replaying: :paste obj-repl.scala Pasting file obj-repl.scala... defined trait Foo defined object Foo Replaying: Foo(new Foo{}) res0: Int = 7 ```
* Merge pull request #2697 from som-snytt/issue/6419-repl-saveAdriaan Moors2013-07-101-0/+7
|\ | | | | SI-6419 Repl save session command
| * SI-6419 Repl save session commandSom Snytt2013-07-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A simple save command to write out the current replay stack. ``` scala> val i = 7 i: Int = 7 scala> val j= 8 j: Int = 8 scala> i * j res0: Int = 56 scala> :save multy.script scala> :q apm@mara:~/tmp$ cat multy.script val i = 7 val j= 8 i * j apm@mara:~/tmp$ skala Welcome to Scala version 2.11.0-20130626-204845-a83ca5bdf7 (OpenJDK 64-Bit Server VM, Java 1.7.0_21). Type in expressions to have them evaluated. Type :help for more information. scala> :load multy.script Loading multy.script... i: Int = 7 j: Int = 8 res0: Int = 56 scala> :load multy.script Loading multy.script... i: Int = 7 j: Int = 8 res1: Int = 56 ```
* | Merge pull request #2701 from som-snytt/issue/4594-repl-settingsAdriaan Moors2013-07-101-10/+54
|\ \ | | | | | | SI-4594 Repl settings command
| * | SI-4594 Repl settings commandSom Snytt2013-07-041-10/+54
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A settings command for the rest of us. The usual command line options are used, except that boolean flags are enabled with +flag and disabled with -flag. ``` scala> :settings +deprecation scala> new BigInt(java.math.BigInteger.TEN) { } <console>:8: warning: inheritance from class BigInt in package math is deprecated: This class will me made final. new BigInt(java.math.BigInteger.TEN) { } ^ res0: BigInt = 10 scala> :settings -deprecation scala> new BigInt(java.math.BigInteger.TEN) { } res1: BigInt = 10 ``` Multivalue "colon" options can be reset by supplying no values after the colon. This behavior is different from the command line. ``` scala> 1 toString warning: there were 1 feature warning(s); re-run with -feature for details res0: String = 1 scala> :settings -language:postfixOps scala> 1 toString res1: String = 1 scala> :settings -d = . -encoding = UTF-8 -explaintypes = false -language = List(postfixOps) -nowarn = false scala> :settings -language: scala> :settings -d = . -encoding = UTF-8 -explaintypes = false -language = List() -nowarn = false ```
* | Merge pull request #2706 from som-snytt/issue/repl-editAdriaan Moors2013-07-101-0/+86
|\ \ | | | | | | SI-7637 Repl edit command
| * | SI-7637 Repl edit commandSom Snytt2013-07-041-0/+86
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Open an editor with historical text. :edit id will use the complete text of the defining line, including a multiline expression or template definition. The id must be a term or type in scope, in particular, defined in the current session. :edit line will use the specified line(s) from history, as a line number (123), range (123-130), offset (123+7), remaining (123-) or previous (-10 for last ten lines). The env var EDITOR is used to specify an editor to invoke. If EDITOR is not set or if :line command is used, the selected text is added to the end of history. Text is still added to history one line at a time (cf SI-1067).
* / Unfork jline: use vanilla jline 2.11 as a dependency.Adriaan Moors2013-07-055-9/+14
|/ | | | | | | | Notes: - no longer specifying terminal by class name in scripts (using 'unix') - jline doesn't need a separate jansi dependency; it includes its own version according to: http://mvnrepository.com/artifact/jline/jline/2.11
* SI-6855: REPL emits error on partial pastieSom Snytt2013-06-221-2/+14
| | | | | | | If pasted code is interpreted with an incomplete result, attempt to compile it to display an error. Unfancily, the code is wrapped in an object for compilation.
* SI-7418 Avoid concurrent use of compiler in REPL startupJason Zaugg2013-06-051-4/+5
| | | | | | | | | | | | | | Enable the tab completer *after* we're finished binding $intp and unleashing power mode on the asynchronous REPL startup thread. Tested manually: - run qbin/scala - Paste "".toUp - Hit <TAB> like a maniac Before this patch, the crash was reproducible almost every time. Afterwards, not the once.
* Merge pull request #2584 from som-snytt/issue/repl-tools-jarPaul Phillips2013-05-261-9/+1
|\ | | | | SI-7410 REPL uses improved tools.jar locator
| * SI-7410 REPL uses improved tools.jar locatorSom Snytt2013-05-231-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic in partest for snooping around for tools.jar is moved to PathResolver, and ILoop uses it from there. If JAVA_HOME is toolless, check out java.home. The use case was that Ubuntu installs with `java` at version 6 and `javac` at version 7; it's easy to wind up with JAVA_HOME pointing at the version 6 JRE, as I discovered. It's confusing when that happens. In future, partest might run under 7 and fork tests under 6, but those permutations are downstream.
* | Concision contribution.Paul Phillips2013-05-231-3/+3
|/ | | | | | | | | | | | | | | | | | | | | We have lots of core classes for which we need not go through the symbol to get the type: ObjectClass.tpe -> ObjectTpe AnyClass.tpe -> AnyTpe I updated everything to use the concise/direct version, and eliminated a bunch of noise where places were calling typeConstructor, erasedTypeRef, and other different-seeming methods only to always wind up with the same type they would have received from sym.tpe. There's only one Object type, before or after erasure, with or without type arguments. Calls to typeConstructor were especially damaging because (see previous commit) it had a tendency to cache a different type than the type one would find via other means. The two types would compare =:=, but possibly not == and definitely not eq. (I still don't understand what == is expected to do with types.)
* Merge pull request #2541 from rjolly/scripting11Adriaan Moors2013-05-171-1/+9
|\ | | | | ScriptEngine.eval() forwards Error instead of new ScriptException
| * ScriptEngine.eval() forwards Error instead of new ScriptExceptionRaphael Jolly2013-05-161-1/+9
| |
* | Merge pull request #2542 from rjolly/scripting12Paul Phillips2013-05-171-1/+1
|\ \ | | | | | | Read-eval-print : the script engine does not need print so make it lazy
| * | Read-eval-print : the script engine does not need print so make it lazyRaphael Jolly2013-05-161-1/+1
| |/ | | | | | | | | This can have a dramatic effect on computing time in cases with big intermediate results but simple final one.
* | Merge pull request #2340 from folone/topic/kind-prAdriaan Moors2013-05-173-3/+67
|\ \ | |/ |/| Added a :kind command to the REPL
| * Add :kind command to REPLEugene Yokota2013-04-203-3/+67
| | | | | | | | | | | | | | | | :kind command diplays the kind of types and type constructors in Scala syntax notation. scala> :kind (Int, Int) => Int scala.Function2's kind is F[-A1,-A2,+A3]
* | Absolutized paths involving the scala package.Paul Phillips2013-05-037-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Confusing, now-it-happens now-it-doesn't mysteries lurk in the darkness. When scala packages are declared like this: package scala.collection.mutable Then paths relative to scala can easily be broken via the unlucky presence of an empty (or nonempty) directory. Example: // a.scala package scala.foo class Bar { new util.Random } % scalac ./a.scala % mkdir util % scalac ./a.scala ./a.scala:4: error: type Random is not a member of package util new util.Random ^ one error found There are two ways to play defense against this: - don't use relative paths; okay sometimes, less so others - don't "opt out" of the scala package This commit mostly pursues the latter, with occasional doses of the former. I created a scratch directory containing these empty directories: actors annotation ant api asm beans cmd collection compat concurrent control convert docutil dtd duration event factory forkjoin generic hashing immutable impl include internal io logging macros man1 matching math meta model mutable nsc parallel parsing partest persistent process pull ref reflect reify remote runtime scalap scheduler script swing sys text threadpool tools transform unchecked util xml I stopped when I could compile the main src directories even with all those empties on my classpath.
* | Eliminated the accumulated feature warnings.Paul Phillips2013-04-231-0/+1
| | | | | | | | | | | | | | | | | | No, this isn't busywork, how dare you suggest such a thing. I intend my tombstone to say HERE LIES EXTEMPORE, WHO ELIMINATED A LOT OF SIP-18 WARNINGS REST IN PEACE
* | Eliminate a pile of -Xlint warnings.Paul Phillips2013-04-232-4/+2
|/ | | | | | Some unused private code, unused imports, and points where an extra pair of parentheses is necessary for scalac to have confidence in our intentions.
* SI-7261 Implicit conversion of BooleanSetting to Boolean and BooleanFlagSom Snytt2013-03-274-6/+6
| | | | | | | This commit shortens expressions of the form `if (settings.debug.value)` to `if (settings.debug)` for various settings. Rarely, the setting is supplied as a method argument. The conversion is not employed in simple definitions where the Boolean type would have to be specified.
* The script engine is given a better binding mechanism and reflexive accessRaphael Jolly2013-03-222-4/+61
| | | | | | | | | | | | Better binding mecanism : formerly done through the default SimpleBindings shipped with the API, it now goes through a custom IBindings class which uses the bind method of the interpreter instead of simply making the bindings available as a Map. Reflexive access : the script engine is made available to itself through a bound variable "engine" of type javax.script.ScriptEngine. This will allow "variable injection" i.e. programmatic redefinition of variables, among others.
* Merge pull request #2239 from paulp/pr/warningsAdriaan Moors2013-03-212-2/+0
|\ | | | | Warnings removal and other cleanup.
| * Eliminate a bunch of -Xlint warnings.Paul Phillips2013-03-122-2/+0
| | | | | | | | | | | | Mostly unused private code, unused imports, and points where an extra pair of parentheses is necessary for scalac to have confidence in our intentions.
* | SI-874 actual JSR-223 implementationRaphael Jolly2013-03-111-25/+149
|/
* Modularized the repl.Paul Phillips2013-03-1148-0/+5856
Following in the footsteps of scaladoc and interactive. The interpreter sources move into src/repl, and are given a separate build target. As with the others, at present they are still packaged into scala-compiler.jar. A summary of changes: - repl requires use of ReplGlobal (this was already implied) - macro code's repl-specific classloader hack pulled into overridable method and overridden in ReplGlobal - removed -Ygen-javap option to eliminate backend's dependency on javap - removed -Yrepl-debug option (can still be enabled with -Dscala.repl.debug) - pushed javap code into src/repl so javax.tools dependency can bee weakened to the repl only - removed some "show pickled" related code which hasn't worked right in a while and isn't the right way to do it anymore anyway. Will return to fix showPickled and provide it with some tests.