The R Project SVN R

Rev

Rev 28032 | Rev 29051 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 r 1
/*
1058 maechler 2
 *  R : A Computer Language for Statistical Data Analysis
2 r 3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
28024 ripley 4
 *  Copyright (C) 1998--2004  The R Development Core Team.
2 r 5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
5458 ripley 18
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2 r 19
 */
20
 
21
#ifndef DEFN_H_
22
#define DEFN_H_
23
 
24
#define COUNTING
27119 ripley 25
/* allows underscore in syntactic names, as from 1.9.0 */
26
#define UNDERSCORE_IN_NAMES 1
2 r 27
 
26145 luke 28
#define BYTECODE
25524 luke 29
#define NEW_CONDITION_HANDLING
30
 
10172 luke 31
/* To test the write barrier used by the generational collector,
32
   define TESTING_WRITE_BARRIER.  This makes the internal structure of
10865 ripley 33
   SEXPRECs visible only inside of files that explicitly define
10172 luke 34
   USE_RINTERNALS, and all uses of SEXPREC fields that do not go
10865 ripley 35
   through the appropriate functions or macros will become compilation
10172 luke 36
   errors.  Since this does impose a small but noticable performance
10865 ripley 37
   penalty, code that includes Defn.h (or code that explicitly defines
38
   USE_RINTERNALS) can access a SEXPREC's fields directly. */
10718 maechler 39
 
10172 luke 40
#ifndef TESTING_WRITE_BARRIER
41
# define USE_RINTERNALS
42
#endif
43
 
11497 hornik 44
#include <Rinternals.h>		/*-> Arith.h, Complex.h, Error.h, Memory.h
7731 ripley 45
				  PrtUtil.h, Utils.h */
10973 hornik 46
#include "Internal.h"		/* do_FOO */
10889 maechler 47
 
7731 ripley 48
#include "Errormsg.h"
2 r 49
 
10851 hornik 50
/* SunOS 4 is famous for broken header files. */
51
#ifdef SunOS4
52
# ifndef NULL
53
#  define	NULL		0
54
# endif
55
#endif /* SunOS4 */
56
 
18653 ripley 57
#ifdef Win32
58
#define PLOTHISTORY
59
void R_ProcessEvents(void);
18833 hornik 60
#endif /* Win32 */
18653 ripley 61
 
62
#ifdef Win32
10851 hornik 63
# include <psignal.h>
7731 ripley 64
#else
10851 hornik 65
# include <signal.h>
66
# include <setjmp.h>
7731 ripley 67
#endif
10851 hornik 68
 
69
#ifdef Unix
70
# define OSTYPE      "unix"
71
# define FILESEP     "/"
72
#endif /* Unix */
10865 ripley 73
 
10851 hornik 74
#ifdef Win32
75
# define OSTYPE      "windows"
76
# define FILESEP     "/"
77
#endif /* Win32 */
7731 ripley 78
 
10973 hornik 79
#ifdef HAVE_F77_UNDERSCORE
80
# define F77_SYMBOL(x)	x ## _
12256 pd 81
# define F77_QSYMBOL(x)	#x "_"
10973 hornik 82
#else
83
# define F77_SYMBOL(x)	x
84
# define F77_QSYMBOL(x) #x
85
#endif
10851 hornik 86
 
1893 ihaka 87
/*  Heap and Pointer Protection Stack Sizes.  */
2 r 88
 
28358 ripley 89
/* NB: will need a 64-bit type, ULONG64 or size_t, for Win64 */
20094 ripley 90
typedef unsigned long R_size_t;
91
#define R_SIZE_T_MAX ULONG_MAX
92
 
3609 pd 93
#define Mega 1048576. /* 1 Mega Byte := 2^20 (= 1048576) Bytes */
20104 ripley 94
#define Giga 1073741824. /* 1 Giga Byte := 2^30 Bytes */
1893 ihaka 95
 
3609 pd 96
/*	R_PPSSIZE  The pointer protection stack size  */
4076 maechler 97
/*	R_NSIZE	   The number of cons cells	 */
98
/*	R_VSIZE	   The vector heap size in bytes */
9035 ripley 99
/*  These values are defaults and can be overridden in config.h
7809 ripley 100
    The maxima and minima are in ../unix/sys-common.c */
3609 pd 101
 
2 r 102
#ifndef R_PPSSIZE
3609 pd 103
#define	R_PPSSIZE	10000L
2 r 104
#endif
105
#ifndef R_NSIZE
7809 ripley 106
#define	R_NSIZE		350000L
2 r 107
#endif
108
#ifndef R_VSIZE
4562 pd 109
#define	R_VSIZE		6291456L
2 r 110
#endif
111
 
3244 ihaka 112
#include <math.h>
464 maechler 113
 
18791 ripley 114
/* declare substitutions */
18792 ripley 115
#if defined(HAVE_DECL_ACOSH) && !HAVE_DECL_ACOSH
18791 ripley 116
extern double acosh(double x);
117
#endif
18792 ripley 118
#if defined(HAVE_DECL_ASINH) && !HAVE_DECL_ASINH
18794 ripley 119
extern double asinh(double x);
18791 ripley 120
#endif
18792 ripley 121
#if defined(HAVE_DECL_ATANH) && !HAVE_DECL_ATANH
18794 ripley 122
extern double atanh(double x);
18791 ripley 123
#endif
18792 ripley 124
#if defined(HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
18791 ripley 125
extern int snprintf (char *s, size_t n, const char *format, ...);
126
#endif
18792 ripley 127
#if defined(HAVE_DECL_STRDUP) && !HAVE_DECL_STRDUP
18791 ripley 128
extern char *strdup(const char *s1);
129
#endif
18792 ripley 130
#if defined(HAVE_DECL_STRNCASECMP) && !HAVE_DECL_STRNCASECMP
18791 ripley 131
extern int strncasecmp(const char *s1, const char *s2, size_t n);
132
#endif
18792 ripley 133
#if defined(HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
18791 ripley 134
extern int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
135
#endif
136
 
5226 hornik 137
/* Getting the working directory */
138
#if defined(HAVE_GETCWD)
10851 hornik 139
# define R_GETCWD(x, y) getcwd(x, y)
5226 hornik 140
#elif defined(Win32)
10851 hornik 141
# define R_GETCWD(x, y) GetCurrentDirectory(y, x)
5226 hornik 142
#else
10851 hornik 143
# undef R_GETCWD
5226 hornik 144
#endif
145
 
146
/* Maximal length of an entire file name */
147
#if !defined(PATH_MAX)
10851 hornik 148
# if defined(HAVE_SYS_PARAM_H)
149
#  include <sys/param.h>
150
# endif
20896 duncan 151
# if !defined(PATH_MAX)
21039 murdoch 152
#  if defined(MAXPATHLEN)
20896 duncan 153
#    define PATH_MAX MAXPATHLEN
154
#  elif defined(Win32)
155
#    define PATH_MAX 260
21039 murdoch 156
#  else
18561 ripley 157
/* quite possibly unlimited, so we make this large, and test when used */
20896 duncan 158
#    define PATH_MAX 5000
159
#  endif
10851 hornik 160
# endif
5226 hornik 161
#endif
162
 
6098 pd 163
#ifdef HAVE_POSIX_SETJMP
25220 luke 164
# define SIGJMP_BUF sigjmp_buf
165
# define SIGSETJMP(x,s) sigsetjmp(x,s)
166
# define SIGLONGJMP(x,i) siglongjmp(x,i)
6098 pd 167
# define JMP_BUF sigjmp_buf
25226 luke 168
# define SETJMP(x) sigsetjmp(x,0)
6098 pd 169
# define LONGJMP(x,i) siglongjmp(x,i)
170
#else
25220 luke 171
# define SIGJMP_BUF jmp_buf
172
# define SIGSETJMP(x,s) setjmp(x)
173
# define SIGLONGJMP(x,i) longjmp(x,i)
6098 pd 174
# define JMP_BUF jmp_buf
175
# define SETJMP(x) setjmp(x)
176
# define LONGJMP(x,i) longjmp(x,i)
177
#endif
178
 
19066 hornik 179
/* Availability of timing: on Unix, we need times(2).
180
   On Windows and the Mac, we can do without.
181
*/
24069 ripley 182
#if (defined(HAVE_TIMES) || defined(Win32))
19066 hornik 183
# define _R_HAVE_TIMING_ 1
184
#endif
185
 
19500 hornik 186
#include <R_ext/Rdynload.h>
7850 ripley 187
 
5182 ripley 188
#define HSIZE	   4119	/* The size of the hash table for symbols */
4076 maechler 189
#define MAXELTSIZE 8192 /* The largest string size */
2467 maechler 190
#define MAXIDSIZE   256	/* Largest symbol size possible */
2 r 191
 
1893 ihaka 192
/* The type of the do_xxxx functions. */
193
/* These are the built-in R functions. */
2 r 194
typedef SEXP (*CCODE)();
195
 
10893 maechler 196
/* Information for Deparsing Expressions */
197
typedef enum {
198
    PP_ASSIGN   =  1,
199
    PP_ASSIGN2  =  2,
200
    PP_BINARY   =  3,
201
    PP_BINARY2  =  4,
202
    PP_BREAK    =  5,
203
    PP_CURLY    =  6,
204
    PP_FOR      =  7,
205
    PP_FUNCALL  =  8,
206
    PP_FUNCTION =  9,
207
    PP_IF 	= 10,
208
    PP_NEXT 	= 11,
209
    PP_PAREN    = 12,
210
    PP_RETURN   = 13,
211
    PP_SUBASS   = 14,
212
    PP_SUBSET   = 15,
213
    PP_WHILE 	= 16,
214
    PP_UNARY 	= 17,
215
    PP_DOLLAR 	= 18,
216
    PP_FOREIGN 	= 19,
217
    PP_REPEAT 	= 20
21039 murdoch 218
} PPkind;
219
 
220
typedef enum {
221
    PREC_FN	 = 0,
222
    PREC_LEFT    = 1,
223
    PREC_EQ	 = 2,
224
    PREC_RIGHT	 = 3,
225
    PREC_TILDE	 = 4,
226
    PREC_OR	 = 5,
227
    PREC_AND	 = 6,
228
    PREC_NOT	 = 7,
229
    PREC_COMPARE = 8,
230
    PREC_SUM	 = 9,
231
    PREC_PROD	 = 10,
232
    PREC_PERCENT = 11,
233
    PREC_COLON	 = 12,
234
    PREC_SIGN	 = 13,
235
    PREC_POWER	 = 14,
236
    PREC_DOLLAR  = 15,
237
    PREC_NS	 = 16,
238
    PREC_SUBSET	 = 17
239
} PPprec;
240
 
241
typedef struct {
242
	PPkind kind; 	 /* deparse kind */
243
	PPprec precedence; /* operator precedence */
244
	unsigned int rightassoc;  /* right associative? */
10893 maechler 245
} PPinfo;
1893 ihaka 246
 
247
/* The type definitions for the table of built-in functions. */
248
/* This table can be found in ../main/names.c */
2 r 249
typedef struct {
1893 ihaka 250
    char   *name;    /* print name */
251
    CCODE  cfun;     /* c-code address */
252
    int	   code;     /* offset within c-code */
253
    int	   eval;     /* evaluate args? */
254
    int	   arity;    /* function arity */
10893 maechler 255
    PPinfo gram;     /* pretty-print info */
2 r 256
} FUNTAB;
257
 
10172 luke 258
#ifdef USE_RINTERNALS
1893 ihaka 259
/* General Cons Cell Attributes */
2 r 260
#define ATTRIB(x)	((x)->attrib)
261
#define OBJECT(x)	((x)->sxpinfo.obj)
262
#define MARK(x)		((x)->sxpinfo.mark)
263
#define TYPEOF(x)	((x)->sxpinfo.type)
264
#define NAMED(x)	((x)->sxpinfo.named)
265
 
1893 ihaka 266
/* Primitive Access Macros */
2 r 267
#define PRIMOFFSET(x)	((x)->u.primsxp.offset)
268
#define PRIMFUN(x)	(R_FunTab[(x)->u.primsxp.offset].cfun)
269
#define PRIMNAME(x)	(R_FunTab[(x)->u.primsxp.offset].name)
270
#define PRIMVAL(x)	(R_FunTab[(x)->u.primsxp.offset].code)
271
#define PRIMARITY(x)	(R_FunTab[(x)->u.primsxp.offset].arity)
272
#define PPINFO(x)	(R_FunTab[(x)->u.primsxp.offset].gram)
273
#define PRIMPRINT(x)	(((R_FunTab[(x)->u.primsxp.offset].eval)/100)%10)
274
 
1893 ihaka 275
/* Promise Access Macros */
26020 luke 276
#define PRCODE(x)	((x)->u.promsxp.expr)
2 r 277
#define PRENV(x)	((x)->u.promsxp.env)
278
#define PRVALUE(x)	((x)->u.promsxp.value)
279
#define PRSEEN(x)	((x)->sxpinfo.gp)
10172 luke 280
#ifndef USE_WRITE_BARRIER
10851 hornik 281
# define SET_PRENV(x,v)	  (((x)->u.promsxp.env)=(v))
282
# define SET_PRVALUE(x,v) (((x)->u.promsxp.value)=(v))
10172 luke 283
#endif
284
#define SET_PRSEEN(x,v)	(((x)->sxpinfo.gp)=(v))
2 r 285
 
8456 rgentlem 286
/* Hashing Macros */
287
#define HASHASH(x)      ((x)->sxpinfo.gp)
10869 luke 288
#define HASHVALUE(x)    TRUELENGTH(x)
10172 luke 289
#define SET_HASHASH(x,v) (((x)->sxpinfo.gp)=(v))
10869 luke 290
#define SET_HASHVALUE(x,v) SET_TRUELENGTH(x, v)
2 r 291
 
1893 ihaka 292
/* Vector Heap Structure */
2 r 293
typedef struct {
294
	union {
295
		SEXP		backpointer;
296
		double		align;
297
	} u;
298
} VECREC, *VECP;
299
 
1893 ihaka 300
/* Vector Heap Macros */
2 r 301
#define BACKPOINTER(v)	((v).u.backpointer)
302
#define BYTE2VEC(n)	(((n)>0)?(((n)-1)/sizeof(VECREC)+1):0)
303
#define INT2VEC(n)	(((n)>0)?(((n)*sizeof(int)-1)/sizeof(VECREC)+1):0)
304
#define FLOAT2VEC(n)	(((n)>0)?(((n)*sizeof(double)-1)/sizeof(VECREC)+1):0)
6994 pd 305
#define COMPLEX2VEC(n)	(((n)>0)?(((n)*sizeof(Rcomplex)-1)/sizeof(VECREC)+1):0)
2 r 306
#define PTR2VEC(n)	(((n)>0)?(((n)*sizeof(SEXP)-1)/sizeof(VECREC)+1):0)
10172 luke 307
#else
308
typedef struct VECREC *VECP;
309
#define PRIMFUN(x)	(R_FunTab[PRIMOFFSET(x)].cfun)
310
#define PRIMNAME(x)	(R_FunTab[PRIMOFFSET(x)].name)
311
#define PRIMVAL(x)	(R_FunTab[PRIMOFFSET(x)].code)
312
#define PRIMARITY(x)	(R_FunTab[PRIMOFFSET(x)].arity)
313
#define PPINFO(x)	(R_FunTab[PRIMOFFSET(x)].gram)
314
#define PRIMPRINT(x)	(((R_FunTab[PRIMOFFSET(x)].eval)/100)%10)
315
#endif
2 r 316
 
26025 luke 317
#ifdef BYTECODE
318
# ifdef BC_INT_STACK
319
typedef union { void *p; int i; } IStackval;
320
# endif
321
#endif
322
 
1893 ihaka 323
/* Evaluation Context Structure */
2 r 324
typedef struct RCNTXT {
1893 ihaka 325
    struct RCNTXT *nextcontext;	/* The next context up the chain */
326
    int callflag;		/* The context "type" */
3090 ihaka 327
    JMP_BUF cjmpbuf;		/* C stack and register information */
1893 ihaka 328
    int cstacktop;		/* Top of the pointer protection stack */
8230 rgentlem 329
    int evaldepth;	        /* evaluation depth at inception */
1893 ihaka 330
    SEXP promargs;		/* Promises supplied to closure */
23463 luke 331
    SEXP callfun;		/* The closure called */
1893 ihaka 332
    SEXP sysparent;		/* environment the closure was called from */
333
    SEXP call;			/* The call that effected this context*/
334
    SEXP cloenv;		/* The environment */
335
    SEXP conexit;		/* Interpreted "on.exit" code */
14561 luke 336
    void (*cend)(void *);	/* C "on.exit" thunk */
337
    void *cenddata;		/* data for C "on.exit" thunk */
14480 luke 338
    char *vmax;		        /* top of R_alloc stack */
25200 luke 339
    int intsusp;                /* interrupts enables */
25523 luke 340
#ifdef NEW_CONDITION_HANDLING
341
    SEXP handlerstack;          /* condition handler stack */
342
    SEXP restartstack;          /* stack of available restarts */
343
#endif
26025 luke 344
#ifdef BYTECODE
345
    SEXP *nodestack;
346
# ifdef BC_INT_STACK
347
    IStackval *intstack;
348
# endif
349
#endif
2 r 350
} RCNTXT, *context;
351
 
6193 maechler 352
/* The Various Context Types.
6188 rgentlem 353
 
6193 maechler 354
 * In general the type is a bitwise OR of the values below.
355
 * Note that CTXT_LOOP is already the or of CTXT_NEXT and CTXT_BREAK.
356
 * Only functions should have the third bit turned on;
357
 * this allows us to move up the context stack easily
358
 * with either RETURN's or GENERIC's or RESTART's.
359
 * If you add a new context type for functions make sure
360
 *   CTXT_NEWTYPE & CTXT_FUNCTION > 0
361
 */
2 r 362
enum {
1893 ihaka 363
    CTXT_TOPLEVEL = 0,
2423 maechler 364
    CTXT_NEXT	  = 1,
365
    CTXT_BREAK	  = 2,
366
    CTXT_LOOP	  = 3,	/* break OR next target */
6188 rgentlem 367
    CTXT_FUNCTION = 4,
2423 maechler 368
    CTXT_CCODE	  = 8,
6188 rgentlem 369
    CTXT_RETURN	  = 12,
370
    CTXT_BROWSER  = 16,
371
    CTXT_GENERIC  = 20,
14631 luke 372
    CTXT_RESTART  = 32,
373
    CTXT_BUILTIN  = 64  /* used in profiling */
2 r 374
};
375
 
6188 rgentlem 376
/*
377
TOP   0 0 0 0 0 0  = 0
378
NEX   1 0 0 0 0 0  = 1
379
BRE   0 1 0 0 0 0  = 2
380
LOO   1 1 0 0 0 0  = 3
381
FUN   0 0 1 0 0 0  = 4
382
CCO   0 0 0 1 0 0  = 8
383
BRO   0 0 0 0 1 0  = 16
384
RET   0 0 1 1 0 0  = 12
385
GEN   0 0 1 0 1 0  = 20
14631 luke 386
RES   0 0 0 0 0 0 1 = 32
387
BUI   0 0 0 0 0 0 0 1 = 64
6188 rgentlem 388
*/
14631 luke 389
 
390
#define IS_RESTART_BIT_SET(flags) ((flags) & CTXT_RESTART)
391
#define SET_RESTART_BIT_ON(flags) (flags |= CTXT_RESTART)
392
#define SET_RESTART_BIT_OFF(flags) (flags &= ~CTXT_RESTART)
393
 
1893 ihaka 394
/* Miscellaneous Definitions */
2 r 395
#define streql(s, t)	(!strcmp((s), (t)))
396
 
1893 ihaka 397
/* Arithmetic and Relation Operators */
10718 maechler 398
typedef enum {
399
    PLUSOP = 1,
400
    MINUSOP,
401
    TIMESOP,
402
    DIVOP,
403
    POWOP,
404
    MODOP,
405
    IDIVOP
406
} ARITHOP_TYPE;
2 r 407
 
10718 maechler 408
typedef enum {
409
    EQOP = 1,
410
    NEOP,
411
    LTOP,
412
    LEOP,
413
    GEOP,
414
    GTOP
415
} RELOP_TYPE;
2 r 416
 
2467 maechler 417
/* File Handling */
6412 pd 418
/*
2467 maechler 419
#define R_EOF	65535
6412 pd 420
*/
421
#define R_EOF	-1
2432 maechler 422
 
2467 maechler 423
/* MAGIC Numbers for files */
424
#define R_MAGIC_BINARY 1975
425
#define R_MAGIC_ASCII  1976
426
#define R_MAGIC_XDR    1977
2 r 427
 
2467 maechler 428
#define R_MAGIC_BINARY_VERSION16 1971
429
#define R_MAGIC_ASCII_VERSION16	 1972
430
 
431
 
432
/*--- Global Variables ---------------------------------------------------- */
433
 
4622 maechler 434
/* Defined and initialized in names.c (not main.c) :*/
435
#ifndef __R_Names__
4709 maechler 436
extern
4622 maechler 437
#endif
438
FUNTAB	R_FunTab[];	    /* Built in functions */
439
 
440
 
15716 ripley 441
#include <R_ext/libextern.h>
442
 
4622 maechler 443
#ifdef __MAIN__
19066 hornik 444
# define INI_as(v) = v
4622 maechler 445
#else
19066 hornik 446
# define INI_as(v)
4622 maechler 447
#endif
448
 
9336 maechler 449
/* Formerly in Arith.h */
450
#ifdef IEEE_754
451
# define MATH_CHECK(call)	(call)
452
#else
453
  extern double R_tmp;
454
# define MATH_CHECK(call)	(errno=0,R_tmp=call,(errno==0)?R_tmp:R_NaN)
455
#endif
456
 
6994 pd 457
/* extern int	errno; already have errno.h ! */
6262 pd 458
extern int	gc_inhibit_torture INI_as(1);
2467 maechler 459
 
25200 luke 460
LibExtern Rboolean R_interrupts_suspended INI_as(FALSE);
25212 luke 461
LibExtern int R_interrupts_pending INI_as(0);
25200 luke 462
 
3094 r 463
/* R Home Directory */
464
extern char*	R_Home;		    /* Root of the R tree */
465
 
1893 ihaka 466
/* Memory Management */
20094 ripley 467
extern R_size_t	R_NSize		INI_as(R_NSIZE);/* Size of cons cell heap */
468
extern R_size_t	R_VSize		INI_as(R_VSIZE);/* Size of the vector heap */
1893 ihaka 469
extern SEXP	R_NHeap;	    /* Start of the cons cell heap */
470
extern SEXP	R_FreeSEXP;	    /* Cons cell free list */
20094 ripley 471
extern R_size_t	R_Collected;	    /* Number of free cons cells (after gc) */
15716 ripley 472
LibExtern SEXP	R_PreciousList;	    /* List of Persistent Objects */
473
LibExtern int	R_Is_Running;	    /* for Windows memory manager */
2 r 474
 
1893 ihaka 475
/* The Pointer Protection Stack */
4622 maechler 476
extern int	R_PPStackSize	INI_as(R_PPSSIZE); /* The stack size (elements) */
1893 ihaka 477
extern int	R_PPStackTop;	    /* The top of the stack */
478
extern SEXP*	R_PPStack;	    /* The pointer protection stack */
479
 
480
/* Evaluation Environment */
15716 ripley 481
LibExtern SEXP	R_CurrentExpr;	    /* Currently evaluating expression */
1893 ihaka 482
extern SEXP	R_ReturnedValue;    /* Slot for return-ing values */
483
extern SEXP*	R_SymbolTable;	    /* The symbol table */
17323 ripley 484
LibExtern RCNTXT R_Toplevel;	    /* Storage for the toplevel environment */
485
LibExtern RCNTXT* R_ToplevelContext;  /* The toplevel environment */
486
LibExtern RCNTXT* R_GlobalContext;    /* The global environment */
15716 ripley 487
LibExtern int	R_Visible;	    /* Value visibility flag */
488
LibExtern int	R_EvalDepth	INI_as(0);	/* Evaluation recursion depth */
4622 maechler 489
extern int	R_BrowseLevel	INI_as(0);	/* how deep the browser is */
1893 ihaka 490
 
8552 maechler 491
extern int	R_Expressions	INI_as(500);	/* options(expressions) */
11139 maechler 492
extern Rboolean	R_KeepSource	INI_as(FALSE);	/* options(keep.source) */
19680 luke 493
extern int	R_UseNamespaceDispatch INI_as(TRUE);
20106 ripley 494
extern int	R_WarnLength	INI_as(1000);	/* Error/warning max length */
8552 maechler 495
 
1893 ihaka 496
/* File Input/Output */
15716 ripley 497
LibExtern Rboolean R_Interactive	INI_as(TRUE);	/* TRUE during interactive use*/
10718 maechler 498
extern Rboolean	R_Quiet		INI_as(FALSE);	/* Be as quiet as possible */
499
extern Rboolean	R_Slave		INI_as(FALSE);	/* Run as a slave process */
500
extern Rboolean	R_Verbose	INI_as(FALSE);	/* Be verbose */
1893 ihaka 501
/* extern int	R_Console; */	    /* Console active flag */
4622 maechler 502
/* IoBuffer R_ConsoleIob; : --> ./IOStuff.h */
503
extern FILE*	R_Consolefile	INI_as(NULL);	/* Console output file */
504
extern FILE*	R_Outputfile	INI_as(NULL);	/* Output file */
13852 ripley 505
extern int	R_ErrorCon	INI_as(2);	/* Error connection */
20669 ripley 506
extern char*	R_TempDir	INI_as(NULL);	/* Name of per-session dir */
1893 ihaka 507
 
508
/* Objects Used In Parsing  */
509
extern SEXP	R_CommentSxp;	    /* Comments accumulate here */
510
extern SEXP	R_ParseText;	    /* Text to be parsed */
511
extern int	R_ParseCnt;	    /* Count of lines of text to be parsed */
4622 maechler 512
extern int	R_ParseError	INI_as(0); /* Line where parse error occured */
1893 ihaka 513
 
514
/* Image Dump/Restore */
4622 maechler 515
extern int	R_DirtyImage	INI_as(0);	/* Current image dirty */
1893 ihaka 516
 
4913 hornik 517
/* History */
15716 ripley 518
LibExtern char*	R_HistoryFile;	/* Name of the history file */
519
LibExtern int	R_HistorySize;	/* Size of the history file */
520
LibExtern int	R_RestoreHistory;	/* restore the history file? */
4913 hornik 521
 
4165 rgentlem 522
/* Warnings/Errors */
4622 maechler 523
extern int	R_CollectWarnings INI_as(0);	/* the number of warnings */
524
extern SEXP	R_Warnings;	    /* the warnings and their calls */
9336 maechler 525
extern int	R_ShowErrorMessages INI_as(1);	/* show error messages? */
25523 luke 526
#ifdef NEW_CONDITION_HANDLING
527
extern SEXP	R_HandlerStack;	/* Condition handler stack */
528
extern SEXP	R_RestartStack;	/* Stack of available restarts */
529
#endif
2 r 530
 
28032 ripley 531
extern Rboolean utf8locale  INI_as(FALSE);  /* is this a UTF-8 locale? */
28024 ripley 532
 
533
 
8925 ripley 534
/* GUI type */
535
 
536
extern char*	R_GUIType	INI_as("unknown");
537
 
26025 luke 538
#ifdef BYTECODE
539
#define R_BCNODESTACKSIZE 10000
540
extern SEXP *R_BCNodeStackBase, *R_BCNodeStackTop, *R_BCNodeStackEnd;
541
# ifdef BC_INT_STACK
542
#define R_BCINTSTACKSIZE 10000
543
extern IStackval *R_BCIntStackBase, *R_BCIntStackTop, *R_BCIntStackEnd;
544
# endif
545
#endif
546
 
16707 jmc 547
/* Pointer  type and utilities for dispatch in the methods package */
20088 jmc 548
typedef SEXP (*R_stdGen_ptr_t)(SEXP, SEXP, SEXP); /* typedef */
15938 jmc 549
R_stdGen_ptr_t R_get_standardGeneric_ptr(); /* get method */
26082 jmc 550
R_stdGen_ptr_t R_set_standardGeneric_ptr(R_stdGen_ptr_t, SEXP); /* set method */
26089 luke 551
extern SEXP R_MethodsNamespace;
16707 jmc 552
SEXP R_deferred_default_method();
553
SEXP R_set_prim_method(SEXP fname, SEXP op, SEXP code_vec, SEXP fundef, SEXP mlist);
554
SEXP do_set_prim_method(SEXP op, char *code_string, SEXP fundef, SEXP mlist);
17000 jmc 555
void R_set_quick_method_check(R_stdGen_ptr_t);
20088 jmc 556
SEXP R_primitive_methods(SEXP op);
15908 ripley 557
 
17000 jmc 558
/* slot management (in attrib.c) */
559
SEXP R_do_slot(SEXP obj, SEXP name);
18558 jmc 560
SEXP R_do_slot_assign(SEXP obj, SEXP name, SEXP value);
17000 jmc 561
 
22668 ripley 562
/* smallest decimal exponent, needed in format.c, set in Init_R_Machine */
563
extern int R_dec_min_exponent		INI_as(-308);
564
 
4622 maechler 565
#ifdef __MAIN__
19066 hornik 566
# undef extern
567
# undef LibExtern
4622 maechler 568
#endif
569
#undef INI_as
570
 
571
 
2467 maechler 572
/*--- FUNCTIONS ------------------------------------------------------ */
2 r 573
 
19066 hornik 574
# define begincontext		Rf_begincontext
575
# define checkArity		Rf_checkArity
576
# define CheckFormals		Rf_CheckFormals
577
# define CleanEd		Rf_CleanEd
578
# define DataFrameClass		Rf_DataFrameClass
579
# define ddfindVar		Rf_ddfindVar
580
# define deparse1		Rf_deparse1
581
# define deparse1line		Rf_deparse1line
582
# define DispatchGroup		Rf_DispatchGroup
583
# define DispatchOrEval		Rf_DispatchOrEval
584
# define duplicated		Rf_duplicated
585
# define dynamicfindVar		Rf_dynamicfindVar
586
# define endcontext		Rf_endcontext
587
# define errorcall		Rf_errorcall
588
# define ErrorMessage		Rf_ErrorMessage
589
# define factorsConform		Rf_factorsConform
590
# define FetchMethod		Rf_FetchMethod
591
# define findcontext		Rf_findcontext
592
# define findVar1		Rf_findVar1
593
# define FrameClassFix		Rf_FrameClassFix
594
# define framedepth		Rf_framedepth
595
# define frameSubscript		Rf_frameSubscript
596
# define get1index		Rf_get1index
597
# define getVar			Rf_getVar
598
# define getVarInFrame		Rf_getVarInFrame
599
# define hashpjw		Rf_hashpjw
600
# define InheritsClass		Rf_InheritsClass
601
# define InitArithmetic		Rf_InitArithmetic
602
# define InitColors		Rf_InitColors
603
# define InitConnections	Rf_InitConnections
604
# define InitEd			Rf_InitEd
605
# define InitFunctionHashing	Rf_InitFunctionHashing
606
# define InitGlobalEnv		Rf_InitGlobalEnv
607
# define InitMemory		Rf_InitMemory
608
# define InitNames		Rf_InitNames
609
# define InitOptions		Rf_InitOptions
20669 ripley 610
# define InitTempDir		Rf_InitTempDir
19066 hornik 611
# define initStack		Rf_initStack
612
# define internalTypeCheck	Rf_internalTypeCheck
613
# define isValidName		Rf_isValidName
614
# define jump_to_toplevel	Rf_jump_to_toplevel
615
# define levelsgets		Rf_levelsgets
616
# define mainloop		Rf_mainloop
617
# define mat2indsub		Rf_mat2indsub
618
# define match			Rf_match
619
# define mkCLOSXP		Rf_mkCLOSXP
620
# define mkComplex              Rf_mkComplex
621
# define mkFalse		Rf_mkFalse
622
# define mkFloat		Rf_mkFloat
623
# define mkNA			Rf_mkNA
624
# define mkPROMISE		Rf_mkPROMISE
625
# define mkQUOTE		Rf_mkQUOTE
626
# define mkSYMSXP		Rf_mkSYMSXP
627
# define mkTrue			Rf_mkTrue
628
# define NewEnvironment		Rf_NewEnvironment
629
# define OneIndex		Rf_OneIndex
630
# define onintr			Rf_onintr
631
# define onsigusr1              Rf_onsigusr1
632
# define onsigusr2              Rf_onsigusr2
633
# define parse			Rf_parse
634
# define PrintGreeting		Rf_PrintGreeting
635
# define PrintVersion		Rf_PrintVersion
636
# define PrintWarnings		Rf_PrintWarnings
637
# define promiseArgs		Rf_promiseArgs
638
# define RemoveClass		Rf_RemoveClass
639
# define setVarInFrame		Rf_setVarInFrame
640
# define sortVector		Rf_sortVector
641
# define ssort			Rf_ssort
642
# define str2type		Rf_str2type
643
# define StrToInternal		Rf_StrToInternal
644
# define substituteList		Rf_substituteList
645
# define tsConform		Rf_tsConform
646
# define tspgets		Rf_tspgets
647
# define type2str		Rf_type2str
648
# define type2symbol		Rf_type2symbol
649
# define unbindVar		Rf_unbindVar
650
# define usemethod		Rf_usemethod
651
# define warningcall		Rf_warningcall
652
# define WarningMessage		Rf_WarningMessage
653
# define yyerror		Rf_yyerror
654
# define yyinit			Rf_yyinit
655
# define yylex			Rf_yylex
656
# define yyparse		Rf_yyparse
657
# define yyprompt		Rf_yyprompt
658
# define yywrap			Rf_yywrap
7754 ripley 659
 
1893 ihaka 660
/* Platform Dependent Gui Hooks */
2 r 661
 
662
#define	R_CONSOLE	1
663
#define	R_FILE		2
664
#define R_TEXT		3
665
 
3921 pd 666
int	R_ReadConsole(char*, unsigned char*, int, int);
290 ihaka 667
void	R_WriteConsole(char*, int);
668
void	R_ResetConsole(void);
669
void	R_FlushConsole(void);
670
void	R_ClearerrConsole(void);
671
void	R_Busy(int);
3552 r 672
int	R_ShowFile(char*, char*);
11139 maechler 673
int	R_ShowFiles(int, char **, char **, char *, Rboolean, char *);
3656 ihaka 674
int	R_ChooseFile(int, char*, int);
11139 maechler 675
char*	R_Date(void);
3558 r 676
char*	R_HomeDir(void);
11139 maechler 677
Rboolean R_FileExists(char*);
678
Rboolean R_HiddenFile(char*);
24522 luke 679
double	R_FileMtime(char*);
2 r 680
 
16300 luke 681
/* environment cell access */
682
typedef struct R_varloc_st *R_varloc_t;
683
R_varloc_t R_findVarLocInFrame(SEXP, SEXP);
684
SEXP R_GetVarLocValue(R_varloc_t);
685
SEXP R_GetVarLocSymbol(R_varloc_t);
25088 luke 686
Rboolean R_GetVarLocMISSING(R_varloc_t);
16300 luke 687
void R_SetVarLocValue(R_varloc_t, SEXP);
688
 
2810 maechler 689
/* Other Internally Used Functions */
690
 
22926 ripley 691
SEXP Rf_append(SEXP, SEXP); /* apparently unused now */
23463 luke 692
void begincontext(RCNTXT*, int, SEXP, SEXP, SEXP, SEXP, SEXP);
2 r 693
void checkArity(SEXP, SEXP);
694
void CheckFormals(SEXP);
5182 ripley 695
void CleanEd(void);
2 r 696
void DataFrameClass(SEXP);
1916 rgentlem 697
SEXP ddfindVar(SEXP, SEXP);
10718 maechler 698
SEXP deparse1(SEXP,Rboolean);
699
SEXP deparse1line(SEXP,Rboolean);
16707 jmc 700
int DispatchOrEval(SEXP, SEXP, char*, SEXP, SEXP, SEXP*, int, int);
2 r 701
int DispatchGroup(char*, SEXP,SEXP,SEXP,SEXP,SEXP*);
702
SEXP duplicated(SEXP);
703
SEXP dynamicfindVar(SEXP, RCNTXT*);
704
void endcontext(RCNTXT*);
705
int factorsConform(SEXP, SEXP);
7758 ripley 706
SEXP FetchMethod(char *, char *, SEXP);
1258 ihaka 707
void findcontext(int, SEXP, SEXP);
2 r 708
SEXP findVar1(SEXP, SEXP, SEXPTYPE, int);
709
void FrameClassFix(SEXP);
710
int framedepth(RCNTXT*);
711
SEXP frameSubscript(int, SEXP, SEXP);
22883 ripley 712
int get1index(SEXP, SEXP, int, Rboolean, int);
2 r 713
SEXP getVar(SEXP, SEXP);
714
SEXP getVarInFrame(SEXP, SEXP);
715
int hashpjw(char*);
13606 maechler 716
Rboolean InheritsClass(SEXP, char*);
2 r 717
void InitArithmetic(void);
718
void InitColors(void);
11656 ripley 719
void InitConnections(void);
2 r 720
void InitEd(void);
721
void InitFunctionHashing(void);
722
void InitGlobalEnv(void);
21102 jmc 723
Rboolean R_current_trace_state();
17000 jmc 724
Rboolean R_has_methods(SEXP);
2 r 725
void R_InitialData(void);
16764 jmc 726
SEXP R_possible_dispatch(SEXP, SEXP, SEXP, SEXP);
2 r 727
void InitMemory(void);
728
void InitNames(void);
729
void InitOptions(void);
20278 ripley 730
void Init_R_Variables(SEXP);
20669 ripley 731
void InitTempDir(void);
2 r 732
void initStack(void);
25523 luke 733
#ifdef NEW_CONDITION_HANDLING
734
void R_InsertRestartHandlers(RCNTXT *, Rboolean);
735
#endif
2 r 736
void internalTypeCheck(SEXP, SEXP, SEXPTYPE);
23073 ripley 737
Rboolean isMethodsDispatchOn(void);
4622 maechler 738
int isValidName(char *);
25520 luke 739
void R_JumpToContext(RCNTXT *, int, SEXP);
2 r 740
void jump_to_toplevel(void);
741
SEXP levelsgets(SEXP, SEXP);
742
void mainloop(void);
743
SEXP mat2indsub(SEXP, SEXP);
744
SEXP match(SEXP, SEXP, int);
745
SEXP mkCLOSXP(SEXP, SEXP, SEXP);
7758 ripley 746
SEXP mkComplex(char *s);
5124 ihaka 747
/* SEXP mkEnv(SEXP, SEXP, SEXP); */
7758 ripley 748
SEXP mkFalse(void);
749
SEXP mkFloat(char *s);
750
SEXP mkNA(void);
2 r 751
SEXP mkPRIMSXP (int, int);
752
SEXP mkPROMISE(SEXP, SEXP);
753
SEXP mkQUOTE(SEXP);
754
SEXP mkSYMSXP(SEXP, SEXP);
7758 ripley 755
SEXP mkTrue(void);
5124 ihaka 756
SEXP NewEnvironment(SEXP, SEXP, SEXP);
2 r 757
void onintr();
8422 tlumley 758
void onsigusr1();
759
void onsigusr2();
22883 ripley 760
int OneIndex(SEXP, SEXP, int, int, SEXP*, int);
2 r 761
SEXP parse(FILE*, int);
762
void PrintGreeting(void);
5194 ripley 763
void PrintVersion(char *);
4165 rgentlem 764
void PrintWarnings(void);
15427 hornik 765
void process_site_Renviron();
766
void process_system_Renviron();
767
void process_user_Renviron();
2 r 768
SEXP promiseArgs(SEXP, SEXP);
11656 ripley 769
void Rcons_vprintf(const char *, va_list);
7758 ripley 770
void RemoveClass(SEXP, char *);
15753 jmc 771
SEXP R_data_class(SEXP , int);
5245 ripley 772
SEXP R_LoadFromFile(FILE*, int);
16242 luke 773
SEXP R_NewHashedEnv(SEXP);
8456 rgentlem 774
extern int R_Newhashpjw(char*);
2467 maechler 775
FILE* R_OpenLibraryFile(char *);
24522 luke 776
char *R_LibraryFileName(char *, char *, size_t);
2 r 777
void R_RestoreGlobalEnv(void);
16803 luke 778
void R_RestoreGlobalEnvFromFile(const char *, Rboolean);
2 r 779
void R_SaveGlobalEnv(void);
16803 luke 780
void R_SaveGlobalEnvToFile(const char *);
11116 ripley 781
void R_SaveToFile(SEXP, FILE*, int);
25087 luke 782
void R_SaveToFileV(SEXP, FILE*, int, int);
15753 jmc 783
SEXP R_set_class(SEXP, SEXP, SEXP);
4229 rgentlem 784
int R_SetOptionWarn(int);
3382 ihaka 785
int R_SetOptionWidth(int);
2467 maechler 786
void R_Suicide(char*);
2 r 787
SEXP setVarInFrame(SEXP, SEXP, SEXP);
18860 ripley 788
void sortVector(SEXP, Rboolean);
2 r 789
void ssort(SEXP*,int);
790
SEXPTYPE str2type(char*);
791
int StrToInternal(char*);
2810 maechler 792
SEXP substituteList(SEXP, SEXP);
571 ihaka 793
SEXP R_syscall(int,RCNTXT*);
794
int R_sysparent(int,RCNTXT*);
795
SEXP R_sysframe(int,RCNTXT*);
796
SEXP R_sysfunction(int,RCNTXT*);
11139 maechler 797
Rboolean tsConform(SEXP,SEXP);
2 r 798
SEXP tspgets(SEXP, SEXP);
799
SEXP type2str(SEXPTYPE);
15459 jmc 800
SEXP type2symbol(SEXPTYPE);
2 r 801
void unbindVar(SEXP, SEXP);
10172 luke 802
#ifdef ALLOW_OLD_SAVE
2 r 803
void unmarkPhase(void);
10172 luke 804
#endif
16335 luke 805
SEXP R_LookupMethod(SEXP, SEXP, SEXP, SEXP);
806
int usemethod(char*, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP*);
24734 ripley 807
 
11139 maechler 808
/* ../main/errors.c : */
13997 duncan 809
void errorcall(SEXP, const char*, ...);
810
void warningcall(SEXP, const char*,...);
11139 maechler 811
void ErrorMessage(SEXP, int, ...);
812
void WarningMessage(SEXP, R_WARNING, ...);
25420 luke 813
SEXP R_GetTraceback(int);
11139 maechler 814
 
20094 ripley 815
R_size_t R_GetMaxVSize(void);
816
void R_SetMaxVSize(R_size_t);
817
R_size_t R_GetMaxNSize(void);
818
void R_SetMaxNSize(R_size_t);
819
R_size_t R_Decode2Long(char *p, int *ierr);
27067 ripley 820
void R_SetPPSize(unsigned long);
2467 maechler 821
 
14477 luke 822
void R_run_onexits(RCNTXT *);
14479 luke 823
void R_restore_globals(RCNTXT *);
11139 maechler 824
 
14477 luke 825
 
2467 maechler 826
/* gram.y & gram.c : */
2432 maechler 827
void yyerror(char *);
2 r 828
void yyinit(void);
2432 maechler 829
int yylex();
2 r 830
int yyparse(void);
831
void yyprompt(char *format, ...);
832
int yywrap(void);
833
 
8684 luke 834
/* Macros for suspending interrupts */
25200 luke 835
#define BEGIN_SUSPEND_INTERRUPTS do { \
836
    Rboolean __oldsusp__ = R_interrupts_suspended; \
837
    R_interrupts_suspended = TRUE;
838
#define END_SUSPEND_INTERRUPTS R_interrupts_suspended = __oldsusp__; \
25497 luke 839
    if (R_interrupts_pending && ! R_interrupts_suspended) \
25200 luke 840
        onintr(); \
841
} while(0)
8684 luke 842
 
11116 ripley 843
#endif /* DEFN_H_ */
2467 maechler 844
/*
845
 *- Local Variables:
846
 *- page-delimiter: "^/\\*---"
847
 *- End:
848
 */