Cory Spencer <[EMAIL PROTECTED]> wrote:

>      http://www.sprocket.org/pcl/pcl-0.1.0.tar.gz

Below is a patch against 0.1.0
- handle a command line file argument:

  $ cat t.lisp
  (print (+ 2 3))
  $ ../parrot lisp.imc t.lisp
  5

- use a FixedPMCArray for cons
- much faster _LIST_LENGTH (not that I start optimizing it, but the
  trace with the original version was *really* big)
- trailing ws removed by a vim macro

> -c

leo
diff -ur pcl-0.1.0/internals.imc pcl-leo/internals.imc
--- pcl-0.1.0/internals.imc     Thu Apr 14 04:52:07 2005
+++ pcl-leo/internals.imc       Tue Apr 19 17:10:22 2005
@@ -267,7 +267,7 @@
 .sub _IS_SPECIAL
   .param pmc symbol
   .local pmc special
-  .local int retv   
+  .local int retv
 
    retv = 1
 
@@ -381,7 +381,7 @@
   .CAR(clval, clargsptr)                       # The lexical value
   .CAR(clarg, clprotptr)                       # The lexical arg prototype
 
-   clsymname = clarg._get_name_as_string()     
+   clsymname = clarg._get_name_as_string()
    clsym = _LEXICAL_SYMBOL(clsymname, clval)   # Create a new lexical symbol
 
   .CDR(clargsptr, clargsptr)
@@ -408,13 +408,13 @@
    pop_pad
 
   .ERROR_0("program-error", "Too few arguments given to LAMBDA")
-   goto CLOSURE_DONE  
+   goto CLOSURE_DONE
 
 CLOSURE_TOO_MANY_ARGS:
    pop_pad
 
   .ERROR_0("program-error", "Too many arguments given to LAMBDA")
-   goto CLOSURE_DONE  
+   goto CLOSURE_DONE
 
 CLOSURE_DONE:
    returncc
@@ -431,9 +431,12 @@
 
    lptr = args
    alen = 0
+  .sym pmc _nilp
+
+  .NIL(_nilp)
 
 LOOP:
-  .NULL(lptr, DONE)
+  eq_addr lptr, _nilp, DONE
    inc alen
   .CDR(lptr, lptr)
    goto LOOP
@@ -519,4 +522,4 @@
 
 DONE:
   .return(retv)
-.end
\ No newline at end of file
+.end
diff -ur pcl-0.1.0/lisp.imc pcl-leo/lisp.imc
--- pcl-0.1.0/lisp.imc  Thu Apr 14 04:16:29 2005
+++ pcl-leo/lisp.imc    Tue Apr 19 17:16:17 2005
@@ -10,6 +10,7 @@
 .include "include/macros.imc"
 
 .sub _main @MAIN
+  .param pmc argv
   .local pmc symbol
   .local pmc stream
   .local pmc name
@@ -24,15 +25,29 @@
 
    new_pad 0                           # Create the null lexical environment.
 
-   push_eh DEBUGGER                    # Setup error handler for debug loop.
 
   .STRING(name, "lisp/bootstrap.l")    # Load the lisp bootstrap file.
   .LIST_1(args, name)
    _load(args)
 
+   $I0 = argv
+   if $I0 <= 1 goto go_rep
+      $S0 = argv[1]
+      $P0 = open $S0, "<"
+      .STREAM($P1, $P0)
+      .LIST_1(args, $P1)                       # Read!
+      retv = _read(args)
+
+      .LIST_1(args, retv)                      # Eval!
+      retv = _eval(args)
+      end
+
+go_rep:
+
    symbol = _LOOKUP_GLOBAL("COMMON-LISP", "*STANDARD-INPUT*")
    stream = symbol._get_value()
 
+   push_eh DEBUGGER                    # Setup error handler for debug loop.
 REP_LOOP:
    print "-> "                         # Display the top level prompt.
 
Only in pcl-leo/: t.lisp
diff -ur pcl-0.1.0/types.imc pcl-leo/types.imc
--- pcl-0.1.0/types.imc Thu Apr 14 04:49:56 2005
+++ pcl-leo/types.imc   Tue Apr 19 15:27:45 2005
@@ -2,7 +2,7 @@
 .sub _init_types
   .local pmc class
 
-   subclass class, "Array", "LispCons"
+   subclass class, "FixedPMCArray", "LispCons"
 
    subclass class, "Float", "LispFloat"
 
@@ -417,7 +417,7 @@
    goto DONE
 
 DONE:
-   top = stack 
+   top = stack
    top = top - 1
 
    symbol = stack[top]
@@ -454,7 +454,7 @@
    top = top - 1
 
    symbol = stack[top]
- 
+
   .return(symbol)
 .end
 
@@ -822,7 +822,7 @@
 .sub __get_bool method
   .local pmc retv
 
-   getprop retv, "defined", self  
+   getprop retv, "defined", self
 
   .return(retv)
 .end

Reply via email to