aboutsummaryrefslogtreecommitdiff
path: root/doc
AgeCommit message (Collapse)Author
2021-09-28sat-arithmetic: update langrefTravis Staloch
2021-09-28sat-arithmetic: fix docgenTravis Staloch
2021-09-27Langref: fix HTML escaped symbol WASM JavaScript code exampleMr. Paul
docgen HTML escapes characters inside of `syntax_block`s. This commit replaces the escaped greater than with the `>` character. No other occurrences were found. Fixes #9840
2021-09-24Spelling corrections (#9833)Josh Soref
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2021-09-20Merge pull request #9649 from Snektron/address-spaceAndrew Kelley
Address Spaces
2021-09-20Merge branch 'address-space' of Snektron/zig into Snektron-address-spaceAndrew Kelley
There were two things to resolve here: * Snektron's branch edited Zir printing, but in master branch I moved the printing code from Zir.zig to print_zir.zig. So that just had to be moved over. * In master branch I fleshed out coerceInMemory a bit more, which caused one of Snektron's test cases to fail, so I had to add addrspace awareness to that. Once I did that the tests passed again.
2021-09-20docgen: re-enable syntax checking for code blocksMr. Paul
In a previous commit (f4d3d29), syntax checking for code blocks with the `syntax` type was disabled due to a change in astgen now checking the existence of identifiers. The change in astgen caused some code samples in the language reference to cause compilation errors. This commit updates the code samples in the language reference and re-enables syntax checking. Some code samples have been changed to unchecked syntax blocks using `{#syntax_block#}` when suitable.
2021-09-20langref: define the inferred error set syntax more explicitlyRory O’Kane
This edit allows the reader to understand the syntax this section is talking about more quickly – they don’t have to read the whole code block and understand which part of it demonstrates the feature being described. Affects https://ziglang.org/documentation/master/#Inferred-Error-Sets
2021-09-20Address Spaces: Render addrspace token in docgenRobin Voetter
2021-09-15stage2: implement `@atomicRmw` and `@atomicLoad`Andrew Kelley
* langref: add some more "see also" links for atomics * Add the following AIR instructions - atomic_load - atomic_store_unordered - atomic_store_monotonic - atomic_store_release - atomic_store_seq_cst - atomic_rmw * Implement those AIR instructions in LLVM and C backends. * AstGen: make the `ty` result locations for `@atomicRmw`, `@atomicLoad`, and `@atomicStore` be `coerced_ty` to avoid unnecessary ZIR instructions when Sema will be doing the coercions redundantly. * Sema for `@atomicLoad` and `@atomicRmw` is done, however Sema for `@atomicStore` is not yet implemented. - comptime eval for `@atomicRmw` is not yet implemented. * Sema: flesh out `coerceInMemoryAllowed` a little bit more. It can now handle pointers.
2021-09-10Improve HTML semantics and a11y of language referenceMr. Paul
The language reference's HTML has been updated to be more semantically correct. This also helps to improve the document's accessibility concerns. * Document structure has single h1, other header sections start at h2, nav sections w/ aria labels, main section * Zig's homepage is linked, Zig Standard Library section link to it * Tables have caption and scoping rows and columns * Code blocks are figures with figure captions citing source files * Change line height 1.5 to include table of contents as well * Luminosity contrast ratios have been adjusted to 7:1 * Dark mode colors adjusted to reduce eye strain * Links have default browser underline with hover and focus effects * Asides, definition lists, keyboard inputs, program outputs are represented semantically Tools used to check: WAVE plugin https://wave.webaim.org/ Firefox Accessibility Developer Tool Lighthouse Accessibility Tool
2021-09-07langref: update link to 0.8.1 docsAndrew Kelley
2021-09-01langref: new usingnamespace semanticsAndrew Kelley
2021-09-01docgen: syntax blocks don't actually run the codeAndrew Kelley
2021-09-01saturating arithmetic builtins: add, sub, mul, shl (#9619)travisstaloch
- adds 1 simple behavior tests for each which does integer and vector ops at runtime and comptime - adds bigint_*_sat() methods for each - use CreateIntrinsic() which accepts a variable number of arguments to pass the scale parameter * update langref - added case to test/compile_errors.zig given floats - explain upstream bug in llvm.smul.fix.sat and link to #9643 in langref and commented out test cases * sat-arithmetic: skip mul tests if arch == .wasm32 because ci is erroring with 'LLVM ERROR: Unable to expand fixed point multiplication' when compiling for wasm32
2021-08-31fix typoPhilipp Lühmann
2021-08-28stage2: delete keywords `true`, `false`, `undefined`, `null`Andrew Kelley
The grammar does not need these as keywords; they are merely primitives provided by the language the same as `void`, `u32`, etc.
2021-08-23stage1: `@intToEnum` implicitly does an `@intCast`Andrew Kelley
This is a backwards-compatible language change. Previously, `@intToEnum` coerced its integer operand to the integer tag type of the destination enum type, often requiring the callsite to additionally wrap the operand in an `@intCast`. Now, the `@intCast` is implicit, and any integer operand can be passed to `@intToEnum`. The same as before, it is illegal behavior to pass any integer which does not have a corresponding enum tag.
2021-08-20Clarify async/await language documentation.bnprks
The async/await documentation was somewhat hard for me to follow when first learning. Two particular sticking points were 1. The alphabet example constructing the string "abcdefghi" breaks the stated rule that every async has a matching await. 2. It was somewhat unclear to me what the rules for control flow were around async/await constructs. I've tried to improve this documentation with some minimal explanatory edits, which are correct to the best of my beginner's understanding & experimentation.
2021-08-20Make clearer inline code blocks in language reference paragraphs (#9317)Paul
* Make clearer inline code blocks in language reference paragraphs This commit makes the inline code blocks within paragraphs standout against the descriptive text. The code blocks within tables are left un-styled. The line-height of the paragraphs has been set to 1.7 based on recommendations from MDN Web Docs and W3C. The value is unitless based on the recommendation. Closes #9316, #6313 * Make clearer inline code blocks in language reference paragraphs Goal: To improve legibility of inline code blocks in the language reference. This commit alters the styles of code HTML elements in paragraphs, unordered lists, ordered lists, tables, and preformatted text elements. Most of the changes here are taken from suggestions from @dbandstra on GitHub in response to a code review. * p, ul, ol, but not #toc are set to the same line-height * p, ul, ol, and table have the same inline code styles * The inline code background color set to match the preformatted code blocks in the light theme and dark theme. The border colors are adjusted as well. * The preformatted code block font size is set to default. The 12pt setting was removed. The line-height of paragraphs is set to 1.5. This value is chosen based on recommendations from W3C [1] via MDN Web Docs [2] and the contents of the language reference. The MDN Web Docs offers two recommendations: 1. Use a unitless number for line-height. 2. Use a minimum value of 1.5 for main paragraph content. [1] https://www.w3.org/TR/WCAG21/#visual-presentation [2] https://developer.mozilla.org/en-US/docs/Web/CSS/line-height Closes #6313, #9316 * Set language reference line-height and pre code border color This commit is an update to a group of commits with the goal of improving the legibility of the language reference. In this commit, the line-height is now set in the `#contents` ID and reset to normal for preformatted code blocks. This change better separates lines of all main content text for legibility. Closes: #9316, #6313 * Style the language reference code elements This commit sets the style of the HTML code element. Since preformatted code blocks have an overriding style, this is safe to set for all inline code elements.
2021-08-01langref- fix packed struct error codeMeghan
2021-08-01langref- fix use after block error codeMeghan
2021-07-27stage2: implement `@boolToInt`Andrew Kelley
This is the first commit in which some behavior tests are passing for both stage1 and stage2.
2021-07-26minimum/maximum builtinsRobin Voetter
2021-07-26Add @selectRobin Voetter
@select( comptime T: type, pred: std.meta.Vector(len, bool), a: std.meta.Vector(len, T), b: std.meta.Vector(len, T) ) std.meta.Vector(len, T) Constructs a vector from a & b, based on the values in the predicate vector. For indices where the predicate value is true, the corresponding element from the a vector is selected, and otherwise from b.
2021-07-25Doc fixes for clz + ctzAuguste Rame
2021-07-25Add vector support for @popCountAuguste Rame
2021-07-23Docs fix array/pointer/slice type coercion section (#9392)David May
* removed deprecated coercion: [X]T => [] const T * Fixed tests and added desc for first test * Improved heading
2021-07-22add -femit-llvm-bc CLI option and implement itAndrew Kelley
* Added doc comments for `std.Target.ObjectFormat` enum * `std.Target.oFileExt` is removed because it is incorrect for Plan-9 targets. Instead, use `std.Target.ObjectFormat.fileExt` and pass a CPU architecture. * Added `Compilation.Directory.joinZ` for when a null byte is desired. * Improvements to `Compilation.create` logic for computing `use_llvm` and reporting errors in contradictory flags. `-femit-llvm-ir` and `-femit-llvm-bc` will now imply `-fLLVM`. * Fix compilation when passing `.bc` files on the command line. * Improvements to the stage2 LLVM backend: - cleaned up error messages and error reporting. Properly bubble up some errors rather than dumping to stderr; others turn into panics. - properly call ZigLLVMCreateTargetMachine and ZigLLVMTargetMachineEmitToFile and implement calculation of the respective parameters (cpu features, code model, abi name, lto, tsan, etc). - LLVM module verification only runs in debug builds of the compiler - use LLVMDumpModule rather than printToString because in the case that we incorrectly pass a null pointer to LLVM it may crash during dumping the module and having it partially printed is helpful in this case. - support -femit-asm, -fno-emit-bin, -femit-llvm-ir, -femit-llvm-bc - Support LLVM backend when used with Mach-O and WASM linkers.
2021-07-19langref: remove incorrect statement on c_voidIsaac Freund
c_void is *not* simply `const c_void = opaque{};`. It has unique semantics as any pointer type may coerce to `*c_void` which is not true for an arbitrary `*opaque{}`.
2021-07-13clarify @bitSizeOf behaviorJonathan Marler
2021-07-08Introduce Zig Test earlier in Language ReferenceMr. Paul
The "Zig Test" section of the language reference has been moved between the current "Hello World" section and the "Comments" section. This was done to introduce the Zig test syntax before it is used in later sections. The description of the Zig test feature has NOT been updated in this commit. Closes #5837
2021-07-08Fix indentation in langref.html.inyetanothercheer
2021-07-04Merge pull request #9175 from kprotty/threadAndrew Kelley
std.Thread enhancements
2021-07-04Link to the GPA now that it's on upstreamNulo
2021-07-02langref: fix test cases now that AST Lowering has priorityAndrew Kelley
2021-07-02AstGen: fix missing compile error for unreachable `@TypeOf` argumentAndrew Kelley
2021-06-30std.Thread: more cleanup & testingkprotty
2021-06-29std: implement a cross platform file locking abstractionAndrew Kelley
This modifies the lock semantics from using AccessMode to using NtLockFile/NtUnlockFile. This is a breaking change.
2021-06-27translate-c: Add documentation for `zig translate-c`Evan Haas
2021-06-25langref: make @setRuntimeSafety more correctJacob G-W
2021-06-23langref: fix unused varsAndrew Kelley
2021-06-23fix typos in langref.htmlVeikka Tuominen
I thought I built the docs locally but apparently not.
2021-06-23Docs clarification: local static variable (#8381)Roman Frołow
2021-06-23docs: top level global assembly -> container levelJacob G-W
2021-06-21std, src, doc, test: remove unused variablesJacob G-W
2021-06-20stage2: Remove special double ampersand parsing case (#9114)Dmitry Matveyev
* Remove parser error on double ampersand * Add failing test for double ampersand case * Add error when encountering double ampersand in AstGen "Bit and" operator should not make sense when one of its operands is an address. * Check that 2 ampersands are adjacent to each other in source string * Remove cases of unused variables in tests
2021-06-16embedFile: change notation from [X:0] to [N:0]Daniele Cocca
This is for consistency with the documentation on sentinel-terminated {arrays,slices,pointers} which already use `N` for a comptime-inferred size rather than `X`. Also adds a behavioral test to assert that a string literal is returned.
2021-06-16typeName: amend return type to string literalDaniele Cocca
This was already the case, but the documentation failed to point out that the returned value is of type `*const [N:0]u8`, i.e. that of a string literal. Also adds a behavioral test to assert that this is the case.
2021-06-16errorName: return a null-terminated sliceDaniele Cocca