From 91860485774924e82da9b0774179d4c3c8da810a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 31 Jul 2026 14:45:04 +0100 Subject: Use transient-0 instead of flatbuffers --- .../transient0/HobgoblinTransient0Sourcetext.java | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/transient-0/java/org/zwobble/sourcetext/transient0/HobgoblinTransient0Sourcetext.java (limited to 'src/transient-0/java/org/zwobble') diff --git a/src/transient-0/java/org/zwobble/sourcetext/transient0/HobgoblinTransient0Sourcetext.java b/src/transient-0/java/org/zwobble/sourcetext/transient0/HobgoblinTransient0Sourcetext.java new file mode 100644 index 00000000..75b369ae --- /dev/null +++ b/src/transient-0/java/org/zwobble/sourcetext/transient0/HobgoblinTransient0Sourcetext.java @@ -0,0 +1,95 @@ +// Generated by hobgoblin. + +package org.zwobble.sourcetext.transient0; + +// Custom area start: org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext imports +import org.shedlang.compiler.transient0.HobgoblinTransient0Builtins; +import org.shedlang.compiler.transient0.HobgoblinTransient0TaggedSharedValue; +import org.zwobble.sourcetext.SourceText; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +// Custom area end: org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext imports + +public final class HobgoblinTransient0Sourcetext { + public static void encodeSourceRange(org.zwobble.sourcetext.SourceRange value, java.io.OutputStream outputStream, java.util.Map sharedValues) throws java.io.IOException { + { + var existingId = sharedValues.get(new org.shedlang.compiler.transient0.HobgoblinTransient0TaggedSharedValue(0, value.sourceText())); + if (existingId != null) { + org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.encodeInt64(existingId, outputStream, sharedValues); + } else { + org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.encodeInt64(sharedValues.size(), outputStream, sharedValues); + sharedValues.put(new org.shedlang.compiler.transient0.HobgoblinTransient0TaggedSharedValue(0, value.sourceText()), (long) sharedValues.size()); + org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.encodeSourceText(value.sourceText(), outputStream, sharedValues); + } + } + org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.encodeSourcePosition(value.start(), outputStream, sharedValues); + org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.encodeSourcePosition(value.end(), outputStream, sharedValues); + } + + public static org.zwobble.sourcetext.SourceRange decodeSourceRange(java.io.InputStream inputStream, java.util.List sharedValues) throws java.io.IOException { + var sourceText$id = org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.decodeInt64(inputStream, sharedValues); + org.zwobble.sourcetext.SourceText sourceText; + if (sourceText$id < sharedValues.size()) { + sourceText = (org.zwobble.sourcetext.SourceText) sharedValues.get((int) sourceText$id); + } else { + var sourceText$decodedValue = org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.decodeSourceText(inputStream, sharedValues); + sharedValues.add(sourceText$decodedValue); + sourceText = sourceText$decodedValue; + } + var start = org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.decodeSourcePosition(inputStream, sharedValues); + var end = org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.decodeSourcePosition(inputStream, sharedValues); + return new org.zwobble.sourcetext.SourceRange(sourceText, start, end); + } + + public static void encodeSourcePosition(org.zwobble.sourcetext.SourcePosition value, java.io.OutputStream outputStream, java.util.Map sharedValues) throws java.io.IOException { + { + var existingId = sharedValues.get(new org.shedlang.compiler.transient0.HobgoblinTransient0TaggedSharedValue(0, value.sourceText())); + if (existingId != null) { + org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.encodeInt64(existingId, outputStream, sharedValues); + } else { + org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.encodeInt64(sharedValues.size(), outputStream, sharedValues); + sharedValues.put(new org.shedlang.compiler.transient0.HobgoblinTransient0TaggedSharedValue(0, value.sourceText()), (long) sharedValues.size()); + org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.encodeSourceText(value.sourceText(), outputStream, sharedValues); + } + } + org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.encodeInt32(value.characterIndex(), outputStream, sharedValues); + } + + public static org.zwobble.sourcetext.SourcePosition decodeSourcePosition(java.io.InputStream inputStream, java.util.List sharedValues) throws java.io.IOException { + var sourceText$id = org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.decodeInt64(inputStream, sharedValues); + org.zwobble.sourcetext.SourceText sourceText; + if (sourceText$id < sharedValues.size()) { + sourceText = (org.zwobble.sourcetext.SourceText) sharedValues.get((int) sourceText$id); + } else { + var sourceText$decodedValue = org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext.decodeSourceText(inputStream, sharedValues); + sharedValues.add(sourceText$decodedValue); + sourceText = sourceText$decodedValue; + } + var characterIndex = org.shedlang.compiler.transient0.HobgoblinTransient0Builtins.decodeInt32(inputStream, sharedValues); + return new org.zwobble.sourcetext.SourcePosition(sourceText, characterIndex); + } + + // Custom area start: org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext body + private static void encodeSourceText( + SourceText sourceText, + OutputStream outputStream, + Map sharedValues + ) throws IOException { + HobgoblinTransient0Builtins.encodeString(sourceText.name(), outputStream, sharedValues); + HobgoblinTransient0Builtins.encodeString(sourceText.charSequence().toString(), outputStream, sharedValues); + } + + private static SourceText decodeSourceText( + InputStream inputStream, + List sharedValues + ) throws IOException { + var name = HobgoblinTransient0Builtins.decodeString(inputStream, sharedValues); + var contents = HobgoblinTransient0Builtins.decodeString(inputStream, sharedValues); + return SourceText.fromString(name, contents); + } + // Custom area end: org.zwobble.sourcetext.transient0.HobgoblinTransient0Sourcetext body +} -- cgit v1.2.3