Permalink
Browse files

Misc type-management fixes

  • Loading branch information...
sorear committed May 27, 2012
1 parent 36b12c7 commit 0750bf7b719fc75d76dd7a329f5302aa63c0dfcd
Showing with 15 additions and 3 deletions.
  1. +14 −2 lib/CodeGen.cs
  2. +1 −1 src/CgOp.pm6
View
@@ -1770,7 +1770,9 @@ class CpsOp {
stmts.Add(new ClrLabel(l2, true));
foreach (ClrEhSpan cl in co) stmts.Add(cl);
- return new CpsOp(stmts.ToArray(), new ClrResult(body.head.Returns));
+ // TODO: this is currently only used for exceptiony stuff so
+ // Variable is required.
+ return new CpsOp(stmts.ToArray(), new ClrResult(Tokens.Variable));
}
public static CpsOp SyncBefore(CpsOp z) {
@@ -1815,6 +1817,13 @@ class CpsOp {
stmts.Add(new ClrLabel(l2, false));
Type ty = iffalse.head.Returns;
+ if (iftrue.head.Returns != ty) {
+ if (Tokens.Variable.IsAssignableFrom(iftrue.head.Returns) &&
+ Tokens.Variable.IsAssignableFrom(ty))
+ ty = Tokens.Variable;
+ else
+ throw new Exception("Cannot match types in ternary: " + iftrue.head.Returns + " " + ty);
+ }
return new CpsOp(stmts.ToArray(),
(ty == Tokens.Void) ? (ClrOp)ClrNoop.Instance :
new ClrResult(ty));
@@ -2016,7 +2025,8 @@ class CpsOp {
return Primitive(zyg, delegate(ClrOp[] heads) {
return new CpsOp((heads.Length >= 1)
? l.SetCode(up, heads[0], EmitUnit.Current.np.sub)
- : l.GetCode(up, EmitUnit.Current.np.sub));
+ : new ClrWiden(Tokens.Variable,
+ l.GetCode(up, EmitUnit.Current.np.sub)));
});
}
@@ -2563,6 +2573,8 @@ class NamProcessor {
th.scope_stack.RemoveAt(th.scope_stack.Count - 1);
return CpsOp.Span(s, e, false, xn, co);
};
+ handlers["widen"] = delegate(NamProcessor th, object[] zyg) {
+ return CpsOp.Widen(namtype(zyg[1]), th.Scan(zyg[2])); };
handlers["letvar"] = delegate(NamProcessor th, object[] zyg) {
return th.AccessLet(zyg); };
handlers["scopedlex"] =
View
@@ -65,7 +65,7 @@ CgOp._register_ops: <
vvarlist_count vvarlist_from_fvarlist vvarlist_item
vvarlist_new_empty vvarlist_new_singleton vvarlist_pop
vvarlist_push vvarlist_shift vvarlist_sort vvarlist_to_fvarlist
- vvarlist_unshift vvarlist_unshiftn whileloop xspan times
+ vvarlist_unshift vvarlist_unshiftn whileloop widen xspan times
divop obj_can sqrt push pop unshift shift ind_method_call
newarray newhash you_are_here frame_outer frame_sub makejunction
who sc_root sc_indir temporize _addmethod _invalidate rxlprim >;

0 comments on commit 0750bf7

Please sign in to comment.