diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-28 20:30:06 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-28 20:30:06 +0100 |
| commit | 42c1a57cd441d1cefd0aea277758b5be83ecf97e (patch) | |
| tree | 58212aafa7f83e1bdcffcf20cb95c55d44120b3d | |
| parent | 9175d04b0652327aa4e52272b1aacad25d24ee38 (diff) | |
Fix endianness of string lengths
3 files changed, 4 insertions, 2 deletions
diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:canHaveMultipleStrings(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:canHaveMultipleStrings(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 0bc8c636..13467187 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:canHaveMultipleStrings(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:canHaveMultipleStrings(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -14,7 +14,7 @@ Code[1]: - func[0] size=14 <f> Data[1]: - segment[0] <.data> memory=0 size=21 - init i32=0 - - 0000000: 0000 0005 6865 6c6c 6f00 0000 0000 0005 ....hello....... + - 0000000: 0500 0000 6865 6c6c 6f00 0000 0500 0000 ....hello....... - 0000010: 776f 726c 64 world Custom: - name: "linking" diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:pushStringIsCompiledToDataAndIndexToData(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:pushStringIsCompiledToDataAndIndexToData(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 914b6ce4..59ded219 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:pushStringIsCompiledToDataAndIndexToData(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.backends.wasm.WasmCodeGenPushStringTests]/[method:pushStringIsCompiledToDataAndIndexToData(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -14,7 +14,7 @@ Code[1]: - func[0] size=8 <f> Data[1]: - segment[0] <.data> memory=0 size=9 - init i32=0 - - 0000000: 0000 0005 6865 6c6c 6f ....hello + - 0000000: 0500 0000 6865 6c6c 6f ....hello Custom: - name: "linking" - segment info [count=1] diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/WasmCodeGenStrings.java b/src/main/java/org/shedlang/compiler/backends/wasm/WasmCodeGenStrings.java index 29fda47d..a7266091 100644 --- a/src/main/java/org/shedlang/compiler/backends/wasm/WasmCodeGenStrings.java +++ b/src/main/java/org/shedlang/compiler/backends/wasm/WasmCodeGenStrings.java @@ -4,6 +4,7 @@ import org.shedlang.compiler.backends.wasm.structure.ast.linking.WasmMemoryAddre import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmAlignment; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; public class WasmCodeGenStrings { @@ -16,6 +17,7 @@ public class WasmCodeGenStrings { ) { var codeUnits = value.getBytes(StandardCharsets.UTF_8); var data = ByteBuffer.allocate(4 + codeUnits.length); + data.order(ByteOrder.LITTLE_ENDIAN); data.putInt(codeUnits.length); data.put(codeUnits); |
