ref: ebda3c4f4770416661b320bf27b470f644bf75b0
parent: 020f025305971f5fed1deed8cc20afe7f424fc11
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Jan 16 18:05:13 EST 2015
Allow casting funcs to ints and ptrs. Sometimes, you just need the address of a func.
--- a/6/simp.c
+++ b/6/simp.c
@@ -896,7 +896,7 @@
/* ptr -> slice conversion is disallowed */
case Tyslice:
if (t->type == Typtr)
- fatal(val, "Bad cast from %s to %s",
+ fatal(val, "bad cast from %s to %s",
tystr(exprtype(val)), tystr(to));
r = slicebase(s, val, NULL);
break;
@@ -910,17 +910,18 @@
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64:
case Tyuint: case Tyulong: case Tychar: case Tybyte:
case Typtr:
+ case Tyfunc:
r = intconvert(s, val, to, 0);
break;
case Tyflt32: case Tyflt64:
if (tybase(to)->type == Typtr)
- fatal(val, "Bad cast from %s to %s",
+ fatal(val, "bad cast from %s to %s",
tystr(exprtype(val)), tystr(to));
r = mkexpr(val->loc, Oflt2int, rval(s, val, NULL), NULL);
r->expr.type = to;
break;
default:
- fatal(val, "Bad cast from %s to %s",
+ fatal(val, "bad cast from %s to %s",
tystr(exprtype(val)), tystr(to));
}
break;
@@ -939,7 +940,7 @@
r->expr.type = to;
break;
default:
- fatal(val, "Bad cast from %s to %s",
+ fatal(val, "bad cast from %s to %s",
tystr(exprtype(val)), tystr(to));
break;
}
@@ -946,7 +947,7 @@
break;
/* no other destination types are handled as things stand */
default:
- fatal(val, "Bad cast from %s to %s",
+ fatal(val, "bad cast from %s to %s",
tystr(exprtype(val)), tystr(to));
}
return r;
@@ -1470,7 +1471,7 @@
r = visit(s, n);
break;
case Obad:
- die("Bad operator");
+ die("bad operator");
break;
}
return r;
@@ -1536,7 +1537,7 @@
simp(s, u);
break;
default:
- die("Bad node passsed to simp()");
+ die("bad node passsed to simp()");
break;
}
return r;