Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@ryansg.com>2020-03-25 23:49:37 -0400
committerMike Gerwitz <mike.gerwitz@ryansg.com>2020-03-26 09:15:59 -0400
commit7dd8717f2f5c3bfe5d6186da843af8bfe3192901 (patch)
treed66781c1cbdc6b5f91673ef52a6f12ac64a7b9d5 /tamer/src/ld/poc.rs
parent537d9e64afdeb6fe3624e23838ecde7309486b77 (diff)
downloadtame-7dd8717f2f5c3bfe5d6186da843af8bfe3192901.tar.gz
tame-7dd8717f2f5c3bfe5d6186da843af8bfe3192901.tar.bz2
tame-7dd8717f2f5c3bfe5d6186da843af8bfe3192901.zip
[DEV-7087] TAMER: Asg: Reintroduce declare_extern
There is some duplication here with `declare` that will be cleared up in a following commit. Reintroducing this method is necessary so that Source can be used to represent the source location of the extern itself; it's currently None to indicate an extern in `declare`.
Diffstat (limited to 'tamer/src/ld/poc.rs')
-rw-r--r--tamer/src/ld/poc.rs35
1 files changed, 19 insertions, 16 deletions
diff --git a/tamer/src/ld/poc.rs b/tamer/src/ld/poc.rs
index d1677da..8bf680f 100644
--- a/tamer/src/ld/poc.rs
+++ b/tamer/src/ld/poc.rs
@@ -176,24 +176,19 @@ fn load_xmlo<'a, 'i, I: Interner<'i>>(
found.insert(sym_src);
} else {
let owned = attrs.src.is_none();
+ let extern_ = attrs.extern_;
let kind = (&attrs).try_into().map_err(|err| {
format!("sym `{}` attrs error: {}", sym, err)
});
- let src = if attrs.extern_ {
- None
- } else {
- let mut s: Source = attrs.into();
+ let mut src: Source = attrs.into();
- // Existing convention is to omit @src of local package
- // (in this case, the program being linked)
- if first {
- s.pkg_name = None;
- }
-
- Some(s)
- };
+ // Existing convention is to omit @src of local package
+ // (in this case, the program being linked)
+ if first {
+ src.pkg_name = None;
+ }
match kind {
Ok(kindval) => {
@@ -203,10 +198,18 @@ fn load_xmlo<'a, 'i, I: Interner<'i>>(
|| kindval == IdentKind::Map
|| kindval == IdentKind::RetMap);
- let node = depgraph.declare(sym, kindval, src)?;
-
- if link_root {
- roots.push(node);
+ if extern_ {
+ depgraph.declare_extern(sym, kindval, src)?;
+ } else {
+ let node = depgraph.declare(
+ sym,
+ kindval,
+ Some(src),
+ )?;
+
+ if link_root {
+ roots.push(node);
+ }
}
}
Err(e) => return Err(e.into()),