#!/bin/sh

# make sure the initial build process was run

if [ ! -f bin/simpvir ]; then
  echo "run build.sh"
  exit 0
fi

if [ ! -f bin/shmall ]; then
  echo "run build.sh"
  exit 0
fi

if [ ! -f bin/schant-int ]; then
  echo "run build.sh"
  exit 0
fi

if [ ! -f bin/schant-bigfloat8 ]; then
  echo "run build.sh"
  exit 0
fi

if [ ! -f bin/schant-bigfloat12 ]; then
  echo "run build.sh"
  exit 0
fi

# the following script uses the shmall C compiler to compile hello.c to
# a file called hello whilch contains simpvir bytecodes.
./compile-with-shmall-to-simpvir.sh hello
# execute the hello bytecodes
cat hello | bin/simpvir
rm hello

# the following script uses the shmall C compiler to compile hello.c to
# a native binary in the file hello.
COMPILATION_METHOD=object # use the binary form of the shmall compiler
                          # could use the simpvir bytecode version of shmall
STACK_SIZE=100 # set the combined stack / heap size to number of 32 bit words
./compile-with-shmall-to-native.sh hello $COMPILATION_METHOD $STACK_SIZE
# execute the binary
./hello
rm hello

# the following script uses the schant scheme compiler to compile hello.scm to
# schant bytecode in the file hello.
echo '(display "hello world") (newline)' >hello.scm
cat bin/schant-compiler.txt hello.scm | bin/schant-bigfloat8 >hello.txt
rm hello.scm
# execute the hello bytecodes with the version of schant which has
# no floating point
cat hello.txt | bin/schant-int
# execute the hello bytecodes with the version of schant which has
# 8 digit precision floating point
cat hello.txt | bin/schant-bigfloat8
# execute the hello bytecodes with the version of schant which has
# 12 digit precision floating point
cat hello.txt | bin/schant-bigfloat12
rm hello.txt
