Commit Graph

204 Commits

Author SHA1 Message Date
David Mak ffcae46bd8 core: WIP - exp and log works now 2024-04-30 16:10:38 +08:00
David Mak b2cdc90e02 core: WIP - sin and cos works now 2024-04-29 23:22:48 +08:00
David Mak e4a5eb4782 core: WIP - isnan and isinf works now 2024-04-29 23:22:48 +08:00
David Mak 14164c332d core: WIP - abs works now 2024-04-29 23:22:48 +08:00
David Mak 163867381a core: WIP - floor and ceil works now 2024-04-29 23:22:48 +08:00
David Mak 37a29162c6 core: WIP - round works now 2024-04-29 23:22:48 +08:00
David Mak 92a40c4b6e core: WIP - float and bool works now 2024-04-29 23:22:48 +08:00
David Mak 5f7cac1c97 core: WIP - int64, uint32 and uint64 works now 2024-04-29 23:22:48 +08:00
David Mak 5ab59147ca core: WIP - int32 works now 2024-04-29 23:22:46 +08:00
David Mak fad0a308a0 standalone: Fix cbrt never tested 2024-04-25 15:46:27 +08:00
David Mak 0f2af3983b standalone: Add explicit `--` for delimiting run args vs NAC3 args 2024-04-25 15:46:27 +08:00
David Mak 847615fc2f core: Implement numpy.matmul for 2D-2D ndarrays 2024-04-23 10:27:37 +08:00
David Mak e0f440040c core/expr: Implement negative indices for ndarray 2024-04-15 12:49:42 +08:00
David Mak 52c731c312 core: Implement Not/UAdd/USub for booleans
Not sure if this is deliberate or an oversight, but we implement it
anyway for consistency with other Python implementations.
2024-04-12 18:29:58 +08:00
David Mak 00d1b9be9b core: Fix __inv__ for i8-based boolean operands 2024-04-12 15:35:54 +08:00
David Mak a920fe0501 core: Implement elementwise comparison operators 2024-04-03 00:07:33 +08:00
David Mak 727a1886b3 core: Implement elementwise unary operators 2024-04-03 00:07:33 +08:00
David Mak 6af13a8261 core: Implement elementwise binary operators
Including immediate variants of these operators.
2024-04-03 00:07:33 +08:00
David Mak fd44ee6887 core: Apply clippy suggestions 2024-03-22 15:07:23 +08:00
David Mak 2edc1de0b6 standalone: Update ndarray.py to output all elements in ndarrays 2024-03-07 14:59:13 +08:00
David Mak 96b7f29679 core: Implement `ndarray.fill` 2024-03-07 14:59:13 +08:00
David Mak 77de24ef74 core: Use BTreeMap for type variable mapping
There have been multiple instances where I had the need to iterate over
type variables, only to discover that the traversal order is arbitrary.

This commit fixes that by adding SortedMapping, which utilizes BTreeMap
internally to guarantee a traversal order. All instances of VarMap are
now refactored to use this to ensure that type variables are iterated in
 the order of its variable ID, which should be monotonically incremented
 by the unifier.
2024-03-04 23:56:04 +08:00
David Mak 8492503af2 core: Update cargo dependencies 2024-02-23 15:41:04 +08:00
David Mak 22e831cb76 core: Add test for indexing into ndarray 2024-02-19 17:13:10 +08:00
David Mak 5cecb2bb74 core: Fix Literal use in variable type annotation 2024-02-06 18:16:14 +08:00
David Mak fef4b2a5ce standalone: Disable tests requiring return of non-primitive values 2024-01-29 12:49:50 +08:00
David Mak af95ba5012 standalone: Add debug flag to run_demo.sh
Allows running demos using the debug build instead of the (default)
release build.
2024-01-25 15:50:53 +08:00
David Mak 9c9756be33 standalone: Use size_t in demo.c 2024-01-25 15:50:53 +08:00
David Mak c679474f5c standalone: Fix redefinition of ndarray consumer functions 2024-01-17 09:38:13 +08:00
Sébastien Bourdeauducq ab3fa05996 demo: use portable format strings 2024-01-10 18:35:35 +08:00
David Mak 140f8f8a08 core: Implement most ndarray-creation functions 2023-12-22 16:29:55 +08:00
David Mak 27fcf8926e core: Implement ndarray constructor and numpy.empty 2023-12-22 16:29:54 +08:00
David Mak bd792904f9 core: Add size_t to primitive store
Used for ndims in ndarray.
2023-12-21 15:20:31 +08:00
David Mak f01d833d48 standalone: Add missing parenthesis 2023-12-20 15:15:47 +08:00
David Mak 6dccb343bb Revert "core: Do not keep unification result for function arguments"
This reverts commit f09f3c27a5.
2023-12-18 10:01:23 +08:00
Sebastien Bourdeauducq d47534e2ad interpret_demo: add typing.Literal 2023-12-18 08:50:49 +08:00
David Mak 8886964776 core: Remove redundant argument in type annotation parsing 2023-12-16 18:40:48 +08:00
David Mak f09f3c27a5 core: Do not keep unification result for function arguments
For some reason, when unifying a function call parameter with an
argument, subsequent calls to the same function will only accept the
type of the substituted argument.

This affect snippets like:

```
def make1() -> C[Literal[1]]:
    return ...

def make2() -> C[Literal[2]]:
    return ...

def consume(instance: C[Literal[1, 2]]):
    pass

consume(make1())
consume(make2())
```

The last statement will result in a compiler error, as the parameter of
consume is replaced with C[Literal[1]].

We fix this by getting a snapshot before performing unification, and
restoring the snapshot after unification succeeds.
2023-12-16 18:40:48 +08:00
David Mak 457d3b6cd7 core: Refactor generic constants to `Literal`
Better matches the syntax of `typing.Literal`.
2023-12-16 18:40:48 +08:00
David Mak c7735d935b standalone: Output id of undefined identifier 2023-12-16 18:40:48 +08:00
David Mak a19f1065e3 meta: Refactor to use more let-else bindings 2023-12-12 16:31:14 +08:00
David Mak 32746c37be core: Refactor to return errors by HashSet 2023-12-12 15:41:59 +08:00
David Mak ddfb532b80 standalone: Apply clippy pedantic changes 2023-12-11 15:16:23 +08:00
David Mak 02933753ca core: Apply clippy pedantic changes 2023-12-11 15:16:23 +08:00
David Mak d304afd333 meta: Apply clippy suggested changes 2023-12-11 15:16:23 +08:00
David Mak 031e660f18 core: Initial implementation for const generics 2023-12-08 18:02:11 +08:00
David Mak 68b97347b1 core: Infer builtins name list using builtin declaration list 2023-12-08 17:29:34 +08:00
Sebastien Bourdeauducq adadf56e2b nac3standalone: generate PIC 2023-12-04 19:09:50 +08:00
Sebastien Bourdeauducq 98199768e3 demo: fix 64-bit format strings 2023-12-04 18:51:06 +08:00
Sebastien Bourdeauducq 120f8da5c7 fix compilation warnings 2023-11-26 09:09:24 +08:00