diff --git a/.run/spice build.run.xml b/.run/spice build.run.xml index d2a017fdc..018d2e961 100644 --- a/.run/spice build.run.xml +++ b/.run/spice build.run.xml @@ -1,5 +1,5 @@ - + diff --git a/docs/docs/how-to/web-assembly.md b/docs/docs/how-to/web-assembly.md index ec8111f67..09a0d8f34 100644 --- a/docs/docs/how-to/web-assembly.md +++ b/docs/docs/how-to/web-assembly.md @@ -1,5 +1,5 @@ --- -title: Compile to WebAssembly +title: Compile for WebAssembly --- Due to the fact, that Spice uses LLVM as compiler backbone, it is capable of cross-compiling to many different target @@ -17,14 +17,11 @@ package. On Windows you can download MinGW64 with Clang from e.g. [winlibs.com]( For the sake of example, we write a recursive fibonacci algorithm in Spice, which we can make accessible to JavaScript. ```spice +#[core.compiler.mangle = false] public f fibo(int n) { if n <= 1 { return n; } return fibo(n - 1) + fibo(n - 2); } - -f main() { - printf("%d", fibo(45)); -} ``` You can test, if the code works by compiling and running it, using the following command:
diff --git a/media/test-project/test.spice b/media/test-project/test.spice index 877fedc09..12351122d 100644 --- a/media/test-project/test.spice +++ b/media/test-project/test.spice @@ -1,6 +1,5 @@ -import "std/os/syscall"; - -f main() { - string str = "Hello World!\n"; - syscallWrite(FileDescriptor::STDOUT, str); +#[core.compiler.mangle = false] +public f fibo(int n) { + if n <= 1 { return n; } + return fibo(n - 1) + fibo(n - 2); }