From a82186dab48c234c507693b166acd7c13433864a Mon Sep 17 00:00:00 2001 From: glenda Date: Sat, 22 Oct 2022 16:45:32 +0000 Subject: Atomic reference counting --- eval.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index cd9b95a..0752d94 100644 --- a/eval.c +++ b/eval.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "apl9.h" @@ -113,9 +114,9 @@ retry: int guardOK = 1; if(stmt->toks[0]->tag != ArrayTag) guardOK = 0; - else if(!stmt->errorguard && GetSize(stmt->toks[0]->array) != 1) + else if(!stmt->errorguard && stmt->toks[0]->array->size != 1) guardOK = 0; - else if(stmt->errorguard && GetSize(stmt->toks[0]->array) < 1) + else if(stmt->errorguard && stmt->toks[0]->array->size < 1) guardOK = 0; else if(GetType(stmt->toks[0]->array) != AtypeInt) guardOK = 0; @@ -174,7 +175,7 @@ lookup(Datum *var) val = symbol->getfn(); else{ val = symbol->value; - incdatumref(val); + incref(val); } val->shy = 0; traceprint("VAR %S = %S\n", var->name, ppdatum(val)); @@ -230,7 +231,7 @@ parens(Datum *left, Datum *right) USED(right); traceprint("PARENS: %S\n", ppdatums(left->stmt.toks, left->stmt.ntoks)); Datum *result = eval(&left->stmt, 1); - incdatumref(result); + incref(result); if(result->tag == ArrayTag) SetStrand(result->array, 0); result->shy = 0; @@ -246,7 +247,7 @@ nameis(Datum *left, Datum *right) result->names.ntoks = 1; result->names.toks = emalloc(sizeof(Datum*)); result->names.toks[0] = left; - incdatumref(left); + incref(left); return result; } @@ -254,7 +255,7 @@ Datum * namesis(Datum *left, Datum *right) { if(left->tag == RParTag){ - incdatumref(right); + incref(right); return right; } @@ -264,7 +265,7 @@ namesis(Datum *left, Datum *right) result->names.toks = emalloc(sizeof(Datum*) * result->names.ntoks); for(int i = 0; i < result->names.ntoks; i++){ result->names.toks[i] = left->stmt.toks[i]; - incdatumref(result->names.toks[i]); + incref(result->names.toks[i]); } return result; } @@ -286,7 +287,7 @@ assign(Datum *left, Datum *right) symbol = getsym(symbol->name, 1); freedatum(symbol->value); symbol->value = right; - incdatumref(right); + incref(right); if(symbol->value->tag == ArrayTag) SetStrand(symbol->value->array, 0); } @@ -307,7 +308,7 @@ assign(Datum *left, Datum *right) locations[nlocs-1]->names.ntoks = 1; locations[nlocs-1]->names.toks = emalloc(sizeof(Datum*)); locations[nlocs-1]->names.toks[0] = loc; - incdatumref(loc); + incref(loc); }else if(loc->tag == LParTag){ i++; nlocs++; @@ -317,12 +318,12 @@ assign(Datum *left, Datum *right) locations[nlocs-1]->names.toks = emalloc(sizeof(Datum*) * loc->stmt.ntoks); for(int j = 0; j < loc->stmt.ntoks; j++){ locations[nlocs-1]->names.toks[j] = loc->stmt.toks[j]; - incdatumref(loc->stmt.toks[j]); + incref(loc->stmt.toks[j]); } } } - if(GetRank(right->array) == 1 && GetSize(right->array) != nlocs) + if(GetRank(right->array) == 1 && right->array->size != nlocs) throwerror(nil, ELength); for(int i = 0; i < nlocs; i++){ @@ -341,7 +342,7 @@ assign(Datum *left, Datum *right) } } Datum *result = right; - incdatumref(right); + incref(right); result->shy = 1; return result; } @@ -359,7 +360,7 @@ monadop(Datum *left, Datum *right) result->func.operator.code = right->hybrid; } result->func.operator.left = left; - incdatumref(left); + incref(left); result->func.left = nil; result->func.scope = right->operator.scope; return result; @@ -372,7 +373,7 @@ dyadop(Datum *left, Datum *right) Datum *result = allocdatum(MonadicOpTag, 0); result->operator = dupoperator(left->operator); result->operator.right = right; - incdatumref(right); + incref(right); return result; } -- cgit v1.2.3