cb2256 | 1995-10-11 | Fredrik Hübinette (Hubbe) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #ifndef SVALUE_H
#define SVALUE_H
#include "types.h"
struct array;
struct mapping;
struct list;
struct object;
struct program;
struct lpc_string;
struct callable;
struct processing
{
struct processing *next;
void *pointer_a, *pointer_b;
};
union anything
{
struct callable *efun;
struct array *array;
struct mapping *mapping;
struct list *list;
struct object *object;
struct program *program;
struct lpc_string *string;
INT32 *refs;
INT32 integer;
FLOAT_TYPE float_number;
struct svalue *lval;
union anything *short_lval;
};
struct svalue
{
|
39e0bd | 1996-06-09 | Fredrik Hübinette (Hubbe) | | unsigned INT16 type;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | INT16 subtype;
union anything u;
};
#define T_ARRAY 0
#define T_MAPPING 1
#define T_LIST 2
#define T_OBJECT 3
#define T_FUNCTION 4
#define T_PROGRAM 5
#define T_STRING 6
#define T_FLOAT 7
#define T_INT 8
|
39e0bd | 1996-06-09 | Fredrik Hübinette (Hubbe) | | #define T_DELETED 246
|
bce86c | 1996-02-25 | Fredrik Hübinette (Hubbe) | | #define T_NOT 247
#define T_AND 248
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | #define T_UNKNOWN 249
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #define T_MANY 250
#define T_OR 251
#define T_SHORT_LVALUE 252
#define T_LVALUE 253
#define T_VOID 254
#define T_MIXED 255
#define BIT_ARRAY (1<<T_ARRAY)
#define BIT_MAPPING (1<<T_MAPPING)
#define BIT_LIST (1<<T_LIST)
#define BIT_OBJECT (1<<T_OBJECT)
#define BIT_FUNCTION (1<<T_FUNCTION)
#define BIT_PROGRAM (1<<T_PROGRAM)
#define BIT_STRING (1<<T_STRING)
#define BIT_INT (1<<T_INT)
#define BIT_FLOAT (1<<T_FLOAT)
|
4eb50a | 1996-05-16 | Fredrik Hübinette (Hubbe) | |
#define BIT_UNFINISHED (1<<15)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #define BIT_NOTHING 0
|
4eb50a | 1996-05-16 | Fredrik Hübinette (Hubbe) | | #define BIT_MIXED 0x7fff
|
624d09 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | #define BIT_BASIC (BIT_INT|BIT_FLOAT|BIT_STRING)
#define BIT_COMPLEX (BIT_ARRAY|BIT_LIST|BIT_OBJECT|BIT_PROGRAM|BIT_MAPPING)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
#define MAX_REF_TYPE T_STRING
#define MAX_TYPE T_INT
#define NUMBER_NUMBER 0
#define NUMBER_UNDEFINED 1
#define NUMBER_DESTRUCTED 2
|
bce86c | 1996-02-25 | Fredrik Hübinette (Hubbe) | | #define is_gt(a,b) is_lt(b,a)
|
07c073 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | #define IS_ZERO(X) ((X)->type==T_INT?(X)->u.integer==0:(1<<(X)->type)&(BIT_OBJECT|BIT_FUNCTION)?!svalue_is_true(X):0)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
#define check_destructed(S) \
do{ \
struct svalue *_s=(S); \
if((_s->type == T_OBJECT || _s->type==T_FUNCTION) && !_s->u.object->prog) { \
free_object(_s->u.object); \
_s->type = T_INT; \
_s->subtype = NUMBER_DESTRUCTED ; \
_s->u.integer = 0; \
} \
}while(0)
#define check_short_destructed(U,T) \
do{ \
union anything *_u=(U); \
if(( (1<<(T)) & (BIT_OBJECT | BIT_FUNCTION) ) && \
_u->object && !_u->object->prog) { \
free_object(_u->object); \
_u->object = 0; \
} \
}while(0)
#ifdef DEBUG
|
39e0bd | 1996-06-09 | Fredrik Hübinette (Hubbe) | | #define check_type(T) if(T > MAX_TYPE && T!=T_LVALUE && T!=T_SHORT_LVALUE && T!=T_VOID && T!=T_DELETED) fatal("Type error\n")
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #define check_refs(S) if((S)->type < MAX_REF_TYPE && (!(S)->u.refs || (S)->u.refs[0] < 0)) fatal("Svalue to object without references.\n")
#define check_refs2(S,T) if((T) < MAX_REF_TYPE && (S)->refs && (S)->refs[0] <= 0) fatal("Svalue to object without references.\n")
#else
#define check_type(T)
#define check_refs(S)
#define check_refs2(S,T)
#endif
void free_short_svalue(union anything *s,TYPE_T type);
void free_svalue(struct svalue *s);
|
fc7695 | 1996-02-17 | Fredrik Hübinette (Hubbe) | | void free_svalues(struct svalue *s,INT32 num, INT32 type_hint);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | void assign_svalue_no_free(struct svalue *to,
struct svalue *from);
void assign_svalues_no_free(struct svalue *to,
struct svalue *from,
|
fc7695 | 1996-02-17 | Fredrik Hübinette (Hubbe) | | INT32 num,
INT32 type_hint);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | void assign_svalue(struct svalue *to, struct svalue *from);
|
99946c | 1996-02-17 | Fredrik Hübinette (Hubbe) | | void assign_svalues(struct svalue *to,
struct svalue *from,
INT32 num,
TYPE_FIELD types);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | void assign_to_short_svalue(union anything *u,
TYPE_T type,
struct svalue *s);
void assign_to_short_svalue_no_free(union anything *u,
|
fc7695 | 1996-02-17 | Fredrik Hübinette (Hubbe) | | TYPE_T type,
struct svalue *s);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | void assign_from_short_svalue_no_free(struct svalue *s,
union anything *u,
TYPE_T type);
void assign_short_svalue_no_free(union anything *to,
union anything *from,
TYPE_T type);
void assign_short_svalue(union anything *to,
union anything *from,
TYPE_T type);
|
07c073 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | unsigned INT32 hash_svalue(struct svalue *s);
int svalue_is_true(struct svalue *s);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | int is_eq(struct svalue *a, struct svalue *b);
int low_is_equal(struct svalue *a,
struct svalue *b,
struct processing *p);
int low_short_is_equal(const union anything *a,
const union anything *b,
TYPE_T type,
struct processing *p);
int is_equal(struct svalue *a,struct svalue *b);
|
07c073 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | int is_lt(struct svalue *a,struct svalue *b);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | void describe_svalue(struct svalue *s,int indent,struct processing *p);
void clear_svalues(struct svalue *s, INT32 num);
void copy_svalues_recursively_no_free(struct svalue *to,
struct svalue *from,
INT32 num,
struct processing *p);
void check_short_svalue(union anything *u,TYPE_T type);
void check_svalue(struct svalue *s);
|
b95bef | 1996-03-29 | Fredrik Hübinette (Hubbe) | | TYPE_FIELD gc_check_svalues(struct svalue *s, int num);
|
bce86c | 1996-02-25 | Fredrik Hübinette (Hubbe) | | void gc_check_short_svalue(union anything *u, TYPE_T type);
|
b95bef | 1996-03-29 | Fredrik Hübinette (Hubbe) | | void gc_mark_svalues(struct svalue *s, int num);
void gc_mark_short_svalue(union anything *u, TYPE_T type);
|
3a5822 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | INT32 lpc_sizeof(struct svalue *s);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
#endif
|