diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-31 14:45:04 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-31 15:22:40 +0100 |
| commit | 91860485774924e82da9b0774179d4c3c8da810a (patch) | |
| tree | e06f52f147502e80aea139c20adac706479cb7ea /src/transient-0/java/org/zwobble/sourcetext | |
| parent | 410fff7b7ecf6f36a0a46ab1d90553169e3728f1 (diff) | |
Use transient-0 instead of flatbuffersmain
Diffstat (limited to 'src/transient-0/java/org/zwobble/sourcetext')
| -rw-r--r-- | src/transient-0/java/org/zwobble/sourcetext/transient0/HobgoblinTransient0Sourcetext.java | 95 |
1 files changed, 95 insertions, 0 deletions
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<org.shedlang.compiler.transient0.HobgoblinTransient0TaggedSharedValue, java.lang.Long> 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<java.lang.Object> 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<org.shedlang.compiler.transient0.HobgoblinTransient0TaggedSharedValue, java.lang.Long> 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<java.lang.Object> 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<HobgoblinTransient0TaggedSharedValue, Long> sharedValues + ) throws IOException { + HobgoblinTransient0Builtins.encodeString(sourceText.name(), outputStream, sharedValues); + HobgoblinTransient0Builtins.encodeString(sourceText.charSequence().toString(), outputStream, sharedValues); + } + + private static SourceText decodeSourceText( + InputStream inputStream, + List<Object> 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 +} |
