aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure18
-rw-r--r--configure.ac2
-rw-r--r--configure.ac.pamphlet2
-rw-r--r--src/ChangeLog7
-rw-r--r--src/interp/compiler.boot137
-rw-r--r--src/interp/newaux.lisp2
6 files changed, 91 insertions, 77 deletions
diff --git a/configure b/configure
index 6f2867f3..bd370e50 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for OpenAxiom 1.4.0-2010-05-07.
+# Generated by GNU Autoconf 2.63 for OpenAxiom 1.4.0-2010-05-10.
#
# Report bugs to <open-axiom-bugs@lists.sf.net>.
#
@@ -745,8 +745,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='OpenAxiom'
PACKAGE_TARNAME='openaxiom'
-PACKAGE_VERSION='1.4.0-2010-05-07'
-PACKAGE_STRING='OpenAxiom 1.4.0-2010-05-07'
+PACKAGE_VERSION='1.4.0-2010-05-10'
+PACKAGE_STRING='OpenAxiom 1.4.0-2010-05-10'
PACKAGE_BUGREPORT='open-axiom-bugs@lists.sf.net'
ac_unique_file="src/Makefile.pamphlet"
@@ -1513,7 +1513,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures OpenAxiom 1.4.0-2010-05-07 to adapt to many kinds of systems.
+\`configure' configures OpenAxiom 1.4.0-2010-05-10 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1583,7 +1583,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of OpenAxiom 1.4.0-2010-05-07:";;
+ short | recursive ) echo "Configuration of OpenAxiom 1.4.0-2010-05-10:";;
esac
cat <<\_ACEOF
@@ -1691,7 +1691,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-OpenAxiom configure 1.4.0-2010-05-07
+OpenAxiom configure 1.4.0-2010-05-10
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1705,7 +1705,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by OpenAxiom $as_me 1.4.0-2010-05-07, which was
+It was created by OpenAxiom $as_me 1.4.0-2010-05-10, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
@@ -21182,7 +21182,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by OpenAxiom $as_me 1.4.0-2010-05-07, which was
+This file was extended by OpenAxiom $as_me 1.4.0-2010-05-10, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -21245,7 +21245,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-OpenAxiom config.status 1.4.0-2010-05-07
+OpenAxiom config.status 1.4.0-2010-05-10
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index b861e645..f6330c90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
sinclude(config/open-axiom.m4)
sinclude(config/aclocal.m4)
-AC_INIT([OpenAxiom], [1.4.0-2010-05-07],
+AC_INIT([OpenAxiom], [1.4.0-2010-05-10],
[open-axiom-bugs@lists.sf.net])
AC_CONFIG_AUX_DIR(config)
diff --git a/configure.ac.pamphlet b/configure.ac.pamphlet
index 3e728094..3a1fd6d5 100644
--- a/configure.ac.pamphlet
+++ b/configure.ac.pamphlet
@@ -1210,7 +1210,7 @@ information:
<<Autoconf init>>=
sinclude(config/open-axiom.m4)
sinclude(config/aclocal.m4)
-AC_INIT([OpenAxiom], [1.4.0-2010-05-07],
+AC_INIT([OpenAxiom], [1.4.0-2010-05-10],
[open-axiom-bugs@lists.sf.net])
@
diff --git a/src/ChangeLog b/src/ChangeLog
index 62e3808c..d62c3ed0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-10 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/compiler.boot (freeVarUsage): New. Split out of
+ compWithMappingMode.
+ (finishLambdaExpression): Likewise.
+ (compWithMappingMode): Restructure.
+
2010-05-09 Gabriel Dos Reis <gdr@cs.tamu.edu>
Add lambda expression syntax to Boot.
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index bee89e0c..4f8d46d3 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -270,101 +270,108 @@ hasFormalMapVariable(x, vl) ==
ScanOrPairVec(function hasone?,x) where
hasone? x == MEMQ(x,$formalMapVariables)
-compWithMappingMode(x,m is ["Mapping",m',:sl],oldE) ==
- $killOptimizeIfTrue: local:= true
- e:= oldE
- isFunctor x =>
- if get(x,"modemap",$CategoryFrame) is [[[.,target,:argModeList],.],:.] and
- (and/[extendsCategoryForm("$",s,mode) for mode in argModeList for s in sl]
- ) and extendsCategoryForm("$",target,m') then return [x,m,e]
- if string? x then x:= INTERN x
- for m in sl for v in (vl:= take(#sl,$FormalMapVariableList)) repeat
- [.,.,e]:= compMakeDeclaration(v,m,e)
- (vl ~= nil) and not hasFormalMapVariable(x, vl) => return
- [u,.,.] := comp([x,:vl],m',e) or return nil
- extractCodeAndConstructTriple(u, m, oldE)
- null vl and (t := comp([x], m', e)) => return
- [u,.,.] := t
- extractCodeAndConstructTriple(u, m, oldE)
- [u,.,.]:= comp(x,m',e) or return nil
- uu:=optimizeFunctionDef [nil,["LAMBDA",vl,u]]
- -- At this point, we have a function that we would like to pass.
- -- Unfortunately, it makes various free variable references outside
- -- itself. So we build a mini-vector that contains them all, and
- -- pass this as the environment to our inner function.
- $FUNNAME :local := nil
- $FUNNAME__TAIL :local := [nil]
- expandedFunction:= transformToBackendCode second uu
- frees:=FreeList(expandedFunction,vl,nil,e)
- where FreeList(u,bound,free,e) ==
+
+++ Return the usage list of free variables in a lambda expresion.
+++ The usage list is an a-list (name, number of timed used.)
+freeVarUsage([.,vars,body],env) ==
+ freeList(body,vars,nil,env) where
+ freeList(u,bound,free,e) ==
atom u =>
not IDENTP u => free
MEMQ(u,bound) => free
- v:=ASSQ(u,free) =>
+ v := ASSQ(u,free) =>
v.rest := 1 + rest v
free
- null getmode(u,e) => free
+ getmode(u,e) = nil => free
[[u,:1],:free]
op := first u
op in '(QUOTE GO function) => free
op = "LAMBDA" =>
bound := UNIONQ(bound, second u)
for v in CDDR u repeat
- free:=FreeList(v,bound,free,e)
+ free := freeList(v,bound,free,e)
free
op = "PROG" =>
bound := UNIONQ(bound, second u)
- for v in CDDR u | not atom v repeat
- free:=FreeList(v,bound,free,e)
+ for v in CDDR u | cons? v repeat
+ free := freeList(v,bound,free,e)
free
op = "SEQ" =>
- for v in rest u | not atom v repeat
- free:=FreeList(v,bound,free,e)
+ for v in rest u | cons? v repeat
+ free := freeList(v,bound,free,e)
free
op = "COND" =>
for v in rest u repeat
for vv in v repeat
- free:=FreeList(vv,bound,free,e)
+ free := freeList(vv,bound,free,e)
free
- if atom op then u := rest u --Atomic functions aren't descended
+ if atom op then --Atomic functions aren't descended
+ u := rest u
for v in u repeat
- free:=FreeList(v,bound,free,e)
+ free := freeList(v,bound,free,e)
free
+
+++ Finish processing a lambda expression with parameter list `vars',
+++ and `env' as the environement after the compilation its body.
+finishLambdaExpression(expr is ["LAMBDA",vars,.],env) ==
+ $FUNNAME: local := nil
+ $FUNNAME__TAIL: local := [nil]
+ expandedFunction := transformToBackendCode expr
+ frees := freeVarUsage(expandedFunction,env)
+ vec := nil -- mini-vector
expandedFunction :=
- --One free can go by itself, more than one needs a vector
- --An A-list name . number of times used
- #frees = 0 => ["LAMBDA",[:vl,"$$"], :CDDR expandedFunction]
- #frees = 1 =>
- vec:=first first frees
- ["LAMBDA",[:vl,vec], :CDDR expandedFunction]
- scode:=nil
- vec:=nil
- slist:=nil
- locals:=nil
- i:=-1
+ frees = nil => ["LAMBDA",[:vars,"$$"], :CDDR expandedFunction]
+ -- At this point, we have a function that we would like to pass.
+ -- Unfortunately, it makes various free variable references outside
+ -- itself. So we build a mini-vector that contains them all, and
+ -- pass this as the environment to our inner function.
+ -- One free can go by itself, more than one needs a vector.
+ frees is [[var,:.]] =>
+ vec := var
+ ["LAMBDA",[:vars,var],:CDDR expandedFunction]
+ scode := nil
+ slist := nil -- list of single used variables, no local bindings.
+ locals := nil -- list of multiple used variables, need local bindings.
+ i := -1
for v in frees repeat
- i:=i+1
- vec:=[first v,:vec]
- rest v = 1 =>
- --Only used once
- slist:=[[first v,"getShellEntry","$$",i],:slist]
- scode:=[['SETQ,first v,["getShellEntry","$$",i]],:scode]
- locals:=[first v,:locals]
- body:=
+ i := i+1
+ vec := [first v,:vec]
+ rest v = 1 => slist := [[first v,"getShellEntry","$$",i],:slist]
+ scode := [['SETQ,first v,["getShellEntry","$$",i]],:scode]
+ locals := [first v,:locals]
+ body :=
slist => SUBLISNQ(slist,CDDR expandedFunction)
CDDR expandedFunction
if locals then
if body is [["DECLARE",:.],:.] then
body := [first body,["PROG",locals,:scode,
["RETURN",["PROGN",:rest body]]]]
- else body:=[["PROG",locals,:scode,["RETURN",["PROGN",:body]]]]
- vec:=["VECTOR",:nreverse vec]
- ["LAMBDA",[:vl,"$$"],:body]
- fname:=["CLOSEDFN",expandedFunction] --Like QUOTE, but gets compiled
- uu:=
- frees => ["CONS",fname,vec]
- ["LIST",fname]
- [uu,m,oldE]
+ else body := [["PROG",locals,:scode,["RETURN",["PROGN",:body]]]]
+ vec := ["VECTOR",:nreverse vec]
+ ["LAMBDA",[:vars,"$$"],:body]
+ fname := ["CLOSEDFN",expandedFunction] --Like QUOTE, but gets compiled
+ frees = nil => ["LIST",fname]
+ ["CONS",fname,vec]
+
+compWithMappingMode(x,m is ["Mapping",m',:sl],oldE) ==
+ $killOptimizeIfTrue: local:= true
+ e:= oldE
+ isFunctor x =>
+ if get(x,"modemap",$CategoryFrame) is [[[.,target,:argModeList],.],:.] and
+ (and/[extendsCategoryForm("$",s,mode) for mode in argModeList for s in sl]
+ ) and extendsCategoryForm("$",target,m') then return [x,m,e]
+ if string? x then x:= INTERN x
+ for m in sl for v in (vl:= take(#sl,$FormalMapVariableList)) repeat
+ [.,.,e]:= compMakeDeclaration(v,m,e)
+ (vl ~= nil) and not hasFormalMapVariable(x, vl) => return
+ [u,.,.] := comp([x,:vl],m',e) or return nil
+ extractCodeAndConstructTriple(u, m, oldE)
+ null vl and (t := comp([x], m', e)) => return
+ [u,.,.] := t
+ extractCodeAndConstructTriple(u, m, oldE)
+ [u,.,.]:= comp(x,m',e) or return nil
+ [.,fun] := optimizeFunctionDef [nil,["LAMBDA",vl,u]]
+ [finishLambdaExpression(fun,e),m,oldE]
extractCodeAndConstructTriple(u, m, oldE) ==
u is ["%Call",fn,:.] =>
@@ -2198,7 +2205,7 @@ compReduce1(form is ["REDUCE",op,.,collectForm],m,e,$formalArgList) ==
$endTestList: local := nil
oldEnv := e
$e:= e
- itl:= [([.,$e]:= compIterator(x,$e) or return "failed").(0) for x in itl]
+ itl:= [([.,$e]:= compIterator(x,$e) or return "failed").0 for x in itl]
itl="failed" => return nil
e:= $e
acc:= GENSYM()
diff --git a/src/interp/newaux.lisp b/src/interp/newaux.lisp
index 60475d2e..b5d82ba4 100644
--- a/src/interp/newaux.lisp
+++ b/src/interp/newaux.lisp
@@ -122,7 +122,7 @@
(/\\ 250 251) (\\/ 200 201)
(\.\. SEGMENT 401 699 (|PARSE-Seg|))
(=> 123 103)
- (+-> 998 112)
+ (+-> 122 121)
(== DEF 122 121)
(==> MDEF 122 121)
(\| 108 111) ;was 190 190