forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotr
executable file
·110 lines (96 loc) · 2.42 KB
/
dotr
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env bash
# Try to autodetect real location of the script
if [ -z "$PROG_HOME" ] ; then
## resolve links - $0 may be a link to PROG_HOME
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
PROG_HOME=`dirname "$PRG"`/..
# make it fully qualified
PROG_HOME=`cd "$PROG_HOME" && pwd`
cd "$saveddir"
fi
addJvmOptions () {
jvm_options+=("$1")
}
addDotcOptions () {
java_options+=("$1")
}
source "$PROG_HOME/bin/common"
declare -a residual_args
execute_repl=false
execute_run=false
with_compiler=false
class_path_count=0
CLASS_PATH=""
# Little hack to check if all arguments are options
all_params="$*"
truncated_params="${*#-}"
# options_indicator != 0 if at least one parameter is not an option
options_indicator=$(( ${#all_params} - ${#truncated_params} - $# ))
while [[ $# -gt 0 ]]; do
case "$1" in
-repl)
execute_repl=true
shift
;;
-run)
execute_run=true
shift
;;
-classpath)
CLASS_PATH="$2"
class_path_count+=1
shift
shift
;;
-with-compiler)
with_compiler=true
shift
;;
-d)
DEBUG="$DEBUG_STR"
shift
;;
-J*)
addJvmOptions "${1:2}"
addDotcOptions "${1}"
shift ;;
*)
residual_args+=("$1")
shift
;;
esac
done
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ $options_indicator == 0 ]); then
if [ "$CLASS_PATH" ]; then
cp_arg="-classpath \"$CLASS_PATH\""
fi
echo "Starting dotty REPL..."
eval "\"$PROG_HOME/bin/dotc\" $cp_arg ${java_options[@]} -repl ${residual_args[@]}"
elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB"
if [ -z "$CLASS_PATH" ]; then
cp_arg+="$PSEP."
else
cp_arg+="$PSEP$CLASS_PATH"
fi
if [ "$class_path_count" -gt 1 ]; then
echo "warning: multiple classpaths are found, dotr only use the last one."
fi
if [ $with_compiler == true ]; then
cp_arg+="$PSEP$DOTTY_COMP$PSEP$TASTY_CORE$PSEP$DOTTY_INTF$PSEP$SCALA_ASM$PSEP$DOTTY_STAGING$PSEP$DOTTY_TASTY_INSPECTOR"
fi
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${jvm_options[@]}" "${residual_args[@]}"
else
echo "warning: command option is not correct."
fi