aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure20
-rw-r--r--configure.ac2
-rw-r--r--src/ChangeLog12
-rw-r--r--src/interp/compiler.boot96
4 files changed, 109 insertions, 21 deletions
diff --git a/configure b/configure
index 24db3418..2f5f7d0e 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.65 for OpenAxiom 1.5.0-2011-09-03.
+# Generated by GNU Autoconf 2.65 for OpenAxiom 1.5.0-2011-11-02.
#
# Report bugs to <open-axiom-bugs@lists.sf.net>.
#
@@ -701,8 +701,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='OpenAxiom'
PACKAGE_TARNAME='openaxiom'
-PACKAGE_VERSION='1.5.0-2011-09-03'
-PACKAGE_STRING='OpenAxiom 1.5.0-2011-09-03'
+PACKAGE_VERSION='1.5.0-2011-11-02'
+PACKAGE_STRING='OpenAxiom 1.5.0-2011-11-02'
PACKAGE_BUGREPORT='open-axiom-bugs@lists.sf.net'
PACKAGE_URL=''
@@ -1493,7 +1493,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.5.0-2011-09-03 to adapt to many kinds of systems.
+\`configure' configures OpenAxiom 1.5.0-2011-11-02 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1568,7 +1568,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of OpenAxiom 1.5.0-2011-09-03:";;
+ short | recursive ) echo "Configuration of OpenAxiom 1.5.0-2011-11-02:";;
esac
cat <<\_ACEOF
@@ -1679,7 +1679,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-OpenAxiom configure 1.5.0-2011-09-03
+OpenAxiom configure 1.5.0-2011-11-02
generated by GNU Autoconf 2.65
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -2669,7 +2669,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.5.0-2011-09-03, which was
+It was created by OpenAxiom $as_me 1.5.0-2011-11-02, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ $0 $@
@@ -5570,7 +5570,7 @@ fi
# Define the identity of the package.
PACKAGE='openaxiom'
- VERSION='1.5.0-2011-09-03'
+ VERSION='1.5.0-2011-11-02'
cat >>confdefs.h <<_ACEOF
@@ -21575,7 +21575,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=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.5.0-2011-09-03, which was
+This file was extended by OpenAxiom $as_me 1.5.0-2011-11-02, which was
generated by GNU Autoconf 2.65. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -21641,7 +21641,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-OpenAxiom config.status 1.5.0-2011-09-03
+OpenAxiom config.status 1.5.0-2011-11-02
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 1a6bbc30..3b8c86c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ dnl Makefiles for building OpenAxiom interpreter, compiler, libraries, and
dnl auxiliary tools where appropriate.
dnl
-AC_INIT([OpenAxiom], [1.5.0-2011-09-03],
+AC_INIT([OpenAxiom], [1.5.0-2011-11-02],
[open-axiom-bugs@lists.sf.net])
dnl Most of the macros used in this configure.ac are defined in files
diff --git a/src/ChangeLog b/src/ChangeLog
index d404b7fe..04edac55 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,17 @@
+2011-11-02 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ Add compiler support for implicit parameters.
+ * interp/compiler.boot (bindPredicateExistentials): Rename from
+ constructorCondition. Now return a substitution on success,
+ otherwise failure.
+ (solveEquation): New.
+ (solveSubsumption): Likewise.
+ (deduceImplicitParameters): Likewise.
+ (evaluateConstructorModemap): Use it. Tidy.
+
2011-10-31 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ Add interpreter support for implicit parameters.
* interp/i-funsel.boot (evalMmCond0): Tidy. Call evalMmGuard to
validate modemap evaluation.
(evalMmGuard): New.
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index 074d225e..88ef6691 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -721,10 +721,77 @@ reshapeArgumentList(form,sig) ==
wantArgumentsAsTuple(args,sig) => [op,["%Comma",:args]]
form
-++ Return true is the constructor condition `cond' holds in the
-++ elaboration environmemt `e'.
-constructorCondition(cond,e) ==
- cond --FIXME: solve it!
+++ Attempt to find values for queries variables `vars' so that
+++ the category expression `x' equals the category expression `p'.
+solveEquation(x,p,sl,vars) ==
+ ident? p and symbolMember?(p,vars) =>
+ z := symbolTarget(p,sl) =>
+ x = z => sl
+ 'failed
+ [[p,:x],:sl]
+ x isnt [.,:.] or p isnt [.,:.] =>
+ x = p => sl
+ 'failed
+ symbolEq?(x.op,p.op) =>
+ #x.args ~= #p.args => 'failed
+ x.args = nil => sl
+ and/[sl := solveEquation(x',p',sl,vars)
+ for x' in x.args for p' in p.args
+ | sl isnt 'failed or leave 'failed]
+ 'failed
+
+++ Attempt to find values for queries variables `vars' so that
+++ the category expression `x' subsumes the category expression `p'.
+solveSubsumption(x,p,sl,vars,typings,e) ==
+ x isnt [.,:.] or p isnt [.,:.] => solveEquation(x,p,sl,vars)
+ p = $Type => sl
+ symbolEq?(x.op,p.op) => solveEquation(x,p,sl,vars)
+ x.op is 'Join =>
+ x.args = nil => 'failed
+ or/[sl' := solveSubsumption(x',p,sl,vars,typings,e) for x' in x.args
+ | sl' isnt 'failed] or 'failed
+ x is ['CATEGORY,.,:xs] =>
+ or/[sl' := solveSubsumption(x',p,sl,vars,typings,e) for x' in xs
+ | sl' isnt 'failed] or 'failed
+ x.op in '(SIGNATURE ATTRIBUTE) => 'failed
+ getConstructorKind x.op isnt 'category => 'failed --FIXME: for now.
+ x := applySubst(constructSubst x,getConstructorCategory x.op)
+ solveSubsumption(x,p,sl,vars,typings,e)
+
+++ Subroutine of bindPredicateExistentials, with similar semantics.
+++ `vars' is the list of quantified variables, and `conds' is a
+++ of conditions the conjunction of which makes the whole predicate.
+deduceImplicitArguments(vars,conds,e) ==
+ eqs := nil -- equation constraints
+ typings := nil -- typing constraints
+ sl := nil
+ for c in conds while sl isnt 'failed repeat
+ c is ['ofCategory,x,y] => -- subsumption constraint
+ ident? x and symbolMember?(x,vars) =>
+ typings := [[x,:y],:typings]
+ eqs := [[x,:y],:eqs]
+ c is ['ofType,x,y] => -- exact type constraints
+ T := comp(x,$EmptyMode,e)
+ T = nil => sl := 'failed
+ sl := solveEquation(T.mode,y,sl,vars)
+ for [x,:y] in eqs while sl isnt 'failed repeat
+ cat :=
+ x isnt [.,:.] => getXmode(x,e)
+ applySubst(constructSubst x,getConstructorCategory x.op)
+ sl := solveSubsumption(cat,y,sl,vars,typings,e)
+ sl is 'failed => sl
+ -- Every existential must have a value
+ or/[symbolTarget(v,sl) = nil for v in vars] => 'failed
+ sl --FIXME: check typing constraints
+
+++ Attempt to find values for existentially quantified variables in
+++ the predicate `cond' so that it holds in the environment `e'.
+++ Return a substitution on success; otherwise fail.
+bindPredicateExistentials(cond,e) ==
+ cond is true => nil -- identity substitution
+ cond is ['%exist,vars,['AND,:conds]] =>
+ deduceImplicitArguments(vars,conds,e)
+ 'failed
++ The argument list `argl' is used to instantiate a constructor
++ with `modemap' in environment `e'. Return the resulting
@@ -734,13 +801,22 @@ evaluateConstructorModemap(argl,modemap is [[dc,:sig],:.],e) ==
keyedSystemError("S2GE0016",['"evaluateConstructorModemap",
'"Incompatible maps"])
#argl ~= #sig.source => nil
- constructorCondition(applySubst(sl,modemap.mmCondition),e) isnt true => nil
+ -- Get `source-level' subtitution in an attempt to deduce implicits.
sl := pairList(dc.args,argl)
- --make new modemap, subst. actual for formal parameters into modemap
- Tl := [[.,.,e] := compOrCroak(a,m,e)
- for a in argl for m in applySubst(sl,modemap.mmSource)]
- sl := [[x,:T.expr] for x in dc.args for T in Tl]
- [applySubst(sl,modemap),e]
+ sl' := bindPredicateExistentials(applySubst(sl,modemap.mmCondition),e)
+ sl' is 'failed => nil
+ -- Subtitute values for implicit in formal modemap. Then substitute
+ -- the `source-level' arguments into the resulting modemap, before
+ -- compiling them. Note the sort of bootstrapping process.
+ signature := applySubst(sl',modemap.mmSignature)
+ args' := [x for a in argl for m in applySubst(sl,signature.source)
+ | [x,.,e] := compOrCroak(a,m,e)]
+ -- Now substitutte elaborations of actual arguments into the formal
+ -- signature to construct the final result.
+ signature := applySubst(pairList(dc.args,args'),signature)
+ -- At this point, the modemap condition was evaluated successfully,
+ -- so we return plain `true' for that part of the modemap.
+ [[[[dc.op,:args'],:signature],[true,dc.op]],e]
--% SPECIAL EVALUATION FUNCTIONS