forked from runtimeverification/python-semantics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkpython
More file actions
executable file
·42 lines (42 loc) · 1.99 KB
/
Copy pathkpython
File metadata and controls
executable file
·42 lines (42 loc) · 1.99 KB
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
#!/bin/bash
ENVIRON=`env | sed "s/^/\"/" | sed "s/$/\"/" | sed "s/=/\" |-> \"/" | tr "\n" " "`
DIR=$(dirname $0)
PYTHON_BINARY=`which python3.3`
PYTHON_PREFIX=${PYTHON_BINARY%/bin/python3.3}
PYTHON_LIB=$PYTHON_PREFIX/lib/python3.3
IMPORTLIB=$PYTHON_LIB/importlib/_bootstrap.py
#IMPORTLIB=$DIR/fake-importlib.py
HASH_COMMON=' "sys.hash_info.inf" |-> 314159 "sys.hash_info.nan" |-> 0 "sys.hash_info.imag" |-> 1000003 "tuple.__hash__:begin" |-> 3430008 "tuple.__hash__:addend" |-> 82520 "tuple.__hash__:end" |-> 97531'
THIRTYTWO_BIT='"sys.hash_info.width" |-> 32 "sys.hash_info.modulus" |-> 147483647'"$HASH_COMMON"
SIXTYFOUR_BIT='"sys.hash_info.width" |-> 64 "sys.hash_info.modulus" |-> 2305843009213693951'"$HASH_COMMON"
DEBUG='"PYTHONOPTIMIZE" |-> 0'
VERBOSE='"PYTHONVERBOSE" |-> false'
DEFAULT_BUFFER_SIZE='"_io.DEFAULT_BUFFER_SIZE" |-> 8192'
HASHINFO=$SIXTYFOUR_BIT
#HASHINFO=$THIRTYTWO_BIT
GC_THRESHOLD=100
PROGRAM_DIR="\"\""
# if we pass a program to kpython, sys.path[0] should be the absolute path to the directory the program is in
SYS_ARGV=""
PAST=
for var in "$@"; do
if [ "$PAST" -a "$SYS_ARGV" = "" ]; then
PROGRAM_DIR=`dirname $var | xargs readlink -f`
PROGRAM_DIR=`printf "\"%q\"" $PROGRAM_DIR`
fi
if [ "$PAST" ]; then
SYS_ARGV="$SYS_ARGV ListItem(\"$var\")"
fi
if [ "$var" = "--" -a "$SYS_ARGV" = "" ]; then
PAST=1
fi
done
if [ "$SYS_ARGV" = "" ]; then
SYS_ARGV=".List"
fi
SYS_PATH="ListItem($PROGRAM_DIR) ListItem(\"$PYTHON_LIB\")"
HASHSEED='"PYTHONHASHSEED" |-> 1'
ERRNO=`python3.3 $DIR/errno.py`
OS='"sys.platform" |-> "linux" "posix.O_WRONLY" |-> 1 "posix.O_CREAT" |-> 64 "posix.O_EXCL" |-> 128'
ulimit -s `ulimit -H -s`
krun --compiled-def "$DIR/python-kompiled" --parser "$DIR/parse.py" -cGCTHRESHOLD="$GC_THRESHOLD" -cSYSPATH="$SYS_PATH" -cSYSARGV="$SYS_ARGV" -cCONSTANTS="$DEBUG $VERBOSE $HASHINFO $HASHSEED $OS $ERRNO $DEFAULT_BUFFER_SIZE" -cENVIRON="$ENVIRON" -cSEMANTICSDIR=" \"$DIR/\" " --cfg-parser="$DIR/parse.py" -cIMPORTLIB="$IMPORTLIB" --cfg-parser="kast -groundParser -e" "$@"