Switched to bigint in lexer

This commit is contained in:
Krzosa Karol
2022-06-06 10:00:53 +02:00
parent 960523b443
commit 4f876a36a4
4 changed files with 46 additions and 17 deletions

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by the GNU LGPLv3.0 license
// a copy of which can be found in the LICENSE file.
struct Token;
function void parsing_error(Token *token, const char *str, ...);
#define malloc_arena(x) exp_alloc(&pernament_arena, x)
#define ALLOC_DIGITS(_digits) (uint64_t *)((_digits) ? malloc_arena(sizeof(uint64_t) * (_digits)) : NULL)
@@ -70,6 +71,33 @@ void bigint_incr(BigInt *x);
size_t bigint_popcount_signed(const BigInt *bi, size_t bit_count);
size_t bigint_popcount_unsigned(const BigInt *big_int);
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
static BigInt
bigint_u64(U64 value){
BigInt result;
bigint_init_unsigned(&result, value);
return result;
}
static BigInt
bigint_s64(S64 value){
BigInt result;
bigint_init_signed(&result, value);
return result;
}
function BigInt
bigint_mul(const BigInt *a, const BigInt *b){
BigInt result;
bigint_mul(&result, a, b);
return result;
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
static inline uint32_t u32_min(uint32_t a, uint32_t b)
{
return a < b ? a : b;