static Code chainMetaPredicateSupervisor(Definition def, Code post) { if ( true(def, P_META) && true(def, P_TRANSPARENT) ) { tmp_buffer buf; unsigned int i; int count = 0; Code codes; initBuffer(&buf); for(i=0; i < def->functor->arity; i++) { int ma = MA_INFO(def, i); if ( ma <= 9 || ma == MA_META || ma == MA_HAT || ma == MA_DCG ) /* 0..9, :, ^ or // */ { addBuffer(&buf, encode(S_MQUAL), code); addBuffer(&buf, VAROFFSET(i), code); count++; } } if ( count > 0 ) { baseBuffer(&buf, code)[(count-1)*2] = encode(S_LMQUAL); copySuperVisorCode((Buffer)&buf, post); freeCodes(post); codes = allocCodes(entriesBuffer(&buf, code)); copyCodes(codes, baseBuffer(&buf, code), entriesBuffer(&buf, code)); return codes; } else { discardBuffer(&buf); } } return post; }
static Code chainMetaPredicateSupervisor(Definition def, Code post) { if ( true(def, P_META) && true(def, P_TRANSPARENT) ) { tmp_buffer buf; unsigned int i; int count = 0; Code codes; initBuffer(&buf); for(i=0; i < def->functor->arity; i++) { int ma = def->impl.any.args[i].meta; if ( MA_NEEDS_TRANSPARENT(ma) ) { addBuffer(&buf, encode(S_MQUAL), code); addBuffer(&buf, VAROFFSET(i), code); count++; } } if ( count > 0 ) { baseBuffer(&buf, code)[(count-1)*2] = encode(S_LMQUAL); copySuperVisorCode((Buffer)&buf, post); freeCodes(post); codes = allocCodes(entriesBuffer(&buf, code)); copyCodes(codes, baseBuffer(&buf, code), entriesBuffer(&buf, code)); return codes; } else { discardBuffer(&buf); } } return post; }
static Code singleClauseSupervisor(Definition def) { if ( def->impl.clauses.number_of_clauses == 1 ) { ClauseRef cref; Code codes = allocCodes(2); int found = getClauses(def, &cref, 1); if ( found == 1 ) { DEBUG(1, Sdprintf("Single clause supervisor for %s\n", predicateName(def))); codes[0] = encode(S_TRUSTME); codes[1] = (code)cref; return codes; } freeCodes(codes); } return NULL; }
static void free_codes_ptr(void *ptr) { freeCodes(ptr); }