[go: up one dir, main page]

Menu

[897c37]: / lpvm / value.h  Maximize  Restore  History

Download this file

166 lines (136 with data), 3.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
** $Id: value.h,v 1.4 2008/12/18 04:03:43 dredd Exp $
**
** $Source: /cvsroot/swlpc/swlpc/lpvm/value.h,v $
** $Revision: 1.4 $
** $Date: 2008/12/18 04:03:43 $
** $State: Exp $
**
** Authors: Mike McGaughey & Geoff Wong, 1993-1999
** geoff.wong@gmail.com
**
** See the file "Copying" distributed with this file.
*/
#ifndef _VALUE_H
#define _VALUE_H
#include "stack.h"
#include "stralloc.h"
#include "object.h"
#if 0
union u
{
Shared * string;
int number;
float real; /* check that it fits :) */
struct object * ob;
struct vector * vec;
struct vector_regexp * reg;
};
/*
* The definition of a value node. It is used for all computations.
* Strings can NOT be constant! All strings (in values) should be created
* with string_copy (since constant strings might be inside other strings which
* could be freed anyway).
*/
struct value
{
union u u;
int type;
};
typedef struct value Val;
#endif
/*
* Definition for constant values in the object global table.
* Really a hack-on. GW.
*/
struct constval
{
struct value * val;
Shared * name;
int type;
};
typedef struct constval CVal;
#define NullValue (struct value *)0
/*
* Use bitflags for type checking
*/
#define T_INVALID 0
#define T_VOID 0
#define T_NUMBER 1 /* bit 0 */
#define T_REAL 2
#define T_STRING 4
#define T_OBJECT 8
#define T_POINTER 16
#define T_IMAGE 32
#define T_HANDLE 64
#define TY_STATIC 128
#define TY_UNDEFC 256
#define TY_PRIVATE 512
#define TY_CONSTANT 1024
#ifdef GRAPHICS
#define T_NUM 7
#else
#define T_NUM 6 /* left shift to get past types */
#endif
#define T_ANY ((1<<T_NUM)-1)
extern struct value *alloc_value();
#define ARRAY_STATS
#ifdef ARRAY_STATS
extern unsigned int total_array_size, num_arrays;
#endif
typedef struct vector
{
short size;
short ref;
struct value item[1];
} Vec;
#define ALLOC_VECTOR(nelem) \
(struct vector *)malloc(sizeof (struct vector) + \
sizeof(struct value) * (nelem - 1))
/*
* regexp compiled code is stored in vector of size -1.
* This is not implemented yet.
*/
struct vector_regexp
{
Vec vector;
struct regexp *regexp;
};
#define MINFIXEDINT (-128)
#define MAXFIXEDINT (127)
#define Const(x) (&staticints[x-MINFIXEDINT])
/*
* This is the maximum array size allowed for a single array.
*/
#define MAX_ARRAY_SIZE 50000
extern Val staticints[];
void
assign_value(Val * dest, Val * v),
clear_assign(Val * dest, Val * v),
free_value(Val * v),
free_vector(Vec * p)
;
Val
* alloc_value(),
* allocate_array(int n),
* copy_value(Val * arg),
* make_number(int n),
* make_handle(void * ),
* make_object(struct object * n),
* make_real(float n),
* make_string(const char * str),
* make_nstring(const char * str, int n),
* make_vector(Vec * p),
* share_string(Shared * str)
;
char
* typename(int)
;
int
copy_in_vector(struct vector *a, struct vector *b, int, int, int)
;
/* Vector stuff */
Vec * create_vector(int n, const char * from);
Val * concatenate(Val * a, Val * b);
int initfixedints();
#endif