Skip to content
Browse files

disasm: Separate out displaying op argument

I'm about to reuse it to display Key contents
  • Loading branch information...
1 parent f4a48b2 commit e8e6a43d1f72b363d613f29a7b9162843bf1a36a @Benabik Benabik committed Aug 9, 2012
Showing with 44 additions and 41 deletions.
  1. +44 −41 src/disasm.winxed
View
85 src/disasm.winxed
@@ -232,55 +232,58 @@ function show_sub(var sc_map, var sub) {
var args = op.args;
for(int i = 0; i < elements(args); ++i) {
print( i == 0 ? ' ' : ', ' );
- var arg = args[i];
- switch(typeof(arg)) {
- case 'PACT;Packfile;Constant;Reference':
- switch(arg.type) {
- case PARROT_ARG_INTVAL: die('Integer reference?');
- case PARROT_ARG_STRING: print('sc'); break;
- case PARROT_ARG_PMC: print('pc'); break;
- case PARROT_ARG_FLOATVAL: print('fc'); break;
- default: die('Unknown constref type ' + string(arg.type));
- }
- print(arg.value);
- break;
-
- case 'PACT;Packfile;Constant':
- switch(arg.type) {
- case PARROT_ARG_INTVAL:
- print(arg.value);
- break;
+ show_argument(sc_map, args[i]);
+ }
- case PARROT_ARG_STRING:
- print('sc', string(sc_map[op.value]));
- break;
+ say();
+ break;
- default:
- die('Unexpected constant type ' + string(arg.type));
- }
- break;
+ default:
+ die("Unknown sub contents type " + string(typeof(op)));
+ }
+ }
+}
- case 'PACT;Packfile;Register':
- switch(arg.type) {
- case PARROT_ARG_INTVAL: print('i'); break;
- case PARROT_ARG_STRING: print('s'); break;
- case PARROT_ARG_PMC: print('p'); break;
- case PARROT_ARG_FLOATVAL: print('f'); break;
- default: die('Unknown register type ' + string(arg.type));
- }
- print(arg.number);
- break;
+function show_argument(var sc_map, var arg) {
+ switch(typeof(arg)) {
+ case 'PACT;Packfile;Constant;Reference':
+ switch(arg.type) {
+ case PARROT_ARG_INTVAL: die('Integer reference?');
+ case PARROT_ARG_STRING: print('sc'); break;
+ case PARROT_ARG_PMC: print('pc'); break;
+ case PARROT_ARG_FLOATVAL: print('fc'); break;
+ default: die('Unknown constref type ' + string(arg.type));
+ }
+ print(arg.value);
+ break;
- default:
- die('Unknown argument type ' + string(typeof(arg)));
- }
- }
+ case 'PACT;Packfile;Constant':
+ switch(arg.type) {
+ case PARROT_ARG_INTVAL:
+ print(arg.value);
+ break;
- say();
+ case PARROT_ARG_STRING:
+ print('sc', string(sc_map[arg.value]));
break;
default:
- die("Unknown sub contents type " + string(typeof(op)));
+ die('Unexpected constant type ' + string(arg.type));
+ }
+ break;
+
+ case 'PACT;Packfile;Register':
+ switch(arg.type) {
+ case PARROT_ARG_INTVAL: print('i'); break;
+ case PARROT_ARG_STRING: print('s'); break;
+ case PARROT_ARG_PMC: print('p'); break;
+ case PARROT_ARG_FLOATVAL: print('f'); break;
+ default: die('Unknown register type ' + string(arg.type));
}
+ print(arg.number);
+ break;
+
+ default:
+ die('Unknown argument type ' + string(typeof(arg)));
}
}

0 comments on commit e8e6a43

Please sign in to comment.
Something went wrong with that request. Please try again.