Skip to content

Commit

Permalink
disasm: Catch up with the new Subroutine world
Browse files Browse the repository at this point in the history
This tracks labels based on Subroutine identity instead of name, which
is far more reliable.  This also means that we handle labels for
multis correctly now!
  • Loading branch information
Benabik committed Aug 9, 2012
1 parent d03e104 commit b2b50d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/disasm.winxed
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $include 'PACT/Packfile/Decompile.winxed';
$load 'PACT/Packfile/Decompile.pbc'; $load 'PACT/Packfile/Decompile.pbc';


$include_const 'call_bits.pasm'; $include_const 'call_bits.pasm';
$include_const 'hash_key_type.pasm';


// Useful opcode // Useful opcode
inline get_repr(var v) return string { inline get_repr(var v) return string {
Expand Down Expand Up @@ -69,14 +70,15 @@ function main[main](var argv) {
say('.constants pmc'); say('.constants pmc');
v = packfile.pmcs; v = packfile.pmcs;
var sub_map = {}; var sub_map = {};
sub_map.set_key_type(Hash_key_type_PMC_ptr);
for (i = 0; i < elements(v); ++i) { for (i = 0; i < elements(v); ++i) {
vi = v[i]; vi = v[i];
print(string(i) + ' ' + string(typeof(vi)) + ' '); print(string(i) + ' ' + string(typeof(vi)) + ' ');
switch(typeof(vi)) { switch(typeof(vi)) {
case 'Sub': case 'PACT;Packfile;Subroutine':
// label, name, options // label, name, options
sub_map[vi] = s = '_sub' + string(i); sub_map[vi] = s = '_sub' + string(i);
print(s + ', sc'+ string(sc_map[string(vi)])); print(s + ', sc'+ string(sc_map[vi.name]));
// TODO: main, tags, subid, multi, etc // TODO: main, tags, subid, multi, etc
say(); say();
break; break;
Expand Down Expand Up @@ -109,7 +111,7 @@ function show_namespace(var sub_map, var sc_map, var ns, var path = []) {
var v = ns.contents[s]; var v = ns.contents[s];
switch(typeof(v)) { switch(typeof(v)) {
case 'PACT;Packfile;Subroutine': case 'PACT;Packfile;Subroutine':
say('.sub ' + string(sub_map[v.name])); say('.sub ' + string(sub_map[v]));
show_sub(sc_map, v); show_sub(sc_map, v);
say('.end'); say('.end');
say(); say();
Expand All @@ -127,10 +129,8 @@ function show_namespace(var sub_map, var sc_map, var ns, var path = []) {
break; break;


case 'PACT;Packfile;Multi': case 'PACT;Packfile;Multi':
// TODO: Fix this!
// uses same label for every canidate, which is _wrong_
for(var sub in v.canidates) { for(var sub in v.canidates) {
say('.sub ' + string(sub_map[v.name])); say('.sub ' + string(sub_map[sub]));
show_sub(sc_map, sub); show_sub(sc_map, sub);
say('.end'); say('.end');
say(); say();
Expand Down

0 comments on commit b2b50d7

Please sign in to comment.