From 0a8f4e1d8f96447faaa94f9df246bb5ae30a22bb Mon Sep 17 00:00:00 2001 From: Dennis Ranke Date: Sat, 6 Nov 2021 11:51:40 +0100 Subject: [PATCH] add license and initial README.md --- Cargo.toml | 1 + LICENSE | 19 +++++++++++++++++++ README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/Cargo.toml b/Cargo.toml index 54c1a1b..3e67c2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "curlywas" version = "0.1.0" edition = "2021" +license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3d59d27 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright 2021 Dennis Ranke + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e6f8a0b --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# CurlyWas + +CurlyWas is a (still WIP) curly-braces, infix synatx for WebAssembly. +The goal is to have as to a 1:1 mapping to the resulting wasm instructions +as possible while still being reasonably convenient to write. + +For this reason alone (and in no way because I'm a little lazy) does this +compiler not implement any optimizations except for constant folding. + +## Example + +```rust +import "env.memory" memory(4); +import "math.sin" fn sin(f32) -> f32; +import "math.atan2" fn atan2(f32, f32) -> f32; + +export fn tic(time: i32) { + let i: i32; + loop screen { + let defer t = time as f32 / 2000 as f32; + let defer o = sin(t) * 0.8; + let defer q = (i % 320) as f32 - 160.1; + let defer w = (i / 320 - 128) as f32; + let defer r = sqrt(q*q + w*w); + let defer z = q / r; + let defer s = z * o + sqrt(z * z * o * o + 1 as f32 - o * o); + let defer q2 = (z * s - o) * 10 as f32 + t; + let defer w2 = w / r * s * 10 as f32 + t; + let defer s2 = s * 50 as f32 / r; + i?120 = max( + 0 as f32, + ((q2 as i32 ^ w2 as i32 & ((s2 + t) * 20 as f32) as i32) & 5) as f32 * + (2 as f32 - s2) * 22 as f32 + ) as i32; + branch_if (i := i + 1) < 320*256: screen + } +} +``` + +You can compile this to `technotunnel.wasm` with the command + +``` +curlywas technotunnel.cwa +``` + +Then run it on [MicroW8](https://exoticorn.github.io/microw8/v0.1pre1) \ No newline at end of file