summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--identifiers.c4
-rw-r--r--infer.c14
-rw-r--r--main.c6
3 files changed, 10 insertions, 14 deletions
diff --git a/identifiers.c b/identifiers.c
index a70028d..187d723 100644
--- a/identifiers.c
+++ b/identifiers.c
@@ -92,9 +92,7 @@ static Identifier ident_insert(Identifiers *ids, char **s) {
static char *ident_to_str(Identifier i) {
char *str = err_malloc(i->len + 1);
- /* for some reason, GCC thinks that i->len is -1 when this is called from type_to_str_ (in release mode)
- TODO: test this now (some stuff was changed)
- */
+ /* for some reason, GCC thinks that i->len is -1 when this is called from type_to_str_ (in release mode) */
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic push
diff --git a/infer.c b/infer.c
index 8cd7064..f96c35e 100644
--- a/infer.c
+++ b/infer.c
@@ -2,9 +2,7 @@ static bool call_arg_param_order(FnExpr *fn, Type *fn_type, Argument *args, Loca
static bool parameterized_struct_arg_order(StructDef *struc, Argument *args, I16 **order, Location where);
static bool types_expr(Typer *tr, Expression *e);
-/* resolved_to should have the same value as to, but not consist of any identifiers which aren't in scope right now */
-/* TODO: is resolved_to necessary? */
-static bool infer_from_expr(Typer *tr, Expression *match, Expression *to, Expression *resolved_to, Identifier *idents, Value *vals, Type *types) {
+static bool infer_from_expr(Typer *tr, Expression *match, Expression *to, Identifier *idents, Value *vals, Type *types) {
#if 0
printf("Matching ");
fprint_expr(stdout, match);
@@ -22,7 +20,7 @@ static bool infer_from_expr(Typer *tr, Expression *match, Expression *to, Expres
if (*ident == match->ident) {
long idx = ident - idents;
types[idx] = to->type;
- if (!eval_expr(tr->evalr, resolved_to, &vals[idx]))
+ if (!eval_expr(tr->evalr, to, &vals[idx]))
return false;
Copier c = copier_create(tr->allocr, tr->block);
Value new_val;
@@ -67,7 +65,7 @@ static bool infer_from_expr(Typer *tr, Expression *match, Expression *to, Expres
val_expr.val = val;
val_expr.type = *decl_type_at_index(param, ident_idx);
val_expr.flags = EXPR_FOUND_TYPE;
- if (!infer_from_expr(tr, arg, &val_expr, &val_expr, idents, vals, types)) {
+ if (!infer_from_expr(tr, arg, &val_expr, idents, vals, types)) {
free(order);
return false;
}
@@ -142,7 +140,7 @@ static bool infer_from_expr(Typer *tr, Expression *match, Expression *to, Expres
}
if (t_arg->kind == EXPR_VAL) {
/* was evaluated, because it's const */
- if (!infer_from_expr(tr, &m_arg->val, t_arg, t_arg, idents, vals, types))
+ if (!infer_from_expr(tr, &m_arg->val, t_arg, idents, vals, types))
return false;
}
}
@@ -219,7 +217,7 @@ static bool infer_from_type(Typer *tr, Type *match, Type *to, Identifier *idents
if (!to_expr) {
to_expr = &e;
}
- if (!infer_from_expr(tr, match->expr, to_expr, &e, idents, vals, types))
+ if (!infer_from_expr(tr, match->expr, to_expr, idents, vals, types))
return false;
} break;
case TYPE_ARR: {
@@ -232,7 +230,7 @@ static bool infer_from_type(Typer *tr, Type *match, Type *to, Identifier *idents
n_type->kind = TYPE_BUILTIN;
n_type->builtin = BUILTIN_I64;
n_type->flags = TYPE_IS_RESOLVED;
- if (!infer_from_expr(tr, match->arr.n_expr, &to_n_expr, &to_n_expr, idents, vals, types))
+ if (!infer_from_expr(tr, match->arr.n_expr, &to_n_expr, idents, vals, types))
return false;
if (!infer_from_type(tr, match->arr.of, to->arr.of, idents, vals, types))
return false;
diff --git a/main.c b/main.c
index eae8c1a..503d80b 100644
--- a/main.c
+++ b/main.c
@@ -18,16 +18,16 @@
/*
TODO:
-see infer.c "is resolved_to necessary" (now that ident system has changed)
replace is_reference in type_resolve_ with system for checking if type is
circularly dependent in a bad way, with compiler_sizeof
foo, _ := bar();
nice syntax for #including something into a namespace
run stuff at compile time without assigning it to a constant
-#compile_only declarations
+the problem of #foreign stuff currently requiring that source and target have the same sizeof(int), etc. -- we may need #C_int, etc.
+---
constants in structs
#if
-
+#returns_code (function/struct body is a block, to be evaluated at compile time, which returns the actual statements -- you can use this for implementation of printf)
variadic fns
switch to / add as an alternative: libffi