Skip to content

Commit

Permalink
Let SliceArrayVectorNode handle warnings on its own
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Feb 7, 2025
1 parent 21d9bc3 commit e6af654
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.enso.interpreter.runtime.error.PanicSentinel;
import org.enso.interpreter.runtime.warning.AppendWarningNode;
import org.enso.interpreter.runtime.warning.WarningsLibrary;
import org.enso.interpreter.runtime.warning.WithWarnings;
import org.enso.pkg.QualifiedName;

/** Root node for use by all the builtin functions. */
Expand Down Expand Up @@ -138,7 +137,7 @@ public final <T> T processArgument(
throw sentinel;
}
if (warnings != null) {
if (value instanceof WithWarnings) {
if (warnings.hasWarnings(value)) {
if (mapInsertAllNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
this.mapInsertAllNode = insert(HashMapInsertAllNode.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.enso.interpreter.node.expression.builtin.immutable;

import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.AcceptsWarning;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers;
import org.enso.interpreter.runtime.data.vector.ArrayLikeLengthNode;
Expand All @@ -14,11 +15,11 @@ public final class SliceArrayVectorNode extends Node {

private SliceArrayVectorNode() {}

public static SliceArrayVectorNode build() {
static SliceArrayVectorNode build() {
return new SliceArrayVectorNode();
}

Object execute(Object vector, long start, long end) {
Object execute(@AcceptsWarning Object vector, long start, long end) {
var len = lengthNode.executeLength(vector);
return ArrayLikeHelpers.slice(vector, start, end, len);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ WithWarnings doWithWarnMultipleWarningsHashMap(
return withWarnings;
}
var maxWarns = withWarnings.maxWarnings;
var warnsMap = withWarnings.warnings;
warnsMap = mapInsertAllNode.executeInsertAll(frame, warnsMap, newWarnsMap, maxWarns);
var warnsMap =
mapInsertAllNode.executeInsertAll(frame, withWarnings.warnings, newWarnsMap, maxWarns);
var isLimitReached = mapSizeNode.execute(warnsMap) >= maxWarns;
return new WithWarnings(withWarnings.value, withWarnings.maxWarnings, isLimitReached, warnsMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.StopIterationException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.library.ExportLibrary;
import com.oracle.truffle.api.library.ExportMessage;
import org.enso.interpreter.dsl.AcceptsWarning;
import org.enso.interpreter.dsl.Builtin;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.builtin.BuiltinObject;
Expand Down Expand Up @@ -61,12 +64,14 @@ public static Warning create(EnsoContext ctx, Object payload, Object origin) {
@SuppressWarnings("generic-enso-builtin-type")
public static Object attach(
EnsoContext ctx,
Object value,
VirtualFrame frame,
@AcceptsWarning Object value,
Object warning,
Object origin,
@CachedLibrary WarningsLibrary warnings,
@Cached AppendWarningNode appendWarningNode) {
var warn = new Warning(warning, origin, ctx.nextSequenceId());
return appendWarningNode.executeAppend(null, value, warn);
return appendWarningNode.executeAppend(frame, value, warn);
}

/** Slow version of {@link #fromMapToArray(EnsoHashMap, InteropLibrary)}. */
Expand Down

0 comments on commit e6af654

Please sign in to comment.