Skip to content

Commit

Permalink
Misc type-management fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed May 27, 2012
1 parent 36b12c7 commit 0750bf7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/CodeGen.cs
Expand Up @@ -1770,7 +1770,9 @@ class CpsOp {
stmts.Add(new ClrLabel(l2, true)); stmts.Add(new ClrLabel(l2, true));
foreach (ClrEhSpan cl in co) stmts.Add(cl); 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) { public static CpsOp SyncBefore(CpsOp z) {
Expand Down Expand Up @@ -1815,6 +1817,13 @@ class CpsOp {
stmts.Add(new ClrLabel(l2, false)); stmts.Add(new ClrLabel(l2, false));


Type ty = iffalse.head.Returns; 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(), return new CpsOp(stmts.ToArray(),
(ty == Tokens.Void) ? (ClrOp)ClrNoop.Instance : (ty == Tokens.Void) ? (ClrOp)ClrNoop.Instance :
new ClrResult(ty)); new ClrResult(ty));
Expand Down Expand Up @@ -2016,7 +2025,8 @@ class CpsOp {
return Primitive(zyg, delegate(ClrOp[] heads) { return Primitive(zyg, delegate(ClrOp[] heads) {
return new CpsOp((heads.Length >= 1) return new CpsOp((heads.Length >= 1)
? l.SetCode(up, heads[0], EmitUnit.Current.np.sub) ? 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)));
}); });
} }


Expand Down Expand Up @@ -2563,6 +2573,8 @@ class NamProcessor {
th.scope_stack.RemoveAt(th.scope_stack.Count - 1); th.scope_stack.RemoveAt(th.scope_stack.Count - 1);
return CpsOp.Span(s, e, false, xn, co); 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) { handlers["letvar"] = delegate(NamProcessor th, object[] zyg) {
return th.AccessLet(zyg); }; return th.AccessLet(zyg); };
handlers["scopedlex"] = handlers["scopedlex"] =
Expand Down
2 changes: 1 addition & 1 deletion src/CgOp.pm6
Expand Up @@ -65,7 +65,7 @@ CgOp._register_ops: <
vvarlist_count vvarlist_from_fvarlist vvarlist_item vvarlist_count vvarlist_from_fvarlist vvarlist_item
vvarlist_new_empty vvarlist_new_singleton vvarlist_pop vvarlist_new_empty vvarlist_new_singleton vvarlist_pop
vvarlist_push vvarlist_shift vvarlist_sort vvarlist_to_fvarlist 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 divop obj_can sqrt push pop unshift shift ind_method_call
newarray newhash you_are_here frame_outer frame_sub makejunction newarray newhash you_are_here frame_outer frame_sub makejunction
who sc_root sc_indir temporize _addmethod _invalidate rxlprim >; who sc_root sc_indir temporize _addmethod _invalidate rxlprim >;
Expand Down

0 comments on commit 0750bf7

Please sign in to comment.