From de846b1c61ba146da38be8a347d1c70dece75e52 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 9 Jul 2023 18:52:02 +0100 Subject: Document behaviour options --- .../ast/typed/TypedFunctionStatementBehaviour.java | 14 +++++++++++++- .../ast/untyped/UntypedFunctionStatementBehaviour.java | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/ast/typed/TypedFunctionStatementBehaviour.java b/src/main/java/org/shedlang/compiler/ast/typed/TypedFunctionStatementBehaviour.java index 0299fd92..d669462f 100644 --- a/src/main/java/org/shedlang/compiler/ast/typed/TypedFunctionStatementBehaviour.java +++ b/src/main/java/org/shedlang/compiler/ast/typed/TypedFunctionStatementBehaviour.java @@ -9,8 +9,20 @@ public sealed interface TypedFunctionStatementBehaviour { static TypedFunctionStatementBehaviour blockReturn(Type type) { return new BlockReturn(type); } - + /** + * The function statement causes the function to terminate i.e. no other + * statements in the function will be executed. + */ record Terminate() implements TypedFunctionStatementBehaviour {} + + /** + * The function statement returns from the current block with a value of the + * given type. + */ record BlockReturn(Type type) implements TypedFunctionStatementBehaviour {} + + /** + * The function statement passes execution to the next function statement. + */ record Continue() implements TypedFunctionStatementBehaviour {} } diff --git a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionStatementBehaviour.java b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionStatementBehaviour.java index 82ee9ce5..2a8358c6 100644 --- a/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionStatementBehaviour.java +++ b/src/main/java/org/shedlang/compiler/ast/untyped/UntypedFunctionStatementBehaviour.java @@ -1,7 +1,19 @@ package org.shedlang.compiler.ast.untyped; public enum UntypedFunctionStatementBehaviour { + /** + * The function statement causes the function to terminate i.e. no other + * statements in the function will be executed. + */ TERMINATE, + + /** + * The function statement returns from the current block with a value. + */ BLOCK_RETURN, + + /** + * The function statement passes execution to the next function statement. + */ CONTINUE, } -- cgit v1.2.3