Permalink
Browse files

Packfile.Decompile: Initial multi handling

Appears to collect multi candidates properly
  • Loading branch information...
1 parent 096353c commit f6ce9b11bc4351d06bf4f6d897142c8256f779a1 @Benabik Benabik committed Aug 7, 2012
Showing with 27 additions and 4 deletions.
  1. +1 −0 PACT/Packfile.winxed
  2. +5 −0 src/PACT/Packfile.winxed
  3. +21 −4 src/PACT/Packfile/Decompile.winxed
View
@@ -4,6 +4,7 @@ class PACT.Packfile.Constant;
class PACT.Packfile.Constant.Reference;
class PACT.Packfile.Constant.Key;
class PACT.Packfile.Subroutine;
+class PACT.Packfile.Multi;
class PACT.Packfile.Op;
class PACT.Packfile.Label;
class PACT.Packfile.Register;
View
@@ -247,6 +247,11 @@ namespace PACT.Packfile {
class Multi {
var name; // String
var canidates; // RPA
+
+ function Multi(string name) {
+ self.name = name;
+ self.canidates = [];
+ }
}
// Below are in Subroutine.ops
@@ -267,11 +267,28 @@ class PACT.Packfile.Decompile {
ns.contents[n] = new PACT.Packfile.Namespace(n);
ns = ns.contents[n];
}
- if (exists ns.contents[string(sub)])
- die("Duplicate sub name"); // TODO handle multis
- ns.contents[string(sub)] = new_sub;
- // TODO: flags, outer, tags, multi, more?
+ // Handle Multi
+ var multisig = sub.get_multisig();
+ if (multisig != null) {
+ var multi;
+ if (exists ns.contents[string(sub)]) {
+ multi = ns.contents[string(sub)];
+ if (!(multi instanceof PACT.Packfile.Multi))
+ die("Duplicate sub name " + string(sub));
+ } else {
+ multi = new PACT.Packfile.Multi(string(sub));
+ ns.contents[multi.name] = multi;
+ }
+
+ push(multi.canidates, new_sub);
+
+ // TODO: Process multisig
+ } else {
+ if (exists ns.contents[string(sub)])
+ die("Duplicate sub name" + string(sub));
+ ns.contents[string(sub)] = new_sub;
+ }
sub = new_sub;

0 comments on commit f6ce9b1

Please sign in to comment.