Skip to content

Commit

Permalink
WIP: main sub
Browse files Browse the repository at this point in the history
Currently, I'm not always getting a PackfileView back, and when I do
it seems to be corrupted.
  • Loading branch information
Benabik committed Aug 10, 2012
1 parent d17a7b4 commit fcd101f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/PACT/Packfile/Decompile.winxed
Expand Up @@ -61,6 +61,10 @@ class PACT.Packfile.Decompile {
if ( !(packfile instanceof 'Packfile') )
die("Need a PBC filename or Packfile PMC");
self.packfile = packfile;
var view = packfile.view();
cry(typeof(packfile), ' ', typeof(view), ' ', view);
if ( !(view instanceof 'PackfileView') )
die('7?!?!?');

:PACT.Packfile ret();
ret.set_uuid(int(packfile['uuid_type']), string(packfile['uuid']));
Expand Down Expand Up @@ -117,15 +121,18 @@ class PACT.Packfile.Decompile {

size = constants.pmc_count();
var pmcs = new 'FixedPMCArray'(size);
var subs = [];
ret.pmcs = pmcs;
var subs = [];
var main = view.main_sub();
for (i = 0; i < size; ++i) {
var c = var(constants[i]);
if (c instanceof 'Sub') {
// Create a new Packfile.Subroutine that we'll reference
// later.
c = new PACT.Packfile.Subroutine(c);
push(subs, c); // TODO: Convert to Packfile.Subroutine
push(subs, c);
if (c.sub === main)
ret.main = c;
}

if (c instanceof 'Key')
Expand All @@ -144,6 +151,8 @@ class PACT.Packfile.Decompile {
return 1;
});

// TODO: load main and tags from Packfile

// Load annotations
var annos;
int annos_size;
Expand Down
3 changes: 3 additions & 0 deletions src/disasm.winxed
Expand Up @@ -112,6 +112,9 @@ function main[main](var argv) {
print(')');
}

if (vi === packfile.main)
print(', main');

say();
break;

Expand Down

0 comments on commit fcd101f

Please sign in to comment.