diff options
Diffstat (limited to 'src/main/java')
3 files changed, 57 insertions, 1 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java index 7523fe0..ebb7aba 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java @@ -277,6 +277,10 @@ public class TypescriptWriter implements AutoCloseable { this.writeCall(call); } + case TypescriptCast cast -> { + this.writeCast(cast); + } + case TypescriptConstructedType constructedType -> { this.writeConstructedType(constructedType); } @@ -336,6 +340,12 @@ public class TypescriptWriter implements AutoCloseable { this.writer.write(")"); } + private void writeCast(TypescriptCast cast) throws IOException { + this.writeExpression(cast.value()); + this.writer.write(" as "); + this.writeExpression(cast.type()); + } + private void writeConstructedType(TypescriptConstructedType constructedType) throws IOException { this.writeExpression(constructedType.receiver()); this.writer.write("<"); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptCast.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptCast.java new file mode 100644 index 0000000..6a2d63e --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptCast.java @@ -0,0 +1,46 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast imports + +public record TypescriptCast( + org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression value, + org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression type +) implements org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression { + public static org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNumberLiteral.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNumberLiteral.arbitrary().build()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression value, + org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression type + ) implements org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast build() { + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast(value, type); + } + + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder withValue(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression value) { + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder(value, type); + } + + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder withValue(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression.Builder value) { + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder(value.build(), type); + } + + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder withType(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression type) { + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder(value, type); + } + + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder withType(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression.Builder type) { + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder(value, type.build()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExpression.java index e047bca..aa23783 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExpression.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExpression.java @@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression imports -public sealed interface TypescriptExpression permits org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptBinaryOperation, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCall, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptConstructedType, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptFieldAccess, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNumberLiteral, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptObjectLiteral, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptRef, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptTypeof, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptTypeUnion { +public sealed interface TypescriptExpression permits org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptBinaryOperation, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCall, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCast, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptConstructedType, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptFieldAccess, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNumberLiteral, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptObjectLiteral, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptRef, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptTypeof, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptTypeUnion { public interface Builder { public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression build(); |
