aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@axiomatics.org>2016-01-31 00:42:06 -0800
committerGabriel Dos Reis <gdr@axiomatics.org>2016-01-31 00:42:06 -0800
commitafdfc4da685d9988f8675798bad70a4fccdc4e2d (patch)
tree6b5b060ba5e760c37aee60643a5aca8c56252003 /src
parent79f3a421e49a1b5baf5dd9bed6c2d640dac7dc95 (diff)
downloadopen-axiom-afdfc4da685d9988f8675798bad70a4fccdc4e2d.tar.gz
Remove a couple of global states from the compiler.
Diffstat (limited to 'src')
-rw-r--r--src/interp/c-util.boot8
-rw-r--r--src/interp/define.boot24
2 files changed, 15 insertions, 17 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot
index 431e17d9..05e29723 100644
--- a/src/interp/c-util.boot
+++ b/src/interp/c-util.boot
@@ -141,13 +141,13 @@ macro domainData d ==
structure %CompilationData ==
Record(subst: %Substitution,idata: %Substitution,bytes: List %Fixnum,
shell: %Vector %Thing, items: %Buffer %Pair(%SourceEntity,%Code),
- sigdefs: %List %Thing, lib: %Libstream,outpath: %Pathname) with
+ capsule: %List %Thing, lib: %Libstream,outpath: %Pathname) with
cdSubstitution == (.subst)
cdImplicits == (.idata)
cdBytes == (.bytes)
cdShell == (.shell)
cdItems == (.items)
- cdSignatureDefinitions == (.sigdefs)
+ cdCapsule == (.capsule)
cdLib == (.lib)
cdOutput == (.outpath)
@@ -193,6 +193,9 @@ macro dbUsedEntities db ==
macro dbEntityCount db ==
rest dbEntityBuffer db
+macro dbCapsuleIR db ==
+ cdCapsule dbCompilerData db
+
macro dbLibstream db ==
cdLib dbCompilerData db
@@ -1266,7 +1269,6 @@ $capsuleDirectory := nil
clearCapsuleDirectory() ==
$capsuleDirectory := nil
- $capsuleFunctionStack := nil
++ Return the linkage name of the exported operation associated with
++ slot number `slot'. A nil entry means that either the operation
diff --git a/src/interp/define.boot b/src/interp/define.boot
index 55db10b7..7ed53af4 100644
--- a/src/interp/define.boot
+++ b/src/interp/define.boot
@@ -56,9 +56,6 @@ compDefine1: (%Maybe %Database,%Form,%Mode,%Env) -> %Maybe %Triple
$doNotCompileJustPrint := false
-++ stack of pending capsule function definitions.
-$capsuleFunctionStack := []
-
--%
$forceAdd := false
@@ -700,11 +697,12 @@ emitSubdomainInfo(form,super,pred) ==
++ record that the operation `op' with signature `sig' and predicate
++ `pred' is defined in the current capsule of the current domain
++ being compiled.
-noteCapsuleFunctionDefinition(cd,op,sig,pred) ==
- listMember?([op,sig,pred],cdSignatureDefinitions cd) =>
+noteCapsuleFunctionDefinition(db,op,sig,pred,impl) ==
+ spec := [[op,:sig],:pred]
+ assoc(spec,dbCapsuleDefinitions db) =>
stackAndThrow('"redefinition of %1b: %2 %3",
[op,formatUnabbreviated ["Mapping",:sig],formatIf pred])
- cdSignatureDefinitions(cd) := [[op,sig,pred],:cdSignatureDefinitions cd]
+ dbCapsuleDefinitions(db) := [[spec,:impl],:dbCapsuleDefinitions db]
++ List of exports (paireed with scope predicate) declared in
++ the category of the currend domain or package.
@@ -1598,11 +1596,11 @@ compFunctorBody(db,body,m,e) ==
$bootStrapMode => incompleteFunctorBody(db,m,body,e)
clearCapsuleDirectory() -- start collecting capsule functions.
T:= compOrCroak(body,m,e)
- $capsuleFunctionStack := reverse! $capsuleFunctionStack
+ dbCapsuleIR(db) := reverse! dbCapsuleIR db
-- ??? Don't resolve default definitions, yet.
backendCompile(db,defs) where defs() ==
- $insideCategoryPackageIfTrue => $capsuleFunctionStack
- foldExportedFunctionReferences(db,$capsuleFunctionStack)
+ $insideCategoryPackageIfTrue => dbCapsuleIR db
+ foldExportedFunctionReferences(db,dbCapsuleIR db)
clearCapsuleDirectory() -- release storage.
body is [op,:.] and op in '(add CAPSULE) => T
$NRTaddForm :=
@@ -1937,8 +1935,6 @@ encodeFunctionName(db,fun,signature,count) ==
strconc(toString n,encodeItem x)
encodedName:= makeSymbol strconc(symbolName dbAbbreviation db,'";",
symbolName fun,'";",encodedSig,'";",toString count)
- dbCapsuleDefinitions(db) :=
- [[encodedName,signature],:dbCapsuleDefinitions db]
encodedName
compDefineCapsuleFunction(db,df is ['DEF,form,signature,body],
@@ -1979,8 +1975,6 @@ compDefineCapsuleFunction(db,df is ['DEF,form,signature,body],
sayBrightly ['" compiling ",localOrExported,
:bright $op,'": ",:formattedSig]
- pred := mkpf($predl,'and)
- noteCapsuleFunctionDefinition(dbCompilerData db,$op,signature,pred)
T := CATCH('compCapsuleBody, compOrCroak(body,rettype,e))
or [$ClearBodyToken,rettype,e]
-- A THROW to the above CATCH occurs if too many semantic errors occur
@@ -1994,6 +1988,8 @@ compDefineCapsuleFunction(db,df is ['DEF,form,signature,body],
userError ['"%b",$op,'"%d",'" is local and exported"]
makeSymbol strconc(symbolName $prefix,'";",symbolName $op)
encodeFunctionName(db,$op,signature,$suffix)
+ pred := mkpf($predl,'and)
+ noteCapsuleFunctionDefinition(db,$op,signature,pred,op')
if n ~= nil and not $insideCategoryPackageIfTrue then
updateCapsuleDirectory([n,:op'],pred)
-- Let the backend know about this function's type
@@ -2149,7 +2145,7 @@ spadCompileOrSetq(db,form is [nam,[lam,vl,body]]) ==
$insideCapsuleFunctionIfTrue =>
$optExportedFunctionReference =>
- $capsuleFunctionStack := [form,:$capsuleFunctionStack]
+ dbCapsuleIR(db) := [form,:dbCapsuleIR db]
first form
first backendCompile(db,[form])
compileConstructor(db,form)