-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SirJosh3917
authored and
SirJosh3917
committed
Sep 6, 2020
1 parent
19a57f7
commit 3ca198e
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# File Descriptors | ||
File Descriptors (witx type `fd`) are an abstract way of representing access to a resource. More often than not, they are processes (WIP), sockets (WIP), files, or even the console. | ||
|
||
# Null File Descriptor | ||
A File Descriptor of 0 is a null file descriptor. It's used whenever there is *no* file descriptor. Passing this to a method is a no-no, and receiving one from a method must be handled. | ||
|
||
# The Console | ||
When a program is initiated, `stdout`, `stdin`, and `stderr` (respectively `fd` ids `1`, `2`, and `3`) are opened. To print to these, simply call `fd_write` with the corresponding arguments. An simple "Hello World!" program written in `wat` is shown below: | ||
|
||
```wat | ||
(module | ||
;; TODO: small hello world? | ||
) | ||
``` | ||
|
||
# Files | ||
Files can be opened and closed with the commands `fd_open` and `fd_close` respectively. These commands will fail if the WASM environment did not give the program permission to execute these. |