Skip to content

Commit f6ce9b1

Browse files
committed
Packfile.Decompile: Initial multi handling
Appears to collect multi candidates properly
1 parent 096353c commit f6ce9b1

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

PACT/Packfile.winxed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class PACT.Packfile.Constant;
44
class PACT.Packfile.Constant.Reference;
55
class PACT.Packfile.Constant.Key;
66
class PACT.Packfile.Subroutine;
7+
class PACT.Packfile.Multi;
78
class PACT.Packfile.Op;
89
class PACT.Packfile.Label;
910
class PACT.Packfile.Register;

src/PACT/Packfile.winxed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ namespace PACT.Packfile {
247247
class Multi {
248248
var name; // String
249249
var canidates; // RPA
250+
251+
function Multi(string name) {
252+
self.name = name;
253+
self.canidates = [];
254+
}
250255
}
251256

252257
// Below are in Subroutine.ops

src/PACT/Packfile/Decompile.winxed

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,28 @@ class PACT.Packfile.Decompile {
267267
ns.contents[n] = new PACT.Packfile.Namespace(n);
268268
ns = ns.contents[n];
269269
}
270-
if (exists ns.contents[string(sub)])
271-
die("Duplicate sub name"); // TODO handle multis
272-
ns.contents[string(sub)] = new_sub;
273270

274-
// TODO: flags, outer, tags, multi, more?
271+
// Handle Multi
272+
var multisig = sub.get_multisig();
273+
if (multisig != null) {
274+
var multi;
275+
if (exists ns.contents[string(sub)]) {
276+
multi = ns.contents[string(sub)];
277+
if (!(multi instanceof PACT.Packfile.Multi))
278+
die("Duplicate sub name " + string(sub));
279+
} else {
280+
multi = new PACT.Packfile.Multi(string(sub));
281+
ns.contents[multi.name] = multi;
282+
}
283+
284+
push(multi.canidates, new_sub);
285+
286+
// TODO: Process multisig
287+
} else {
288+
if (exists ns.contents[string(sub)])
289+
die("Duplicate sub name" + string(sub));
290+
ns.contents[string(sub)] = new_sub;
291+
}
275292

276293
sub = new_sub;
277294

0 commit comments

Comments
 (0)