From 52c1bb5ebe732582606116342730e76aaaba0c55 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Wed, 12 Jul 2017 14:26:30 -0400 Subject: [PATCH] Properly resolve paths of symbols of imports This solves a long-standing problem whereby relative paths are not properly resolved, leading to incorrect symbol conflicts when relative paths to the same package vary between two imports. See doc/notes/path-processing for an illustration. * src/current/include/preproc/path.xsl (preproc:resolve-relative-import): Add function. (preproc:resolv-path, preproc:resolve-path, preproc:get-path): Add functions to invoke existing templates. * src/current/include/preproc/symtable.xsl (preproc:symimport): Use `preproc:resolve-relative-import'. * doc/notes/path-processing: Add notes. --- doc/notes/path-processing | 65 ++++++++++++++++++++++ src/current/include/preproc/path.xsl | 71 ++++++++++++++++++++++++ src/current/include/preproc/symtable.xsl | 40 +++++-------- 3 files changed, 149 insertions(+), 27 deletions(-) create mode 100644 doc/notes/path-processing diff --git a/doc/notes/path-processing b/doc/notes/path-processing new file mode 100644 index 00000000..8560ee0a --- /dev/null +++ b/doc/notes/path-processing @@ -0,0 +1,65 @@ +Path processing +--------------- +Need rules that will work for both the existing scenario (B) and the new +scenario (A): + + + _ + / \ + / _ \ + / ___ \ +/_/ \_\ +--------- + +root = ../ +package = suppliers/colony <--- /suppliers/colony +import = ../map/return/colony <--- /map/return/colony + +mapimport = ../../suppliers/colony/gl <-- /suppliers/colony/gl + + + this is the root + / \ + v v +1) <..>/map/return/ | <..>/../suppliers/colony/gl + = ../suppliers/colony/gl + ^^^^^^^^^^^^^^^^ + \ / + package name + +2) strip root||(package base) from package import + = ../map/return | <../suppliers/>colony/gl + = colony/gl + ^^^^^^^^^ + ` The relative path from package + + + + ____ +| __ ) +| _ \ +| |_) | +|____/ +------- + +what about normal includes? + + +root = ../ +package = suppliers/colony <--- /suppliers/colony +import = ../common/foo <--- /common/foo + +subimport = bar/baz <--- /common/foo/bar/baz + + + one has root, other does not + / + v +1) <..>/common/ | bar/baz + = ../common/bar/baz + +2) strip root||(package base) from package import + = ../common/bar/baz + ^^^^^^^^^^^^^^^^^ + ` no such prefix, + so this is the relative path diff --git a/src/current/include/preproc/path.xsl b/src/current/include/preproc/path.xsl index 14d0ceee..6d611478 100644 --- a/src/current/include/preproc/path.xsl +++ b/src/current/include/preproc/path.xsl @@ -22,6 +22,7 @@ --> @@ -59,6 +60,15 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/current/include/preproc/symtable.xsl b/src/current/include/preproc/symtable.xsl index 2cf726cd..e9a7c619 100644 --- a/src/current/include/preproc/symtable.xsl +++ b/src/current/include/preproc/symtable.xsl @@ -521,12 +521,18 @@ - + + select="document( $path, $orig-root )/lv:*/preproc:symtable" /> + + + - - - - - - @@ -626,23 +624,11 @@ itself) onto the existing relative path and resolving relative paths --> - - - - - - - - - - - - - - - - - +