-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute.sh
executable file
·42 lines (32 loc) · 1.22 KB
/
execute.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
#!/bin/bash
#
# Execute the generated code
#
# This script takes in the filename of the ORIGINAL program AFTER the codegen has been run
# i.e. programs/3-semantics+codegen/valid/test.go
#
# It MUST then
# (a) Compile the GENERATED file
# i.e. programs/3-semantics+codegen/valid/main/test.java
# (b) Execute the compiled code
#
#
# To conform with the verification script, this script MUST:
# (a) Output ONLY the execution
# You MUST replace the following line with the command to compile your generated code
# Note the bash replacement which changes:
# programs/3-semantics+codegen/valid/test.go -> programs/3-semantics+codegen/valid/main/test.java
EXECUTEPATH="$(dirname ${1%.*})"
JAVAFILEWITHDASHES="$(basename ${1%.*})GoLite"
JAVAFILE="${JAVAFILEWITHDASHES//[-0-9_]}"
javac $EXECUTEPATH/$JAVAFILE.java
# You MUST replace the following line with the command to execute your compiled code
# Note the bash replacement which changes:
# programs/3-semantics+codegen/valid/test.go -> programs/3-semantics+codegen/valid/main/test.java
cd $EXECUTEPATH
java $JAVAFILE
EXITCODE="${?}"
# clean up directory
rm *.java *.class STRUCT*.class Slice.class Cast.class 2> /dev/null
# Lastly, we propagate the exit code
exit $EXITCODE