diff --git a/premake5.lua b/premake5.lua index 90f13cb..fcf3cc6 100644 --- a/premake5.lua +++ b/premake5.lua @@ -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 diff --git a/readme.md b/readme.md index aa0d2fa..a5fc975 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/ssc/compiler.cs b/ssc/compiler.cs index a681f29..2dc9e3d 100644 --- a/ssc/compiler.cs +++ b/ssc/compiler.cs @@ -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()) { + callable.Compile(this); + } + } +#endif #if SSC_CLEAN_SYMBOLS void CleanSymbols() { var i = 0;