Compare commits
1 Commits
2039d11e19
...
7a8b1baa25
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a8b1baa25 |
68
README.md
68
README.md
@ -6,11 +6,39 @@ Elevator pitch
|
|||||||
A programming language, that looks like Python, handles like Haskell,
|
A programming language, that looks like Python, handles like Haskell,
|
||||||
and compiles directly to WebAssembly.
|
and compiles directly to WebAssembly.
|
||||||
|
|
||||||
Name origin
|
Project state
|
||||||
-----------
|
-------------
|
||||||
- p from python
|
This is a hobby project for now. Use at your own risk.
|
||||||
- ha from Haskell
|
|
||||||
- asm from WebAssembly
|
How to run
|
||||||
|
----------
|
||||||
|
You should only need make and python3. Currently, we're working with python3.8,
|
||||||
|
since we're using the python ast parser, it might not work on other versions.
|
||||||
|
|
||||||
|
To run the examples:
|
||||||
|
```sh
|
||||||
|
make examples
|
||||||
|
```
|
||||||
|
|
||||||
|
To run the tests:
|
||||||
|
```sh
|
||||||
|
make test
|
||||||
|
```
|
||||||
|
|
||||||
|
To run the linting and type checking:
|
||||||
|
```sh
|
||||||
|
make lint typecheck
|
||||||
|
```
|
||||||
|
|
||||||
|
To compile a Phasm file:
|
||||||
|
```sh
|
||||||
|
python3.8 -m phasm source.py output.wat
|
||||||
|
```
|
||||||
|
|
||||||
|
Additional required tools
|
||||||
|
-------------------------
|
||||||
|
At the moment, the compiler outputs WebAssembly text format. To actually
|
||||||
|
get a binary, you will need the wat2wasm tool[6].
|
||||||
|
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
@ -38,32 +66,34 @@ Gotcha's
|
|||||||
- When importing and exporting unsigned values to WebAssembly, they will become
|
- When importing and exporting unsigned values to WebAssembly, they will become
|
||||||
signed, as WebAssembly has no native unsigned type. You may need to cast
|
signed, as WebAssembly has no native unsigned type. You may need to cast
|
||||||
or reinterpret them.
|
or reinterpret them.
|
||||||
|
- Currently, Phasm files have the .py extension, which helps with syntax
|
||||||
|
highlighting, that might change in the future.
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
At this time, I'm mostly looking for use cases for WebAssembly, other than to
|
At this time, we're mostly looking for use cases for WebAssembly, other than to
|
||||||
compile existing C code and running them in the browser. The goal of WebAssembly
|
compile existing C code and running them in the browser. The goal of WebAssembly
|
||||||
is to enable high-performance applications on web pages[5]. Though most people
|
is to enable high-performance applications on web pages[5]. Though most people
|
||||||
seem to use it to have existing code run in the browser.
|
seem to use it to have existing code run in the browser.
|
||||||
|
|
||||||
If you have a situation where WebAssembly would be useful for it's speed, I'm
|
If you have a situation where WebAssembly would be useful for it's speed, we're
|
||||||
interested to see what you want to use it for.
|
interested to see what you want to use it for.
|
||||||
|
|
||||||
Also, if you are trying out Phasm, and you're running into a limitation, I'm
|
Also, if you are trying out Phasm, and you're running into a limitation, we're
|
||||||
interested in a minimal test case that shows what you want to achieve and how
|
interested in a minimal test case that shows what you want to achieve and how
|
||||||
Phasm currently fails you.
|
Phasm currently fails you.
|
||||||
|
|
||||||
Additional required tools
|
Name origin
|
||||||
-------------------------
|
-----------
|
||||||
At the moment, the compiler outputs WebAssembly text format. To actually
|
- p from python
|
||||||
get a binary, you will need the wat2wasm tool[6].
|
- ha from Haskell
|
||||||
.
|
- asm from WebAssembly
|
||||||
|
|
||||||
References
|
References
|
||||||
----------
|
----------
|
||||||
[1] https://www.python.org/
|
[1] https://www.python.org/
|
||||||
[2] https://www.haskell.org/
|
[2] https://www.haskell.org/
|
||||||
[3] https://webassembly.org/
|
[3] https://webassembly.org/
|
||||||
[4] https://www.w3.org/TR/wasm-core-1/
|
[4] https://www.w3.org/TR/wasm-core-1/
|
||||||
[5] https://en.wikipedia.org/w/index.php?title=WebAssembly&oldid=1103639883
|
[5] https://en.wikipedia.org/w/index.php?title=WebAssembly&oldid=1103639883
|
||||||
[6] https://github.com/WebAssembly/wabt
|
[6] https://github.com/WebAssembly/wabt
|
||||||
|
|||||||
2
TODO.md
2
TODO.md
@ -4,3 +4,5 @@
|
|||||||
- Implement a proper type matching / checking system
|
- Implement a proper type matching / checking system
|
||||||
- Check if we can use DataView in the Javascript examples, e.g. with setUint32
|
- Check if we can use DataView in the Javascript examples, e.g. with setUint32
|
||||||
- Storing u8 in memory still claims 32 bits (since that's what you need in local variables). However, using load8_u / loadu_s we can optimize this.
|
- Storing u8 in memory still claims 32 bits (since that's what you need in local variables). However, using load8_u / loadu_s we can optimize this.
|
||||||
|
- Implement a FizzBuzz example
|
||||||
|
- Also, check the codes for FIXME and TODO
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
def helper(n: i64, a: i64, b: i64) -> i64:
|
def helper(n: u64, a: u64, b: u64) -> u64:
|
||||||
if n < 1:
|
if n < 1:
|
||||||
return a + b
|
return a + b
|
||||||
|
|
||||||
return helper(n - 1, a + b, a)
|
return helper(n - 1, a + b, a)
|
||||||
|
|
||||||
@exported
|
@exported
|
||||||
def fib(n: i64) -> i64:
|
def fib(n: u64) -> u64:
|
||||||
if n == 0:
|
if n == 0:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -15,5 +15,5 @@ def fib(n: i64) -> i64:
|
|||||||
return helper(n - 1, 0, 1)
|
return helper(n - 1, 0, 1)
|
||||||
|
|
||||||
@exported
|
@exported
|
||||||
def testEntry() -> i64:
|
def testEntry() -> u64:
|
||||||
return fib(40)
|
return fib(40)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user