-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_extracted_examples.sh
executable file
·66 lines (52 loc) · 1.76 KB
/
run_extracted_examples.sh
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
#!/bin/bash
EXAMPLES_DIR=Source/Examples
EXTRACTION_DIR=/tmp
SOURCE_PREFIX="run_source_"
INTERMEDIATE_PREFIX="run_intermediate_compiled_"
TARGET_PREFIX="run_target_compiled_"
MP_PREFIX="run_compiled_"
if (( $# == 1 )); then
if [[ $1 = "--force-extraction" ]]; then
echo "*** Forcing extraction ***"
touch $EXAMPLES_DIR/*.v
make
fi
fi
cp Lib/big.ml $EXTRACTION_DIR/big.ml
pushd $EXTRACTION_DIR
ocamlc -a nums.cma big.ml -o big.cma
# ocamlc -c nums.cma Extraction/big.ml -o $EXTRACTION_DIR/big.cmo
# run source examples
echo "*** Running examples at the source level ***"
for example in $SOURCE_PREFIX*.ml; do
# prepend big int import to each example
echo -e "open Big_int\n$(cat $example)" > $example
# run the example
echo "Output of $example:"
ocaml nums.cma big.cma $example
done
# run compiled examples at the intermediate level
echo "*** Examples compiled at the intermediate level ***"
for example in $INTERMEDIATE_PREFIX*.ml; do
# prepend big int import to each example
echo -e "open Big_int\n$(cat $example)" > $example
echo "Output of $example:"
ocaml nums.cma big.cma $example
done
# run sources compiled to target
echo "*** Examples compiled at the SFI level ***"
for example in $TARGET_PREFIX*.ml; do
# prepend big int import to each example
echo -e "open Big_int;;\n$(cat $example)" > $example
echo "Output of $example:"
ocaml nums.cma big.cma $example
done
# # run compiled examples at the micro-policy level
# echo "*** Examples compiled at the micro-policy level ***"
# for example in $MP_PREFIX*.ml; do
# # prepend big int import to each example
# echo -e "open Big_int\n$(cat $example)" > $example
# echo "Output of $example:"
# ocaml nums.cma big.cma $example
# done
popd