@define mkzas(len){ @local dispatch, str; str = mkstr(len); @define dispatch(args ...) { @local arg, range, new, beg, end; arg = listref(args, 1); if(arg == "get"){ range = listref(args, 2); beg = rangebeg(range); end = beg+rangelen(range); printf("get %x %x\n", beg, end); return substr(str, beg, end); } if(arg == "put"){ range = listref(args, 2); beg = rangebeg(range); end = beg+rangelen(range); new = listref(args, 3); strput(str, beg, new); printf("put %x %x\n", beg, end); return; } printf("bad argument to dispatch!\n"); } return mkas([ "dispatch" : dispatch ]); } ns = @names c32le { struct X { @@ 0 int x00:1; @@ 1 int x01:1; @@ 2 int x02:1; @@ 3 int x03:1; @@ 4 int x04:1; @@ 5 int x05:1; @@ 6 int x06:1; @@ 7 int x07:1; @@ 8 int x08:1; @@ 9 int x09:1; @@10 int x10:1; @@11 int x11:1; @@12 int x12:1; @@13 int x13:1; @@14 int x14:1; @@15 int x15:1; @@16 int x16:1; @@17 int x17:1; @@18 int x18:1; @@19 int x19:1; @@20 int x20:1; @@21 int x21:1; @@22 int x22:1; @@23 int x23:1; @@24 int x24:1; @@25 int x25:1; @@26 int x26:1; @@27 int x27:1; @@28 int x28:1; @@29 int x29:1; @@30 int x30:1; @@31 int x31:1; @0x4; }; @0x0 struct X x; @0x0 unsigned i; }; vec = tabvals(ns.enumtype()); s = nil; for(i = 0; i < length(vec); i++){ s = vecref(vec, i); if(isstruct(s)) break; } fs = fields(s); for(i = 0; i < length(fs); i++){ @local f, t; f = vecref(fs, i); t = fieldtype(f); if(isbitfield(t)){ printf("bitfield %s (off = %d, width = %d, " "pos = %d, container = %t)\n", fieldid(f), fieldoff(f), bitfieldwidth(t), bitfieldpos(t), bitfieldcontainer(t)); } } as = mkzas(1024); dom = mkdom(ns, as); dom`i = 0xaaaaaaaa; dom`x.x00 = 0x1; dom`x.x01 = 0x1; dom`x.x02 = 0x1; dom`x.x03 = 0x1; dom`x.x04 = 0x1; dom`x.x05 = 0x1; dom`x.x06 = 0x1; dom`x.x07 = 0x1; dom`x.x08 = 0x1; dom`x.x09 = 0x1; dom`x.x10 = 0x1; dom`x.x11 = 0x1; dom`x.x12 = 0x1; dom`x.x13 = 0x1; dom`x.x14 = 0x1; dom`x.x15 = 0x1; dom`x.x16 = 0x1; dom`x.x17 = 0x1; dom`x.x18 = 0x1; dom`x.x19 = 0x1; dom`x.x20 = 0x1; dom`x.x21 = 0x1; dom`x.x22 = 0x1; dom`x.x23 = 0x1; dom`x.x24 = 0x1; dom`x.x25 = 0x1; dom`x.x26 = 0x1; dom`x.x27 = 0x1; dom`x.x28 = 0x1; dom`x.x29 = 0x1; dom`x.x30 = 0x1; dom`x.x31 = 0x1; printf("%d\n", dom`x.x00); printf("%d\n", dom`x.x01); printf("%d\n", dom`x.x02); printf("%d\n", dom`x.x03); printf("%d\n", dom`x.x04); printf("%d\n", dom`x.x05); printf("%d\n", dom`x.x06); printf("%d\n", dom`x.x07); printf("%d\n", dom`x.x08); printf("%d\n", dom`x.x09); printf("%d\n", dom`x.x10); printf("%d\n", dom`x.x11); printf("%d\n", dom`x.x12); printf("%d\n", dom`x.x13); printf("%d\n", dom`x.x14); printf("%d\n", dom`x.x15); printf("%d\n", dom`x.x16); printf("%d\n", dom`x.x17); printf("%d\n", dom`x.x18); printf("%d\n", dom`x.x19); printf("%d\n", dom`x.x20); printf("%d\n", dom`x.x21); printf("%d\n", dom`x.x22); printf("%d\n", dom`x.x23); printf("%d\n", dom`x.x24); printf("%d\n", dom`x.x25); printf("%d\n", dom`x.x26); printf("%d\n", dom`x.x27); printf("%d\n", dom`x.x28); printf("%d\n", dom`x.x29); printf("%d\n", dom`x.x30); printf("%d\n", dom`x.x31); dom`i = 0x55555555; printf("%d\n", dom`x.x00); printf("%d\n", dom`x.x01); printf("%d\n", dom`x.x02); printf("%d\n", dom`x.x03); printf("%d\n", dom`x.x04); printf("%d\n", dom`x.x05); printf("%d\n", dom`x.x06); printf("%d\n", dom`x.x07); printf("%d\n", dom`x.x08); printf("%d\n", dom`x.x09); printf("%d\n", dom`x.x10); printf("%d\n", dom`x.x11); printf("%d\n", dom`x.x12); printf("%d\n", dom`x.x13); printf("%d\n", dom`x.x14); printf("%d\n", dom`x.x15); printf("%d\n", dom`x.x16); printf("%d\n", dom`x.x17); printf("%d\n", dom`x.x18); printf("%d\n", dom`x.x19); printf("%d\n", dom`x.x20); printf("%d\n", dom`x.x21); printf("%d\n", dom`x.x22); printf("%d\n", dom`x.x23); printf("%d\n", dom`x.x24); printf("%d\n", dom`x.x25); printf("%d\n", dom`x.x26); printf("%d\n", dom`x.x27); printf("%d\n", dom`x.x28); printf("%d\n", dom`x.x29); printf("%d\n", dom`x.x30); printf("%d\n", dom`x.x31);