1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
}
|