All Projects → SPY → idris-codegen-wasm

SPY / idris-codegen-wasm

Licence: other
WebAssembly Code Generation Backend for Idris Compiler

Programming Languages

haskell
3896 projects
HTML
75241 projects
WebAssembly
147 projects
typescript
32286 projects

Projects that are alternatives of or similar to idris-codegen-wasm

go-wasm-examples
Some small examples of using Go and WebAssembly
Stars: ✭ 22 (-72.15%)
Mutual labels:  webassembly, wasm
koder
QR/bar code scanner for the Browser
Stars: ✭ 73 (-7.59%)
Mutual labels:  webassembly, wasm
TypeScriptXX
🧷 Stay safe! Type-safe scripting for C++ using TypeScriptToLua and CMake with auto-generated declarations.
Stars: ✭ 33 (-58.23%)
Mutual labels:  webassembly, wasm
imgalign
Webapplication for image stitching and aligning
Stars: ✭ 162 (+105.06%)
Mutual labels:  webassembly, wasm
wapc-rust
Rust-based WebAssembly Host Runtime for waPC-compliant modules
Stars: ✭ 75 (-5.06%)
Mutual labels:  webassembly, wasm
vmrp
mrp emulator, virtual machine, mrp模拟器
Stars: ✭ 126 (+59.49%)
Mutual labels:  webassembly, wasm
warpy
WebAssembly interpreter in RPython
Stars: ✭ 54 (-31.65%)
Mutual labels:  webassembly, wasm
wasm-linker-js
A simple WebAssembly Linker in JavaScript
Stars: ✭ 14 (-82.28%)
Mutual labels:  webassembly, wasm
cabasa
Haxe Framework for WebAssembly
Stars: ✭ 30 (-62.03%)
Mutual labels:  webassembly, wasm
node-wasi
WASI for Node.js
Stars: ✭ 64 (-18.99%)
Mutual labels:  webassembly, wasm
fullstack-rust
Reference implementation of a full-stack Rust application
Stars: ✭ 39 (-50.63%)
Mutual labels:  webassembly, wasm
rustwasmc
Tool for building Rust functions for Node.js. Combine the performance of Rust, safety and portability of WebAssembly, and ease of use of JavaScript.
Stars: ✭ 97 (+22.78%)
Mutual labels:  webassembly, wasm
wasmsign2
PoC implementation of the WebAssembly Modules Signatures proposal.
Stars: ✭ 18 (-77.22%)
Mutual labels:  webassembly, wasm
rustexp
A Rust regular expression editor and tester that runs entirely within the browser!
Stars: ✭ 59 (-25.32%)
Mutual labels:  webassembly, wasm
jasper
🧳 Single-binary packaging for Ruby applications that supports native and Wasm targets
Stars: ✭ 29 (-63.29%)
Mutual labels:  webassembly, wasm
gearoenix
Cross-platform C++ 3D game engine.
Stars: ✭ 33 (-58.23%)
Mutual labels:  webassembly, wasm
vrcpu
Code, documentation, schematics, notes for my Ben Eater inspired breadboard computer and emulator
Stars: ✭ 98 (+24.05%)
Mutual labels:  webassembly, wasm
wasm-ops
Chart of WebAssembly Instructions
Stars: ✭ 46 (-41.77%)
Mutual labels:  webassembly, wasm
image-hub
Image Hub is a sample application for exploring WebAssembly modules used as Envoy filters.
Stars: ✭ 56 (-29.11%)
Mutual labels:  webassembly, wasm
block-aligner
SIMD-accelerated library for computing global and X-drop affine gap penalty sequence-to-sequence or sequence-to-profile alignments using an adaptive block-based algorithm.
Stars: ✭ 58 (-26.58%)
Mutual labels:  webassembly, wasm

Idris WebAssembly CodeGen

It is still on early stages of development.

Implemented

  • Control flow instructions
  • Garbadge Collection
  • String representation and implementation of primitive operations in RTS(with UTF8 support)
  • Char and native int operations
  • Double operations
  • Bit8/16/32/64 operations
  • Convertions (int to big num, bits to int, etc)
  • Unwrap self-tail calls with LOOP instruction
  • Effective unboxed representation for int and char
  • Effective substrings representation as StrOffset

Todo

  • BigNum primitives(now they are emulated as WASM i64 number)
  • Pass Idris language test suite
  • FFI and Idris-level support for new back-end

Build

Current implementation fully depends on haskell-wasm. To build you need clone idris-codegen-wasm

cd ./idris-codegen-wasm && cabal build

Sample code fully functioning now

module Main

factorial : Int -> Int
factorial 0 = 1
factorial n = n * factorial (n - 1)

range : Int -> Int -> List Int
range from to = if from == to then [to] else from :: range (from + 1) to

moreThan : Int -> Int -> Maybe Int
moreThan lowLimit n = if n >= lowLimit then Just n else Nothing

main : IO ()
main = do
    let hello = "Hello"
    let world = "Мир"
    -- long string to trigger GC
    let longString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
    putStrLn $ show $ range 1 10
    putStrLn $ show $ split (== ' ') longString
    putStrLn $ hello ++ strCons ' ' world
    putStrLn $ show $ sum $ range 0 256
    putStrLn $ show $ fromMaybe 42 $ moreThan 88 $ factorial 5

To build it run:

idris fact.idr --codegen wasm -o fact.wasm

For running compiled code you can use runner from rts/index.html. It contains some bootstrap code and simple tools for runtime introspection(print const section, stack, heap, fallback GC implementation, etc).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].