~kameliya/piret

1f7f0673d7dd05a316e0d9dcef634bbb3f46fdff — Arlen Christian Mart Cuss 8 years ago ca53a0e
SUCCESSFUL BOOTSTRAP
3 files changed, 20 insertions(+), 5 deletions(-)

M .gitignore
M piretc.pi
M strap
M .gitignore => .gitignore +2 -0
@@ 5,3 5,5 @@ boot1
boot2
boot1.c
boot2.c
boot3
boot3.c

M piretc.pi => piretc.pi +13 -4
@@ 319,7 319,7 @@
    (eq name (symbol "while"))
     (do
       (set v (index args 0))
       (set w (index args 1))
       (set w (from args 1))
       (puts "while (1) {
")
       (set v (call process v))


@@ 330,7 330,8 @@
  }
  if (!(")
       (puts v)
       (puts ").integer) { break; }")
       (puts ").integer) { break; }
")
       (set i 0)
       (while (neq nil (index w i))
         (call process (index w i))


@@ 723,6 724,14 @@
       (puts ").integer]);
")
       vn)
    (eq name (symbol "return"))
     (do
       (set v (call process (index args 0)))
       (puts "  return ")
       (puts v)
       (puts ";
")
       "piret_nil()")
    true
     (do
       (print value)


@@ 831,11 840,11 @@
        (set arglist (index n 3))
        (set varlist (index n 4))
        (set rest (from n 5))
        (if (eq name "main")
        (if (eq name (symbol "main"))
          (puts "int main(int argc, char **argv) {
")
          (do
            (puts "struct piret_val ")
            (puts "struct piret_val piret_user_")
            (puts (call procsym name))
            (puts "(")
            (set j 0)

M strap => strap +5 -1
@@ 4,4 4,8 @@ gcc -std=gnu99 boot1.c -g -o boot1 || (echo 'failed boot1'; exit 1) || exit 1
gcc -std=gnu99 boot2.c -g -o boot2 || (echo 'failed boot2'; exit 1) || exit 1
./boot2 piretc.pi > boot3.c
gcc -std=gnu99 boot3.c -g -o boot3 || (echo 'failed boot3'; exit 1) || exit 1
diff boot2.c boot3.c
if [ x"`diff boot2.c boot3.c`" != x ]; then
	echo "boot2.c and boot3.c differ (failure)"
else
	echo "boot2.c and boot3.c are identical (success)"
fi