summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-10-06 22:32:14 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-10-06 22:32:14 -0400
commitfa60d0d8d6b1ef0e02c118de39bde740ed18496f (patch)
treeef1ea163597073288d5a5fe678655380f2deb1f1 /types.c
parent2f8808172f2bb35119fe8f654f5a01a8247b6770 (diff)
some work on compile time array accesses
Diffstat (limited to 'types.c')
-rw-r--r--types.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/types.c b/types.c
index 66a6e6f..772254a 100644
--- a/types.c
+++ b/types.c
@@ -1,12 +1,3 @@
-typedef struct {
- Allocator allocr;
- Evaluator *evalr;
- Declaration **in_decls; /* array of declarations we are currently inside */
- Block *block;
- bool can_ret;
- Type ret_type; /* the return type of the function we're currently parsing. */
-} Typer;
-
static bool types_stmt(Typer *tr, Statement *s);
static bool types_decl(Typer *tr, Declaration *d);
static bool types_expr(Typer *tr, Expression *e);
@@ -570,10 +561,12 @@ static bool types_expr(Typer *tr, Expression *e) {
} break;
case EXPR_NEW:
t->kind = TYPE_PTR;
- t->ptr.of = typer_malloc(tr, sizeof *t->ptr.of);
- t->ptr.of = &e->new.type;
- if (!type_resolve(tr, t))
- return false;
+ if (e->new.type.kind == TYPE_ARR) {
+ *t = e->new.type;
+ } else {
+ t->ptr.of = typer_malloc(tr, sizeof *t->ptr.of);
+ t->ptr.of = &e->new.type;
+ }
break;
case EXPR_IF: {
IfExpr *i = &e->if_;
@@ -1117,3 +1110,4 @@ static bool types_file(Typer *tr, ParsedFile *f) {
static void typer_free(Typer *tr) {
allocr_free_all(&tr->allocr);
}
+