Skip to content

Commit

Permalink
Add a way to generate binary chunks using the front-end application.
Browse files Browse the repository at this point in the history
  • Loading branch information
vddCore committed May 18, 2024
1 parent 48badee commit f485d41
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FrontEnd/EVIL.evil/EVIL.evil.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<AssemblyName>evil</AssemblyName>
<Version>1.8.2</Version>
<Version>1.9.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
31 changes: 30 additions & 1 deletion FrontEnd/EVIL.evil/EvmFrontEnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ public partial class EvmFrontEnd
{ "v|version", "display compiler and VM version information.", (v) => _displayVersionAndQuit = v != null },
{ "g|gen-docs", "generate documentation for all detected native modules.", (g) => _generateModuleDocsAndQuit = g != null },
{ "d|disasm", "disassemble the compiled script.", (d) => _disassembleCompiledScript = d != null },
{ "o|optimize", "optimize generated code.", (o) => _optimizeCode = o != null }
{ "o|optimize", "optimize generated code.", (o) => _optimizeCode = o != null },
{ "c|compile-only=", "don't run, compile only requires a file name", (o) =>
{
_compileOnly = !string.IsNullOrEmpty(o);
_outputFileName = o;
}}
};

private static bool _displayHelpAndQuit;
private static bool _displayVersionAndQuit;
private static bool _generateModuleDocsAndQuit;
private static bool _disassembleCompiledScript;
private static bool _optimizeCode;
private static bool _compileOnly;
private static string _outputFileName = "a.evx";

public async Task Run(string[] args)
{
Expand Down Expand Up @@ -142,6 +149,28 @@ public async Task Run(string[] args)
Console.WriteLine(_compiler.Log.ToString());
}

if (_compileOnly)
{
try
{
using var fs = new FileStream(
Path.Combine(
Environment.CurrentDirectory,
_outputFileName
),
FileMode.Create
);

rootChunk.Serialize(fs);
}
catch (Exception e)
{
Terminate($"Fatal: unable to write executable to disk - {e.Message}");
}

return;
}

RegisterAllModules();
SetStandardGlobals(scriptPath);

Expand Down

0 comments on commit f485d41

Please sign in to comment.