new multiline string syntax

This patch also moves a bunch of the parser code into the tokenizer.

Closes #162.
This commit is contained in:
Andrew Kelley
2016-08-01 23:11:31 -07:00
parent 0450b73e3e
commit d0b11af2bd
15 changed files with 810 additions and 1101 deletions

View File

@@ -6,6 +6,7 @@
*/
#include "bignum.hpp"
#include "buffer.hpp"
#include <assert.h>
#include <math.h>
@@ -41,6 +42,10 @@ void bignum_init_signed(BigNum *dest, int64_t x) {
}
}
void bignum_init_bignum(BigNum *dest, BigNum *src) {
memcpy(dest, src, sizeof(BigNum));
}
bool bignum_fits_in_bits(BigNum *bn, int bit_count, bool is_signed) {
assert(bn->kind == BigNumKindInt);
@@ -343,3 +348,15 @@ bool bignum_cmp_gte(BigNum *op1, BigNum *op2) {
return true;
}
}
bool bignum_increment_by_scalar(BigNum *bignum, uint64_t scalar) {
assert(bignum->kind == BigNumKindInt);
assert(!bignum->is_negative);
return __builtin_uaddll_overflow(bignum->data.x_uint, scalar, &bignum->data.x_uint);
}
bool bignum_multiply_by_scalar(BigNum *bignum, uint64_t scalar) {
assert(bignum->kind == BigNumKindInt);
assert(!bignum->is_negative);
return __builtin_umulll_overflow(bignum->data.x_uint, scalar, &bignum->data.x_uint);
}