diff options
Diffstat (limited to 'src/main')
3 files changed, 6 insertions, 11 deletions
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 5d777ea..b2a5009 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 @@ -53,9 +53,9 @@ public record RustGeneratorConfig( private static final Map<SimpleNativeType, RustNativeTypeConfig> DEFAULT_NATIVE_TYPE_CONFIGS = Map.ofEntries( 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.of("std", "string", "String"))), - Map.entry(NativeTypes.LIST_INNER, new RustNativeTypeConfig(RustTypePath.of("std", "vec", "Vec"))), - Map.entry(NativeTypes.OPTION_INNER, new RustNativeTypeConfig(RustTypePath.of("std", "option", "Option"))) + 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"))) ); 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 d4e7fd1..2e8b244 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 @@ -156,7 +156,7 @@ public class RustTypesGenerator implements Generator { var variantType = generateRustTypeExpression(variant.type(), context); if (variant.isBox()) { - variantType = RustTypePath.of("std", "boxed", "Box") + variantType = RustTypePath.global("std", "boxed", "Box") .withArgs(List.of(variantType)); } 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 index 6b51792..8b0adf0 100644 --- 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 @@ -42,12 +42,7 @@ public record RustTypePath(java.util.List<org.zwobble.hobgoblin.compiler.output. // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath body public static RustTypePath primitive(String name) { - return new RustTypePath(List.of( - new RustTypePathSegment( - new RustPathIdentSegmentIdentifier(new RustIdentifier(name)), - Optional.empty() - ) - )); + return global("core", "primitive", name); } public static RustTypePath of(String... names) { @@ -83,7 +78,7 @@ public record RustTypePath(java.util.List<org.zwobble.hobgoblin.compiler.output. return new RustTypePath(segments); } - public static RustType global(String... names) { + public static RustTypePath global(String... names) { var segments = Stream.concat( Stream.of(RustTypePathSegment.global()), Arrays.stream(names) |
