From 1c8789198373a52da9e80dc9b2b1ee2b67af61c4 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Fri, 16 Jul 2021 00:42:49 +0000 Subject: Make operators local to each module, and implement some more correct prettyprint code, used by write_term --- builtins.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'builtins.c') diff --git a/builtins.c b/builtins.c index 224750a..7230ba4 100644 --- a/builtins.c +++ b/builtins.c @@ -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; } -- cgit v1.2.3