pike.git/
src/
pike_types.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2020-09-18
2020-09-18 17:23:31 by Henrik Grubbström (Grubba) <grubba@grubba.org>
bdaf7fb726b94ada897ef31272367c66b97ee266 (
40
lines) (+
40
/-
0
)
[
Show
|
Annotate
]
Branch:
master
Compiler
[Typechecker]
: Preparations for remapping type markers.
3712:
/******/
+
struct remap_state {
+
unsigned char map[0x20];
+
unsigned INT32 allocated;
+
};
+
+
static int remap_marker(struct remap_state *remap, int marker, int alloc)
+
{
+
int ret;
+
+
if (!remap) return '0' | (marker & 0x0f);
+
+
if ((ret = remap->map[marker & 0x1f])) return ret;
+
+
if (!alloc) return 0;
+
+
for (ret = 0; ret < 10; ret++) {
+
if (!(remap->allocated & (1 << ret))) {
+
remap->allocated |= (1 << ret);
+
ret |= '0';
+
remap->map[marker & 0x1f] = ret;
+
return ret;
+
}
+
}
+
+
return 0;
+
}
+
+
static void free_marker(struct remap_state *remap, int marker)
+
{
+
int m;
+
+
if (!remap) return;
+
+
if (!(m = remap->map[marker & 0x1f])) return;
+
+
remap->map[marker & 0x1f] = 0;
+
remap->allocated &= ~(1 << (m & 0x0f));
+
}
+
/* * match two type strings, return zero if they don't match, and return * the part of 'a' that _did_ match if it did.