diff options
author | Gabriel Dos Reis <gdr@axiomatics.org> | 2016-12-29 02:13:58 -0800 |
---|---|---|
committer | Gabriel Dos Reis <gdr@axiomatics.org> | 2016-12-29 02:13:58 -0800 |
commit | 2bd3cc876cc90b8e28e0e8d88a5982f69729f867 (patch) | |
tree | 89fb25441b1c7868411aeeb169bc3b34eec6a31a /src | |
parent | a8a3b2cdf66d274c831ad6229e6123e9cd68e07d (diff) | |
download | open-axiom-2bd3cc876cc90b8e28e0e8d88a5982f69729f867.tar.gz |
Add Boot support for native load unit specification in foreign
function import.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 14 | ||||
-rw-r--r-- | src/Makefile.in | 1 | ||||
-rw-r--r-- | src/algebra/Makefile.in | 1 | ||||
-rw-r--r-- | src/boot/Makefile.in | 1 | ||||
-rw-r--r-- | src/boot/ast.boot | 7 | ||||
-rw-r--r-- | src/boot/parser.boot | 23 | ||||
-rw-r--r-- | src/boot/translator.boot | 14 | ||||
-rw-r--r-- | src/lib/Makefile.in | 8 | ||||
-rw-r--r-- | src/lisp/Makefile.in | 3 | ||||
-rw-r--r-- | src/lisp/core.lisp.in | 7 | ||||
-rw-r--r-- | src/rt/Makefile.in | 1 | ||||
-rw-r--r-- | src/utils/Makefile.in | 1 |
12 files changed, 65 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 85638c7f..ab2df6a9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2016-12-29 Gabriel Dos Reis <gdr@axiomatics.org> + + * lisp/core.lisp.in ($NativeModulePrefix): Define and export. + * boot/ast.boot (%Ast): Ad %LoadUnit alternative. + (genImportDeclaration): Take a third parameter. Update caller. + * boot/parser.boot (bpProvenance): New. + (bpImport): Use it to parse load unit specification. + * boot/translator.boot ($foreignLoadUnits): New. + (translateToplevel): Update. + (loadNativeModule): Tidy. + (loadSystemRuntimeCore): Likewise. + * lib/Makefile.in: Tidy reference to shared library pathname. + * lisp/Makefile.in (edit): Translate oa_shrlib_prefix. + 2016-12-26 Gabriel Dos Reis <gdr@axiomatics.org> * interp/i-output.boot (appChar): Don't modify string parameter. diff --git a/src/Makefile.in b/src/Makefile.in index 8598a6c9..68d49d27 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -368,6 +368,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/algebra/Makefile.in b/src/algebra/Makefile.in index 797e0fc8..59191ac7 100644 --- a/src/algebra/Makefile.in +++ b/src/algebra/Makefile.in @@ -552,6 +552,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/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" diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 8d7e563e..7a8d4609 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -1,4 +1,4 @@ -# 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 @@ -60,7 +60,7 @@ libspad_objects = $(libspad_SOURCES:.c=.lo) oa_installed_corelib = $(oa_target_libdir)/libopen-axiom-core.$(LIBEXT) ifeq (@oa_use_dynamic_lib@,yes) -oa_installed_corelib += $(oa_target_libdir)/libopen-axiom-core$(SHREXT) +oa_installed_corelib += $(oa_target_libdir)/$(oa_shrlib_prefix)open-axiom-core$(SHREXT) endif subdir = src/lib/ @@ -83,7 +83,7 @@ $(oa_target_libdir)/libopen-axiom-core.$(LIBEXT): \ # Don't put the shared lib here -- place it directly in its final home; # we don't want to pick it accidently. -$(oa_target_libdir)/libopen-axiom-core$(SHREXT): \ +$(oa_target_libdir)/$(oa_shrlib_prefix)open-axiom-core$(SHREXT): \ $(libopen_axiom_core_objects) $(mkdir_p) $(oa_target_libdir) $(CXXLINK_SHRLIB) $(oa_shrlib_flags) -o $@ \ @@ -109,7 +109,7 @@ mostlyclean-local: @rm -f *.$(OBJEXT) *.lo clean-local: mostlyclean-local - @rm -f $(oa_target_libdir)/libopen-axiom-core$(SHREXT) + @rm -f $(oa_target_libdir)/$(oa_shrlib_prefix)open-axiom-core$(SHREXT) @rm -f libopen-axiom-core.$(LIBEXT) @rm -f libspad.$(LIBEXT) @rm -fr .libs _libs diff --git a/src/lisp/Makefile.in b/src/lisp/Makefile.in index 3602fe53..979d0432 100644 --- a/src/lisp/Makefile.in +++ b/src/lisp/Makefile.in @@ -1,4 +1,4 @@ -# 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 @@ -156,6 +156,7 @@ edit = sed \ -e 's|@host[@]|$(host)|g' \ -e 's|@build[@]|$(build)|g' \ -e 's|@target[@]|$(target)|g' \ + -e 's|@oa_shrlib_prefix[@]|$(oa_shrlib_prefix)|g' \ -e 's|@SHREXT[@]|$(SHREXT)|g' \ -e 's|@LIBEXT[@]|$(LIBEXT)|g' \ -e 's|@oa_c_runtime_extra[@]|$(patsubst %,"%",$(oa_c_runtime_extra))|g' \ diff --git a/src/lisp/core.lisp.in b/src/lisp/core.lisp.in index 302a2c78..4fce2768 100644 --- a/src/lisp/core.lisp.in +++ b/src/lisp/core.lisp.in @@ -3,7 +3,7 @@ ;; Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd. ;; All rights reserved. ;; -;; Copyright (C) 2007-2015, Gabriel Dos Reis. +;; Copyright (C) 2007-2016, Gabriel Dos Reis. ;; All rights reserved. ;; ;; Redistribution and use in source and binary forms, with or without @@ -186,6 +186,7 @@ "$delayedFFI" "$useLLVM" "$effectiveFaslType" + "$NativeModulePrefix" "$NativeModuleExt" "$systemInstallationDirectory" "$NativeTypeTable" @@ -469,6 +470,10 @@ #+:ecl (pathname-type (compile-file-pathname "foo.lisp" :system-p t)) #-:ecl |$faslType|) +;; Prefix of pathname for file containers of native load units. +(defconstant |$NativeModulePrefix| + "@oa_shrlib_prefix@") + ;; Extension of file containers for native shared libraries. (defconstant |$NativeModuleExt| (cond (|$useDynamicLink| "@SHREXT@") diff --git a/src/rt/Makefile.in b/src/rt/Makefile.in index 712b3094..2f7147a0 100644 --- a/src/rt/Makefile.in +++ b/src/rt/Makefile.in @@ -358,6 +358,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/utils/Makefile.in b/src/utils/Makefile.in index 7450de6c..95e438e6 100644 --- a/src/utils/Makefile.in +++ b/src/utils/Makefile.in @@ -373,6 +373,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@ |