1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* NSC -- new Scala compiler
* Copyright 2006 LAMP/EPFL
* @author Lex Spoon
*/
// $Id$
package scala.tools.nsc
import scala.collection.mutable.Queue
class GenericRunnerSettings(error: String => Unit)
extends Settings(error) {
val howtorun =
ChoiceSetting(
"-howtorun",
"how to run the specified code",
List("guess", "object", "script"),
"guess")
val savecompiled =
BooleanSetting(
"-savecompiled",
"save the compiled script (assumes the code is a script)")
/* For some reason, "object defines extends Setting(...)"
does not work here. The object is present but the setting
is not added to allsettings. Thus,
*/
class DefinesSetting
extends Setting("-D<prop>", "set a Java property")
{
private val props = new Queue[Pair[String, String]]
def value = props.toList
def tryToSet(args: List[String]): List[String] = {
args match {
case arg0::rest
if arg0.startsWith("-D") =>
{
val stripD = arg0.substring(2)
val eqidx = stripD.indexOf('=')
val addition =
if(eqidx < 0)
Pair(stripD, "")
else
Pair(stripD.substring(0, eqidx), stripD.substring(eqidx+1))
props += addition
rest
}
case _ => args
}
}
/** Apply the specified properties to the current JVM */
def applyToCurrentJVM = {
val systemProps = System.getProperties
for(val Pair(key, value) <- props.toList)
systemProps.setProperty(key, value)
}
}
val defines = new DefinesSetting
}
|