diff options
| author | Yong He <yonghe@outlook.com> | 2025-04-28 11:42:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-28 11:42:22 -0700 |
| commit | c39c29bf4c52a85d7c83cc8b66ae45e265f9e078 (patch) | |
| tree | 969339828d49d7db92ed9294a17bd34cc021db84 /tests/byte-code/composite.slang | |
| parent | 8f6c6e333c06ae1c3b9f00396563c14a2ae09b4d (diff) | |
Add Slang Byte Code generation and interpreter. (#6896)
* Add Slang Byte Code generation and interpreter.
* Fix compile issues.
* format code
* More compile fix.
* Fix clang issue.
* Fix more clang issues.
* Another clang fix.
* Fix clang issues.
* Fix another clang issue.
* Fix wasm build.
* Update building.md
* Fix test-server.
* Fix compile error.
* Fix bug.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests/byte-code/composite.slang')
| -rw-r--r-- | tests/byte-code/composite.slang | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/byte-code/composite.slang b/tests/byte-code/composite.slang new file mode 100644 index 000000000..41729b6c2 --- /dev/null +++ b/tests/byte-code/composite.slang @@ -0,0 +1,34 @@ +//TEST:INTERPRET(filecheck=CHECK): +struct Inner +{ + int header; + int array[3]; +} +struct MyType +{ + float3 value1; + float3 value2; + Inner inner; +} +MyType getValue() +{ + MyType t = { float3(1, 2, 3), float3(-1,-2, 3), { 4, { 5, 6, 7 } } }; + return t; +} +int main() +{ + var t = getValue(); + int sum = 0; + for (int i = 0; i < 3; ++i) + { + sum += t.inner.array[i]; + } + t.value1 += t.value2; + for (int i = 0; i < 3; i++) + { + sum += (int)t.value1[i]; + } + //CHECK: 24 + printf("%d\n", sum); + return 0; +} |
