aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-27 16:38:46 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-27 16:38:46 +0000
commit02d268ef9d0e42db38715f796621962f7d47c4a6 (patch)
treea0a00cdaacbe162afc13030554758a99efb79541 /src/test/java
parent099e5501ad29a5db8411973e7dbf5f61dfda33f0 (diff)
Fix writing of int data elements for wasm64
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
index 2972384d..d25aa5a9 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
@@ -50,6 +50,45 @@ public abstract class PatioExampleTests {
}
@Test
+ public void canLoadIntFromMiddleOfDataElement() throws IOException, InterruptedException {
+ var patioDataElement = new PatioDataElementImmutable(
+ "answer",
+ PatioDataValues.struct(List.of(
+ PatioDataValues.int_(37),
+ PatioDataValues.int_(42),
+ PatioDataValues.int_(47)
+ )),
+ Sources.NULL
+ );
+ var patioFunction = PatioFunctionDefinition.builder()
+ .withName(FUNCTION_NAME)
+ .withReturnType(PatioTypes.INT)
+ .addLocal(Patio.val("x", PatioTypes.INT))
+ .addBodyInstruction(Patio.memoryLoad(
+ Patio.localRef("x"),
+ Patio.dataPtr("answer"),
+ PatioDataLayouts.struct(List.of(
+ PatioDataLayouts.INT,
+ PatioDataLayouts.INT,
+ PatioDataLayouts.INT
+ )),
+ List.of(1)
+ ))
+ .addBodyInstruction(Patio.return_(
+ Patio.localRef("x")
+ ))
+ .build();
+ var patio = Patio.compilationUnit(List.of(
+ patioDataElement,
+ patioFunction
+ ));
+
+ var result = run(patio);
+
+ assertThat(result, isSilentExit(42));
+ }
+
+ @Test
public void allocStack() throws IOException, InterruptedException {
var patioFunction = PatioFunctionDefinition.builder()
.withName(FUNCTION_NAME)