aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2009-02-18 15:37:25 +0000
committerdos-reis <gdr@axiomatics.org>2009-02-18 15:37:25 +0000
commitf04f6bff2bb92b851b5aef56c6846fd01b493d7d (patch)
treec6a1e58944d528c6e4671d891d7dcf4c9804ed7c /src/interp
parent54c2b07353f228554b92269a9a4e688683ae85d6 (diff)
downloadopen-axiom-f04f6bff2bb92b851b5aef56c6846fd01b493d7d.tar.gz
* interp/parse.boot (parseHas): Constants are not attributes.
* interp/compiler.boot (compHasFormat): Handle signature for constants too. * interp/info.boot (actOnInfo): Likewise. * algebra/data.spad.pamphlet (sample$Byte): Make a constant. (SystemInteger): Export constant 'sample'. (SystemNonNegativeInteger): Likewise. * algebra/aggcat2.spad.pamphlet (FiniteLinearAggregateFunctions2): Use 'sample' or 'random' elements when allocating new aggregates.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/compiler.boot6
-rw-r--r--src/interp/info.boot19
-rw-r--r--src/interp/parse.boot1
3 files changed, 14 insertions, 12 deletions
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index aa09ea1f..b5faa805 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -1101,6 +1101,7 @@ compElt(form,m,E) ==
E:= addDomain(aDomain,E)
mmList:= getModemapListFromDomain(anOp,0,aDomain,E)
modemap:=
+ -- FIXME: do this only for constants.
n:=#mmList
1=n => mmList.(0)
0=n =>
@@ -1112,7 +1113,6 @@ compElt(form,m,E) ==
mmList.(0)
[sig,[pred,val]]:= modemap
#sig^=2 and ^val is ["elt",:.] => nil --what does the second clause do ????
---+
val := genDeltaEntry [opOf anOp,:modemap]
convert([["call",val],first rest sig,E], m) --implies fn calls used to access constants
compForm(form,m,E)
@@ -1121,9 +1121,7 @@ compElt(form,m,E) ==
compHas: (%Form,%Mode,%Env) -> %Maybe %Triple
compHas(pred is ["has",a,b],m,$e) ==
- --b is (":",:.) => (.,.,E):= comp(b,$EmptyMode,E)
$e:= chaseInferences(pred,$e)
- --pred':= ("has",a',b') := formatHas(pred)
predCode:= compHasFormat pred
coerce([predCode,$Boolean,$e],m)
@@ -1136,7 +1134,7 @@ compHasFormat (pred is ["has",olda,b]) ==
[a,:.] := comp(a,$EmptyMode,$e) or return nil
a := SUBLISLIS(formals,argl,a)
b is ["ATTRIBUTE",c] => ["HasAttribute",a,["QUOTE",c]]
- b is ["SIGNATURE",op,sig] =>
+ b is ["SIGNATURE",op,sig,:.] =>
["HasSignature",a,
mkList [MKQ op,mkList [mkTypeForm type for type in sig]]]
isCategoryForm(b,$e) => ["HasCategory",a,mkTypeForm b]
diff --git a/src/interp/info.boot b/src/interp/info.boot
index 36daa11c..878b78b0 100644
--- a/src/interp/info.boot
+++ b/src/interp/info.boot
@@ -97,7 +97,7 @@ formatInfo u ==
b="%noBranch" => ["COND",:liftCond [["not",formatPred a],formatInfo c]]
["COND",:liftCond [formatPred a,formatInfo b],:
liftCond [["not",formatPred a],formatInfo c]]
- systemError '"formatInfo"
+ systemError ['"formatInfo",u]
liftCond (clause is [ante,conseq]) ==
conseq is ["COND",:l] =>
@@ -118,7 +118,7 @@ formatPred u ==
["has",a,["ATTRIBUTE",b]]
atom u => u
u is ["and",:v] => ["and",:[formatPred w for w in v]]
- systemError '"formatPred"
+ systemError ['"formatPred",u]
chaseInferences(pred,$e) ==
foo hasToInfo pred where
@@ -220,18 +220,21 @@ actOnInfo(u,$e) ==
cat:= ["CATEGORY",key,["ATTRIBUTE",att]]
$e:= put(name,"value",[vval,mkJoin(cat,vmode),venv],$e)
--there is nowhere %else that this sort of thing exists
- u is ["SIGNATURE",name,operator,modemap] =>
+ u is ["SIGNATURE",name,operator,modemap,:q] =>
+ kind :=
+ q is ["constant"] => "CONST"
+ "ELT"
implem:=
(implem:=ASSOC([name,:modemap],get(operator,'modemap,$e))) =>
CADADR implem
- name = "$" => ['ELT,name,-1]
- ['ELT,name,substitute('$,name,modemap)]
+ name = "$" => [kind,name,-1]
+ [kind,name,substitute('$,name,modemap)]
$e:= addModemap(operator,name,modemap,true,implem,$e)
[vval,vmode,venv]:= GetValue name
compilerMessage('"augmenting %1: %2p",
- [name,["SIGNATURE",operator,modemap]])
+ [name,["SIGNATURE",operator,modemap,:q]])
key:= if CONTAINED("$",vmode) then "domain" else name
- cat:= ["CATEGORY",key,["SIGNATURE",operator,modemap]]
+ cat:= ["CATEGORY",key,["SIGNATURE",operator,modemap,:q]]
$e:= put(name,"value",[vval,mkJoin(cat,vmode),venv],$e)
u is ["has",name,cat] =>
[vval,vmode,venv]:= GetValue name
@@ -255,7 +258,7 @@ actOnInfo(u,$e) ==
$e:= put(name,"value",[vval,mkJoin(cat,vmode),venv],$e)
SAY("extension of ",vval," to ",cat," ignored")
$e
- systemError '"knownInfo"
+ systemError ['"actOnInfo",u]
mkJoin(cat,mode) ==
mode is ['Join,:cats] => ['Join,cat,:cats]
diff --git a/src/interp/parse.boot b/src/interp/parse.boot
index cff6ef7c..92c040bd 100644
--- a/src/interp/parse.boot
+++ b/src/interp/parse.boot
@@ -211,6 +211,7 @@ parseHas t ==
kk = "domain" or kk = "category" => [makeNonAtomic y]
y is ["ATTRIBUTE",:.] => [y]
y is ["SIGNATURE",:.] => [y]
+ y is [":",op,type] => [["SIGNATURE",op,[type],"constant"]]
[["ATTRIBUTE",y]]
parseDEF: %ParseForm -> %Form