-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmyjit-unique.sh
executable file
·58 lines (43 loc) · 1.15 KB
/
myjit-unique.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
#!/bin/bash
PREFIX="jit_internal_"
TARGET_DIR="../myjit-unique"
SCRIPT=`mktemp`
#
# lists all functions in the source codes passed to the stdin
#
function list_functions {
sed -n -e '/^[[:alpha:]].*(/p' | \
sed -e 's/\([A-Za-z0-9_]*\)(.*/#\1/' -e 's/.*#//' | \
grep -v '^\(jit\|JIT\)' | sort | uniq
}
#
# lists all types in the source codes passed to the stdin
#
function list_types {
tr '\r\n' ' ' | sed -e 's/{[^}]*}//g' | tr ';' '\n' | sed -n -e '/typedef/ {s/.* //p}' | \
grep -v "^jit" | sort | uniq | grep -v "value"
}
function list_constants {
echo "OUT_REGS"
echo "x86_cc_unsigned_map"
echo "x86_cc_signed_map"
}
#
# reads a list of symbols from stdin and prints sed script
#
function create_sed_script {
while read SYMBOL; do
echo "s/\b$SYMBOL/$PREFIX$SYMBOL/g"
done
}
cat ../myjit/*.c ../myjit/*.h | list_functions | create_sed_script > "$SCRIPT"
cat ../myjit/*.c ../myjit/*.h | list_types | create_sed_script >> "$SCRIPT"
cat ../myjit/*.c ../myjit/*.h | list_constants | create_sed_script >> "$SCRIPT"
mkdir -p "$TARGET_DIR"
cd ../myjit
for FILE in *.c *.h
do
echo $FILE
sed -f "$SCRIPT" $FILE > "$TARGET_DIR/$FILE"
done
rm -f "$SCRIPT"