summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--copy.c7
-rw-r--r--eval.c2
-rw-r--r--main.c6
-rw-r--r--tokenizer.c4
-rw-r--r--types.c6
5 files changed, 19 insertions, 6 deletions
diff --git a/copy.c b/copy.c
index f691d18..227f3e1 100644
--- a/copy.c
+++ b/copy.c
@@ -10,6 +10,13 @@ static void copy_decl(Copier *c, Declaration *out, Declaration *in);
static void copy_block(Copier *c, Block *out, Block *in);
static void copy_type(Copier *c, Type *out, Type *in);
+static Copier copier_create(Allocator *a, Block *b) {
+ Copier c;
+ c.allocr = a;
+ c.block = b;
+ return c;
+}
+
static void copy_val(Allocator *a, Value *out, Value *in, Type *t) {
assert(t->flags & TYPE_IS_RESOLVED);
switch (t->kind) {
diff --git a/eval.c b/eval.c
index bdb90db..f5a0ead 100644
--- a/eval.c
+++ b/eval.c
@@ -732,7 +732,7 @@ static void *eval_ptr_to_struct_field(Evaluator *ev, Expression *dot_expr) {
Value struc;
if (!eval_expr(ev, dot_expr->binary.lhs, &struc))
- return false;
+ return NULL;
void *struc_data;
if (is_ptr) {
struc_data = *(void **)struc.ptr;
diff --git a/main.c b/main.c
index 17f0bd1..470f5c2 100644
--- a/main.c
+++ b/main.c
@@ -3,6 +3,7 @@ TODO:
fix VBS with structs
test ArrInt @= Arr(int);
+there are probably places where we enter a function and never exit (in typing?) if there's an error
packages
X @= newtype(int); or something
don't allow while {3; 5} (once break is added)
@@ -11,6 +12,11 @@ make sure futurely/currently-declared types are only used by pointer/slice
allow omission of trailing ; in foo @= fn() {}?
*/
+#ifdef __cplusplus
+#define new new_
+#define this this_
+#endif
+
#include "toc.c"
int main(int argc, char **argv) {
diff --git a/tokenizer.c b/tokenizer.c
index 6481cfb..595927f 100644
--- a/tokenizer.c
+++ b/tokenizer.c
@@ -18,7 +18,7 @@ static const char *directives[DIRECT_COUNT] =
/* Returns KW_COUNT if it's not a keyword */
/* OPTIM: don't use strncmp so much */
static Keyword tokenize_kw(char **s) {
- for (Keyword k = 0; k < KW_COUNT; k++) {
+ for (Keyword k = 0; k < KW_COUNT; k = k + 1) {
size_t len = strlen(keywords[k]);
if (strncmp(*s, keywords[k], len) == 0) {
if (k > KW_LAST_SYMBOL) {
@@ -40,7 +40,7 @@ static Keyword tokenize_kw(char **s) {
/* Returns DIRECT_COUNT if it's not a directive */
static Directive tokenize_direct(char **s) {
- for (Directive d = 0; d < DIRECT_COUNT; d++) {
+ for (Directive d = 0; d < DIRECT_COUNT; d = d + 1) {
size_t len = strlen(directives[d]);
if (strncmp(*s, directives[d], len) == 0) {
if (isident((*s)[len])) {
diff --git a/types.c b/types.c
index 282c930..e0335b4 100644
--- a/types.c
+++ b/types.c
@@ -198,7 +198,7 @@ static bool type_of_fn(Typer *tr, FnExpr *f, Location where, Type *t, U16 flags)
FnExpr fn_copy;
if (!(flags & TYPE_OF_FN_NO_COPY_EVEN_IF_CONST) && fn_has_any_const_params(f)) {
- Copier cop = {.allocr = tr->allocr, .block = tr->block};
+ Copier cop = copier_create(tr->allocr, tr->block);
copy_fn_expr(&cop, &fn_copy, f, false);
f = &fn_copy;
}
@@ -1105,7 +1105,7 @@ static bool types_expr(Typer *tr, Expression *e) {
/* TODO: evaluate once per decl, not once per ident */
Expression copy;
/* make a copy of the default argument, and type and evaluate it. */
- Copier cop = {.block = tr->block, .allocr = tr->allocr};
+ Copier cop = copier_create(tr->allocr, tr->block);
copy_expr(&cop, &copy, &param->expr);
if (!types_expr(tr, &copy))
return false;
@@ -1146,7 +1146,7 @@ static bool types_expr(Typer *tr, Expression *e) {
/* fn is the instance, original_fn is not */
FnExpr *original_fn = fn;
FnExpr fn_copy;
- Copier cop = {.allocr = tr->allocr, .block = tr->block};
+ Copier cop = copier_create(tr->allocr, tr->block);
/* TODO: somehow don't do all of this if we've already generated this instance */
copy_fn_expr(&cop, &fn_copy, fn, true);
fn = &fn_copy;