Added clean-functions option

This commit is contained in:
arookas 2016-02-13 18:15:18 -05:00
parent a51c5d9e8b
commit 5de905e9e5
3 changed files with 17 additions and 1 deletions

View file

@ -5,6 +5,11 @@ newoption {
value = "PATH"
}
newoption {
trigger = "clean-functions",
description = "Compiles only used functions"
}
newoption {
trigger = "clean-symbols",
description = "Cleans up the symbol table from unused symbols"
@ -40,6 +45,9 @@ workspace "ssc"
links { "System", "arookas", "grammatica-1.6" }
-- apply options
if _OPTIONS["clean-functions"] then
defines { "SSC_CLEAN_FUNCTIONS" }
end
if _OPTIONS["clean-symbols"] then
defines { "SSC_CLEAN_SYMBOLS" }
end

View file

@ -68,6 +68,7 @@ There are also options which are able to be configured via the premake5 command
|Option|Description|
|------|-----------|
|lib-dir|Sets the path to the dependencies. Defaults to the _lib/_ folder.|
|clean-functions|Compiles only used functions.|
|clean-symbols|Cleans symbol table of unused symbols.|
## Language

View file

@ -1,7 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace arookas {
public class sunCompiler {
@ -85,6 +84,7 @@ namespace arookas {
}
mBinary.WriteEND();
}
#if SSC_CLEAN_FUNCTIONS
void CompileFunctions() {
while (DoCompileFunctions() > 0) ;
}
@ -96,6 +96,13 @@ namespace arookas {
}
return count;
}
#else
void CompileFunctions() {
foreach (var callable in mContext.SymbolTable.Get<sunCallableSymbol>()) {
callable.Compile(this);
}
}
#endif
#if SSC_CLEAN_SYMBOLS
void CleanSymbols() {
var i = 0;