-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rather than going through instance checks, introduced a separate node that uses specializations for that. In the process, discovered that ComparatorNode was never used or covered on our test suite. If it did, we would notice that we were comparing Atoms with AtomConstructors, meaning that we would always throw a panic when sort is given a comparator. It made more sense to remove that specialization.
- Loading branch information
Showing
4 changed files
with
51 additions
and
75 deletions.
There are no files selected for viewing
58 changes: 0 additions & 58 deletions
58
...me/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/ComparatorNode.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...main/java/org/enso/interpreter/node/expression/builtin/mutable/InvalidComparisonNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.enso.interpreter.node.expression.builtin.mutable; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.nodes.Node; | ||
import com.oracle.truffle.api.nodes.NodeInfo; | ||
import org.enso.interpreter.runtime.Context; | ||
import org.enso.interpreter.runtime.error.DataflowError; | ||
import org.enso.interpreter.runtime.error.PanicException; | ||
|
||
@NodeInfo( | ||
shortName = "invalidComparison", | ||
description = "Propagates the result of the invalid comparison via a Panic.") | ||
public abstract class InvalidComparisonNode extends Node { | ||
|
||
public abstract int execute(Object result); | ||
|
||
public static InvalidComparisonNode build() { | ||
return InvalidComparisonNodeGen.create(); | ||
} | ||
|
||
@Specialization | ||
int doDataFlowError(DataflowError dataflowError) { | ||
System.out.println("DoDataflowc " + dataflowError.getPayload()); | ||
CompilerDirectives.transferToInterpreter(); | ||
throw new PanicException(dataflowError.getPayload(), dataflowError.getLocation()); | ||
} | ||
|
||
@Specialization | ||
int doPanic(Object result) { | ||
CompilerDirectives.transferToInterpreter(); | ||
var ordering = Context.get(this).getBuiltins().ordering().getType(); | ||
throw new PanicException( | ||
Context.get(this).getBuiltins().error().makeTypeError(ordering, result, "result"), this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters