summaryrefslogtreecommitdiff
path: root/src/main/java/com/seaofnodes/simple/node/FRefNode.java
diff options
context:
space:
mode:
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(); }
}