@@ -54,15 +54,15 @@ case "`uname`" in
5454esac
5555
5656unset CYGPATHCMD
57- if [[ $cygwin || $mingw || $msys ]]; then
57+ if [[ ${ cygwin-} || ${ mingw-} || ${ msys-} ]]; then
5858 # ConEmu terminal is incompatible with jna-5.*.jar
59- [[ ($CONEMUANSI || $ConEmuANSI ) ]] && conemu=true
59+ [[ (${ CONEMUANSI-} || ${ ConEmuANSI-} ) ]] && conemu=true
6060 # cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc.
6161 CYGPATHCMD=` which cygpath 2> /dev/null`
6262 case " $TERM " in
6363 rxvt* | xterm* | cygwin* )
6464 stty -icanon min 1 -echo
65- SCALA_OPTS =" $SCALA_OPTS -Djline.terminal=unix"
65+ JAVA_OPTS =" $JAVA_OPTS -Djline.terminal=unix"
6666 ;;
6767 esac
6868fi
@@ -111,14 +111,14 @@ CLASSPATH_SUFFIX=""
111111PSEP=" :"
112112
113113# translate paths to Windows-mixed format before running java
114- if [ -n " $CYGPATHCMD " ]; then
115- [ -n " $PROG_HOME " ] &&
114+ if [ -n " ${ CYGPATHCMD-} " ]; then
115+ [ -n " ${ PROG_HOME-} " ] &&
116116 PROG_HOME=` " $CYGPATHCMD " -am " $PROG_HOME " `
117117 [ -n " $JAVA_HOME " ] &&
118118 JAVA_HOME=` " $CYGPATHCMD " -am " $JAVA_HOME " `
119119 CLASSPATH_SUFFIX=" ;"
120120 PSEP=" ;"
121- elif [[ $mingw || $msys ]]; then
121+ elif [[ ${ mingw-} || ${ msys-} ]]; then
122122 # For Mingw / Msys, convert paths from UNIX format before anything is touched
123123 [ -n " $PROG_HOME " ] &&
124124 PROG_HOME=" ` (cd " $PROG_HOME " ; pwd -W | sed ' s|/|\\\\|g' )` "
@@ -155,8 +155,95 @@ SBT_INTF=$(find_lib "*compiler-interface*")
155155JLINE_READER=$( find_lib " *jline-reader-3*" )
156156JLINE_TERMINAL=$( find_lib " *jline-terminal-3*" )
157157JLINE_TERMINAL_JNA=$( find_lib " *jline-terminal-jna-3*" )
158- [[ $conemu ]] || JNA=$( find_lib " *jna-5*" )
158+ [[ ${ conemu-} ]] || JNA=$( find_lib " *jna-5*" )
159159
160160# debug
161161
162162DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
163+
164+ classpathArgs () {
165+ # echo "dotty-compiler: $DOTTY_COMP"
166+ # echo "dotty-interface: $DOTTY_INTF"
167+ # echo "dotty-library: $DOTTY_LIB"
168+ # echo "tasty-core: $TASTY_CORE"
169+ # echo "scala-asm: $SCALA_ASM"
170+ # echo "scala-lib: $SCALA_LIB"
171+ # echo "sbt-intface: $SBT_INTF"
172+
173+ toolchain=" "
174+ toolchain+=" $SCALA_LIB$PSEP "
175+ toolchain+=" $DOTTY_LIB$PSEP "
176+ toolchain+=" $SCALA_ASM$PSEP "
177+ toolchain+=" $SBT_INTF$PSEP "
178+ toolchain+=" $DOTTY_INTF$PSEP "
179+ toolchain+=" $DOTTY_COMP$PSEP "
180+ toolchain+=" $TASTY_CORE$PSEP "
181+ toolchain+=" $DOTTY_STAGING$PSEP "
182+ toolchain+=" $DOTTY_TASTY_INSPECTOR$PSEP "
183+
184+ # jine
185+ toolchain+=" $JLINE_READER$PSEP "
186+ toolchain+=" $JLINE_TERMINAL$PSEP "
187+ toolchain+=" $JLINE_TERMINAL_JNA$PSEP "
188+ toolchain+=" $JNA$PSEP "
189+
190+ jvm_cp_args=" -classpath \" $toolchain \" "
191+ }
192+
193+ default_java_opts=" -Xmx768m -Xms768m"
194+
195+ addJava () {
196+ java_args+=(" '$1 '" )
197+ }
198+ addScala () {
199+ scala_args+=(" '$1 '" )
200+ }
201+ addResidual () {
202+ residual_args+=(" '$1 '" )
203+ }
204+ addScripting () {
205+ scripting_args+=(" '$1 '" )
206+ }
207+ prepScalacCommandLine () {
208+ withCompiler=true
209+
210+ CompilerMain=dotty.tools.dotc.Main
211+ DecompilerMain=dotty.tools.dotc.decompiler.Main
212+ ReplMain=dotty.tools.repl.Main
213+ ScriptingMain=dotty.tools.scripting.Main
214+
215+ while [[ $# -gt 0 ]]; do
216+ case " $1 " in
217+ --) shift ; for arg; do addResidual " $arg " ; done ; set -- ;;
218+ -v|-verbose) verbose=true && addScala " -verbose" && shift ;;
219+ -debug) DEBUG=" $DEBUG_STR " && shift ;;
220+ -q|-quiet) quiet=true && shift ;;
221+
222+ # Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
223+ -Oshort) addJava " -XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
224+ -repl) PROG_NAME=" $ReplMain " && shift ;;
225+ -script) PROG_NAME=" $ScriptingMain " && target_script=" $2 " && shift && shift
226+ while [[ $# -gt 0 ]]; do addScripting " $1 " && shift ; done ;;
227+ -compile) PROG_NAME=" $CompilerMain " && shift ;;
228+ -decompile) PROG_NAME=" $DecompilerMain " && shift ;;
229+ -print-tasty) PROG_NAME=" $DecompilerMain " && addScala " -print-tasty" && shift ;;
230+ -run) PROG_NAME=" $ReplMain " && shift ;;
231+ -colors) colors=true && shift ;;
232+ -no-colors) unset colors && shift ;;
233+ -with-compiler) jvm_cp_args=" $PSEP$DOTTY_COMP$PSEP$TASTY_CORE " && shift ;;
234+
235+ # break out -D and -J options and add them to java_args so
236+ # they reach the JVM in time to do some good. The -D options
237+ # will be available as system properties.
238+ -D* ) addJava " $1 " && shift ;;
239+ -J* ) addJava " ${1: 2} " && shift ;;
240+ * ) addResidual " $1 " && shift ;;
241+ esac
242+ done
243+
244+ classpathArgs
245+
246+ if [ " $PROG_NAME " == " $ScriptingMain " ]; then
247+ scripting_string=" -script $target_script ${scripting_args[@]} "
248+ fi
249+ }
0 commit comments