more reflection updates
This commit is contained in:
parent
0ea61e8f1a
commit
3edb01f5f7
39
C/cdmgr.c
39
C/cdmgr.c
@ -2941,6 +2941,7 @@ p_new_multifile( USES_REGS1 )
|
|||||||
/* static */
|
/* static */
|
||||||
pe->PredFlags |= (SourcePredFlag|CompiledPredFlag);
|
pe->PredFlags |= (SourcePredFlag|CompiledPredFlag);
|
||||||
}
|
}
|
||||||
|
pe->src.OwnerFile = YapConsultingFile( PASS_REGS1 );
|
||||||
UNLOCKPE(43,pe);
|
UNLOCKPE(43,pe);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -5197,7 +5198,7 @@ p_static_clause( USES_REGS1 )
|
|||||||
return fetch_next_static_clause(pe, pe->CodeOfPred, ARG1, ARG3, ARG4, new_cp, TRUE);
|
return fetch_next_static_clause(pe, pe->CodeOfPred, ARG1, ARG3, ARG4, new_cp, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int /* $hidden_predicate(P) */
|
static Int /* $nth_clause(P) */
|
||||||
p_nth_clause( USES_REGS1 )
|
p_nth_clause( USES_REGS1 )
|
||||||
{
|
{
|
||||||
PredEntry *pe;
|
PredEntry *pe;
|
||||||
@ -6154,6 +6155,42 @@ p_instance_property( USES_REGS1 )
|
|||||||
return Yap_unify(ARG3, MkIntTerm(cl->usc.ClSource->ag.line_number));
|
return Yap_unify(ARG3, MkIntTerm(cl->usc.ClSource->ag.line_number));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (FunctorOfTerm(t1) == FunctorMegaClause) {
|
||||||
|
PredEntry *ap = (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t1));
|
||||||
|
MegaClause *mcl = ClauseCodeToMegaClause(ap->cs.p_code.FirstClause);
|
||||||
|
|
||||||
|
if (op == CL_PROP_ERASED) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (op == CL_PROP_PRED || op == CL_PROP_FILE || op == CL_PROP_STREAM) {
|
||||||
|
if (op == CL_PROP_FILE) {
|
||||||
|
if (ap->src.OwnerFile)
|
||||||
|
return Yap_unify(ARG3,MkAtomTerm(ap->src.OwnerFile));
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
Functor nf = ap->FunctorOfPred;
|
||||||
|
UInt arity = ArityOfFunctor(nf);
|
||||||
|
Atom name = NameOfFunctor(nf);
|
||||||
|
Term t[2];
|
||||||
|
|
||||||
|
t[0] = MkAtomTerm(name);
|
||||||
|
t[1] = MkIntegerTerm(arity);
|
||||||
|
t[1] = Yap_MkApplTerm(FunctorSlash, 2, t);
|
||||||
|
if (ap->ModuleOfPred == PROLOG_MODULE) {
|
||||||
|
t[0] = MkAtomTerm(AtomProlog);
|
||||||
|
} else {
|
||||||
|
t[0] = ap->ModuleOfPred;
|
||||||
|
}
|
||||||
|
return Yap_unify( ARG3, Yap_MkApplTerm(FunctorModule, 2, t) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (op == CL_PROP_FACT) {
|
||||||
|
return Yap_unify(ARG3, MkAtomTerm(AtomTrue));
|
||||||
|
}
|
||||||
|
if (op == CL_PROP_LINE) {
|
||||||
|
return Yap_unify(ARG3, MkIntTerm(mcl->ClLine));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((dbr = DBRefOfTerm(t1))->Flags & LogUpdMask) {
|
} else if ((dbr = DBRefOfTerm(t1))->Flags & LogUpdMask) {
|
||||||
|
@ -1360,6 +1360,9 @@ X_API int PL_unify_wchars(term_t t, int type, size_t len, const pl_wchar_t *char
|
|||||||
case PL_STRING:
|
case PL_STRING:
|
||||||
chterm = Yap_MkBlobWideStringTerm(chars, len);
|
chterm = Yap_MkBlobWideStringTerm(chars, len);
|
||||||
break;
|
break;
|
||||||
|
case PL_UTF8_STRING:
|
||||||
|
chterm = Yap_MkBlobWideStringTerm(chars, len);
|
||||||
|
break;
|
||||||
case PL_CODE_LIST:
|
case PL_CODE_LIST:
|
||||||
chterm = YAP_NWideBufferToString(chars, len);
|
chterm = YAP_NWideBufferToString(chars, len);
|
||||||
break;
|
break;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
:- source.
|
||||||
|
|
||||||
% memberchk(+Element, +Set)
|
% memberchk(+Element, +Set)
|
||||||
% means the same thing, but may only be used to test whether a known
|
% means the same thing, but may only be used to test whether a known
|
||||||
% Element occurs in a known Set. In return for this limited use, it
|
% Element occurs in a known Set. In return for this limited use, it
|
||||||
@ -21,4 +24,5 @@ lists:append([H|T], L, [H|R]) :-
|
|||||||
lists:append(T, L, R).
|
lists:append(T, L, R).
|
||||||
|
|
||||||
|
|
||||||
|
:- no_source.
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ module(N) :-
|
|||||||
% redefining a previously-defined file, no problem.
|
% redefining a previously-defined file, no problem.
|
||||||
'$add_preexisting_module_on_file'(F, F, Mod, Exports, R) :- !,
|
'$add_preexisting_module_on_file'(F, F, Mod, Exports, R) :- !,
|
||||||
erase(R),
|
erase(R),
|
||||||
( recorded('$import','$import'(Mod,M,_,_,N,A),R), erase(R), abolish(M:N/A), fail; true),
|
( recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R), fail; true),
|
||||||
( source_location(_, Line) -> true ; Line = 0 ),
|
( source_location(_, Line) -> true ; Line = 0 ),
|
||||||
recorda('$module','$module'(F,Mod,Exports, Line),_).
|
recorda('$module','$module'(F,Mod,Exports, Line),_).
|
||||||
'$add_preexisting_module_on_file'(F,F0,Mod,Exports,R) :-
|
'$add_preexisting_module_on_file'(F,F0,Mod,Exports,R) :-
|
||||||
@ -622,7 +622,7 @@ abolish_module(Mod) :-
|
|||||||
recorded('$module','$module'(_,Mod,_,_),R), erase(R),
|
recorded('$module','$module'(_,Mod,_,_),R), erase(R),
|
||||||
fail.
|
fail.
|
||||||
abolish_module(Mod) :-
|
abolish_module(Mod) :-
|
||||||
recorded('$import','$import'(Mod,M,_,_,N,A),R), erase(R), abolish(M:N/A),
|
recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R),
|
||||||
fail.
|
fail.
|
||||||
abolish_module(Mod) :-
|
abolish_module(Mod) :-
|
||||||
'$current_predicate'(Mod,Na,Ar),
|
'$current_predicate'(Mod,Na,Ar),
|
||||||
@ -806,9 +806,9 @@ export_list(Module, List) :-
|
|||||||
G1=..[N1|Args],
|
G1=..[N1|Args],
|
||||||
( '$check_import'(M0,ContextMod,N1,K) ->
|
( '$check_import'(M0,ContextMod,N1,K) ->
|
||||||
( ContextMod = user ->
|
( ContextMod = user ->
|
||||||
( recordzifnot('$import','$import'(M0,user,G0,G1,N1,K),_) -> true ; true )
|
( recordzifnot('$import','$import'(M0,user,G0,G1,N1,K),_) -> true ; true)
|
||||||
;
|
;
|
||||||
( recordaifnot('$import','$import'(M0,ContextMod,G0,G1,N1,K),_) -> true ; true )
|
( recordaifnot('$import','$import'(M0,ContextMod,G0,G1,N1,K),_) -> true ; true )
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
true
|
true
|
||||||
|
12
pl/preds.yap
12
pl/preds.yap
@ -379,7 +379,7 @@ nth_clause(V,I,R) :-
|
|||||||
between(1, N, I),
|
between(1, N, I),
|
||||||
'$nth_clause'(P,M,I,R).
|
'$nth_clause'(P,M,I,R).
|
||||||
'$nth_clause'(P,M,I,R) :-
|
'$nth_clause'(P,M,I,R) :-
|
||||||
'$p_nth_clause'(P,M,I,R), writeln(R), !.
|
'$p_nth_clause'(P,M,I,R), !.
|
||||||
'$nth_clause'(P,M,I,R) :-
|
'$nth_clause'(P,M,I,R) :-
|
||||||
'$is_dynamic'(P,M), !,
|
'$is_dynamic'(P,M), !,
|
||||||
'$nth_instancep'(M:P,I,R).
|
'$nth_instancep'(M:P,I,R).
|
||||||
@ -1068,9 +1068,15 @@ compile_predicates(Ps) :-
|
|||||||
|
|
||||||
|
|
||||||
clause_property(ClauseRef, file(FileName)) :-
|
clause_property(ClauseRef, file(FileName)) :-
|
||||||
'$instance_property'(ClauseRef, 2, FileName).
|
( recorded('$mf','$mf_clause'(FileName,_Name,_Arity,_Module,ClauseRef),_R)
|
||||||
|
-> true
|
||||||
|
;
|
||||||
|
'$instance_property'(ClauseRef, 2, FileName) ).
|
||||||
clause_property(ClauseRef, source(FileName)) :-
|
clause_property(ClauseRef, source(FileName)) :-
|
||||||
'$instance_property'(ClauseRef, 2, FileName).
|
( recorded('$mf','$mf_clause'(FileName,_Name,_Arity,_Module,ClauseRef),_R)
|
||||||
|
-> true
|
||||||
|
;
|
||||||
|
'$instance_property'(ClauseRef, 2, FileName) ).
|
||||||
clause_property(ClauseRef, line_count(LineNumber)) :-
|
clause_property(ClauseRef, line_count(LineNumber)) :-
|
||||||
'$instance_property'(ClauseRef, 4, LineNumber),
|
'$instance_property'(ClauseRef, 4, LineNumber),
|
||||||
LineNumber > 0.
|
LineNumber > 0.
|
||||||
|
Reference in New Issue
Block a user