aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-03-21 12:45:59 +0000
committerMichael Williamson <mike@zwobble.org>2026-03-21 12:45:59 +0000
commitf0e1c8c32732ea37e508fae3ff5d5cf085042733 (patch)
tree4d858208ee4ad8d269de0be9f5a1da7bfbd027c8 /src
parentbef5f2a093007b4554c1746d1af550b64272dd34 (diff)
Serialize Patio mutable data element declaration
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/shedlang/compiler/patio/protobuf/PatioToProtobuf.java7
-rw-r--r--src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java15
2 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/protobuf/PatioToProtobuf.java b/src/main/java/org/shedlang/compiler/patio/protobuf/PatioToProtobuf.java
index 9ed1789e..71e74967 100644
--- a/src/main/java/org/shedlang/compiler/patio/protobuf/PatioToProtobuf.java
+++ b/src/main/java/org/shedlang/compiler/patio/protobuf/PatioToProtobuf.java
@@ -80,7 +80,11 @@ public class PatioToProtobuf {
);
case DATA_ELEMENT_MUTABLE_DECLARATION ->
- throw new UnsupportedOperationException("TODO");
+ new PatioDataElementMutableDeclaration(
+ elementProtobuf.getDataElementMutableDeclaration().getName(),
+ deserializeDataLayout(elementProtobuf.getDataElementMutableDeclaration().getLayout()),
+ deserializeSource(elementProtobuf.getDataElementMutableDeclaration().getSource(), parentSource)
+ );
case DATA_ELEMENT_MUTABLE_DEFINITION ->
throw new UnsupportedOperationException("TODO");
@@ -109,6 +113,7 @@ public class PatioToProtobuf {
var builder = PatioProtobuf.PatioDataElementMutableDeclaration.newBuilder();
builder.setSource(serializeSource(element.source(), parentSource));
builder.setName(element.name());
+ builder.setLayout(serializeDataLayout(element.layout()));
return builder.build();
}
diff --git a/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java b/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java
index ceb14468..6aac1e0e 100644
--- a/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java
@@ -34,6 +34,21 @@ public class PatioToProtobufTests {
assertThat(deserializedElement, equalTo(element));
}
+ @Test
+ public void canSerializeDataElementMutableDeclaration() {
+ var element = Patio.dataElementMutableDeclaration(
+ "x",
+ PatioDataLayouts.INT
+ );
+
+ var deserializedElement = PatioToProtobuf.deserializeCompilationUnitElement(
+ PatioToProtobuf.serializeCompilationUnitElement(element, Sources.NULL),
+ Sources.NULL
+ );
+
+ assertThat(deserializedElement, equalTo(element));
+ }
+
// == Data ptr values ==
@Test