summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java12
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java16
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java16
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java48
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java10
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java10
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPath.java121
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegment.java57
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpression.java95
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegment.java66
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java10
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java10
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePath.java100
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegment.java65
16 files changed, 244 insertions, 396 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java
index 5ad86de..1b05b47 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java
@@ -36,7 +36,7 @@ public class RustGenerator {
return switch (type) {
case ConstructedNativeType constructedNativeType -> {
// TODO: avoid cast
- var rustType = (RustTypePath) generateRustTypeExpression(
+ var rustType = (RustPath) generateRustTypeExpression(
constructedNativeType.constructor().genericType()
);
var rustArgs = constructedNativeType.args().stream()
@@ -83,13 +83,13 @@ public class RustGenerator {
}
private RustType generateTypePath(NamespaceName namespaceName, String typeName) {
- var segments = new ArrayList<RustTypePathSegment>();
- segments.add(RustTypePathSegment.crate());
+ var segments = new ArrayList<RustPathSegment>();
+ segments.add(RustPathSegment.crate());
for (var moduleName : this.namespaceNameToRustCrateModulePath(namespaceName)) {
- segments.add(RustTypePathSegment.of(moduleName));
+ segments.add(RustPathSegment.of(moduleName));
}
- segments.add(RustTypePathSegment.of(generateTypeName(typeName)));
- return new RustTypePath(segments);
+ segments.add(RustPathSegment.of(generateTypeName(typeName)));
+ return new RustPath(segments);
}
public List<RustIdentifier> namespaceNameToRustCrateModulePath(NamespaceName namespaceName) {
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java
index d8851c4..7a6af2d 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java
@@ -1,7 +1,7 @@
package org.zwobble.hobgoblin.compiler.output.generators.rust;
import org.zwobble.hobgoblin.compiler.builtins.NativeTypes;
-import org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath;
+import org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath;
import org.zwobble.hobgoblin.compiler.parser.Parser;
import org.zwobble.hobgoblin.compiler.types.SimpleNativeType;
import org.zwobble.json5.reader.Json5ObjectReader;
@@ -41,7 +41,7 @@ public record RustGeneratorConfig(
// TODO: less hacky type representation
var rustTypeString = nativeTypeJson.getString("rust").value();
- var rustType = RustTypePath.of(rustTypeString);
+ var rustType = RustPath.of(rustTypeString);
nativeTypeConfigs.put(hobgoblinType, new RustNativeTypeConfig(rustType));
}
@@ -51,12 +51,12 @@ public record RustGeneratorConfig(
}
private static final Map<SimpleNativeType, RustNativeTypeConfig> DEFAULT_NATIVE_TYPE_CONFIGS = Map.ofEntries(
- Map.entry(NativeTypes.BOOL, new RustNativeTypeConfig(RustTypePath.primitive("bool"))),
- Map.entry(NativeTypes.INT_32, new RustNativeTypeConfig(RustTypePath.primitive("i32"))),
- Map.entry(NativeTypes.INT_64, new RustNativeTypeConfig(RustTypePath.primitive("i64"))),
- Map.entry(NativeTypes.STRING, new RustNativeTypeConfig(RustTypePath.global("std", "string", "String"))),
- Map.entry(NativeTypes.LIST_INNER, new RustNativeTypeConfig(RustTypePath.global("std", "vec", "Vec"))),
- Map.entry(NativeTypes.OPTION_INNER, new RustNativeTypeConfig(RustTypePath.global("std", "option", "Option")))
+ Map.entry(NativeTypes.BOOL, new RustNativeTypeConfig(RustPath.primitive("bool"))),
+ Map.entry(NativeTypes.INT_32, new RustNativeTypeConfig(RustPath.primitive("i32"))),
+ Map.entry(NativeTypes.INT_64, new RustNativeTypeConfig(RustPath.primitive("i64"))),
+ Map.entry(NativeTypes.STRING, new RustNativeTypeConfig(RustPath.global("std", "string", "String"))),
+ Map.entry(NativeTypes.LIST_INNER, new RustNativeTypeConfig(RustPath.global("std", "vec", "Vec"))),
+ Map.entry(NativeTypes.OPTION_INNER, new RustNativeTypeConfig(RustPath.global("std", "option", "Option")))
);
public Optional<RustNativeTypeConfig> nativeTypeConfig(SimpleNativeType type) {
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java
index 7695bf4..279f944 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java
@@ -114,7 +114,7 @@ public class RustTypesGenerator implements Generator {
}
private static final RustOuterAttribute DERIVE_ATTRIBUTE = new RustOuterAttribute(
- RustTypePath.of("derive"),
+ RustPath.of("derive"),
Optional.of("(Debug, PartialEq)")
);
@@ -158,7 +158,7 @@ public class RustTypesGenerator implements Generator {
var variantType = generateRustTypeExpression(variant.type(), context);
if (variant.isBox()) {
- variantType = RustTypePath.global("std", "boxed", "Box")
+ variantType = RustPath.global("std", "boxed", "Box")
.withArgs(List.of(variantType));
}
@@ -183,8 +183,8 @@ public class RustTypesGenerator implements Generator {
var variantType = generateRustTypeExpression(variant.type(), context);
var variantName = this.rustGenerator.generateVariantName(variant.type().value());
var innerValueName = new RustIdentifier("value");
- RustExpression innerValue = new RustPathInExpression(List.of(
- new RustPathExprSegment(
+ RustExpression innerValue = new RustPath(List.of(
+ new RustPathSegment(
new RustPathIdentSegmentIdentifier(innerValueName),
Optional.empty()
)
@@ -192,25 +192,25 @@ public class RustTypesGenerator implements Generator {
if (variant.isBox()) {
innerValue = new RustCallExpression(
- RustPathInExpression.global("std", "boxed", "Box", "new"),
+ RustPath.global("std", "boxed", "Box", "new"),
List.of(innerValue)
);
}
var fromImpl = new RustTraitImpl(
- RustTypePath.global("std", "convert", "From")
+ RustPath.global("std", "convert", "From")
.withArgs(List.of(variantType)),
this.rustGenerator.generateRustTypeExpression(sumDefinition.type()),
List.of(
new RustFunction(
new RustIdentifier("from"),
List.of(new RustFunctionParam(innerValueName, variantType)),
- Optional.of(RustTypePath.selfType()),
+ Optional.of(RustPath.selfType()),
Optional.of(new RustBlockExpression(
List.of(),
Optional.of(
new RustCallExpression(
- RustPathInExpression.selfType(variantName),
+ RustPath.selfType(variantName),
List.of(innerValue)
)
)
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java
index 26a2737..9d6e2e0 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java
@@ -207,14 +207,14 @@ public class RustWriter implements AutoCloseable {
}
private void writeImpl(
- Optional<RustTypePath> implementedTrait,
+ Optional<RustPath> implementedTrait,
RustType type,
List<RustAssociatedItem> items
) throws IOException {
this.writer.write("impl ");
if (implementedTrait.isPresent()) {
- this.writeTypePath(implementedTrait.get());
+ this.writePath(implementedTrait.get());
this.writer.write(" for ");
}
@@ -264,7 +264,7 @@ public class RustWriter implements AutoCloseable {
private void writeOuterAttribute(RustOuterAttribute attribute) throws IOException {
this.writer.write("#[");
- this.writeTypePath(attribute.path());
+ this.writePath(attribute.path());
if (attribute.input().isPresent()) {
this.writer.write(attribute.input().get());
@@ -309,8 +309,8 @@ public class RustWriter implements AutoCloseable {
this.writeFieldExpression(fieldExpression);
}
- case RustPathInExpression pathInExpression -> {
- this.writePathInExpression(pathInExpression);
+ case RustPath path -> {
+ this.writePath(path);
}
case RustStructExpression structExpression -> {
@@ -362,7 +362,7 @@ public class RustWriter implements AutoCloseable {
}
private void writeStructExpression(RustStructExpression structExpression) throws IOException {
- this.writePathInExpression(structExpression.structPath());
+ this.writePath(structExpression.structPath());
this.writer.write(" {");
if (!structExpression.fieldValues().isEmpty()) {
@@ -392,28 +392,28 @@ public class RustWriter implements AutoCloseable {
writeImplTraitType(implTraitType);
}
- case RustTypePath typePath -> {
- writeTypePath(typePath);
+ case RustPath path -> {
+ writePath(path);
}
}
}
private void writeImplTraitType(RustImplTraitType implTraitType) throws IOException {
this.writer.write("impl ");
- this.writeTypePath(implTraitType.trait());
+ this.writePath(implTraitType.trait());
}
// == Paths ==
- private void writePathInExpression(RustPathInExpression pathInExpression) throws IOException {
+ private void writePath(RustPath path) throws IOException {
writeWithSeparator(
- pathInExpression.segments(),
- this::writePathExprSegment,
+ path.segments(),
+ this::writePathSegment,
() -> this.writer.write("::")
);
}
- private void writePathExprSegment(RustPathExprSegment segment) throws IOException {
+ private void writePathSegment(RustPathSegment segment) throws IOException {
writePathIdentSegment(segment.pathIdentSegment());
if (segment.args().isPresent()) {
@@ -428,28 +428,6 @@ public class RustWriter implements AutoCloseable {
}
}
- private void writeTypePath(RustTypePath typePath) throws IOException {
- writeWithSeparator(
- typePath.segments(),
- this::writeTypePathSegment,
- () -> this.writer.write("::")
- );
- }
-
- private void writeTypePathSegment(RustTypePathSegment segment) throws IOException {
- writePathIdentSegment(segment.pathIdentSegment());
-
- if (segment.args().isPresent()) {
- this.writer.write("<");
- writeWithSeparator(
- segment.args().get(),
- this::writeType,
- () -> this.writer.write(", ")
- );
- this.writer.write(">");
- }
- }
-
private void writePathIdentSegment(RustPathIdentSegment pathIdentSegment) throws IOException {
switch (pathIdentSegment) {
case RustPathIdentSegmentCrate _ -> {
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java
index 1918fab..3a14bec 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java
@@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression imports
-public sealed interface RustExpression permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBlockExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression {
+public sealed interface RustExpression permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBlockExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression {
public interface Builder {
public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression build();
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java
index 2adba8e..4cc0f4c 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java
@@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType imports
-public record RustImplTraitType(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType {
+public record RustImplTraitType(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType {
public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.arbitrary().build());
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build());
}
- public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder {
+ public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder {
public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType build() {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType(trait);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath trait) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath trait) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(trait);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder trait) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder trait) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(trait.build());
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java
index 3c045e2..08e3564 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java
@@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute imports
-public record RustOuterAttribute(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath path, java.util.Optional<String> input) {
+public record RustOuterAttribute(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath path, java.util.Optional<String> input) {
public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.arbitrary().build(), java.util.Optional.empty());
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build(), java.util.Optional.empty());
}
- public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath path, java.util.Optional<String> input) {
+ public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath path, java.util.Optional<String> input) {
public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute build() {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute(path, input);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath path) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath path) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(path, input);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder path) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder path) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(path.build(), input);
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPath.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPath.java
new file mode 100644
index 0000000..895e194
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPath.java
@@ -0,0 +1,121 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath imports
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Stream;
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath imports
+
+public record RustPath(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(java.util.List.of());
+ }
+
+ public record Builder(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath build() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath(segments);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder withSegments(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment> segments) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(segments);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment segment) {
+ var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>(this.segments);
+ segments.add(segment);
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(segments);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder segment) {
+ var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>(this.segments);
+ segments.add(segment.build());
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(segments);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath body
+ public static RustPath primitive(String name) {
+ return global("core", "primitive", name);
+ }
+
+ public static RustPath of(String... names) {
+ var segments = Arrays.stream(names)
+ .map(name -> new RustPathSegment(
+ new RustPathIdentSegmentIdentifier(new RustIdentifier(name)),
+ Optional.empty()
+ ))
+ .toList();
+ return new RustPath(segments);
+ }
+
+ public static RustType of(RustIdentifier... names) {
+ var segments = Arrays.stream(names)
+ .map(name -> new RustPathSegment(
+ new RustPathIdentSegmentIdentifier(name),
+ Optional.empty()
+ ))
+ .toList();
+ return new RustPath(segments);
+ }
+
+ public static RustType crate(String... names) {
+ return qualified(RustPathSegment.crate(), names);
+ }
+
+ public static RustPath global(String... names) {
+ return qualified(RustPathSegment.global(), names);
+ }
+
+ public static RustPath selfType() {
+ return qualified(RustPathSegment.selfType(), new String[0]);
+ }
+
+ public static RustPath selfType(String... names) {
+ return qualified(RustPathSegment.selfType(), names);
+ }
+
+ public static RustPath selfType(RustIdentifier... names) {
+ return qualified(RustPathSegment.selfType(), names);
+ }
+
+ private static RustPath qualified(RustPathSegment qualifier, String... names) {
+ var segments = Stream.concat(
+ Stream.of(qualifier),
+ Arrays.stream(names)
+ .map(name -> new RustPathSegment(
+ new RustPathIdentSegmentIdentifier(new RustIdentifier(name)),
+ Optional.empty()
+ ))
+ )
+ .toList();
+ return new RustPath(segments);
+ }
+
+ private static RustPath qualified(RustPathSegment qualifier, RustIdentifier... names) {
+ var segments = Stream.concat(
+ Stream.of(qualifier),
+ Arrays.stream(names)
+ .map(name -> new RustPathSegment(
+ new RustPathIdentSegmentIdentifier(name),
+ Optional.empty()
+ ))
+ )
+ .toList();
+ return new RustPath(segments);
+ }
+
+ public RustPath withArgs(List<RustType> args) {
+ var segments = new ArrayList<>(this.segments);
+ var lastSegment = segments.removeLast().withArgs(args);
+ segments.add(lastSegment);
+ return new RustPath(segments);
+ }
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath body
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegment.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegment.java
deleted file mode 100644
index 7246ac0..0000000
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegment.java
+++ /dev/null
@@ -1,57 +0,0 @@
-// Generated by hobgoblin.
-
-package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
-
-// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment imports
-import java.util.List;
-import java.util.Optional;
-// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment imports
-
-public record RustPathExprSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
- public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate.arbitrary().build(), java.util.Optional.empty());
- }
-
- public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment build() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment(pathIdentSegment, args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment, args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment.Builder pathIdentSegment) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment.build(), args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withArgs(java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment, args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> args) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment, java.util.Optional.of(args));
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder body
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder body
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment body
- public static RustPathExprSegment global() {
- return new RustPathExprSegment(new RustPathIdentSegmentGlobal(), Optional.empty());
- }
-
- public static RustPathExprSegment selfType() {
- return new RustPathExprSegment(new RustPathIdentSegmentSelfType(), Optional.empty());
- }
-
- public RustPathExprSegment withArgs(List<RustType> args) {
- if (this.args.isPresent()) {
- throw new IllegalArgumentException("Expression path segment already has args");
- }
-
- return new RustPathExprSegment(this.pathIdentSegment, Optional.of(args));
- }
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment body
-}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpression.java
deleted file mode 100644
index 78baabc..0000000
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpression.java
+++ /dev/null
@@ -1,95 +0,0 @@
-// Generated by hobgoblin.
-
-package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
-
-// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression imports
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Stream;
-// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression imports
-
-public record RustPathInExpression(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression {
- public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(java.util.List.of());
- }
-
- public record Builder(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder {
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression build() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression(segments);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder withSegments(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment> segments) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(segments);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment segment) {
- var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>(this.segments);
- segments.add(segment);
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(segments);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder segment) {
- var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>(this.segments);
- segments.add(segment.build());
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(segments);
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder body
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder body
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression body
- public static RustPathInExpression of(String... names) {
- var segments = Arrays.stream(names)
- .map(name -> new RustPathExprSegment(
- new RustPathIdentSegmentIdentifier(new RustIdentifier(name)),
- Optional.empty()
- ))
- .toList();
- return new RustPathInExpression(segments);
- }
-
- public static RustExpression global(String... names) {
- return qualified(RustPathExprSegment.global(), names);
- }
-
- public static RustPathInExpression selfType(RustIdentifier... names) {
- return qualified(RustPathExprSegment.selfType(), names);
- }
-
- private static RustPathInExpression qualified(RustPathExprSegment qualifier, RustIdentifier... names) {
- var segments = Stream.concat(
- Stream.of(qualifier),
- Arrays.stream(names)
- .map(name -> new RustPathExprSegment(
- new RustPathIdentSegmentIdentifier(name),
- Optional.empty()
- ))
- )
- .toList();
- return new RustPathInExpression(segments);
- }
-
- private static RustPathInExpression qualified(RustPathExprSegment qualifier, String... names) {
- var segments = Stream.concat(
- Stream.of(qualifier),
- Arrays.stream(names)
- .map(name -> new RustPathExprSegment(
- new RustPathIdentSegmentIdentifier(new RustIdentifier(name)),
- Optional.empty()
- ))
- )
- .toList();
- return new RustPathInExpression(segments);
- }
-
- public RustPathInExpression withArgs(List<RustType> args) {
- var segments = new ArrayList<>(this.segments);
- var lastSegment = segments.removeLast().withArgs(args);
- segments.add(lastSegment);
- return new RustPathInExpression(segments);
- }
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression body
-}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegment.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegment.java
new file mode 100644
index 0000000..c2c57d6
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegment.java
@@ -0,0 +1,66 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment imports
+import java.util.List;
+import java.util.Optional;
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment imports
+
+public record RustPathSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate.arbitrary().build(), java.util.Optional.empty());
+ }
+
+ public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment build() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment(pathIdentSegment, args);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment, args);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment.Builder pathIdentSegment) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment.build(), args);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withArgs(java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment, args);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> args) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment, java.util.Optional.of(args));
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment body
+ public static RustPathSegment of(RustIdentifier name) {
+ return new RustPathSegment(new RustPathIdentSegmentIdentifier(name), Optional.empty());
+ }
+
+ public static RustPathSegment crate() {
+ return new RustPathSegment(new RustPathIdentSegmentCrate(), Optional.empty());
+ }
+
+ public static RustPathSegment global() {
+ return new RustPathSegment(new RustPathIdentSegmentGlobal(), Optional.empty());
+ }
+
+ public static RustPathSegment selfType() {
+ return new RustPathSegment(new RustPathIdentSegmentSelfType(), Optional.empty());
+ }
+
+ public RustPathSegment withArgs(List<RustType> args) {
+ if (this.args.isPresent()) {
+ throw new IllegalArgumentException("Type path segment already has args");
+ }
+
+ return new RustPathSegment(this.pathIdentSegment, Optional.of(args));
+ }
+
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment body
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java
index 370e17c..817610c 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java
@@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression imports
-public record RustStructExpression(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression {
+public record RustStructExpression(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression {
public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.arbitrary().build(), java.util.List.of());
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build(), java.util.List.of());
}
- public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder {
+ public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder {
public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression build() {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression(structPath, fieldValues);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression structPath) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath structPath) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(structPath, fieldValues);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder structPath) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder structPath) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(structPath.build(), fieldValues);
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java
index ba729ab..f039453 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java
@@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl imports
-public record RustTraitImpl(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem {
+public record RustTraitImpl(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem {
public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.arbitrary().build(), java.util.List.of());
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.arbitrary().build(), java.util.List.of());
}
- public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem.Builder {
+ public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem.Builder {
public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl build() {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl(implementedTrait, type, items);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath implementedTrait) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath implementedTrait) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(implementedTrait, type, items);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder implementedTrait) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder implementedTrait) {
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(implementedTrait.build(), type, items);
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java
index 0886074..41f1777 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java
@@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType imports
-public sealed interface RustType permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath {
+public sealed interface RustType permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath {
public interface Builder {
public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType build();
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePath.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePath.java
deleted file mode 100644
index 6ce5f7f..0000000
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePath.java
+++ /dev/null
@@ -1,100 +0,0 @@
-// Generated by hobgoblin.
-
-package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
-
-// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath imports
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Stream;
-// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath imports
-
-public record RustTypePath(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType {
- public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(java.util.List.of());
- }
-
- public record Builder(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder {
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath build() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath(segments);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder withSegments(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment> segments) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(segments);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment segment) {
- var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>(this.segments);
- segments.add(segment);
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(segments);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder segment) {
- var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>(this.segments);
- segments.add(segment.build());
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(segments);
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder body
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder body
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath body
- public static RustTypePath primitive(String name) {
- return global("core", "primitive", name);
- }
-
- public static RustTypePath of(String... names) {
- var segments = Arrays.stream(names)
- .map(name -> new RustTypePathSegment(
- new RustPathIdentSegmentIdentifier(new RustIdentifier(name)),
- Optional.empty()
- ))
- .toList();
- return new RustTypePath(segments);
- }
-
- public static RustType of(RustIdentifier... names) {
- var segments = Arrays.stream(names)
- .map(name -> new RustTypePathSegment(
- new RustPathIdentSegmentIdentifier(name),
- Optional.empty()
- ))
- .toList();
- return new RustTypePath(segments);
- }
-
- public static RustType crate(String... names) {
- return qualified(RustTypePathSegment.crate(), names);
- }
-
- public static RustTypePath global(String... names) {
- return qualified(RustTypePathSegment.global(), names);
- }
-
- public static RustTypePath selfType(String... names) {
- return qualified(RustTypePathSegment.selfType(), names);
- }
-
- private static RustTypePath qualified(RustTypePathSegment qualifier, String... names) {
- var segments = Stream.concat(
- Stream.of(qualifier),
- Arrays.stream(names)
- .map(name -> new RustTypePathSegment(
- new RustPathIdentSegmentIdentifier(new RustIdentifier(name)),
- Optional.empty()
- ))
- )
- .toList();
- return new RustTypePath(segments);
- }
-
- public RustTypePath withArgs(List<RustType> args) {
- var segments = new ArrayList<>(this.segments);
- var lastSegment = segments.removeLast().withArgs(args);
- segments.add(lastSegment);
- return new RustTypePath(segments);
- }
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath body
-}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegment.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegment.java
deleted file mode 100644
index 6531925..0000000
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegment.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Generated by hobgoblin.
-
-package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
-
-// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment imports
-import java.util.List;
-import java.util.Optional;
-// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment imports
-
-public record RustTypePathSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
- public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate.arbitrary().build(), java.util.Optional.empty());
- }
-
- public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment build() {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment(pathIdentSegment, args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment, args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment.Builder pathIdentSegment) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment.build(), args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withArgs(java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment, args);
- }
-
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> args) {
- return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment, java.util.Optional.of(args));
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder body
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder body
- }
-
- // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment body
- public static RustTypePathSegment of(RustIdentifier name) {
- return new RustTypePathSegment(new RustPathIdentSegmentIdentifier(name), Optional.empty());
- }
-
- public static RustTypePathSegment crate() {
- return new RustTypePathSegment(new RustPathIdentSegmentCrate(), Optional.empty());
- }
-
- public static RustTypePathSegment global() {
- return new RustTypePathSegment(new RustPathIdentSegmentGlobal(), Optional.empty());
- }
-
- public static RustTypePathSegment selfType() {
- return new RustTypePathSegment(new RustPathIdentSegmentSelfType(), Optional.empty());
- }
-
- public RustTypePathSegment withArgs(List<RustType> args) {
- if (this.args.isPresent()) {
- throw new IllegalArgumentException("Type path segment already has args");
- }
-
- return new RustTypePathSegment(this.pathIdentSegment, Optional.of(args));
- }
- // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment body
-}