Compile only used functions/builtins
Uses iteration as to properly detect functions called only from within other functions (which appear unused from the global scope).
This commit is contained in:
parent
dc559130bf
commit
ba559b3fa3
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace arookas {
|
namespace arookas {
|
||||||
public class sunCompiler {
|
public class sunCompiler {
|
||||||
|
@ -71,9 +72,15 @@ namespace arookas {
|
||||||
mBinary.WriteEND();
|
mBinary.WriteEND();
|
||||||
}
|
}
|
||||||
void CompileFunctions() {
|
void CompileFunctions() {
|
||||||
foreach (var callable in mContext.SymbolTable.Callables) {
|
while (DoCompileFunctions() > 0) ;
|
||||||
|
}
|
||||||
|
int DoCompileFunctions() {
|
||||||
|
var count = 0;
|
||||||
|
foreach (var callable in mContext.SymbolTable.Callables.Where(i => i.HasRelocations && i.CompileCount == 0)) {
|
||||||
callable.Compile(this);
|
callable.Compile(this);
|
||||||
|
++count;
|
||||||
}
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
void CompileRelocations() {
|
void CompileRelocations() {
|
||||||
foreach (var symbol in mContext.SymbolTable) {
|
foreach (var symbol in mContext.SymbolTable) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue