1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-19 16:40:26 +02:00

More const eval progress

This commit is contained in:
Brian Fiete 2020-12-19 14:19:33 -08:00
parent a3ea79cd62
commit 9b80c26d0a
26 changed files with 1673 additions and 460 deletions

View file

@ -23,7 +23,16 @@ namespace System
[LinkName("#CallerExpression")]
public static extern String[Int32.MaxValue] CallerExpression;
[LinkName("#ProjectName")]
public static extern String ProjectName;
[LinkName("#ModuleName")]
public static extern String ModuleName;
[LinkName("#TimeLocal")]
public static extern String TimeLocal;
[LinkName("#IsConstEval")]
public static extern bool IsConstEval;
}
}

View file

@ -35,10 +35,8 @@ namespace System
if (data == null)
return true;
var type = data.GetType();
if (type == typeof(List<T>))
if (var list = data as List<T>)
{
var list = (List<T>)data;
return list.Count == 0;
}
return false;
@ -54,10 +52,8 @@ namespace System
if (data == null)
return 0;
var type = data.GetType();
if (type == typeof(List<T>))
if (var list = data as List<T>)
{
var list = (List<T>)data;
return list.Count;
}
return 1;
@ -105,11 +101,8 @@ namespace System
return;
}
var type = data.GetType();
if (type == typeof(List<T>))
if (var list = data as List<T>)
{
var list = (List<T>)data;
list.Add(ownDelegate);
}
else
@ -125,10 +118,8 @@ namespace System
{
Object data = Target;
var type = data.GetType();
if (type == typeof(List<T>))
if (var list = data as List<T>)
{
var list = (List<T>)data;
int32 idx = -1;
for (int32 i = 0; i < list.Count; i++)
if (Delegate.Equals(list[i], compareDelegate))
@ -193,9 +184,8 @@ namespace System
if (mData == 0)
return;
var data = Target;
if (data.GetType() == typeof(List<T>))
if (var list = data as List<T>)
{
var list = (List<T>)data;
for (var dlg in list)
delete dlg;
}
@ -282,10 +272,8 @@ namespace System
if (data == null)
return false;
var type = data.GetType();
if (type == typeof(List<T>))
if (var list = data as List<T>)
{
var list = (List<T>)data;
repeat
{
mIdx++;

View file

@ -83,6 +83,8 @@ namespace System.Globalization
{
get
{
if (Compiler.IsConstEval)
return InitUserDefaultCulture();
if (tlCurrentCulture == null)
tlCurrentCulture = CultureInfo.DefaultThreadCurrentCulture ?? CultureInfo.UserDefaultCulture;
return tlCurrentCulture;

View file

@ -127,6 +127,8 @@ namespace System
public static T* AllocRawArrayUnmarked<T>(int size)
{
#if BF_ENABLE_REALTIME_LEAK_CHECK
if (Compiler.IsConstEval)
return new T[size]*(?);
// We don't want to use the default mark function because the GC will mark the entire array,
// whereas we have a custom marking routine because we only want to mark up to mSize
return (T*)Internal.Dbg_RawAlloc(size * strideof(T), &DbgRawAllocData.Unmarked<T>.sRawAllocData);

View file

@ -109,7 +109,7 @@ namespace System
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
};*/
private static uint64[2048] MantissaBitsTable = .(
private const uint64[2048] MantissaBitsTable = .(
4556951262222748432UL, 9113902524445496865UL, 1822780504889099373UL,
3645561009778198746UL, 7291122019556397492UL, 14582244039112794984UL,
2916448807822558996UL, 5832897615645117993UL, 11665795231290235987UL,
@ -794,7 +794,7 @@ namespace System
4602094425247528723UL, 9204188850495057447UL, 1840837770099011489UL,
3681675540198022979UL, 7363351080396045958UL);
private static int32[2048] TensExponentTable = .(
private const int32[2048] TensExponentTable = .(
-323, -323, -322, -322, -322, -322, -321, -321, -321, -320, -320, -320,
-319, -319, -319, -319, -318, -318, -318, -317, -317, -317, -316, -316,
-316, -316, -315, -315, -315, -314, -314, -314, -313, -313, -313, -313,
@ -966,9 +966,9 @@ namespace System
284, 284, 284, 285, 285, 285, 286, 286, 286, 286, 287, 287,
287, 288, 288, 288, 289, 289, 289, 289, 290, 290, 290, 291,
291, 291, 292, 292, 292, 293, 293, 293 );
private static char8[16] DigitLowerTable = .('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
private static char8[16] DigitUpperTable = .('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
private static int64[19] TenPowersList = .(
private const char8[16] DigitLowerTable = .('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
private const char8[16] DigitUpperTable = .('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
private const int64[19] TenPowersList = .(
1L,
10L,
100L,
@ -991,7 +991,7 @@ namespace System
// DecHexDigits s a translation table from a decimal number to its
// digits hexadecimal representation (e.g. DecHexDigits [34] = 0x34).
private static int32[100] DecHexDigits = .(
private const int32[100] DecHexDigits = .(
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
@ -1235,8 +1235,10 @@ namespace System
// _isCustomFormat, _specifierIsUpper, _specifier & _precision.
this(CultureInfo cultureInfo)
{
//_cbuf = EmptyArray<char>.Value;
_cbuf = sEmtpyBuf;
if (Compiler.IsConstEval)
_cbuf = new char8[0];
else
_cbuf = sEmtpyBuf;
if (cultureInfo != null)
CurrentCulture = cultureInfo;
}
@ -2032,13 +2034,12 @@ namespace System
private void FormatHexadecimal (int32 precision, String outString)
{
int32 size = Math.Max (precision, _decPointPos);
char8* digits = _specifierIsUpper ? &DigitUpperTable : &DigitLowerTable;
ResetCharBuf (size);
_ind = size;
uint64 val = _val1 | ((uint64)_val2 << 32);
while (size > 0) {
_cbuf [--size] = digits [val & 0xf];
_cbuf [--size] = _specifierIsUpper ? DigitUpperTable[val & 0xf] : DigitLowerTable[val & 0xf];
val >>= 4;
}
outString.Append(_cbuf, 0, _ind);
@ -2046,8 +2047,6 @@ namespace System
private void FormatAddress(String outString)
{
char8* digits = _specifierIsUpper ? &DigitUpperTable : &DigitLowerTable;
const int bufLen = 18;
char8* strChars = scope:: char8[bufLen]* (?);
int32 curLen = 0;
@ -2056,7 +2055,7 @@ namespace System
{
if (curLen == 8)
strChars[bufLen - curLen++ - 1] = '\'';
strChars[bufLen - curLen++ - 1] = digits[(int)(valLeft & 0xF)];
strChars[bufLen - curLen++ - 1] = _specifierIsUpper ? DigitUpperTable[(int)(valLeft & 0xF)] : DigitLowerTable[(int)(valLeft & 0xF)];
valLeft >>= 4;
}

View file

@ -40,9 +40,13 @@ namespace System
return false;
}
#endif
extern Type ConstEval_GetType();
public Type GetType()
{
if (Compiler.IsConstEval)
return ConstEval_GetType();
Type type;
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
ClassVData* maskedVData = (ClassVData*)(void*)(mClassVData & ~(int)0xFF);
@ -61,6 +65,9 @@ namespace System
[NoShow]
Type RawGetType()
{
if (Compiler.IsConstEval)
return ConstEval_GetType();
Type type;
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
ClassVData* maskedVData = (ClassVData*)(void*)(mClassVData & ~(int)0xFF);

View file

@ -1,9 +1,10 @@
using System.Diagnostics;
namespace System.Text
{
class UTF8
{
public static int8* sTrailingBytesForUTF8 = new int8[]*
(
public const int8[256] sTrailingBytesForUTF8 =
.(
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -12,13 +13,13 @@ namespace System.Text
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
) ~ delete _;
);
public static uint32* sOffsetsFromUTF8 = new uint32[]*
(
public const uint32[6] sOffsetsFromUTF8 =
.(
0x00000000, 0x00003080, 0x000E2080,
0x03C82080, 0xFA082080, 0x82082080
) ~ delete _;
);
public static int GetEncodedLength(char32 c)
{
@ -58,6 +59,7 @@ namespace System.Text
case 2: c <<= 6; c += (int32)buf[bufIdx++]; fallthrough;
case 1: c <<= 6; c += (int32)buf[bufIdx++]; fallthrough;
}
c -= (int32)UTF8.sOffsetsFromUTF8[trailingBytes];
return (c, trailingBytes + 1);
}