1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-21 01:18:02 +02:00

Support for comptime file IO and process creation

This commit is contained in:
Brian Fiete 2021-12-20 09:39:39 -05:00
parent 045e706600
commit ce4b6e04de
19 changed files with 726 additions and 89 deletions

View file

@ -2,6 +2,7 @@ using System.Reflection;
using System.Diagnostics;
using System.Collections;
using System.Security.Cryptography;
using System.IO;
namespace System
{
@ -306,5 +307,21 @@ namespace System
if (Compiler.IsComptime)
Comptime_EmitMixin(text);
}
[Comptime]
public static Span<uint8> ReadBinary(StringView path)
{
List<uint8> data = scope .();
File.ReadAll(path, data);
return data;
}
[Comptime]
public static String ReadText(StringView path)
{
String data = scope .();
File.ReadAllText(path, data);
return data;
}
}
}

View file

@ -106,5 +106,24 @@ namespace System.Diagnostics
if (gIsDebuggerPresent)
Break();
}
public static void WriteMemory(Span<uint8> mem)
{
String str = scope .();
for (int i < mem.Length)
{
if ((i != 0) && (i % 16 == 0))
str.Append('\n');
str.AppendF($" {mem.[Friend]mPtr[i]:X2}");
}
str.Append('\n');
Write(str);
}
public static void WriteMemory<T>(T result)
{
#unwarn
WriteMemory(.((.)&result, sizeof(T)));
}
}
}

View file

@ -118,6 +118,9 @@ namespace System
public this()
{
if (Compiler.IsComptime)
return;
#if BF_PLATFORM_WINDOWS
bool isWinSrv()
{