aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-03-02 13:52:32 +0000
committerMichael Williamson <mike@zwobble.org>2024-03-02 13:52:32 +0000
commitf6a85de5487af16af0f48eced8f770dbada24f75 (patch)
tree8022f2ef3f755e43135efacce4ede327f02af3b0 /src/main/java
parentd6afd5049c97159fbcb6e13aa033a07e4f56d181 (diff)
Add EffectParam
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/types/Effect.java2
-rw-r--r--src/main/java/org/shedlang/compiler/types/EffectParam.java24
2 files changed, 25 insertions, 1 deletions
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;
+ }
+}