diff options
Diffstat (limited to 'src/main/java/org/zwobble')
3 files changed, 22 insertions, 7 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java index 8fc9b61..d96130b 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java @@ -419,8 +419,8 @@ public class RustTransient0Generator implements Generator { bytes, true, new RustArrayRepeatExpression( - new RustIntegerLiteral(0), - new RustIntegerLiteral(length) + new RustIntegerLiteral(0, Optional.empty()), + new RustIntegerLiteral(length, Optional.empty()) ) ), new RustExpressionStatement(new RustTryPropagationExpression(new RustCallExpression( 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 06c35c6..0f026a2 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 @@ -426,6 +426,9 @@ public class RustWriter implements AutoCloseable { private void writeIntegerLiteral(RustIntegerLiteral integerLiteral) throws IOException { this.writer.write(Long.toString(integerLiteral.value())); + if (integerLiteral.type().isPresent()) { + this.writeIdentifier(integerLiteral.type().get()); + } } private void writePrefixExpression(RustPrefixExpression prefixExpression) throws IOException { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIntegerLiteral.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIntegerLiteral.java index 8034c2b..eb297b0 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIntegerLiteral.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIntegerLiteral.java @@ -5,18 +5,30 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral imports -public record RustIntegerLiteral(long value) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression { +public record RustIntegerLiteral(long value, java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> type) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression { public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder(0); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder(0, java.util.Optional.empty()); } - public record Builder(long value) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder { + public record Builder(long value, java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> type) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral build() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral(value); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral(value, type); } public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder withValue(long value) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder(value); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder(value, type); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder withType(java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> type) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder(value, type); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder withType(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier type) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder(value, java.util.Optional.of(type)); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder withType(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier.Builder type) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder(value, java.util.Optional.of(type.build())); } // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral.Builder body |
