From e8cfe1a0a9ab271ce840e374c48ba4a88f793f9f Mon Sep 17 00:00:00 2001 From: EinBurgbauer Date: Thu, 30 Dec 2021 15:32:38 +0100 Subject: [PATCH 1/3] handle large uint constExpr printing --- BeefLibs/corlib/src/Type.bf | 2 ++ IDE/mintest/minlib/src/System/Type.bf | 2 ++ 2 files changed, 4 insertions(+) diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index 08b7c865..731752d2 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -1126,6 +1126,8 @@ namespace System.Reflection (*(float*)&mValue).ToString(strBuffer); case typeof(double): (*(double*)&mValue).ToString(strBuffer); + case typeof(uint64), typeof(uint): + (*(uint64*)&mValue).ToString(strBuffer); default: mValue.ToString(strBuffer); } diff --git a/IDE/mintest/minlib/src/System/Type.bf b/IDE/mintest/minlib/src/System/Type.bf index 08b7c865..731752d2 100644 --- a/IDE/mintest/minlib/src/System/Type.bf +++ b/IDE/mintest/minlib/src/System/Type.bf @@ -1126,6 +1126,8 @@ namespace System.Reflection (*(float*)&mValue).ToString(strBuffer); case typeof(double): (*(double*)&mValue).ToString(strBuffer); + case typeof(uint64), typeof(uint): + (*(uint64*)&mValue).ToString(strBuffer); default: mValue.ToString(strBuffer); } From 6c03b8c8c984626cfad8ce90424fcee481d98812 Mon Sep 17 00:00:00 2001 From: EinBurgbauer Date: Thu, 30 Dec 2021 17:00:49 +0100 Subject: [PATCH 2/3] support printing bool and char in theory --- BeefLibs/corlib/src/Type.bf | 6 ++++++ IDE/mintest/minlib/src/System/Type.bf | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index 731752d2..bf698466 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -1126,6 +1126,12 @@ namespace System.Reflection (*(float*)&mValue).ToString(strBuffer); case typeof(double): (*(double*)&mValue).ToString(strBuffer); + case typeof (bool): + strBuffer.Append((*(bool*)&mValue) ? "true" : "false"); + case typeof(char8), typeof(char16), typeof(char32): + strBuffer.Append('\''); + (*(char32*)&mValue).ToString(strBuffer); + strBuffer.Append('\''); case typeof(uint64), typeof(uint): (*(uint64*)&mValue).ToString(strBuffer); default: diff --git a/IDE/mintest/minlib/src/System/Type.bf b/IDE/mintest/minlib/src/System/Type.bf index 731752d2..bf698466 100644 --- a/IDE/mintest/minlib/src/System/Type.bf +++ b/IDE/mintest/minlib/src/System/Type.bf @@ -1126,6 +1126,12 @@ namespace System.Reflection (*(float*)&mValue).ToString(strBuffer); case typeof(double): (*(double*)&mValue).ToString(strBuffer); + case typeof (bool): + strBuffer.Append((*(bool*)&mValue) ? "true" : "false"); + case typeof(char8), typeof(char16), typeof(char32): + strBuffer.Append('\''); + (*(char32*)&mValue).ToString(strBuffer); + strBuffer.Append('\''); case typeof(uint64), typeof(uint): (*(uint64*)&mValue).ToString(strBuffer); default: From ea0a76142a1d652f72adf10e9ba461836a227bcd Mon Sep 17 00:00:00 2001 From: EinBurgbauer Date: Thu, 30 Dec 2021 18:06:55 +0100 Subject: [PATCH 3/3] properly quote char --- BeefLibs/corlib/src/Type.bf | 5 ++++- IDE/mintest/minlib/src/System/Type.bf | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index bf698466..14ef5228 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -1130,7 +1130,10 @@ namespace System.Reflection strBuffer.Append((*(bool*)&mValue) ? "true" : "false"); case typeof(char8), typeof(char16), typeof(char32): strBuffer.Append('\''); - (*(char32*)&mValue).ToString(strBuffer); + var str = (*(char32*)&mValue).ToString(.. scope .()); + let len = str.Length; + String.QuoteString(&str[0], len, str); + strBuffer.Append(str[(len + 1)...^2]); strBuffer.Append('\''); case typeof(uint64), typeof(uint): (*(uint64*)&mValue).ToString(strBuffer); diff --git a/IDE/mintest/minlib/src/System/Type.bf b/IDE/mintest/minlib/src/System/Type.bf index bf698466..14ef5228 100644 --- a/IDE/mintest/minlib/src/System/Type.bf +++ b/IDE/mintest/minlib/src/System/Type.bf @@ -1130,7 +1130,10 @@ namespace System.Reflection strBuffer.Append((*(bool*)&mValue) ? "true" : "false"); case typeof(char8), typeof(char16), typeof(char32): strBuffer.Append('\''); - (*(char32*)&mValue).ToString(strBuffer); + var str = (*(char32*)&mValue).ToString(.. scope .()); + let len = str.Length; + String.QuoteString(&str[0], len, str); + strBuffer.Append(str[(len + 1)...^2]); strBuffer.Append('\''); case typeof(uint64), typeof(uint): (*(uint64*)&mValue).ToString(strBuffer);