1
/* File: private_builtin.c
2
** Author(s): Work of thousands
3
** Contact: xsb-contact@cs.sunysb.edu
5
** Copyright (C) The Research Foundation of SUNY, 1999
7
** XSB is free software; you can redistribute it and/or modify it under the
8
** terms of the GNU Library General Public License as published by the Free
9
** Software Foundation; either version 2 of the License, or (at your option)
12
** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
13
** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
** FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for
17
** You should have received a copy of the GNU Library General Public License
18
** along with XSB; if not, write to the Free Software Foundation,
19
** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
** $Id: private_builtin.in,v 1.9 2005/05/31 19:00:21 kifer Exp $
26
/* This file is never committed into the repository, so you can put
27
experimental code here.
28
It is also a place for private builtins that you might be using for
30
Note: even though this is a single builtin, YOU CAN SIMULATE ANY
31
NUMBER OF BUILTINS WITH IT. */
33
#include "xsb_config.h"
34
#include "xsb_debug.h"
46
#include "setjmp_xsb.h"
49
#include "error_xsb.h"
55
#include "flags_xsb.h"
57
/* The folowing function must be defined. What's inside doesn't matter */
58
xsbBool private_builtin(void)
61
ctop_string(1, "abc");
66
/* Here is an example of how to hang multiple pseudo-builtins
67
off of private_builtin/11 */
75
#define PRINT_ALL_STACKS 6
81
/* Arg 1 is the OP code. The rest are real arguments to the builtin */
83
xsbBool private_builtin(void)
85
switch (ptoc_int(1)) {
86
case PRINT_LS: print_ls(1) ; return TRUE ;
87
case PRINT_TR: print_tr(1) ; return TRUE ;
88
case PRINT_HEAP: print_heap(0,2000,1) ; return TRUE ;
89
case PRINT_CP: print_cp(1) ; return TRUE ;
90
case PRINT_REGS: print_regs(10,1) ; return TRUE ;
91
case PRINT_ALL_STACKS: print_all_stacks() ; return TRUE ;
92
case EXP_HEAP: glstack_realloc(glstack.size + 1,0) ; return TRUE ;
93
case MARK_HEAP: mark_heap(ptoc_int(2),&tmpval) ; return TRUE ;
94
case GC_HEAP: return(gc_heap(0)) ;
99
/* To use these bultins, you must have a .P file with the following
103
print_ls :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).
104
print_tr :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).
105
print_heap :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).
106
print_cp :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).
107
print_regs :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).
108
print_all_stacks :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).
109
exp_heap :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).
110
mark_heap(A) :- private_builtin(1,A,_,_,_,_,_,_,_,_,_).
111
gc_heap :- private_builtin(1,_,_,_,_,_,_,_,_,_,_).