summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-29 01:33:27 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-29 01:33:27 -0700
commit6a4040c99ee0127808d77ad2dc38220f1a8a1c46 (patch)
tree13bcf7821021b988dd0e7ad546dd92ce8253017e /6
parent501c03fca3a77243ae2e7415a199b08e806c96b2 (diff)
downloadmc-6a4040c99ee0127808d77ad2dc38220f1a8a1c46.tar.gz
Implement casting functions to pointers.
Useful for interfacing with C ABIs.
Diffstat (limited to '6')
-rw-r--r--6/simp.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/6/simp.c b/6/simp.c
index d4dd168..c6db9b7 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -933,11 +933,15 @@ static Node *simpcast(Simp *s, Node *val, Type *to)
switch (t->type) {
/* ptr -> slice conversion is disallowed */
case Tyslice:
- if (t->type == Typtr)
- fatal(val, "bad cast from %s to %s",
- tystr(exprtype(val)), tystr(to));
+ if (to->type != Typtr)
+ fatal(val, "bad cast from %s to %s", tystr(exprtype(val)), tystr(to));
r = slicebase(s, val, NULL);
break;
+ case Tyfunc:
+ if (to->type != Typtr)
+ fatal(val, "bad cast from %s to %s", tystr(exprtype(val)), tystr(to));
+ r = getcode(s, val);
+ break;
/* signed conversions */
case Tyint8: case Tyint16: case Tyint32: case Tyint64:
case Tyint: