2 * Copyright (C) 2010 Luca Barbieri <luca@luca-barbieri.com>
3 * Copyright (C) 2010 Marcelina KoĆcielnicka <mwk@0x04.net>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
33 void expand (const char* prefix
, struct rnndelem
*elem
, uint64_t base
, int width
, struct rnndeccontext
*vc
) {
35 if(elem
->length
> 1024)
37 if(!rnndec_varmatch(vc
, &elem
->varinfo
))
41 for(i
= 0; i
< elem
->length
; ++i
) {
43 printf("d %s %08"PRIx64
" %s(%i)", prefix
, base
+ elem
->offset
+ i
* elem
->stride
, elem
->fullname
, i
);
45 printf("d %s %08"PRIx64
" %s", prefix
, base
+ elem
->offset
, elem
->fullname
);
47 printf(" %s\n", elem
->typeinfo
.name
);
50 case RNN_ETYPE_STRIPE
:
52 for (i
= 0; i
< elem
->length
; i
++)
53 for (j
= 0; j
< elem
->subelemsnum
; j
++)
54 expand(prefix
, elem
->subelems
[j
], base
+ elem
->offset
+ i
* elem
->stride
, width
, vc
);
61 int main(int argc
, char **argv
) {
64 struct rnndb
*db
= rnn_newdb();
65 rnn_parsefile (db
, argv
[1]);
67 struct rnndeccontext
*vc
= rnndec_newcontext(db
);
68 vc
->colors
= &rnndec_colorsterm
;
70 while (*argp
&& !strcmp (*argp
, "-v")) {
72 if(!argp
[0] || !argp
[1])
73 fprintf(stderr
, "error: -v option lacking VARSET and VARIANT arguments following it\n");
75 rnndec_varadd(vc
, argp
[0], argp
[1]);
80 for(i
= 0; i
< db
->domainsnum
; ++i
)
81 for (j
= 0; j
< db
->domains
[i
]->subelemsnum
; ++j
)
82 expand (db
->domains
[i
]->name
, db
->domains
[i
]->subelems
[j
], 0, db
->domains
[i
]->width
, vc
);
83 for(i
= 0; i
< db
->enumsnum
; ++i
)
84 for (j
= 0; j
< db
->enums
[i
]->valsnum
; ++j
)
85 if (db
->enums
[i
]->vals
[j
]->valvalid
)
86 printf("e %s %"PRIx64
" %s\n", db
->enums
[i
]->name
, db
->enums
[i
]->vals
[j
]->value
, db
->enums
[i
]->vals
[j
]->name
);
88 rnndec_freecontext(vc
);