Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When a variable lookup fails at translation time, postpone it to CHEC…

…K time or runtime
  • Loading branch information...
commit c4c5d5377daf1665389342e9347e1eb57459a078 1 parent 58f8f28
@sorear authored
Showing with 17 additions and 1 deletion.
  1. +17 −1 lib/CodeGen.cs
View
18 lib/CodeGen.cs
@@ -2210,6 +2210,18 @@ class NamProcessor {
LexInfo lex = ResolveLex(name, outer>0, out uplevel, core);
+ if (lex == null) {
+ CpsOp sc = CpsOp.ConstructorCall(Tokens.SC_ctor,
+ CpsOp.CallFrame(), CpsOp.IntLiteral(
+ scope_stack.Count));
+ if (core) name = "CORE::" + name;
+ if (outer != 0) name = "OUTER::" + name;
+ return CpsOp.MethodCall(Tokens.StashCursor.
+ GetMethod("Indirect"), sc, CpsOp.StringLiteral(name),
+ CpsOp.BoolLiteral(false), set_to != null ? set_to :
+ CpsOp.Null(Tokens.Variable));
+ }
+
return CpsOp.LexAccess(lex, uplevel,
set_to == null ? new CpsOp[0] : new CpsOp[] { set_to });
}
@@ -2235,7 +2247,7 @@ class NamProcessor {
}
}
if (csr.outer == null)
- throw new Exception("Unable to find lexical " + name + " in " + sub.name);
+ return null;
csr = csr.outer;
uplevel++;
}
@@ -2244,6 +2256,8 @@ class NamProcessor {
STable ResolvePkg(string name) {
int dummy;
LexInfo li = ResolveLex(name, false, out dummy, true);
+ if (li == null)
+ throw new Exception("Unable to find lexical " + name + " in " + sub.name);
return ((LIPackage)li).pkg;
}
@@ -2645,6 +2659,8 @@ class NamProcessor {
} else {
int dummy;
LexInfo li = th.ResolveLex(name,false,out dummy,true);
+ if (li == null)
+ throw new NieczaException("Cannot resolve package " + name);
mo = th.cpb.eu.TypeConstant((li as LIPackage).pkg);
}
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.