diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-19 19:11:44 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-19 19:11:44 +0100 |
| commit | 4be0a1caf255fa3c1dd86dfc210671b7ae395ebe (patch) | |
| tree | f063e319fd94da91edc00f96764f1129e5a60c8d /src/main/java/org/shedlang/compiler/util | |
| parent | cdd6065a224cdc623eda83106d6d167504de4f67 (diff) | |
Write directly to file when serializing LLVM IR
Diffstat (limited to 'src/main/java/org/shedlang/compiler/util')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/util/Iterables.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/org/shedlang/compiler/util/Iterables.java b/src/main/java/org/shedlang/compiler/util/Iterables.java index 6fcb02e1..ff043c13 100644 --- a/src/main/java/org/shedlang/compiler/util/Iterables.java +++ b/src/main/java/org/shedlang/compiler/util/Iterables.java @@ -1,12 +1,22 @@ package org.shedlang.compiler.util; -import java.util.function.Consumer; - public class Iterables { private Iterables() { } - public static <T> void forEachInterspersed(Iterable<T> values, Consumer<T> onElement, Action between) { + public interface OnElement<T, E extends Exception> { + void accept(T value) throws E; + } + + public interface Between<E extends Exception> { + void call() throws E; + } + + public static <T, E extends Exception> void forEachInterspersed( + Iterable<T> values, + OnElement<T, E> onElement, + Between<E> between + ) throws E { var first = true; for (var value : values) { if (!first) { |
