Skip to content

Commit ba427e1

Browse files
committed
dead code remover working again
1 parent eaf4098 commit ba427e1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

source/codeRemover.d

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class CodeRemover {
1212
Node[][string] functions;
1313
string[] funcStack;
1414
bool success = true;
15+
string[] specialFuncs;
1516

1617
this() {
17-
usedFunctions = [
18+
specialFuncs = [
1819
"__x86_64_program_init",
1920
"__x86_64_program_exit",
2021
"__rm86_program_init",
@@ -23,12 +24,15 @@ class CodeRemover {
2324
"__arm64_program_exit",
2425
"uxn_program_init",
2526
"uxn_program_end",
27+
"__uxn_program_init",
28+
"__uxn_program_end",
2629
"__x86_64_exception",
2730
"__rm86_exception",
2831
"__uxn_exception",
2932
"__arm64_exception",
3033
"__lua_exception",
3134
];
35+
usedFunctions = specialFuncs;
3236
}
3337

3438
final void Error(Char, A...)(ErrorInfo error, in Char[] fmt, A args) {
@@ -101,6 +105,18 @@ class CodeRemover {
101105
FindFunctions(node.nodes);
102106
break;
103107
}
108+
case NodeType.FuncDef: {
109+
auto node = cast(FuncDefNode) inode;
110+
111+
if (!specialFuncs.canFind(node.name)) {
112+
continue;
113+
}
114+
115+
funcStack ~= node.name;
116+
FindFunctions(functions[node.name]);
117+
funcStack = funcStack[0 .. $ - 1];
118+
break;
119+
}
104120
default: break;
105121
}
106122
}

0 commit comments

Comments
 (0)