diff options
| author | Baitinq <[email protected]> | 2025-04-01 20:31:36 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-04-01 20:31:36 +0200 |
| commit | 36b1571bc9307263e83fb03b3ba4cf9f116b98a7 (patch) | |
| tree | fc12949c3b4ca5ea35b5bcdeb8c0dfee8a54e3e1 /examples | |
| parent | Feature: Add basic support for pointer references and dereferences (diff) | |
| download | interpreter-36b1571bc9307263e83fb03b3ba4cf9f116b98a7.tar.gz interpreter-36b1571bc9307263e83fb03b3ba4cf9f116b98a7.tar.bz2 interpreter-36b1571bc9307263e83fb03b3ba4cf9f116b98a7.zip | |
Codegen: Start supporting pointer arithmetic
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/18.src | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/18.src b/examples/18.src new file mode 100644 index 0000000..90234c4 --- /dev/null +++ b/examples/18.src @@ -0,0 +1,16 @@ +extern printf = (*i64, varargs) => void; +extern malloc = (i64) => *i64; +extern free = (*i64) => void; + +let main = () => i64 { + let x = malloc(128); + /* + *(x+0) = 10; + *(x+8) = 20; + */ + printf("%p\n", x); + printf("%d\n", *x); + printf("%d\n", *(x+1)); + free(x); + return 0; +}; |