diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-11-19 15:47:38 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-11-19 15:49:28 +0000 |
| commit | b99b938b2f33e4d12d63629f3d80e987c31d1892 (patch) | |
| tree | 5057bba7084240792bfa23520ea18d66564b7cdd /src/main/java | |
| parent | 303f428e78cf44f10032e55a69d5d5cd00f5d715 (diff) | |
Implement basic effect handling in the runtime
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java index ad5d64de..dc97456e 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java @@ -42,7 +42,8 @@ public class PatioCodeGenEffects { private static final PatioFunctionDeclaration PUSH_HANDLER_DECLARATION = new PatioFunctionDeclaration( "shed__runtime__effects_push_handler", List.of( - new PatioLocal.Param("effectTag", EFFECT_TAG_TYPE) + new PatioLocal.Param("effectTag", EFFECT_TAG_TYPE), + new PatioLocal.Param("methodCount", PatioTypes.INT) ), EFFECT_HANDLER_TYPE, Sources.RUNTIME @@ -229,6 +230,8 @@ public class PatioCodeGenEffects { Source source, PatioCodeGenContext context ) { + var effectInfo = context.userDefinedEffectInfo(effect); + context = context .ensureCompilationUnitElement(PUSH_HANDLER_DECLARATION) .ensureCompilationUnitElement(SET_HANDLER_METHOD_DECLARATION) @@ -245,12 +248,12 @@ public class PatioCodeGenEffects { Optional.of(effectHandler), PUSH_HANDLER_DECLARATION.name(), List.of( - new PatioInt(context.effectTag(effect)) + new PatioInt(context.effectTag(effect)), + new PatioInt(effectInfo.methodCount()) ), source )); - var effectInfo = context.userDefinedEffectInfo(effect); for (var handlerMethodInfo : effectInfo.methods()) { context = context.addInstruction(new PatioCall( Optional.empty(), |
