CT variables now follow CT scopes. It's now allowed to mutate CT variables in deeper runtime scopes.

This commit is contained in:
Christoffer Lerno
2022-12-07 16:25:08 +01:00
committed by Christoffer Lerno
parent f7659776fc
commit 1ea5625183
19 changed files with 212 additions and 119 deletions

View File

@@ -81,16 +81,17 @@ macro bool equals(a, b, isz len = -1, usz $align = 0)
$endif;
if (!len) return true;
var $Type;
$switch ($align):
$case 1:
var $Type = char;
$Type = char;
$case 2:
var $Type = ushort;
$Type = ushort;
$case 4:
var $Type = uint;
$Type = uint;
$case 8:
$default:
var $Type = ulong;
$Type = ulong;
$endswitch;
var $step = $Type.sizeof;
usz end = len / $step;

View File

@@ -1,7 +1,5 @@
module std::core::string::iterator;
struct StringIterator
{
char[] utf8;

View File

@@ -82,26 +82,27 @@ fn int128 __fixsfti(float a) @weak @extname("__fixsfti") = fixint(a);
private macro float_from_i128($Type, a)
{
var $Rep;
$switch ($Type):
$case double:
var $Rep = ulong;
$Rep = ulong;
const MANT_DIG = DOUBLE_MANT_DIG;
const SIGNIFICANT_BITS = 52;
const EXP_BIAS = 1023;
const MANTISSA_MASK = 0xFFFFF_FFFF_FFFFu64;
const SIGN_BIT = 1u64 << 63;
$case float:
var $Rep = uint;
$Rep = uint;
const MANT_DIG = FLOAT_MANT_DIG;
const EXP_BIAS = 127;
const SIGNIFICANT_BITS = 23;
const MANTISSA_MASK = 0x7F_FFFFu32;
const SIGN_BIT = 1u32 << 31;
$case float16:
var $Rep = ushort;
$Rep = ushort;
const MANT_DIG = HALF_MANT_DIG;
$case float128:
var $Rep = uint128;
$Rep = uint128;
const MANT_DIG = QUAD_MANT_DIG;
$endswitch;
if (a == 0) return ($Type)0;
@@ -140,24 +141,25 @@ private macro float_from_i128($Type, a)
private macro float_from_u128($Type, a)
{
var $Rep;
$switch ($Type):
$case double:
var $Rep = ulong;
$Rep = ulong;
const MANT_DIG = DOUBLE_MANT_DIG;
const SIGNIFICANT_BITS = 52;
const EXP_BIAS = 1023;
const MANTISSA_MASK = 0xFFFFF_FFFF_FFFFu64;
$case float:
var $Rep = uint;
$Rep = uint;
const MANT_DIG = FLOAT_MANT_DIG;
const EXP_BIAS = 127;
const SIGNIFICANT_BITS = 23;
const MANTISSA_MASK = 0x7F_FFFFu32;
$case float16:
var $Rep = ushort;
$Rep = ushort;
const MANT_DIG = HALF_MANT_DIG;
$case float128:
var $Rep = uint128;
$Rep = uint128;
const MANT_DIG = QUAD_MANT_DIG;
$endswitch;
if (a == 0) return ($Type)0;
@@ -194,21 +196,22 @@ private macro float_from_u128($Type, a)
private macro fixuint(a)
{
var $Rep;
$switch ($typeof(a)):
$case double:
var $Rep = ulong;
$Rep = ulong;
const EXPONENT_BITS = 11;
const SIGNIFICANT_BITS = 52;
$case float:
var $Rep = uint;
$Rep = uint;
const EXPONENT_BITS = 8;
const SIGNIFICANT_BITS = 23;
$case float16:
var $Rep = ushort;
$Rep = ushort;
const EXPONENT_BITS = 5;
const SIGNIFICANT_BITS = 10;
$case float128:
var $Rep = uint128;
$Rep = uint128;
const EXPONENT_BITS = 15;
const SIGNIFICANT_BITS = 112;
$endswitch;
@@ -237,21 +240,22 @@ private macro fixuint(a)
private macro fixint(a)
{
var $Rep;
$switch ($typeof(a)):
$case double:
var $Rep = ulong;
$Rep = ulong;
const EXPONENT_BITS = 11;
const SIGNIFICANT_BITS = 52;
$case float:
var $Rep = uint;
$Rep = uint;
const EXPONENT_BITS = 8;
const SIGNIFICANT_BITS = 23;
$case float16:
var $Rep = ushort;
$Rep = ushort;
const EXPONENT_BITS = 5;
const SIGNIFICANT_BITS = 10;
$case float128:
var $Rep = uint128;
$Rep = uint128;
const EXPONENT_BITS = 15;
const SIGNIFICANT_BITS = 112;
$endswitch;