ndtypes 0.2.0dev5 → 0.2.0dev6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +12 -0
- data/Rakefile +8 -0
- data/ext/ruby_ndtypes/GPATH +0 -0
- data/ext/ruby_ndtypes/GRTAGS +0 -0
- data/ext/ruby_ndtypes/GTAGS +0 -0
- data/ext/ruby_ndtypes/extconf.rb +1 -1
- data/ext/ruby_ndtypes/include/ndtypes.h +231 -122
- data/ext/ruby_ndtypes/include/ruby_ndtypes.h +1 -1
- data/ext/ruby_ndtypes/lib/libndtypes.a +0 -0
- data/ext/ruby_ndtypes/lib/libndtypes.so.0.2.0dev3 +0 -0
- data/ext/ruby_ndtypes/ndtypes/Makefile +87 -0
- data/ext/ruby_ndtypes/ndtypes/config.h +68 -0
- data/ext/ruby_ndtypes/ndtypes/config.log +477 -0
- data/ext/ruby_ndtypes/ndtypes/config.status +1027 -0
- data/ext/ruby_ndtypes/ndtypes/doc/_static/style.css +7 -0
- data/ext/ruby_ndtypes/ndtypes/doc/_templates/layout.html +2 -0
- data/ext/ruby_ndtypes/ndtypes/doc/conf.py +40 -4
- data/ext/ruby_ndtypes/ndtypes/doc/images/xndlogo.png +0 -0
- data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/types.rst +1 -1
- data/ext/ruby_ndtypes/ndtypes/doc/requirements.txt +2 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile +287 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.in +20 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.vc +22 -3
- data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.c +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/attr.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/Makefile +73 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.c +246 -229
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.h +15 -11
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.y +38 -28
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.c +91 -91
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.l +4 -3
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.c +8 -7
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.c +2 -2
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/context.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.c +263 -182
- data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/encodings.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.c +67 -7
- data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.c +1112 -1000
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.h +69 -58
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.y +150 -99
- data/ext/ruby_ndtypes/ndtypes/libndtypes/io.c +185 -15
- data/ext/ruby_ndtypes/ndtypes/libndtypes/io.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.c +301 -276
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.l +9 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.a +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so +1 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so.0 +1 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so.0.2.0dev3 +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/match.c +729 -228
- data/ext/ruby_ndtypes/ndtypes/libndtypes/match.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.c +768 -403
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h +1002 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h.in +231 -122
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.c +176 -84
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.h +26 -14
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.c +57 -35
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/primitive.c +420 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/primitive.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.c +8 -8
- data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/Makefile +48 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.c +200 -116
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.c +46 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.c +58 -27
- data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.c +3 -5
- data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.h +12 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile +55 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.in +8 -8
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.vc +5 -5
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/runtest.c +274 -172
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test.h +24 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_array.c +2 -2
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_buffer.c +14 -14
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_match.c +32 -30
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse.c +37 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_error.c +36 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_roundtrip.c +16 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_record.c +5 -5
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typecheck.c +706 -253
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_unify.c +132 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/unify.c +703 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/unify.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/util.c +335 -127
- data/ext/ruby_ndtypes/ndtypes/libndtypes/util.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/values.c +2 -2
- data/ext/ruby_ndtypes/ndtypes/libndtypes/values.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndt_randtype.py +88 -71
- data/ext/ruby_ndtypes/ndtypes/python/ndt_support.py +0 -1
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/__init__.py +10 -13
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/_ndtypes.c +395 -314
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.a +0 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so +1 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so.0 +1 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so.0.2.0dev3 +0 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/ndtypes.h +1002 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/pyndtypes.h +15 -33
- data/ext/ruby_ndtypes/ndtypes/python/test_ndtypes.py +340 -132
- data/ext/ruby_ndtypes/ndtypes/setup.py +11 -2
- data/ext/ruby_ndtypes/ruby_ndtypes.c +364 -241
- data/ext/ruby_ndtypes/ruby_ndtypes.h +1 -1
- data/ext/ruby_ndtypes/ruby_ndtypes_internal.h +0 -1
- data/lib/ndtypes.rb +11 -0
- data/lib/ndtypes/version.rb +2 -2
- data/lib/ruby_ndtypes.so +0 -0
- data/ndtypes.gemspec +3 -0
- data/spec/ndtypes_spec.rb +6 -0
- metadata +98 -4
- data/ext/ruby_ndtypes/gc_guard.c +0 -36
- data/ext/ruby_ndtypes/gc_guard.h +0 -12
Binary file
|
@@ -231,17 +231,35 @@ static int64_t
|
|
231
231
|
write_var_dim(char * const ptr, int64_t offset, const ndt_t * const t,
|
232
232
|
bool *overflow)
|
233
233
|
{
|
234
|
-
const
|
234
|
+
const ndt_offsets_t *offsets = t->Concrete.VarDim.offsets;
|
235
|
+
const int32_t noffsets = offsets ? offsets->n : 0;
|
236
|
+
const int32_t *offset_array = offsets ? offsets->v : NULL;
|
235
237
|
const int32_t nslices = t->Concrete.VarDim.nslices;
|
236
238
|
|
237
239
|
offset = write_int64(ptr, offset, t->Concrete.VarDim.itemsize, overflow);
|
238
240
|
offset = write_int32(ptr, offset, noffsets, overflow);
|
239
241
|
offset = write_int32(ptr, offset, t->Concrete.VarDim.nslices, overflow);
|
240
|
-
offset = write_int32_array(ptr, offset,
|
242
|
+
offset = write_int32_array(ptr, offset, offset_array, noffsets, overflow);
|
241
243
|
offset = write_ndt_slice_array(ptr, offset, t->Concrete.VarDim.slices, nslices, overflow);
|
242
244
|
return write_type(ptr, offset, t->VarDim.type, overflow);
|
243
245
|
}
|
244
246
|
|
247
|
+
static int64_t
|
248
|
+
write_var_dim_elem(char * const ptr, int64_t offset, const ndt_t * const t,
|
249
|
+
bool *overflow)
|
250
|
+
{
|
251
|
+
offset = write_int64(ptr, offset, t->VarDimElem.index, overflow);
|
252
|
+
return write_var_dim(ptr, offset, t, overflow);
|
253
|
+
}
|
254
|
+
|
255
|
+
static int64_t
|
256
|
+
write_array(char * const ptr, int64_t offset, const ndt_t * const t,
|
257
|
+
bool *overflow)
|
258
|
+
{
|
259
|
+
offset = write_int64(ptr, offset, t->Array.itemsize, overflow);
|
260
|
+
return write_type(ptr, offset, t->Array.type, overflow);
|
261
|
+
}
|
262
|
+
|
245
263
|
static int64_t
|
246
264
|
write_tuple(char * const ptr, int64_t offset, const ndt_t * const t,
|
247
265
|
bool *overflow)
|
@@ -291,6 +309,27 @@ write_record(char * const ptr, int64_t offset, const ndt_t * const t,
|
|
291
309
|
return offset;
|
292
310
|
}
|
293
311
|
|
312
|
+
static int64_t
|
313
|
+
write_union(char * const ptr, int64_t offset, const ndt_t * const t,
|
314
|
+
bool *overflow)
|
315
|
+
{
|
316
|
+
const int64_t ntags = t->Union.ntags;
|
317
|
+
int64_t metaoffset;
|
318
|
+
|
319
|
+
offset = write_int64(ptr, offset, ntags, overflow);
|
320
|
+
offset = write_string_array(ptr, offset, t->Union.tags, ntags, overflow);
|
321
|
+
|
322
|
+
metaoffset = offset;
|
323
|
+
offset = alloc_int64_array(offset, ntags, overflow);
|
324
|
+
|
325
|
+
for (int64_t i = 0; i < ntags; i++) {
|
326
|
+
metaoffset = write_int64(ptr, metaoffset, offset, overflow);
|
327
|
+
offset = write_type(ptr, offset, t->Union.types[i], overflow);
|
328
|
+
}
|
329
|
+
|
330
|
+
return offset;
|
331
|
+
}
|
332
|
+
|
294
333
|
static int64_t
|
295
334
|
write_ref(char * const ptr, int64_t offset, const ndt_t * const t,
|
296
335
|
bool *overflow)
|
@@ -376,8 +415,11 @@ write_type(char * const ptr, int64_t offset, const ndt_t * const t,
|
|
376
415
|
case SymbolicDim: return write_symbolic_dim(ptr, offset, t, overflow);
|
377
416
|
case EllipsisDim: return write_ellipsis_dim(ptr, offset, t, overflow);
|
378
417
|
case VarDim: return write_var_dim(ptr, offset, t, overflow);
|
418
|
+
case VarDimElem: return write_var_dim_elem(ptr, offset, t, overflow);
|
419
|
+
case Array: return write_array(ptr, offset, t, overflow);
|
379
420
|
case Tuple: return write_tuple(ptr, offset, t, overflow);
|
380
421
|
case Record: return write_record(ptr, offset, t, overflow);
|
422
|
+
case Union: return write_union(ptr, offset, t, overflow);
|
381
423
|
case Ref: return write_ref(ptr, offset, t, overflow);
|
382
424
|
case Constr: return write_constr(ptr, offset, t, overflow);
|
383
425
|
case Nominal: return write_nominal(ptr, offset, t, overflow);
|
@@ -391,8 +433,8 @@ write_type(char * const ptr, int64_t offset, const ndt_t * const t,
|
|
391
433
|
case Bool:
|
392
434
|
case Int8: case Int16: case Int32: case Int64:
|
393
435
|
case Uint8: case Uint16: case Uint32: case Uint64:
|
394
|
-
case Float16: case Float32: case Float64:
|
395
|
-
case Complex32: case Complex64: case Complex128:
|
436
|
+
case BFloat16: case Float16: case Float32: case Float64:
|
437
|
+
case BComplex32: case Complex32: case Complex64: case Complex128:
|
396
438
|
case String:
|
397
439
|
|
398
440
|
case AnyKind:
|
Binary file
|
@@ -44,11 +44,11 @@
|
|
44
44
|
#include "substitute.h"
|
45
45
|
|
46
46
|
|
47
|
-
static ndt_t *
|
47
|
+
static const ndt_t *
|
48
48
|
substitute_named_ellipsis(const ndt_t *t, const symtable_t *tbl, ndt_context_t *ctx)
|
49
49
|
{
|
50
50
|
symtable_entry_t v;
|
51
|
-
ndt_t *u;
|
51
|
+
const ndt_t *u;
|
52
52
|
int i;
|
53
53
|
|
54
54
|
assert(t->tag == EllipsisDim && t->EllipsisDim.name != NULL);
|
@@ -67,7 +67,8 @@ substitute_named_ellipsis(const ndt_t *t, const symtable_t *tbl, ndt_context_t *
|
|
67
67
|
assert(ndt_is_concrete(w));
|
68
68
|
assert(w->tag == FixedDim);
|
69
69
|
|
70
|
-
|
70
|
+
const ndt_t *x = ndt_fixed_dim(u, w->FixedDim.shape, INT64_MAX, ctx);
|
71
|
+
ndt_move(&u, x);
|
71
72
|
if (u == NULL) {
|
72
73
|
return NULL;
|
73
74
|
}
|
@@ -81,25 +82,44 @@ substitute_named_ellipsis(const ndt_t *t, const symtable_t *tbl, ndt_context_t *
|
|
81
82
|
}
|
82
83
|
else {
|
83
84
|
const ndt_t *w = v.VarSeq.dims[0];
|
84
|
-
|
85
|
+
const ndt_t *x = ndt_copy_contiguous_dtype(w, u, v.VarSeq.linear_index, ctx);
|
86
|
+
ndt_decref(u);
|
87
|
+
return x;
|
85
88
|
}
|
86
89
|
}
|
90
|
+
case ArraySeq: {
|
91
|
+
for (i = v.ArraySeq.size-1; i >= 0; i--) {
|
92
|
+
const ndt_t *w = v.ArraySeq.dims[i];
|
93
|
+
assert(ndt_is_concrete(w));
|
94
|
+
assert(w->tag == Array);
|
95
|
+
|
96
|
+
const ndt_t *x = ndt_array(u, false, ctx);
|
97
|
+
ndt_move(&u, x);
|
98
|
+
if (u == NULL) {
|
99
|
+
return NULL;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
return u;
|
104
|
+
}
|
87
105
|
default:
|
88
106
|
ndt_err_format(ctx, NDT_ValueError,
|
89
107
|
"variable not found or has incorrect type");
|
90
|
-
|
108
|
+
ndt_decref(u);
|
91
109
|
return NULL;
|
92
110
|
}
|
93
111
|
}
|
94
112
|
|
95
|
-
ndt_t *
|
113
|
+
const ndt_t *
|
96
114
|
ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete,
|
97
115
|
ndt_context_t *ctx)
|
98
116
|
{
|
99
|
-
|
117
|
+
bool opt = ndt_is_optional(t);
|
118
|
+
const ndt_t *u, *w;
|
100
119
|
|
101
120
|
if (ndt_is_concrete(t)) {
|
102
|
-
|
121
|
+
ndt_incref(t);
|
122
|
+
return t;
|
103
123
|
}
|
104
124
|
|
105
125
|
switch (t->tag) {
|
@@ -109,8 +129,10 @@ ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete,
|
|
109
129
|
return NULL;
|
110
130
|
}
|
111
131
|
|
112
|
-
|
113
|
-
|
132
|
+
w = ndt_fixed_dim(u, t->FixedDim.shape, t->Concrete.FixedDim.step,
|
133
|
+
ctx);
|
134
|
+
ndt_decref(u);
|
135
|
+
return w;
|
114
136
|
}
|
115
137
|
|
116
138
|
case VarDim: {
|
@@ -119,7 +141,9 @@ ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete,
|
|
119
141
|
return NULL;
|
120
142
|
}
|
121
143
|
|
122
|
-
|
144
|
+
w = ndt_copy_abstract_var_dtype(t, u, ctx);
|
145
|
+
ndt_decref(u);
|
146
|
+
return w;
|
123
147
|
}
|
124
148
|
|
125
149
|
case SymbolicDim: {
|
@@ -131,21 +155,25 @@ ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete,
|
|
131
155
|
const int64_t shape = symtable_find_shape(tbl, t->SymbolicDim.name, ctx);
|
132
156
|
if (shape < 0) {
|
133
157
|
if (req_concrete) {
|
134
|
-
|
158
|
+
ndt_decref(u);
|
135
159
|
return NULL;
|
136
160
|
}
|
137
161
|
else {
|
138
162
|
ndt_err_clear(ctx);
|
139
163
|
char *name = ndt_strdup(t->SymbolicDim.name, ctx);
|
140
164
|
if (name == NULL) {
|
141
|
-
|
165
|
+
ndt_decref(u);
|
142
166
|
return NULL;
|
143
167
|
}
|
144
|
-
|
168
|
+
w = ndt_symbolic_dim(name, u, ctx);
|
169
|
+
ndt_decref(u);
|
170
|
+
return w;
|
145
171
|
}
|
146
172
|
}
|
147
173
|
|
148
|
-
|
174
|
+
w = ndt_fixed_dim(u, shape, INT64_MAX, ctx);
|
175
|
+
ndt_decref(u);
|
176
|
+
return w;
|
149
177
|
}
|
150
178
|
|
151
179
|
case EllipsisDim: {
|
@@ -188,7 +216,9 @@ ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete,
|
|
188
216
|
return NULL;
|
189
217
|
}
|
190
218
|
|
191
|
-
|
219
|
+
w = ndt_constr(name, u, opt, ctx);
|
220
|
+
ndt_decref(u);
|
221
|
+
return w;
|
192
222
|
}
|
193
223
|
|
194
224
|
case Nominal: {
|
@@ -203,31 +233,32 @@ ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete,
|
|
203
233
|
return NULL;
|
204
234
|
}
|
205
235
|
|
206
|
-
|
236
|
+
w = ndt_nominal(name, u, opt, ctx);
|
237
|
+
ndt_decref(u);
|
238
|
+
return w;
|
207
239
|
}
|
208
240
|
|
209
|
-
case Ref:
|
241
|
+
case Ref: {
|
210
242
|
u = ndt_substitute(t->Ref.type, tbl, req_concrete, ctx);
|
211
243
|
if (u == NULL) {
|
212
244
|
return NULL;
|
213
245
|
}
|
214
246
|
|
215
|
-
|
247
|
+
w = ndt_ref(u, opt, ctx);
|
248
|
+
ndt_decref(u);
|
249
|
+
return w;
|
250
|
+
}
|
216
251
|
|
217
252
|
case Bool:
|
218
253
|
case Int8: case Int16: case Int32: case Int64:
|
219
254
|
case Uint8: case Uint16: case Uint32: case Uint64:
|
220
|
-
case Float16: case Float32: case Float64:
|
221
|
-
case Complex32: case Complex64: case Complex128:
|
255
|
+
case BFloat16: case Float16: case Float32: case Float64:
|
256
|
+
case BComplex32: case Complex32: case Complex64: case Complex128:
|
222
257
|
case FixedString: case FixedBytes:
|
223
258
|
case String: case Bytes:
|
224
259
|
case Char: {
|
225
|
-
|
226
|
-
|
227
|
-
return NULL;
|
228
|
-
}
|
229
|
-
*u = *t;
|
230
|
-
return u;
|
260
|
+
ndt_incref(t);
|
261
|
+
return t;
|
231
262
|
}
|
232
263
|
|
233
264
|
default:
|
@@ -41,7 +41,7 @@
|
|
41
41
|
/* LOCAL SCOPE */
|
42
42
|
NDT_PRAGMA(NDT_HIDE_SYMBOLS_START)
|
43
43
|
|
44
|
-
ndt_t *ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete, ndt_context_t *ctx);
|
44
|
+
const ndt_t *ndt_substitute(const ndt_t *t, const symtable_t *tbl, const bool req_concrete, ndt_context_t *ctx);
|
45
45
|
|
46
46
|
/* END LOCAL SCOPE */
|
47
47
|
NDT_PRAGMA(NDT_HIDE_SYMBOLS_END)
|
Binary file
|
@@ -106,7 +106,7 @@ typedef_trie_del(typedef_trie_t *t)
|
|
106
106
|
return;
|
107
107
|
}
|
108
108
|
|
109
|
-
|
109
|
+
ndt_decref(t->def.type);
|
110
110
|
|
111
111
|
for (i = 0; i < ALPHABET_LEN; i++) {
|
112
112
|
typedef_trie_del(t->next[i]);
|
@@ -116,7 +116,7 @@ typedef_trie_del(typedef_trie_t *t)
|
|
116
116
|
}
|
117
117
|
|
118
118
|
int
|
119
|
-
ndt_typedef_add(const char *key, ndt_t *type, const ndt_methods_t *m, ndt_context_t *ctx)
|
119
|
+
ndt_typedef_add(const char *key, const ndt_t *type, const ndt_methods_t *m, ndt_context_t *ctx)
|
120
120
|
{
|
121
121
|
typedef_trie_t *t = typedef_map;
|
122
122
|
const unsigned char *cp;
|
@@ -127,14 +127,12 @@ ndt_typedef_add(const char *key, ndt_t *type, const ndt_methods_t *m, ndt_contex
|
|
127
127
|
if (i == UCHAR_MAX) {
|
128
128
|
ndt_err_format(ctx, NDT_ValueError,
|
129
129
|
"invalid character in typedef: '%c'", *cp);
|
130
|
-
ndt_del(type);
|
131
130
|
return -1;
|
132
131
|
}
|
133
132
|
|
134
133
|
if (t->next[i] == NULL) {
|
135
134
|
typedef_trie_t *u = typedef_trie_new(ctx);
|
136
135
|
if (u == NULL) {
|
137
|
-
ndt_del(type);
|
138
136
|
return -1;
|
139
137
|
}
|
140
138
|
t->next[i] = u;
|
@@ -147,10 +145,10 @@ ndt_typedef_add(const char *key, ndt_t *type, const ndt_methods_t *m, ndt_contex
|
|
147
145
|
|
148
146
|
if (t->def.type) {
|
149
147
|
ndt_err_format(ctx, NDT_ValueError, "duplicate typedef '%s'", key);
|
150
|
-
ndt_del(type);
|
151
148
|
return -1;
|
152
149
|
}
|
153
150
|
|
151
|
+
ndt_incref(type);
|
154
152
|
t->def.type = type;
|
155
153
|
|
156
154
|
if (m != NULL) {
|
@@ -46,13 +46,20 @@ enum symtable_entry {
|
|
46
46
|
Type,
|
47
47
|
BroadcastSeq,
|
48
48
|
FixedSeq,
|
49
|
-
VarSeq
|
49
|
+
VarSeq,
|
50
|
+
ArraySeq
|
50
51
|
};
|
51
52
|
|
52
53
|
typedef struct {
|
53
54
|
int size;
|
54
55
|
const ndt_t *dims[NDT_MAX_DIM];
|
55
|
-
}
|
56
|
+
} fixed_list_t;
|
57
|
+
|
58
|
+
typedef struct {
|
59
|
+
int size;
|
60
|
+
int64_t linear_index;
|
61
|
+
const ndt_t *dims[NDT_MAX_DIM];
|
62
|
+
} var_list_t;
|
56
63
|
|
57
64
|
typedef struct {
|
58
65
|
int size;
|
@@ -66,8 +73,9 @@ typedef struct {
|
|
66
73
|
const char *Symbol;
|
67
74
|
const ndt_t *Type;
|
68
75
|
broadcast_list_t BroadcastSeq;
|
69
|
-
|
70
|
-
|
76
|
+
fixed_list_t FixedSeq;
|
77
|
+
var_list_t VarSeq;
|
78
|
+
fixed_list_t ArraySeq;
|
71
79
|
};
|
72
80
|
} symtable_entry_t;
|
73
81
|
|
Binary file
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
SRCDIR = ..
|
3
|
+
|
4
|
+
CC = gcc
|
5
|
+
|
6
|
+
LIBSTATIC = libndtypes.a
|
7
|
+
LIBSHARED = libndtypes.so.0.2.0dev3
|
8
|
+
|
9
|
+
CONFIGURE_CFLAGS = -I.. -Wall -Wextra -std=c11 -pedantic -O2 -g
|
10
|
+
NDT_CFLAGS = $(strip $(CONFIGURE_CFLAGS) $(CFLAGS))
|
11
|
+
|
12
|
+
CONFIGURE_COV_CFLAGS = -I.. -Wall -Wextra -std=c11 -pedantic -O0 -g -fno-inline -fprofile-arcs -ftest-coverage
|
13
|
+
CONFIGURE_COV_LDFLAGS = -shared -Wl,-soname,libndtypes.so.0 -fprofile-arcs
|
14
|
+
ifeq ($(MAKECMDGOALS), coverage)
|
15
|
+
NDT_CFLAGS = $(strip $(CONFIGURE_COV_CFLAGS) $(CFLAGS))
|
16
|
+
NDT_LDFLAGS = $(strip $(CONFIGURE_COV_LDFLAGS) $(LDFLAGS))
|
17
|
+
endif
|
18
|
+
|
19
|
+
|
20
|
+
default: runtest runtest_shared
|
21
|
+
|
22
|
+
coverage: runtest runtest_shared
|
23
|
+
|
24
|
+
|
25
|
+
runtest:\
|
26
|
+
Makefile runtest.c alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
27
|
+
test_indent.c test_typecheck.c test_numba.c test_typedef.c test_match.c test_unify.c \
|
28
|
+
test_record.c test_buffer.c test.h alloc_fail.h \
|
29
|
+
$(SRCDIR)/ndtypes.h $(SRCDIR)/$(LIBSTATIC)
|
30
|
+
$(CC) -DTEST_ALLOC $(NDT_CFLAGS) -o runtest runtest.c \
|
31
|
+
alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
32
|
+
test_indent.c test_typedef.c test_match.c test_unify.c test_typecheck.c \
|
33
|
+
test_numba.c test_record.c test_array.c test_buffer.c $(SRCDIR)/$(LIBSTATIC)
|
34
|
+
|
35
|
+
runtest_shared:\
|
36
|
+
Makefile runtest.c alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
37
|
+
test_indent.c test_typecheck.c test_numba.c test_typedef.c test_match.c test_unify.c \
|
38
|
+
test_record.c test_buffer.c test.h alloc_fail.h \
|
39
|
+
$(SRCDIR)/ndtypes.h $(SRCDIR)/$(LIBSHARED)
|
40
|
+
$(CC) -L$(SRCDIR) -DTEST_ALLOC $(NDT_CFLAGS) -o runtest_shared runtest.c \
|
41
|
+
alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
42
|
+
test_indent.c test_typedef.c test_match.c test_unify.c test_typecheck.c \
|
43
|
+
test_numba.c test_record.c test_array.c test_buffer.c -lndtypes
|
44
|
+
|
45
|
+
|
46
|
+
FORCE:
|
47
|
+
|
48
|
+
clean: FORCE
|
49
|
+
rm -f *.o *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock
|
50
|
+
rm -f runtest runtest_shared
|
51
|
+
|
52
|
+
distclean: clean
|
53
|
+
rm -rf Makefile
|
54
|
+
|
55
|
+
|
@@ -24,23 +24,23 @@ coverage: runtest runtest_shared
|
|
24
24
|
|
25
25
|
runtest:\
|
26
26
|
Makefile runtest.c alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
27
|
-
test_indent.c test_typecheck.c test_numba.c test_typedef.c test_match.c
|
28
|
-
test_buffer.c test.h alloc_fail.h \
|
27
|
+
test_indent.c test_typecheck.c test_numba.c test_typedef.c test_match.c test_unify.c \
|
28
|
+
test_record.c test_buffer.c test.h alloc_fail.h \
|
29
29
|
$(SRCDIR)/ndtypes.h $(SRCDIR)/$(LIBSTATIC)
|
30
30
|
$(CC) -DTEST_ALLOC $(NDT_CFLAGS) -o runtest runtest.c \
|
31
31
|
alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
32
|
-
test_indent.c test_typedef.c test_match.c
|
33
|
-
test_record.c test_array.c test_buffer.c $(SRCDIR)/$(LIBSTATIC)
|
32
|
+
test_indent.c test_typedef.c test_match.c test_unify.c test_typecheck.c \
|
33
|
+
test_numba.c test_record.c test_array.c test_buffer.c $(SRCDIR)/$(LIBSTATIC)
|
34
34
|
|
35
35
|
runtest_shared:\
|
36
36
|
Makefile runtest.c alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
37
|
-
test_indent.c test_typecheck.c test_numba.c test_typedef.c test_match.c
|
38
|
-
test_buffer.c test.h alloc_fail.h \
|
37
|
+
test_indent.c test_typecheck.c test_numba.c test_typedef.c test_match.c test_unify.c \
|
38
|
+
test_record.c test_buffer.c test.h alloc_fail.h \
|
39
39
|
$(SRCDIR)/ndtypes.h $(SRCDIR)/$(LIBSHARED)
|
40
40
|
$(CC) -L$(SRCDIR) -DTEST_ALLOC $(NDT_CFLAGS) -o runtest_shared runtest.c \
|
41
41
|
alloc_fail.c test_parse.c test_parse_error.c test_parse_roundtrip.c \
|
42
|
-
test_indent.c test_typedef.c test_match.c
|
43
|
-
test_record.c test_array.c test_buffer.c -lndtypes
|
42
|
+
test_indent.c test_typedef.c test_match.c test_unify.c test_typecheck.c \
|
43
|
+
test_numba.c test_record.c test_array.c test_buffer.c -lndtypes
|
44
44
|
|
45
45
|
|
46
46
|
FORCE:
|