aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog8
-rw-r--r--src/interp/c-util.boot4
-rw-r--r--src/interp/define.boot17
3 files changed, 27 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8bcccaa2..52592a9b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
2008-10-05 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/c-util.boot ($optExportedFunctionReference): New.
+ (setCompilerOptimizations): Set it.
+ * interp/define.boot ($capsuleFunctionStack): New.
+ (spadCompileOrSetq): Collect capsule function definitions.
+ (compFunctorBody): Compile them at end of capsule.
+
+2008-10-05 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/c-util.boot (getFunctionReplacement): Tidy.
* algebra/data.spad.pamphlet (Byte): Likewise.
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot
index a85d8bb0..080e683d 100644
--- a/src/interp/c-util.boot
+++ b/src/interp/c-util.boot
@@ -58,6 +58,8 @@ $optProclaim := false
++ true if we have to inline simple functions before codegen.
$optReplaceSimpleFunctions := false
+++ true if we have to resolve references to exported operations.
+$optExportedFunctionReference := false
--%
@@ -904,6 +906,8 @@ setCompilerOptimizations level ==
if level > 0 then
$optProclaim := true
$optReplaceSimpleFunctions := true
+ if level > 1 then
+ $optExportedFunctionReference := true
coreError '"unknown optimization level request"
diff --git a/src/interp/define.boot b/src/interp/define.boot
index 58c39f1b..7dc8a79a 100644
--- a/src/interp/define.boot
+++ b/src/interp/define.boot
@@ -37,6 +37,8 @@ import cattable
import category
namespace BOOT
+module define
+
--%
NRTPARSE := false
@@ -55,9 +57,11 @@ $suffix := nil
-- ??? turns off buggy code
$NRTopt := false
-
$doNotCompileJustPrint := false
+++ stack of pending capsule function definitions.
+$capsuleFunctionStack := []
+
--%
++ List of operations defined in a given capsule
@@ -659,7 +663,10 @@ disallowNilAttribute x ==
compFunctorBody(body,m,e,parForm) ==
$bootStrapMode = true =>
[bootStrapError($functorForm, _/EDITFILE),m,e]
+ $capsuleFunctionStack := nil -- start collecting capsule functions.
T:= compOrCroak(body,m,e)
+ COMP $capsuleFunctionStack
+ $capsuleFunctionStack := nil -- release storage.
body is [op,:.] and MEMQ(op,'(add CAPSULE)) => T
$NRTaddForm :=
body is ["SubDomain",domainForm,predicate] => domainForm
@@ -1244,7 +1251,11 @@ spadCompileOrSetq (form is [nam,[lam,vl,body]]) ==
macform := ['XLAM,vl',body]
LAM_,EVALANDFILEACTQ ['PUT,MKQ nam,MKQ 'SPADreplace,MKQ macform]
sayBrightly ['" ",:bright nam,'"is replaced by",:bright body]
- $insideCapsuleFunctionIfTrue => first COMP LIST form
+ $insideCapsuleFunctionIfTrue =>
+ $optExportedFunctionReference =>
+ $capsuleFunctionStack := [form,:$capsuleFunctionStack]
+ first form
+ first COMP LIST form
compileConstructor form
compileConstructor form ==
@@ -1679,3 +1690,5 @@ compCategoryItem(x,predl,env) ==
diagnoseUknownType(t,env)
noteExport(rest x,pred)
PUSH(MKQ [rest x,pred],$sigList)
+
+--%