pike.git
/
src
/
program.h
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.h:1:
/* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: program.h,v 1.
182
2003/
06
/
03
18
:
03
:
26
mast Exp $
+
|| $Id: program.h,v 1.
183
2003/
08
/
02
01
:
07
:
18
mast Exp $
*/ #ifndef PROGRAM_H #define PROGRAM_H #include <stdarg.h> #include "global.h" #include "pike_types.h" #include "pike_macros.h" #include "svalue.h"
pike.git/src/program.h:138:
* Max program dimensions: * 2^16 functions + global variables * 2^16 inherits * 2^16 arguments to pike functions * 2^32 efuns * 2^8 local variables (and arguments) */ union idptr {
+
/* C function pointer. */
void (*c_fun)(INT32);
-
+
+
/* For variables: Offset of the variable in the storage pointed to
+
* by inherit.storage_offset in the struct inherit that corresponds
+
* to the identifier. See LOW_GET_GLOBAL and GET_GLOBAL. The stored
+
* variable may be either a normal or a short svalue, depending on
+
* identifier.run_time_type.
+
*
+
* For constants: Offset of the struct program_constant in
+
* program.constants in the program pointed to by prog in the struct
+
* inherit that corresponds to the identifier.
+
*
+
* For pike functions: Offset to the start of the function in
+
* program.program in the program pointed to by prog in the struct
+
* inherit that corresponds to the identifier. */
ptrdiff_t offset; }; #define IDENTIFIER_PIKE_FUNCTION 1 #define IDENTIFIER_C_FUNCTION 2 #define IDENTIFIER_FUNCTION 3 #define IDENTIFIER_CONSTANT 4 #define IDENTIFIER_VARARGS 8 /* Used for functions only. */ #define IDENTIFIER_NO_THIS_REF 8 /* Used for variables only: Don't count refs to self. */ #define IDENTIFIER_HAS_BODY 16 /* Function has a body (set already in pass 1). */
pike.git/src/program.h:224:
#define ID_SAVE_PARENT 0x10000 /* #pragma save_parent */ #define ID_DONT_SAVE_PARENT 0x20000 /* #pragma dont_save_parent */ /* * All identifiers in this program * and all identifiers in inherited programs * need to have a 'struct reference' in this * program. When we overload a function, we simply * change the reference to point to the new 'struct identifier'.
+
*
+
* When an identifier is represented as an integer, it's typically the
+
* offset of the corresponding struct reference in
+
* program.identifier_references.
*/ struct reference {
-
+
/* Offset of the struct inherit in program.inherits for the program
+
* that the struct identifier is in. See INHERIT_FROM_PTR and
+
* INHERIT_FROM_INT. */
unsigned INT16 inherit_offset;
-
+
+
/* Offset of the struct identifier in program.identifiers in the
+
* program pointed to by the struct inherit through inherit_offset
+
* above. See ID_FROM_PTR and ID_FROM_INT. */
unsigned INT16 identifier_offset;
-
INT16
id
_flags
;
/*
static, private etc.. */
+
+
/*
ID
_
*
flags
-
static, private etc.. */
+
INT16 id_flags;
};
-
+
/* Magic values in inherit.parent_offset; see below. */
+
#define OBJECT_PARENT -18
+
#define INHERIT_PARENT -17
+
/* * Each program has an array of these, * the first entry points to itself, the * rest are from inherited programs. * Note that when a program is inherited, * all 'struct inherit' from that program are * copied, so the whole tree of inherits is * represented. */ struct inherit {
-
+
/* The depth of the inherited program in this program. I.e. the
+
* number of times the program has been inherited, directly or
+
* indirectly.
+
*
+
* Note that the struct inherit for the program that directly
+
* inherited the program represented by this struct inherit can be
+
* found by going backwards in program.inherits from this struct
+
* until one is found with an inherit_level less than this one. */
INT16 inherit_level;
-
+
+
/* All the identifier references in the inherited program has been
+
* copied to this program with the first one at this offset. */
INT16 identifier_level;
-
+
+
/* The index of the identifier reference in the parent program for
+
* the identifier from which this inherit was done. -1 if there's no
+
* such thing. It's always -1 in the inherit struct for the top
+
* level program. */
INT16 parent_identifier;
-
+
+
/* Describes how to find the parent object for the external
+
* identifier references associated with this inherit:
+
*
+
* OBJECT_PARENT: Follow the object parent, providing
+
* PROGRAM_USES_PARENT is set in the program containing this
+
* inherit. See PARENT_INFO. This is used for external references
+
* in the top level program (i.e. the one containing the inherit
+
* table).
+
*
+
* INHERIT_PARENT: Follow the parent pointer in this inherit. This
+
* is used when finished programs with parent objects are
+
* inherited.
+
*
+
* A non-negative integer: The parent is found by following this
+
* number of parent pointers in the program that directly
+
* inherited the program in this inherit, i.e. in the closest
+
* lower level inherit. This is used when a program is inherited
+
* whose parent is still being compiled, so it's parent object is
+
* fake. That implies that that program also contains the current
+
* program on some level, and that level is stored here. An
+
* example:
+
*
+
* class A {
+
* class B {}
+
* class C {
+
* class D {
+
* inherit B;
+
* }
+
* }
+
* }
+
*
+
* The parent program of B is A, which is still being compiled
+
* when B is inherited in D, so it has a fake object. A is also
+
* the parent of D, but two levels out, and hence 2 is stored in
+
* parent_offset.
+
*
+
* Note that parent_offset can be 0:
+
*
+
* class A {
+
* class B {}
+
* inherit B;
+
* }
+
*/
INT16 parent_offset;
-
+
+
/* The offset of the first entry in prog->identifier_references that
+
* comes from the program in this inherit. prog is in this case the
+
* program that directly inherited it, and not the top level
+
* program. I.e. for inherits on level 1, this is always the same as
+
* identifier_level.
+
*
+
* Are both really necessary? /mast */
size_t identifier_ref_offset;
-
+
+
/* Offset in object->storage to the start of the storage for the
+
* variables from the program in this inherit. */
ptrdiff_t storage_offset;
-
+
+
/* The parent object for the program in this inherit, or NULL if
+
* there isn't any. */
struct object *parent;
-
+
+
/* The program for this inherit. */
struct program *prog;
-
+
+
/* The name of the inherit, if there is any. For nested inherits,
+
* this can be a string on the form "A::B::C". */
struct pike_string *name; }; /* * Storage struct for a trampoline object * (not a part of the program type) */ struct pike_trampoline {
pike.git/src/program.h:292:
* Normally only used for mutex lock keys and similar */ #define PROGRAM_DESTRUCT_IMMEDIATE 0x10 /* Self explanatory, automatically detected */ #define PROGRAM_HAS_C_METHODS 0x20 /* Objects created from this program are constant and shareable */ #define PROGRAM_CONSTANT 0x40
-
/* */
+
/*
Objects have pointers to the parent object. Use LOW_PARENT_INFO or
+
*
PARENT_INFO to extract it. *
/
#define PROGRAM_USES_PARENT 0x80 /* Objects should not be destructed even when they only have weak * references left. */ #define PROGRAM_NO_WEAK_FREE 0x100 /* Objects should not be destructed by f_destruct(). */ #define PROGRAM_NO_EXPLICIT_DESTRUCT 0x200 /* Program is in an inconsistant state */ #define PROGRAM_AVOID_CHECK 0x400 /* Program has not yet been used for compilation */ #define PROGRAM_VIRGIN 0x800
-
/* */
+
/*
Don't allow the program to be inherited or cloned if there's no
+
*
parent object. Only set if PROGRAM_USES_PARENT is. *
/
#define PROGRAM_NEEDS_PARENT 0x1000 /* Using define instead of enum allows for ifdefs - Hubbe */ #define PROG_EVENT_INIT 0 #define PROG_EVENT_EXIT 1 #define PROG_EVENT_GC_RECURSE 2 #define PROG_EVENT_GC_CHECK 3 #define NUM_PROG_EVENTS 4 /* These macros should only be used if (p->flags & PROGRAM_USES_PARENT)