@@ -33,6 +33,7 @@ withCompiler=true
33
33
CompilerMain=dotty.tools.dotc.Main
34
34
DecompilerMain=dotty.tools.dotc.decompiler.Main
35
35
ReplMain=dotty.tools.repl.Main
36
+ ScriptingMain=dotty.tools.scripting.Main
36
37
37
38
PROG_NAME=$CompilerMain
38
39
@@ -45,6 +46,9 @@ addScala () {
45
46
addResidual () {
46
47
residual_args+=(" '$1 '" )
47
48
}
49
+ addScripting () {
50
+ scripting_args+=(" '$1 '" )
51
+ }
48
52
49
53
classpathArgs () {
50
54
# echo "dotty-compiler: $DOTTY_COMP"
@@ -74,6 +78,7 @@ classpathArgs () {
74
78
jvm_cp_args=" -classpath \" $toolchain \" "
75
79
}
76
80
81
+ in_scripting_args=false
77
82
while [[ $# -gt 0 ]]; do
78
83
case " $1 " in
79
84
--) shift ; for arg; do addResidual " $arg " ; done ; set -- ;;
@@ -85,6 +90,7 @@ case "$1" in
85
90
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
86
91
-Oshort) addJava " -XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
87
92
-repl) PROG_NAME=" $ReplMain " && shift ;;
93
+ -script) PROG_NAME=" $ScriptingMain " && target_script=" $2 " && in_scripting_args=true && shift && shift ;;
88
94
-compile) PROG_NAME=" $CompilerMain " && shift ;;
89
95
-decompile) PROG_NAME=" $DecompilerMain " && shift ;;
90
96
-print-tasty) PROG_NAME=" $DecompilerMain " && addScala " -print-tasty" && shift ;;
@@ -98,12 +104,22 @@ case "$1" in
98
104
# will be available as system properties.
99
105
-D* ) addJava " $1 " && shift ;;
100
106
-J* ) addJava " ${1: 2} " && shift ;;
101
- * ) addResidual " $1 " && shift ;;
107
+ * ) if [ $in_scripting_args == false ]; then
108
+ addResidual " $1 "
109
+ else
110
+ addScripting " $1 "
111
+ fi
112
+ shift
113
+ ;;
102
114
esac
103
115
done
104
116
105
117
classpathArgs
106
118
119
+ if [ " $PROG_NAME " == " $ScriptingMain " ]; then
120
+ scripting_string=" -script $target_script ${scripting_args[@]} "
121
+ fi
122
+
107
123
eval exec " \" $JAVACMD \" " \
108
124
${JAVA_OPTS:- $default_java_opts } \
109
125
" $DEBUG " \
@@ -112,5 +128,6 @@ eval exec "\"$JAVACMD\"" \
112
128
-Dscala.usejavacp=true \
113
129
" $PROG_NAME " \
114
130
" ${scala_args[@]} " \
115
- " ${residual_args[@]} "
131
+ " ${residual_args[@]} " \
132
+ " $scripting_string "
116
133
exit $?
0 commit comments