ref: dc335f52e7cd8526d3cc9d979057d3de593f94c6
parent: c89acbc27ac8af0314555f50aff5820e78f48fa1
author: Ori Bernstein <[email protected]>
date: Fri Feb 7 06:52:42 EST 2014
Uniqify the builtin atomic types.
--- a/parse/type.c
+++ b/parse/type.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
@@ -30,6 +31,18 @@
{
Type *t;
int i;
+
+ /* the first 'n' types will be identity mapped: tytab[Tyint], eg,
+ * will map to an instantitaion of Tyint.
+ *
+ * This is accomplished at program startup by calling mktype() on
+ * each builtin type in order. As we do this, we put the type into
+ * the table as ususal, which gives us an identity mapping.
+ */
+ if (ty <= Tyvalist && ty < ntypes) {
+ assert(types[ty] != NULL);
+ return types[ty];
+ }
t = zalloc(sizeof(Type));
t->type = ty;