From f6a85de5487af16af0f48eced8f770dbada24f75 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 2 Mar 2024 13:52:32 +0000 Subject: Add EffectParam --- .../java/org/shedlang/compiler/types/Effect.java | 2 +- .../org/shedlang/compiler/types/EffectParam.java | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/shedlang/compiler/types/EffectParam.java (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/types/Effect.java b/src/main/java/org/shedlang/compiler/types/Effect.java index 01ba00a3..cb47c81f 100644 --- a/src/main/java/org/shedlang/compiler/types/Effect.java +++ b/src/main/java/org/shedlang/compiler/types/Effect.java @@ -1,4 +1,4 @@ package org.shedlang.compiler.types; -public sealed interface Effect extends TypeLevelValue permits EffectUnion, IoEffect, NoneEffect, UserDefinedEffect { +public sealed interface Effect extends TypeLevelValue permits EffectParam, EffectUnion, IoEffect, NoneEffect, UserDefinedEffect { } diff --git a/src/main/java/org/shedlang/compiler/types/EffectParam.java b/src/main/java/org/shedlang/compiler/types/EffectParam.java new file mode 100644 index 00000000..e8ae6121 --- /dev/null +++ b/src/main/java/org/shedlang/compiler/types/EffectParam.java @@ -0,0 +1,24 @@ +package org.shedlang.compiler.types; + +public record EffectParam(Scope scope, String name) implements Effect { + public static EffectParam forFunction( + NamespaceName namespaceName, + String functionName, + String name + ) { + return new EffectParam(new Scope.Function(namespaceName, functionName), name); + } + + public static EffectParam forStructType(SimpleStructType structType, String name) { + return new EffectParam(new Scope.Struct(structType), name); + } + + public static EffectParam forSumType(SimpleSumType sumType, String name) { + return new EffectParam(new Scope.Sum(sumType), name); + } + + @Override + public String describe() { + return name; + } +} -- cgit v1.2.3