From b91e15e352fec989389a47079b1894224a683c80 Mon Sep 17 00:00:00 2001 From: JFronny Date: Mon, 14 Aug 2023 15:24:44 +0200 Subject: [PATCH] fix(muscript): it builds again --- .../java/io/gitlab/jfronny/muscript/StandardLib.java | 3 ++- .../io/gitlab/jfronny/muscript/ast/dynamic/Call.java | 2 +- .../data/dynamic/additional/DCallableObject.java | 6 ++---- .../muscript/data/dynamic/additional/DEnum.java | 11 +++++------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/muscript/src/main/java/io/gitlab/jfronny/muscript/StandardLib.java b/muscript/src/main/java/io/gitlab/jfronny/muscript/StandardLib.java index c441f31..961cd26 100644 --- a/muscript/src/main/java/io/gitlab/jfronny/muscript/StandardLib.java +++ b/muscript/src/main/java/io/gitlab/jfronny/muscript/StandardLib.java @@ -12,6 +12,7 @@ import io.gitlab.jfronny.muscript.error.LocationalException; import java.time.LocalDate; import java.time.LocalTime; import java.util.*; +import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -198,7 +199,7 @@ public class StandardLib { public static Dynamic fold(DList args) { if (args.size() != 3) throw new IllegalArgumentException("Invalid number of arguments for fold: expected 3 but got " + args.size()); - return args.get(0).asList().getValue().stream().reduce(args.get(1), args.get(2).asCallable()::call); + return args.get(0).asList().getValue().stream().>map(Function.identity()).reduce(args.get(1), args.get(2).asCallable()::call); } public static Dynamic forEach(DList args) { diff --git a/muscript/src/main/java/io/gitlab/jfronny/muscript/ast/dynamic/Call.java b/muscript/src/main/java/io/gitlab/jfronny/muscript/ast/dynamic/Call.java index 46899ea..8296654 100644 --- a/muscript/src/main/java/io/gitlab/jfronny/muscript/ast/dynamic/Call.java +++ b/muscript/src/main/java/io/gitlab/jfronny/muscript/ast/dynamic/Call.java @@ -97,7 +97,7 @@ public class Call extends DynamicExpr { } public record Arg(DynamicExpr expr, boolean variadic) { - public Stream> get(Scope dataRoot) { + public Stream> get(Scope dataRoot) { return variadic ? expr.get(dataRoot).asList().getValue().stream() : Stream.of(expr.get(dataRoot)); } diff --git a/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DCallableObject.java b/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DCallableObject.java index ac544d4..1370673 100644 --- a/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DCallableObject.java +++ b/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DCallableObject.java @@ -3,16 +3,14 @@ package io.gitlab.jfronny.muscript.data.dynamic.additional; import io.gitlab.jfronny.muscript.ast.DynamicExpr; import io.gitlab.jfronny.muscript.ast.dynamic.*; import io.gitlab.jfronny.muscript.compiler.CodeLocation; -import io.gitlab.jfronny.muscript.compiler.ExprWriter; import io.gitlab.jfronny.muscript.data.dynamic.*; -import java.io.IOException; import java.util.List; import java.util.Map; -public record DCallableObject(Map> value, DCallable callable) implements DObject { +public record DCallableObject(Map> value, DCallable callable) implements DObject { @Override - public Map> getValue() { + public Map> getValue() { return value; } diff --git a/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DEnum.java b/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DEnum.java index 4c75e1a..0b39bd1 100644 --- a/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DEnum.java +++ b/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/additional/DEnum.java @@ -5,23 +5,22 @@ import io.gitlab.jfronny.muscript.ast.DynamicExpr; import io.gitlab.jfronny.muscript.ast.dynamic.Call; import io.gitlab.jfronny.muscript.ast.dynamic.Variable; import io.gitlab.jfronny.muscript.ast.literal.StringLiteral; -import io.gitlab.jfronny.muscript.compiler.*; +import io.gitlab.jfronny.muscript.compiler.CodeLocation; import io.gitlab.jfronny.muscript.data.dynamic.*; import org.jetbrains.annotations.Nullable; -import java.io.IOException; import java.util.*; /** * An enum represented as an OObject. * May also have a selected value with automatic conversions to a number (index) and string */ -public record DEnum(Map> values, @Nullable DEnumEntry value) implements DObject { - public DEnum(Map> values) { +public record DEnum(Map> values, @Nullable DEnumEntry value) implements DObject { + public DEnum(Map> values) { this(values, (DEnumEntry) null); } - public DEnum(Map> values, @Nullable String value) { + public DEnum(Map> values, @Nullable String value) { this(values, value == null ? null : new DEnumEntry(value, values.keySet().stream().toList().indexOf(value), true)); } @@ -34,7 +33,7 @@ public record DEnum(Map> values, @Nullable DEnumEntry value) } @Override - public Map> getValue() { + public Map> getValue() { return values; }