diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-16 00:42:49 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-16 00:42:49 +0000 |
commit | 1c8789198373a52da9e80dc9b2b1ee2b67af61c4 (patch) | |
tree | 980040a8d1828a85428b175eef9f6a4106248309 /builtins.c | |
parent | 2a77288e28f2725b5621c239d2393d49f61993e8 (diff) |
Make operators local to each module, and implement some more correct prettyprint code, used by write_term
Diffstat (limited to 'builtins.c')
-rw-r--r-- | builtins.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -137,7 +137,7 @@ findbuiltin(Term *goal) return builtinsetoutput; if(Match(L"$read_term", 3)) return builtinreadterm; - if(Match(L"write_term", 3)) + if(Match(L"$write_term", 3)) return builtinwriteterm; if(Match(L">=", 2)) return builtingeq; @@ -354,7 +354,6 @@ builtincompare(Term *goal, Binding **bindings, Module *module) int builtinfunctor(Term *goal, Binding **bindings, Module *module) { - USED(module); Term *term = goal->children; Term *name = term->next; Term *arity = name->next; @@ -395,7 +394,7 @@ builtinfunctor(Term *goal, Binding **bindings, Module *module) namestr = term->text; arityint = term->arity; }else{ - namestr = prettyprint(term, 0, 0, 0); + namestr = prettyprint(term, 0, 0, 0, module); arityint = 0; } Term *realname = mkatom(namestr); @@ -558,11 +557,10 @@ int builtinthrow(Term *goal, Binding **bindings, Module *module) { USED(bindings); - USED(module); Term *ball = goal->children; - print("Throwing: %S\n", prettyprint(ball, 0, 0, 0)); + print("Throwing: %S\n", prettyprint(ball, 0, 0, 0, module)); Goal *g; for(g = goalstack; g != nil; g = g->next){ if(g->catcher == nil) @@ -571,7 +569,7 @@ builtinthrow(Term *goal, Binding **bindings, Module *module) if(unify(g->catcher, ball, bindings)){ if(g->goal == nil){ /* As soon as we have print facilities as builtins, we can avoid this by having the protector frame have a unhandled exception handler*/ - print("Unhandled exception: %S\n", prettyprint(ball, 0, 0, 0)); + print("Unhandled exception: %S\n", prettyprint(ball, 0, 0, 0, module)); exits("exception"); return 0; }else{ @@ -912,8 +910,6 @@ builtinwriteterm(Term *goal, Binding **bindings, Module *module) if(stream->tag == VariableTerm) Throw(instantiationerror()); - if(options->tag != AtomTerm || runestrcmp(options->text, L"[]") != 0) - Throw(typeerror(L"empty_list", options)); if(stream->tag != IntegerTerm && stream->tag != AtomTerm) Throw(domainerror(L"stream_or_alias", stream)); if(!isopenstream(stream)) @@ -922,7 +918,7 @@ builtinwriteterm(Term *goal, Binding **bindings, Module *module) Throw(permissionerror(L"output", L"stream", stream)); if(isbinarystream(stream)) Throw(permissionerror(L"output", L"binary_stream", stream)); - writeterm(stream, options, term); + writeterm(stream, options, term, module); return 1; } |