diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -113,24 +113,36 @@ retry: int guardOK = 1; if(stmt->toks[0]->tag != ArrayTag) guardOK = 0; - else if(GetSize(stmt->toks[0]->array) != 1) + else if(!stmt->errorguard && GetSize(stmt->toks[0]->array) != 1) + guardOK = 0; + else if(stmt->errorguard && GetSize(stmt->toks[0]->array) < 1) guardOK = 0; else if(GetType(stmt->toks[0]->array) != AtypeInt) guardOK = 0; - else if(stmt->toks[0]->array->intdata[0] != 0 && stmt->toks[0]->array->intdata[0] != 1) + else if(!stmt->errorguard && stmt->toks[0]->array->intdata[0] != 0 && stmt->toks[0]->array->intdata[0] != 1) guardOK = 0; - if(!guardOK) - throwerror(L"Guard expected single valued boolean", EDomain); - else{ + if(!guardOK){ + if(!stmt->errorguard) + throwerror(L"Guard expected single valued boolean", EDomain); + else + throwerror(L"Error guard expected an array of error numbers", EDomain); + }else{ stop = 0; - if(stmt->toks[0]->array->intdata[0] == 1) - return eval(stmt->guard, toplevel); + if(!stmt->errorguard){ + if(stmt->toks[0]->array->intdata[0] == 1) + return eval(stmt->guard, toplevel); + }else + print("Not registering error guard for error codes: %S\n", ppdatum(stmt->toks[0])); } } if(stmt->next && !stop) return eval(stmt->next, toplevel); - else + else if(!stmt->guard) return stmt->toks[0]; + else{ + throwerror(L"No value produced", EValue); + return nil; + } }else return nil; } |