Vincent Rischmann
533bfc68bf
big int: fix Managed.dump()
2020-09-07 20:44:01 +03:00
Vexu
1df0f3ac24
update uses of deprecated type field access
2020-09-03 18:10:40 +03:00
Andrew Kelley
b498eebfd4
std.math.big: fix use-after-free
...
When there is parameter aliasing, the ensureCapacity calls can cause the
Const parameters to become dangling pointers.
See #6167
2020-08-25 19:49:40 -07:00
Andrew Kelley
4a69b11e74
add license header to all std lib files
...
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
joachimschmidt557
616355807f
Fix bug in big.int.Mutable.toManaged() and add tests
...
Fixes #5918
2020-07-27 07:16:44 +00:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted
2020-07-11 20:41:19 +03:00
joachimschmidt557
0ae1157e45
std.mem.dupe is deprecated, move all references in std
...
Replaced all occurences of std.mem.dupe in stdlib with
Allocator.dupe/std.mem.dupeZ -> Allocator.dupeZ
2020-07-04 21:40:06 +03:00
Jonathan Marler
12051b02f1
fix memory errors
2020-06-09 00:17:22 -04:00
Andrew Kelley
ec6ef86219
fix off-by-one error in sizeInBaseUpperBound
2020-05-01 13:33:46 -04:00
Andrew Kelley
4044a77621
update std.meta.IntType => std.meta.Int
2020-05-01 06:49:30 -04:00
Andrew Kelley
8766821157
rework std.math.big.Int
...
Now there are 3 types:
* std.math.big.int.Const
- the memory is immutable, only stores limbs and is_positive
- all methods operating on constant data go here
* std.math.big.int.Mutable
- the memory is mutable, stores capacity in addition to limbs and
is_positive
- methods here have some Mutable parameters and some Const
parameters. These methods expect callers to pre-calculate the
amount of resources required, and asserts that the resources are
available.
* std.math.big.int.Managed
- the memory is mutable and additionally stores an allocator.
- methods here perform the resource calculations for the programmer.
- this is the high level abstraction from before
Each of these 3 types can be converted to the other ones.
You can see the use case for this in the self-hosted compiler, where we
only store limbs, and construct the big ints as needed.
This gets rid of the hack where the allocator was optional and the
notion of "fixed" versions of the struct. Such things are now modeled
with the `big.int.Const` type.
2020-05-01 06:47:56 -04:00
Andrew Kelley
28729efe29
ZIR: implement return instruction
2020-05-01 06:47:20 -04:00
Andrew Kelley
6b0f7de247
ZIR: add cmp and condbr instructions
2020-05-01 06:47:20 -04:00
Tadeo Kondrak
350b2adacd
std.meta.IntType -> std.meta.Int
2020-04-28 19:11:31 -06:00
Andrew Kelley
1eda2ada9a
std.math.big.Int: don't rely on the allocator when printing
2020-04-22 03:49:50 -04:00
Andrew Kelley
2cdbb5f472
ir: analyze int casting
2020-04-21 19:48:59 -04:00
joachimschmidt557
3fd38429e4
Enable formatting in std.big.Int.format
2020-04-15 12:51:43 -04:00
Vexu
ca3bf6e6ad
translate-c cleanup and zig fmt
2020-04-15 15:15:32 +03:00
joachimschmidt557
1ee59c5c31
move big.rational.gcd to big.int.gcd
2020-04-07 13:43:15 -04:00
xackus
7a28c644aa
new ArrayList API: fix everything else
2020-04-02 16:12:08 +02:00
Joachim Schmidt
5acc8afb5f
Use math.Order for comparing bigints instead of i8 ( #4791 )
2020-03-23 23:16:57 -04:00
Andrew Kelley
13d04f9963
Merge pull request #4741 from momumi/master
...
allow `_` separators in number literals (stage 1)
2020-03-23 00:54:54 -04:00
momumi
8de45e5143
update parsing of int literals in self-hosted
...
* update std.math.big.Int.setString() to ignore underscores and make it
case insensitive
* fix issue in ir.zig with leading zeroes in integer literals
2020-03-22 13:59:14 +10:00
Andrew Kelley
dbde5df568
clean up some self-hosted bitrot + don't assume libstdc++
...
closes #4682
The self-hosted compiler is still bit rotted and still not compiling
successfully yet. I have a more serious rework of the code in a
different branch.
2020-03-17 23:03:45 -04:00
Benjamin Feng
4aae55b4cc
Replace fmt with new fmtstream
2020-03-12 10:41:09 -05:00
Benjamin Feng
c11d1055b8
Integrated outstreams with new formatter
2020-03-12 10:26:28 -05:00
Vexu
538d9a5dd8
remove uses of @ArgType
and @IntType
2020-02-24 23:39:03 +02:00
Vexu
45da72c5b6
remove usages of @typeId
, @memberCount
, @memberName
and @memberType
2020-02-24 23:09:01 +02:00
daurnimator
6ea6d5a4bd
std: use testing.allocator in tests
2020-02-14 19:15:09 +11:00
daurnimator
ca41567924
std: use testing.allocator in big int tests
2020-02-14 18:59:40 +11:00
daurnimator
b61e53cc40
std: bigint.deinit() shouldn't need a mutable pointer
2020-02-14 18:59:07 +11:00
LemonBoy
e81b505960
Use the correct calling convention for AEABI intrinsics
2020-01-07 13:42:47 -05:00
ForLoveOfCats
b28824ef66
Add missing deferred deinits to math.big.Int.toString
(mem leak fix)
2019-12-28 15:31:32 -05:00
Robin Voetter
4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
...
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
Andrew Kelley
8b2622cdd5
std.fmt.format: tuple parameter instead of var args
2019-12-08 22:53:51 -05:00
Andrew Kelley
343987cd05
remove @inlineCall
from zig
2019-12-06 14:12:01 -05:00
Andrew Kelley
aa0daea541
update more of the std lib to use @as
2019-11-08 15:57:25 -05:00
Andrew Kelley
e0db54e89d
update the codebase to use @as
2019-11-08 15:57:24 -05:00
Brendan Hansknecht
52207f22de
Add karatsuba to big ints
2019-11-04 13:20:03 -05:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
...
that's all this commit does. further commits will fix cli flags and
such.
see #2221
2019-09-25 23:35:41 -04:00