Commit Graph

15471 Commits

Author SHA1 Message Date
Mr. Paul
65e4926c5b langref: Explain Zig Test
Updates the Language Reference sections: Comments, Values, and Zig Test.

Zig Test section moved down with the goal "make sure it can be read top to
bottom sensibly" in mind (issue #1524).

Comments and Values section examples changed test declarations to a main
function and expect statement to print statements.

A print statement was added to the "String Literals and Unicode Code Point"
section's example to demonstrate the "u" format specifier.

Zig Test Section:
* Addresses the question: "How does the syntax work?".
* Partially answers the question: "What can I do with the zig test tool?" but
should be sufficient to understand the examples in all of this document.
* Addresses the question: "How does a top-level test block differ from a function definition?"
* Provides a example to run multiple test.

Lacks clear definitions of containers, top-level, order independence, lazy
analysis, resolve, reference.

GitHub Issues: #8221, #8234
2021-10-04 15:35:01 -04:00
Andrew Kelley
d4ebfa8763
Merge pull request #9880 from squeek502/deflate-construct-errors
deflate: Better Huffman.construct errors and error handling
2021-10-04 15:31:08 -04:00
Matthew Borkowski
66204b7806 deflate.zig: check for distances past beginning of output stream 2021-10-04 15:30:37 -04:00
alichraghi
5125788e33 add phi constant 2021-10-04 15:27:25 -04:00
Andrew Kelley
ac2333ee63 stage2: fix Type max/min int calculation
This was an attempt to move saturating_arithmetic.zig to the "passing
for stage2" section, which did not pan out due to the discovery of 2
prerequisite items that need to be done, but I did make a bug fix along
the way of the calculation of max/min integers.

This commit also simplifies the saturating arithmetic behavior tests to
depend on less of the zig language that is not related to saturating
arithmetic.
2021-10-04 12:23:49 -07:00
Andrew Kelley
a28f2e0dd2
Merge pull request #9885 from Snektron/big-int-wrapping
Big int wrapping/saturating
2021-10-04 14:29:09 -04:00
Andrew Kelley
2454459ef5
Merge pull request #9882 from mattbork/astgen-cursor
astgen.zig: keep source cursor increasing monotonically as much as possible
2021-10-04 14:16:33 -04:00
Robin Voetter
95fe86e3db big ints: Fix tests for 32-bit architectures 2021-10-04 11:25:29 +02:00
Robin Voetter
a1e02f33ad fmt 2021-10-04 11:25:29 +02:00
Robin Voetter
3dc47b8161 Apply new big int wrap/saturate to Value.zig 2021-10-04 11:25:29 +02:00
Robin Voetter
a62ce87f1f big ints: mulWrap tests 2021-10-04 11:25:29 +02:00
Robin Voetter
b352564b36 big ints: Some extra comments 2021-10-04 11:25:29 +02:00
Robin Voetter
ebcdfebaa6 big ints: saturate() tests 2021-10-04 11:25:29 +02:00
Robin Voetter
bbd50248f2 big ints: saturate() function 2021-10-04 11:25:29 +02:00
Robin Voetter
fdf13fb819 big ints: Wrapping multiplication 2021-10-04 11:25:29 +02:00
Robin Voetter
41e9c1bac1 big ints: Allow llmulaccum to wrap 2021-10-04 11:25:29 +02:00
Robin Voetter
5907b3e383 big ints: Improve karatsuba multiplication 2021-10-04 11:25:29 +02:00
Robin Voetter
15351f206f big.int: truncate tests 2021-10-04 11:25:29 +02:00
Robin Voetter
8701d8579d Adapt Value.intAddSat and intSubSat to new big int saturating functions 2021-10-04 11:25:29 +02:00
Robin Voetter
96f095987f Adapt Type.minInt and maxInt to use setTwosCompLimit 2021-10-04 11:25:29 +02:00
Robin Voetter
692827baa7 big ints: [add|sub]Sat tests 2021-10-04 11:25:29 +02:00
Robin Voetter
52721d3a7e big ints: [add|sub]Wrap tests 2021-10-04 11:25:29 +02:00
Robin Voetter
bb53f4f15a big ints: implement normal/wrapping/saturating subtraction in terms of addition 2021-10-04 11:25:29 +02:00
Robin Voetter
16991f920b big ints: saturating addition 2021-10-04 11:25:29 +02:00
Robin Voetter
f1b3a90ef6 big ints: setTwosCompIntLimit
This function can be used to initialize a big integer to either the upper
or lower limit of a 2s-complement integer. Note that the result is still
in sign-magnitude representation, though in order to convert it into twos
complement all one has to do is take the absolute value.
2021-10-04 11:25:29 +02:00
Robin Voetter
dc1f698545 big ints: unify add/sub with their wrapping variants 2021-10-04 11:25:29 +02:00
Robin Voetter
a36ef84deb big ints: Basic wrapping multiplication 2021-10-04 11:25:29 +02:00
Robin Voetter
69be6ba8ee Comptime wrapping addition/subtraction 2021-10-04 11:25:29 +02:00
Robin Voetter
fdb37743fa big ints: addWrap, subWrap + fix Managed.truncate allocation size 2021-10-04 11:25:29 +02:00
Robin Voetter
a733692444 Update Value.intTrunc to use new big int truncate 2021-10-04 11:25:29 +02:00
Robin Voetter
b58cf6dab6 big ints: 2s complement truncate 2021-10-04 11:25:29 +02:00
Robin Voetter
616b23c815 big ints: split lladd/llsub into carry variants
lladd is now implemented in terms of lladdcarry, which returns the carry limb.
Similarly, llsub is implemented using llsubcarry, which returns the borrow limb.
2021-10-04 11:25:29 +02:00
Andrew Kelley
c41b989ab8 C backend: improved Decl name lowering
Decl names are now rendered fully qualified, so that e.g. "main" in two
different files does not conflict with each other.

Additionally, they are now mangled so as to not generate invalid C
identifier names.
2021-10-03 21:12:52 -07:00
Andrew Kelley
a41f812bdb C backend: fix lowering of struct types
with fields which are function pointers.
Before the name was in the wrong place.
2021-10-03 13:28:51 -07:00
Andrew Kelley
c79bf18044 C backend: fix lowering of struct, float, and slice constants 2021-10-03 12:50:34 -07:00
Andrew Kelley
86c265aec8 stage2: Type: fix eql impl for error unions
Also implement renderFullyQualifiedName.
2021-10-03 12:49:57 -07:00
Andrew Kelley
c4df9bf56f AstGen: fix while and for with unreachable bodies
Companion commit to 61a53a5875.

This commit also moves over a bunch of behavior test cases to the
passing-for-stage2 section.
2021-10-02 20:15:03 -07:00
Andrew Kelley
61a53a5875 AstGen: fix if, orelse, catch, with unreachable bodies
Before, the system to replace a result location pointer with a
traditional break instruction did not notice the case when one of the
bodies was unreachable. Now, the emitted ZIR code is improved and
simplified in this case, resulting in a new passing behavior test.
2021-10-02 19:09:54 -07:00
Andrew Kelley
ac52e00564
Merge pull request #9873 from SpexGuy/fix-struct-namespaces
Stage 2: A bunch of cleaning up
2021-10-02 16:25:15 -04:00
Martin Wickham
1d2c3af906 Remove address of pointer 2021-10-02 15:21:49 -05:00
Martin Wickham
272bad3f12 Delete Module.Scope, move Block into Sema 2021-10-02 15:21:49 -05:00
Martin Wickham
fd60012c21 Change *Scope to *Scope.Block, use Sema when required 2021-10-02 15:21:49 -05:00
Martin Wickham
01e08c92b3 Revert collateral changes, clarify abortAnonDecl() 2021-10-02 15:21:49 -05:00
Martin Wickham
53a36eacfa Remove my dumb "namespace decl" hack 2021-10-02 15:21:48 -05:00
Martin Wickham
d1a4bdb1f3 Declare generic fn dependency earlier to keep invariant 2021-10-02 15:21:48 -05:00
Martin Wickham
f7c11acb7f Resolve struct fields in a separate sema context 2021-10-02 15:21:48 -05:00
Martin Wickham
806eee8e99 Fix abortAnonDecl() 2021-10-02 15:21:48 -05:00
Martin Wickham
8d42500699 Implement hashing and equals for some pointer values 2021-10-02 15:21:48 -05:00
Martin Wickham
0b8ddb4478 Improve debug names of decls 2021-10-02 15:21:48 -05:00
Martin Wickham
993dc2ae77 Fix ownership of array type and elements 2021-10-02 15:21:48 -05:00