GNU PROLOG with UTF8 support
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
dynam_supp.h
Go to the documentation of this file.
1 
2 /*-------------------------------------------------------------------------*
3  * GNU Prolog *
4  * *
5  * Part : Prolog buit-in predicates *
6  * File : dynam_supp.h *
7  * Descr.: dynamic predicate support - header file *
8  * Author: Daniel Diaz *
9  * *
10  * Copyright (C) 1999-2015 Daniel Diaz *
11  * *
12  * This file is part of GNU Prolog *
13  * *
14  * GNU Prolog is free software: you can redistribute it and/or *
15  * modify it under the terms of either: *
16  * *
17  * - the GNU Lesser General Public License as published by the Free *
18  * Software Foundation; either version 3 of the License, or (at your *
19  * option) any later version. *
20  * *
21  * or *
22  * *
23  * - the GNU General Public License as published by the Free *
24  * Software Foundation; either version 2 of the License, or (at your *
25  * option) any later version. *
26  * *
27  * or both in parallel, as here. *
28  * *
29  * GNU Prolog is distributed in the hope that it will be useful, *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
32  * General Public License for more details. *
33  * *
34  * You should have received copies of the GNU General Public License and *
35  * the GNU Lesser General Public License along with this program. If *
36  * not, see http://www.gnu.org/licenses/. *
37  *-------------------------------------------------------------------------*/
38 
39 
40 /*---------------------------------*
41  * Constants *
42  *---------------------------------*/
43 
44 #define DYN_ALT_FCT_FOR_TEST 0
45 #define DYN_ALT_FCT_FOR_JUMP 1
46 
47 
48 
49 
50 /*---------------------------------*
51  * Type Definitions *
52  *---------------------------------*/
53 
54 typedef PlLong (*ScanFct) ();
55 
56 typedef PlULong DynStamp;
57 
58 typedef struct dynpinf *DynPInfP;
59 
60 typedef struct dyncinf *DynCInfP;
61 
62 typedef struct /* Dobly-linked chain header */
63 { /* ----------------------------- */
64  DynCInfP first; /* first clause (or NULL) */
65  DynCInfP last; /* last clause (or NULL) */
66 }D2ChHdr;
67 
68 
69 typedef struct /* Dobly-linked chain cell */
70 { /* ----------------------------- */
71  DynCInfP next; /* next clause (or NULL) */
72  DynCInfP prev; /* previous clause (or NULL) */
73 }D2ChCell;
74 
75 
76 typedef struct dyncinf /* Dynamic clause information */
77 { /* ------------------------------ */
78  D2ChCell seq_chain; /* sequential chain */
79  D2ChCell ind_chain; /* indexical chain */
80  DynPInfP dyn; /* back ptr to associated dyn inf */
81  D2ChHdr *p_ind_hdr; /* back ptr to ind_chain header */
82  char **p_ind_htbl; /* back ptr to ind htbl (or NULL) */
83  int cl_no; /* clause number */
84  int pl_file; /* file name of its definition */
85  DynStamp erase_stamp; /* FFF...F if not erased or stamp */
86  DynCInfP next_erased_cl; /* pointer to next erased clause */
87  unsigned *byte_code; /* bc pointer (NULL=interpreted) */
88  int term_size; /* size of the term of the clause */
89  WamWord term_word; /* clause [Head|Body]=<LST,adr+1> */
90  WamWord head_word; /* adr+1 = Car = clause term Head */
91  WamWord body_word; /* adr+2 = Cdr = clause term Body */
92 }
93 DynCInf;
94 
95 
96 
97 
98 typedef struct /* Dynamic switch item info */
99 { /* ------------------------------ */
100  PlLong key; /* key: atm, int, f/n */
101  D2ChHdr ind_chain; /* indexical chain */
102 }
103 DSwtInf;
104 
105 
106 
107 
108 typedef struct dynpinf /* Dynamic predicate information */
109 { /* ------------------------------ */
110  D2ChHdr seq_chain; /* sequential chain */
111  D2ChHdr var_ind_chain; /* index if 1st arg=VAR (chain) */
112  char *atm_htbl; /* index if 1st arg=ATM (htable) */
113  char *int_htbl; /* index if 1st arg=INT (htable) */
114  D2ChHdr lst_ind_chain; /* index if 1st arg=LST (chain) */
115  char *stc_htbl; /* index if 1st arg=STC (htable) */
116  int arity; /* arity (redundant but faster) */
117  int count_a; /* next clause nb for asserta */
118  int count_z; /* next clause nb for assertz */
119  DynCInfP first_erased_cl; /* 1st erased clause NULL if none */
120  DynPInfP next_dyn_with_erase; /* next dyn with erased clauses */
121 }
122 DynPInf;
123 
124 
125 
126 
127 /*---------------------------------*
128  * Global Variables *
129  *---------------------------------*/
130 
131 /*---------------------------------*
132  * Function Prototypes *
133  *---------------------------------*/
134 
136  Bool asserta, Bool check_perm, int pl_file);
137 
138 void Pl_Delete_Dynamic_Clause(DynCInf *clause);
139 
140 PredInf *Pl_Update_Dynamic_Pred(int func, int arity, int what_to_do, int pl_file_for_multi);
141 
142 DynCInf *Pl_Scan_Dynamic_Pred(int owner_func, int owner_arity,
143  DynPInf *dyn, WamWord first_arg_word,
144  ScanFct alt_fct, int alt_fct_type,
145  int alt_info_size, WamWord *alt_info);
146 
147 int Pl_Scan_Choice_Point_Pred(WamWord *b, int *arity);
148 
150  WamWord *body_word);
Definition: dynam_supp.h:108
int cl_no
Definition: dynam_supp.h:83
struct dynpinf * DynPInfP
Definition: dynam_supp.h:58
unsigned * byte_code
Definition: dynam_supp.h:87
DynCInfP next_erased_cl
Definition: dynam_supp.h:86
DynCInfP first_erased_cl
Definition: dynam_supp.h:119
int Pl_Scan_Choice_Point_Pred(WamWord *b, int *arity)
Definition: dynam_supp.c:1079
WamWord body_word
Definition: dynam_supp.h:91
PlLong key
Definition: dynam_supp.h:100
WamWord term_word
Definition: dynam_supp.h:89
D2ChCell ind_chain
Definition: dynam_supp.h:79
char * int_htbl
Definition: dynam_supp.h:113
int pl_file
Definition: dynam_supp.h:84
int count_a
Definition: dynam_supp.h:117
DynPInfP next_dyn_with_erase
Definition: dynam_supp.h:120
D2ChHdr * p_ind_hdr
Definition: dynam_supp.h:81
D2ChHdr ind_chain
Definition: dynam_supp.h:101
int arity
Definition: dynam_supp.h:116
intptr_t PlLong
Definition: gprolog.h:88
DynCInfP first
Definition: dynam_supp.h:64
WamWord head_word
Definition: dynam_supp.h:90
PredInf * Pl_Update_Dynamic_Pred(int func, int arity, int what_to_do, int pl_file_for_multi)
Definition: dynam_supp.c:794
D2ChCell seq_chain
Definition: dynam_supp.h:78
int count_z
Definition: dynam_supp.h:118
DynCInfP next
Definition: dynam_supp.h:71
Definition: dynam_supp.h:69
PlULong DynStamp
Definition: dynam_supp.h:56
char * atm_htbl
Definition: dynam_supp.h:112
D2ChHdr seq_chain
Definition: dynam_supp.h:110
DynStamp erase_stamp
Definition: dynam_supp.h:85
DynCInf * Pl_Add_Dynamic_Clause(WamWord head_word, WamWord body_word, Bool asserta, Bool check_perm, int pl_file)
Definition: dynam_supp.c:225
DynCInfP last
Definition: dynam_supp.h:65
DynPInfP dyn
Definition: dynam_supp.h:80
Definition: dynam_supp.h:76
D2ChHdr lst_ind_chain
Definition: dynam_supp.h:114
Definition: dynam_supp.h:62
struct dynpinf DynPInf
DynCInfP prev
Definition: dynam_supp.h:72
int term_size
Definition: dynam_supp.h:88
void Pl_Copy_Clause_To_Heap(DynCInf *clause, WamWord *head_word, WamWord *body_word)
Definition: dynam_supp.c:1100
long WamWord
Definition: LINUX_SIGSEGV.c:4
char ** p_ind_htbl
Definition: dynam_supp.h:82
Definition: dynam_supp.h:98
Definition: pred.h:62
PlLong(* ScanFct)()
Definition: dynam_supp.h:54
char * stc_htbl
Definition: dynam_supp.h:115
int Bool
Definition: bool.h:65
void Pl_Delete_Dynamic_Clause(DynCInf *clause)
Definition: dynam_supp.c:535
D2ChHdr var_ind_chain
Definition: dynam_supp.h:111
struct dyncinf DynCInf
struct dyncinf * DynCInfP
Definition: dynam_supp.h:60
uintptr_t PlULong
Definition: gprolog.h:90
DynCInf * Pl_Scan_Dynamic_Pred(int owner_func, int owner_arity, DynPInf *dyn, WamWord first_arg_word, ScanFct alt_fct, int alt_fct_type, int alt_info_size, WamWord *alt_info)
Definition: dynam_supp.c:862