summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java14
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustBoolLiteral.java28
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java18
3 files changed, 60 insertions, 0 deletions
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 1e93d1d..299a8b5 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
@@ -202,6 +202,20 @@ public class RustWriter implements AutoCloseable {
this.writer.write("}");
}
+ // == Expressions ==
+
+ void writeExpression(RustExpression expression) throws IOException {
+ switch (expression) {
+ case RustBoolLiteral boolLiteral -> {
+ this.writeBoolLiteral(boolLiteral);
+ }
+ }
+ }
+
+ private void writeBoolLiteral(RustBoolLiteral boolLiteral) throws IOException {
+ this.writer.write(boolLiteral.value() ? "true" : "false");
+ }
+
// == Types ==
void writeType(RustType type) throws IOException {
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustBoolLiteral.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustBoolLiteral.java
new file mode 100644
index 0000000..5e6a90a
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustBoolLiteral.java
@@ -0,0 +1,28 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral imports
+
+public record RustBoolLiteral(boolean value) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral.Builder(false);
+ }
+
+ public record Builder(boolean value) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral build() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral(value);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral.Builder withValue(boolean value) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral.Builder(value);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral body
+}
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
new file mode 100644
index 0000000..f665e26
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java
@@ -0,0 +1,18 @@
+// Generated by hobgoblin.
+
+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.RustBoolLiteral {
+ public interface Builder {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression build();
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression body
+}