Permalink
Browse files

disasm: Show annotation values

Requires Parrot > RELEASE_3_10_0-26-g2001ad8
  • Loading branch information...
1 parent 1426a0c commit 7d1d64882602a9f0694a1f5af5f714e5cbfa82b8 @Benabik Benabik committed Nov 16, 2011
Showing with 22 additions and 2 deletions.
  1. +22 −2 src/disasm.winxed
View
@@ -355,10 +355,30 @@ function annotations_segment(var packfile) {
say( ' ', size, ' annotations:' );
for (int i = 0; i < size; ++i) {
var annotation = annotations[i];
+
int offset = annotation.get_offset();
string name = annotation.get_name();
- // XXX: No way to determine value type
- say( ' ', offset, ': ', name );
+ print( ' ', offset, ' ', name, ': ' );
+
+ switch (annotation.get_type()) {
+ case TYPE_INT:
+ say(int(annotation));
+ break;
+
+ case TYPE_STR:
+ string s = annotation;
+ say(encoding_name(s), ':"', escape(s), '"' );
+ break;
+
+ case TYPE_PMC:
+ var val = annotation.get_pmc_value();
+ print( '(', typeof(val), '): ' );
+ try {
+ say(val);
+ } catch () {
+ say('<Unprintable>');
+ }
+ }
}
}

0 comments on commit 7d1d648

Please sign in to comment.