summaryrefslogtreecommitdiff
path: root/src/main/java/com/seaofnodes/simple/node/FRefNode.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-08-10 11:11:18 -0700
committerCliff Click <cliffc@acm.org>2026-10-08 16:52:27 -0700
commitd32f97238c903765dec4e9a9f3cbfa5fd12cded6 (patch)
treea5ac731801ef7066bab6359c4e85c2bdd20082a6 /src/main/java/com/seaofnodes/simple/node/FRefNode.java
parentb5ebb2032aa04cf4506d533127d373d4cf5a25c6 (diff)
downloadSimple-linear.tar.gz
Simple-linear.zip
Chapter 25: Modules, Separate Compilation, and SSA Constructionlinear
Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: Symious <14933944+symious@users.noreply.github.com> Co-authored-by: Jun Kawasaki <jun784@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/main/java/com/seaofnodes/simple/node/FRefNode.java')
-rw-r--r--src/main/java/com/seaofnodes/simple/node/FRefNode.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/main/java/com/seaofnodes/simple/node/FRefNode.java b/src/main/java/com/seaofnodes/simple/node/FRefNode.java
index e7333c23..644f1434 100644
--- a/src/main/java/com/seaofnodes/simple/node/FRefNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/FRefNode.java
@@ -10,17 +10,32 @@ import com.seaofnodes.simple.type.Type;
* A Forward Reference. Its any final constant, including functions. When
* the Def finally appears its plugged into the forward reference, which then
* peepholes to the Def.
+
+ * FRefs can be external references, to other Simple defined values in ELF
+ * files, or external FFI/C libs. If external, a file system lookup needs to
+ * find it in another file, and the name (one time) change to match the found
+ * location.
+ *
+ * Example, a ambiguous name "foo" is looked up externally; it might resolve
+ * to "A.B.foo" or "libc.foo" or the like; the name is changed to match.
*/
public class FRefNode extends ConstantNode {
public static final Type FREF_TYPE = Type.BOTTOM;
- public final Var _n;
- public FRefNode( Var n ) { super(FREF_TYPE); _n = n; }
+ public String _name;
+ public final Parser.Lexer _loc; // Source location
+
+ public FRefNode( String name, Parser.Lexer loc ) { this(name,loc,FREF_TYPE); }
+ public FRefNode( String name, Parser.Lexer loc, Type type ) {
+ super(type);
+ _name = name;
+ _loc = loc;
+ }
- @Override public String label() { return "FRef"+_n; }
+ @Override public String label() { return "FRef"+_name; }
@Override protected ExprPrinter<Node> _print1(ExprPrinter<Node> p) {
- return p.p("FRef_").p(_n);
+ return p.p("FRef_").p(_name);
}
@Override public Node idealize() {
@@ -28,8 +43,8 @@ public class FRefNode extends ConstantNode {
return nIns()==1 ? null : in(1);
}
- public Parser.ParseException err() { return Parser.error("Undefined name '"+_n._name+"'",_n._loc); }
+ public Parser.ParseException err() { return Parser.error("Undefined name '"+_name+"'",_loc); }
@Override public boolean eq(Node n) { return this==n; }
- @Override int hash() { return _n._idx; }
+ @Override int hash() { return _name.hashCode(); }
}