File: vectors.c

package info (click to toggle)
rscheme 0.7.2-1.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 10,672 kB
  • ctags: 12,430
  • sloc: lisp: 37,104; ansic: 29,763; cpp: 2,630; sh: 1,677; makefile: 568; yacc: 202; lex: 175; perl: 33
file content (303 lines) | stat: -rw-r--r-- 6,860 bytes parent folder | download | duplicates (2)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/**********************************************
THIS FILE WAS AUTOMATICALLY GENERATED, AND MAY
BE AUTOMATICALLY RE-GENERATED WHEN THE COMPILER
OR SOURCE CHANGES.  DO NOT MODIFY THIS FILE BY HAND!
RScheme Build (v0.7.2, 97.12.21)
**********************************************/

/******************************** Preamble ********************************/

#define _MODULE_LOW_SCHEME
#define _SCM_VECTORS
#define _C_VECTORS
#include "low_sch1.h"
#include <rscheme/vinsns.h>
extern struct module_descr module_low_scheme;
extern struct part_descr low_scheme_part_vectors;
static char sccsid[] = "@(#)low-scheme modules/lowscm/vectors.scm[337842177] (RS v0.7.2, 97.12.21)";

/************************** Function Definitions **************************/


/************************* Raw glue `make-vector' *************************/
#define vec_length REG0
#define vec_fill REG1

static char rsfn_make_vector_name[] = "make-vector";
#define FUNCTION rsfn_make_vector_name

PROLOGUE(make_vector)

BEGIN_FWD(make_vector)
  FWD_MONOTONE(make_vector_0)
END_FWD(make_vector)

#define FPLACE_CODE (1000+0)
MONOTONE(make_vector_0)
{
UINT_32 i, len;
obj fill = FALSE_OBJ;

    if (arg_count_reg != 1)
    {
	if (arg_count_reg == 2)
	    fill = vec_fill;
	else
	    wrong_num_args_range( FUNCTION, 1, 2 );
    }

    if (!OBJ_ISA_FIXNUM(vec_length))
	scheme_error( string_text(LITERAL(0)), 1, vec_length );

    len = FXWORDS_TO_RIBYTES(vec_length);
    REG0 = make_gvec( vector_class, len, fill );
    RETURN(1);
}
#undef FPLACE_CODE

EPILOGUE(make_vector)

BEGIN_BACK(make_vector)
  BACK_MONOTONE(make_vector_0)
END_BACK(make_vector)

static struct function_descr make_vector_descr = {
	&low_scheme_part_vectors,
	JUMP_TABLE( make_vector ),
	rsfn_make_vector_name };
#undef FUNCTION

#undef vec_length
#undef vec_fill

/************************ Raw glue `list->vector' ************************/
#define list REG0

static char rsfn_list_vector_name[] = "list->vector";
#define FUNCTION rsfn_list_vector_name

PROLOGUE(list_vector)

BEGIN_FWD(list_vector)
  FWD_MONOTONE(list_vector_0)
END_FWD(list_vector)

#define FPLACE_CODE (1000+0)
MONOTONE(list_vector_0)
{
UINT_32 i, len;
obj vector;
obj lp;

    len = 0;
    for (lp=list; PAIR_P(lp); lp=pair_cdr(lp))
	len += sizeof(obj);
    if (!NULL_P(lp))
	scheme_error( "list->vector: ~a not a proper list at: ~a",
			2, list, lp );

    vector = alloc( len, vector_class );

    i = 0;
    while (!NULL_P(list))
    {
        gvec_write_init( vector, i, pair_car(list) );
	list = pair_cdr( list );
	i += sizeof(obj);
    }
    REG0 = vector;
    RETURN1();
}
#undef FPLACE_CODE

EPILOGUE(list_vector)

BEGIN_BACK(list_vector)
  BACK_MONOTONE(list_vector_0)
END_BACK(list_vector)

static struct function_descr list_vector_descr = {
	&low_scheme_part_vectors,
	JUMP_TABLE( list_vector ),
	rsfn_list_vector_name };
#undef FUNCTION

#undef list

/************************ Raw glue `vector-fill!' ************************/
#define vector REG0
#define fill REG1

static char rsfn_vector_fill_name[] = "vector-fill!";
#define FUNCTION rsfn_vector_fill_name

PROLOGUE(vector_fill)

BEGIN_FWD(vector_fill)
  FWD_MONOTONE(vector_fill_0)
END_FWD(vector_fill)

#define FPLACE_CODE (1000+0)
MONOTONE(vector_fill_0)
{
UINT_32 i, len;

    COUNT_ARGS(2);
    len = SIZEOF_PTR(vector);
    
    if (OBJ_ISA_PTR(fill))
    {
	for (i=0; i<len; i+=SLOT(1))
	    gvec_write_ptr( vector, i, fill );
    }
    else
    {
	for (i=0; i<len; i+=SLOT(1))
	    gvec_write_non_ptr( vector, i, fill );
    }
    RETURN1();
}
#undef FPLACE_CODE

EPILOGUE(vector_fill)

BEGIN_BACK(vector_fill)
  BACK_MONOTONE(vector_fill_0)
END_BACK(vector_fill)

static struct function_descr vector_fill_descr = {
	&low_scheme_part_vectors,
	JUMP_TABLE( vector_fill ),
	rsfn_vector_fill_name };
#undef FUNCTION

#undef vector
#undef fill

/*************************** Raw glue `vector' ***************************/

static char rsfn_vector_name[] = "vector";
#define FUNCTION rsfn_vector_name

PROLOGUE(vector)

BEGIN_FWD(vector)
  FWD_MONOTONE(vector_0)
END_FWD(vector)

#define FPLACE_CODE (1000+0)
MONOTONE(vector_0)
{
unsigned i;
obj old0;

    old0 = REG0;
    REG0 = alloc( SLOT(arg_count_reg), vector_class );
    switch (arg_count_reg)
    {
	default:
	         for (i=10; i<arg_count_reg; i++)
		  gvec_write_init( REG0, SLOT(i), REG(i) );
	case 10: gvec_write_init( REG0, SLOT(9), REG9 );
	case  9: gvec_write_init( REG0, SLOT(8), REG8 );
	case  8: gvec_write_init( REG0, SLOT(7), REG7 );
	case  7: gvec_write_init( REG0, SLOT(6), REG6 );
	case  6: gvec_write_init( REG0, SLOT(5), REG5 );
	case  5: gvec_write_init( REG0, SLOT(4), REG4 );
	case  4: gvec_write_init( REG0, SLOT(3), REG3 );
	case  3: gvec_write_init( REG0, SLOT(2), REG2 );
	case  2: gvec_write_init( REG0, SLOT(1), REG1 );
	case  1: gvec_write_init( REG0, SLOT(0), old0 );
	case  0: /* the empty vector */;
    }
    RETURN1();
}
#undef FPLACE_CODE

EPILOGUE(vector)

BEGIN_BACK(vector)
  BACK_MONOTONE(vector_0)
END_BACK(vector)

static struct function_descr vector_descr = {
	&low_scheme_part_vectors,
	JUMP_TABLE( vector ),
	rsfn_vector_name };
#undef FUNCTION


/************************ Raw glue `vector-append' ************************/

static char rsfn_vector_append_name[] = "vector-append";
#define FUNCTION rsfn_vector_append_name

PROLOGUE(vector_append)

BEGIN_FWD(vector_append)
  FWD_MONOTONE(vector_append_0)
END_FWD(vector_append)

#define FPLACE_CODE (1000+0)
MONOTONE(vector_append_0)
{
  obj r, v, totlen = ZERO;
  UINT_32 i, j, k;

  for (i=0; i<arg_count_reg; i++)
    {
      v = reg_ref(i);
      if (VECTOR_P(v))
	totlen = FX_ADD( totlen, RIBYTES_TO_FXWORDS(SIZEOF_PTR(v)) );
      else
	scheme_error( "vector-append: arg ~d is not a vector: ~s",
		      2, int2fx(i), v );
    }
  r = alloc( FXWORDS_TO_RIBYTES(totlen), vector_class );
  k = 0;
  for (i=0; i<arg_count_reg; i++)
    {
      v = reg_ref(i);
      for (j=0; j<SIZEOF_PTR(v); j+=SLOT(1))
	{
	  gvec_write_init( r, k, gvec_ref( v, j ) );
	  k += SLOT(1);
	}
    }
  REG0 = r;
  RETURN1();
}
#undef FPLACE_CODE

EPILOGUE(vector_append)

BEGIN_BACK(vector_append)
  BACK_MONOTONE(vector_append_0)
END_BACK(vector_append)

static struct function_descr vector_append_descr = {
	&low_scheme_part_vectors,
	JUMP_TABLE( vector_append ),
	rsfn_vector_append_name };
#undef FUNCTION

/******************************* Postamble *******************************/
/**************************** Part Link Table ****************************/


static struct function_descr *(part_vectors_tab[]) = {
    &make_vector_descr,
    &list_vector_descr,
    &vector_fill_descr,
    &vector_descr,
    &vector_append_descr,
    NULL };
struct part_descr low_scheme_part_vectors = {
    337842177,
    &module_low_scheme,
    part_vectors_tab,
    "vectors",
    0 };
#undef _MODULE_LOW_SCHEME
#undef _SCM_VECTORS
#undef _C_VECTORS