From 4844cebd56b423bfb36d562e2740505c7d49f8c6 Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 28 Jul 2025 01:06:38 +0300 Subject: [PATCH] Update documentation and readme --- README.md | 4 ++-- documentation/README.md | 6 ++++++ documentation/intrinsics.md | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 documentation/intrinsics.md diff --git a/README.md b/README.md index c2ecf1b..e5a8f35 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ contains the relevant abstraction to produce a more Rust'y API from that. Much of the syntax in Reid is directly inspired by rust, but mostly it is driven by simplicity. -Specifications and documentation for the language can be found -[here](./documentation/). +Specifications and a bunch of [documentation for the language can be found +here](./documentation/). Reid is currently able to (non-exhaustively): - Do basic algebra binary and unary-operations (e.g. Add, Sub, Div, Mult, And, diff --git a/documentation/README.md b/documentation/README.md index 7bdd8aa..55b691b 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -18,6 +18,12 @@ A collection of documentation and examples to get you going can be found at [the Book of Reid](./book.md). It is recommended you read through the chapter about Syntax first though to familiarize yourself with the basic concepts of Reid. +## Intrinsics + +Reid also has intrinsic functions that are good to know about. These are more +in-depth, but when you're feeling up to it, you can read about them +[here](./intrinsics.md). + ## Syntax and general information Syntax for Reid is very much inspired by rust, and examples of the language can diff --git a/documentation/intrinsics.md b/documentation/intrinsics.md new file mode 100644 index 0000000..59aa81b --- /dev/null +++ b/documentation/intrinsics.md @@ -0,0 +1,28 @@ +## Intrinsics + +Intrinsics are functions that are defined within the language compiler but not +in standard library, thus they do not require importing in order to use (and +trying to re-define these will end up causing issues). Intrinsics include all +pre-existing binary-operators, but also some regular functions and associated +functions (that every type has by-default). This document lists them all (except +for the binary operators, because there are hundreds of those). + +### Associated Intrinsics + +#### `::sizeof() -> u64` + +Simply returns the size of type `T` in bits. + +```rust +i32::sizeof(); // Returns 32 +``` + +#### `::alloca(size: u64) -> *T` + +Allocates `T::sizeof() * size` bits and returns a pointer to `T`. + +**Note:** This does not seem to work correctly currently. + +```rust +i32::alloca(30); // Returns *i32 +``` \ No newline at end of file