aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@axiomatics.org>2016-12-29 02:13:58 -0800
committerGabriel Dos Reis <gdr@axiomatics.org>2016-12-29 02:13:58 -0800
commit2bd3cc876cc90b8e28e0e8d88a5982f69729f867 (patch)
tree89fb25441b1c7868411aeeb169bc3b34eec6a31a /src/boot
parenta8a3b2cdf66d274c831ad6229e6123e9cd68e07d (diff)
downloadopen-axiom-2bd3cc876cc90b8e28e0e8d88a5982f69729f867.tar.gz
Add Boot support for native load unit specification in foreign
function import.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/Makefile.in1
-rw-r--r--src/boot/ast.boot7
-rw-r--r--src/boot/parser.boot23
-rw-r--r--src/boot/translator.boot14
4 files changed, 35 insertions, 10 deletions
diff --git a/src/boot/Makefile.in b/src/boot/Makefile.in
index 4a06e736..c3d91bec 100644
--- a/src/boot/Makefile.in
+++ b/src/boot/Makefile.in
@@ -396,6 +396,7 @@ oa_lisp_flavor = @oa_lisp_flavor@
oa_optimize_options = @oa_optimize_options@
oa_quiet_flags = @oa_quiet_flags@
oa_shrlib_flags = @oa_shrlib_flags@
+oa_shrlib_prefix = @oa_shrlib_prefix@
oa_shrobj_flags = @oa_shrobj_flags@
oa_src_algdir = @oa_src_algdir@
oa_src_datadir = @oa_src_datadir@
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index 25c7a9ae..b37992de 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -61,7 +61,8 @@ structure %Ast ==
%Module(%Symbol,%List,%List) -- module declaration
%Namespace(%Symbol) -- namespace AxiomCore
%Import(%Ast) -- import module; import namespace foo
- %ImportSignature(%Symbol,%Signature) -- import function declaration
+ %LoadUnit(%Symbol) -- System.LoadUnit lib
+ %ImportSignature(%Symbol,%Signature,%Domain) -- import function declaration
%Record(%List,%List) -- Record(num: %Short, den: %Short)
%AccessorDef(%Symbol,%Ast) -- numerator == (.num)
%TypeAlias(%Head, %List) -- type alias definition
@@ -1950,11 +1951,13 @@ $ffs := nil
++ Generate an import declaration for `op' as equivalent of the
++ foreign signature `sig'. Here, `foreign' operationally means that
++ the entity is from the C language world.
-genImportDeclaration(op, sig) ==
+genImportDeclaration(op, sig, dom) ==
sig isnt ["%Signature", op', m] => coreError '"invalid signature"
m isnt ["%Mapping", t, s] => coreError '"invalid function type"
if s ~= nil and symbol? s then s := [s]
$ffs := [op,:$ffs]
+ if dom is ["%LoadUnit",lib] and not symbolMember?(lib,$foreignLoadUnits) then
+ $foreignLoadUnits := [lib,:$foreignLoadUnits]
%hasFeature KEYWORD::GCL => genGCLnativeTranslation(op,s,t,op')
%hasFeature KEYWORD::SBCL => genSBCLnativeTranslation(op,s,t,op')
diff --git a/src/boot/parser.boot b/src/boot/parser.boot
index 3864fc13..0b589ead 100644
--- a/src/boot/parser.boot
+++ b/src/boot/parser.boot
@@ -1,6 +1,6 @@
-- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd.
-- All rights reserved.
--- Copyright (C) 2007-2014, Gabriel Dos Reis.
+-- Copyright (C) 2007-2016, Gabriel Dos Reis.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
@@ -518,9 +518,21 @@ bpModule ps ==
bpPush(ps,%Module(bpPop3 ps,bpPop2 ps,bpPop1 ps))
nil
+++ Provenance:
+++ IN Application
+bpProvenance ps ==
+ bpEqKey(ps,"IN") =>
+ bpApplication ps or return bpTrap ps
+ x := bpPop1 ps
+ x isnt [["ELT","System","LoadUnit"],['QUOTE,lib]] =>
+ bpGeneralErrorHere ps
+ bpPush(ps,%LoadUnit lib)
+ bpPush(ps,nil)
+
++ Parse a module import, or a import declaration for a foreign entity.
++ Import:
++ IMPORT Signature FOR Name
+++ IMPORT Signature IN Application FOR Name
++ IMPORT Name
++ IMPORT NAMESPACE LongName
bpImport ps ==
@@ -533,10 +545,11 @@ bpImport ps ==
bpRequire(ps,function bpName)
bpEqPeek(ps,"COLON") =>
bpRestore(ps,a)
- bpRequire(ps,function bpSignature) and
- (bpEqKey(ps,"FOR") or bpTrap ps) and
- bpRequire(ps,function bpName) and
- bpPush(ps,%ImportSignature(bpPop1 ps, bpPop1 ps))
+ bpRequire(ps,function bpSignature)
+ bpProvenance ps
+ bpEqKey(ps,"FOR") or bpTrap ps
+ bpRequire(ps,function bpName)
+ bpPush(ps,%ImportSignature(bpPop1 ps, bpPop2 ps, bpPop1 ps))
bpPush(ps,%Import bpPop1 ps)
false
diff --git a/src/boot/translator.boot b/src/boot/translator.boot
index f44fee4c..03c493a1 100644
--- a/src/boot/translator.boot
+++ b/src/boot/translator.boot
@@ -45,6 +45,9 @@ module translator (evalBootFile, loadNativeModule, loadSystemRuntimeCore,
++ If non nil, holds the name of the current module being translated.
$currentModuleName := nil
+++ List of foreign load units mentioned in foreign imports.
+$foreignLoadUnits := []
+
++ Stack of foreign definitions to cope with CLisp's odd FFI interface.
$foreignsDefsForCLisp := []
@@ -53,6 +56,10 @@ reallyPrettyPrint(x,st == _*STANDARD_-OUTPUT_*) ==
writeNewline st
genModuleFinalization(stream) ==
+ loadUnits := [symbolName x for x in $foreignLoadUnits]
+ if loadUnits ~= [] then
+ loadUnitsForm := ["MAP",quote "loadNativeModule",quote loadUnits]
+ reallyPrettyPrint(atLoadOrExecutionTime loadUnitsForm,stream)
$ffs = nil => nil
$currentModuleName = nil => coreError '"current module has no name"
setFFS := ["SETQ","$dynamicForeignFunctions",
@@ -448,8 +455,8 @@ translateToplevel(ps,b,export?) ==
bootImport symbolName m
[["IMPORT-MODULE", symbolName m]]
- %ImportSignature(x, sig) =>
- genImportDeclaration(x, sig)
+ %ImportSignature(x, sig, dom) =>
+ genImportDeclaration(x, sig, dom)
%TypeAlias(lhs, rhs) => [genTypeAlias(lhs,rhs)]
@@ -602,6 +609,7 @@ associateRequestWithFileType(Option '"compile", '"boot",
++ Load native dynamically linked module
loadNativeModule m ==
+ m := strconc($NativeModulePrefix,m,$NativeModuleExt)
%hasFeature KEYWORD::SBCL =>
apply(bfColonColon("SB-ALIEN","LOAD-SHARED-OBJECT"),
[m,KEYWORD::DONT_-SAVE,true])
@@ -615,4 +623,4 @@ loadNativeModule m ==
loadSystemRuntimeCore() ==
%hasFeature KEYWORD::ECL or %hasFeature KEYWORD::GCL => nil
- loadNativeModule strconc('"libopen-axiom-core",$NativeModuleExt)
+ loadNativeModule '"open-axiom-core"