| ... | ... | @@ -398,10 +398,10 @@ false otherwise. |
| 398 | 398 | |
| 399 | 399 | ``` |
| 400 | 400 | Function Operation |
| 401 | | @add_with_overflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a + b |
| 402 | | @sub_with_overflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a - b |
| 403 | | @mul_with_overflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a * b |
| 404 | | @shl_with_overflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a << b |
| 401 | @addWithOverflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a + b |
| 402 | @subWithOverflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a - b |
| 403 | @mulWithOverflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a * b |
| 404 | @shlWithOverflow(inline T: type, a: T, b: T, result: &T) -> bool *x = a << b |
| 405 | 405 | ``` |
| 406 | 406 | |
| 407 | 407 | ### @memset(dest, c: u8, byte_count: usize) |
| ... | ... | @@ -437,7 +437,7 @@ debuggers to break there. |
| 437 | 437 | |
| 438 | 438 | This function is only valid within function scope. |
| 439 | 439 | |
| 440 | | ### @return_address() |
| 440 | ### @returnAddress() |
| 441 | 441 | |
| 442 | 442 | This function returns a pointer to the return address of the current stack |
| 443 | 443 | frame. |
| ... | ... | @@ -447,7 +447,7 @@ all platforms. |
| 447 | 447 | |
| 448 | 448 | This function is only valid within function scope. |
| 449 | 449 | |
| 450 | | ### @frame_address() |
| 450 | ### @frameAddress() |
| 451 | 451 | |
| 452 | 452 | This function returns the base pointer of the current stack frame. |
| 453 | 453 | |
| ... | ... | @@ -457,21 +457,21 @@ aggressive optimizations. |
| 457 | 457 | |
| 458 | 458 | This function is only valid within function scope. |
| 459 | 459 | |
| 460 | | ### @max_value(inline T: type) -> (number literal) |
| 460 | ### @maxValue(inline T: type) -> (number literal) |
| 461 | 461 | |
| 462 | 462 | This function returns the maximum integer value of the integer type T. |
| 463 | 463 | |
| 464 | 464 | The result is a compile time constant. For some types such as `c_long`, the |
| 465 | 465 | result is marked as depending on a compile variable. |
| 466 | 466 | |
| 467 | | ### @min_value(inline T: type) -> (number literal) |
| 467 | ### @minValue(inline T: type) -> (number literal) |
| 468 | 468 | |
| 469 | 469 | This function returns the minimum integer value of the integer type T. |
| 470 | 470 | |
| 471 | 471 | The result is a compile time constant. For some types such as `c_long`, the |
| 472 | 472 | result is marked as depending on a compile variable. |
| 473 | 473 | |
| 474 | | ### @member_count(inline T: type) -> (number literal) |
| 474 | ### @memberCount(inline T: type) -> (number literal) |
| 475 | 475 | |
| 476 | 476 | This function returns the number of enum values in an enum type. |
| 477 | 477 | |
| ... | ... | @@ -487,7 +487,7 @@ such as "std". |
| 487 | 487 | |
| 488 | 488 | This function is only valid at top level scope. |
| 489 | 489 | |
| 490 | | ### @c_import(expression) -> (namespace) |
| 490 | ### @cImport(expression) -> (namespace) |
| 491 | 491 | |
| 492 | 492 | This function parses C code and imports the functions, types, variables, and |
| 493 | 493 | compatible macro definitions into the result namespace. |
| ... | ... | @@ -498,25 +498,25 @@ appending to a temporary buffer which is then parsed as C code. |
| 498 | 498 | |
| 499 | 499 | This function is only valid at top level scope. |
| 500 | 500 | |
| 501 | | ### @c_include(inline path: []u8) |
| 501 | ### @cInclude(inline path: []u8) |
| 502 | 502 | |
| 503 | 503 | This function can only occur inside `@c_import`. |
| 504 | 504 | |
| 505 | 505 | This appends `#include <$path>\n` to the `c_import` temporary buffer. |
| 506 | 506 | |
| 507 | | ### @c_define(inline name: []u8, value) |
| 507 | ### @cDefine(inline name: []u8, value) |
| 508 | 508 | |
| 509 | 509 | This function can only occur inside `@c_import`. |
| 510 | 510 | |
| 511 | 511 | This appends `#define $name $value` to the `c_import` temporary buffer. |
| 512 | 512 | |
| 513 | | ### @c_undef(inline name: []u8) |
| 513 | ### @cUndef(inline name: []u8) |
| 514 | 514 | |
| 515 | 515 | This function can only occur inside `@c_import`. |
| 516 | 516 | |
| 517 | 517 | This appends `#undef $name` to the `c_import` temporary buffer. |
| 518 | 518 | |
| 519 | | ### @compile_var(inline name: []u8) -> (varying type) |
| 519 | ### @compileVar(inline name: []u8) -> (varying type) |
| 520 | 520 | |
| 521 | 521 | This function returns a compile-time variable. There are built in compile |
| 522 | 522 | variables: |
| ... | ... | @@ -533,7 +533,7 @@ Build scripts can set additional compile variables of any name and type. |
| 533 | 533 | The result of this function is a compile time constant that is marked as |
| 534 | 534 | depending on a compile variable. |
| 535 | 535 | |
| 536 | | ### @const_eval(expression) -> @typeof(expression) |
| 536 | ### @constEval(expression) -> @typeof(expression) |
| 537 | 537 | |
| 538 | 538 | This function wraps an expression and generates a compile error if the |
| 539 | 539 | expression is not known at compile time. |
| ... | ... | @@ -550,7 +550,7 @@ type T. |
| 550 | 550 | This function counts the number of leading zeroes in x which is an integer |
| 551 | 551 | type T. |
| 552 | 552 | |
| 553 | | ### @err_name(err: error) -> []u8 |
| 553 | ### @errorName(err: error) -> []u8 |
| 554 | 554 | |
| 555 | 555 | This function returns the string representation of an error. If an error |
| 556 | 556 | declaration is: |
| ... | ... | @@ -564,7 +564,7 @@ Then the string representation is "OutOfMem". |
| 564 | 564 | If there are no calls to `@err_name` in an entire application, then no error |
| 565 | 565 | name table will be generated. |
| 566 | 566 | |
| 567 | | ### @embed_file(inline path: []u8) -> [X]u8 |
| 567 | ### @embedFile(inline path: []u8) -> [X]u8 |
| 568 | 568 | |
| 569 | 569 | This function returns a compile time constant fixed-size array with length |
| 570 | 570 | equal to the byte count of the file given by `path`. The contents of the array |
| ... | ... | @@ -578,7 +578,7 @@ This function performs an atomic compare exchange operation. |
| 578 | 578 | |
| 579 | 579 | The `fence` function is used to introduce happens-before edges between operations. |
| 580 | 580 | |
| 581 | | ### @div_exact(a: T, b: T) -> T |
| 581 | ### @divExact(a: T, b: T) -> T |
| 582 | 582 | |
| 583 | 583 | This function performs integer division `a / b` and returns the result. |
| 584 | 584 | |
| ... | ... | @@ -608,13 +608,13 @@ const b: u8 = @truncate(u8, a); |
| 608 | 608 | // b is now 0xcd |
| 609 | 609 | ``` |
| 610 | 610 | |
| 611 | | ### @compile_err(inline msg: []u8) |
| 611 | ### @compileError(inline msg: []u8) |
| 612 | 612 | |
| 613 | 613 | This function, when semantically analyzed, causes a compile error with the message `msg`. |
| 614 | 614 | |
| 615 | 615 | There are several ways that code avoids being semantically checked, such as using `if` |
| 616 | 616 | or `switch` with compile time constants, and inline functions. |
| 617 | 617 | |
| 618 | | ### @int_type(inline is_signed: bool, inline bit_count: u8) -> type |
| 618 | ### @intType(inline is_signed: bool, inline bit_count: u8) -> type |
| 619 | 619 | |
| 620 | 620 | This function returns an integer type with the given signness and bit count. |