mirror of
https://github.com/enso-org/enso.git
synced 2024-11-29 04:29:24 +03:00
works in standalone
This commit is contained in:
parent
a474955e28
commit
d6e795456f
@ -17,7 +17,7 @@ import project.System
|
||||
from project.Data.Boolean import Boolean, False, True
|
||||
from project.Data.Index_Sub_Range.Index_Sub_Range import First, Last
|
||||
from project.Data.Text.Extensions import all
|
||||
from project.Runtime.Context import Input, Output
|
||||
from project.Runtime.Context import Dataflow_Stack_Trace, Input, Output
|
||||
|
||||
## Utilities for interacting with the runtime.
|
||||
|
||||
@ -150,6 +150,9 @@ type Context
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Output
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Dataflow_Stack_Trace
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
@ -161,6 +164,7 @@ type Context
|
||||
case self of
|
||||
Input -> "Input"
|
||||
Output -> "Output"
|
||||
Dataflow_Stack_Trace -> "Dataflow_Stack_Trace "
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
@ -4,6 +4,7 @@ import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
import com.oracle.truffle.api.nodes.Node;
|
||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||
import org.enso.interpreter.runtime.error.DataflowError;
|
||||
import org.enso.interpreter.runtime.state.State;
|
||||
|
||||
@BuiltinMethod(
|
||||
type = "Error",
|
||||
@ -11,7 +12,7 @@ import org.enso.interpreter.runtime.error.DataflowError;
|
||||
description = "Returns a new value error with given payload.",
|
||||
inlineable = true)
|
||||
public class ThrowErrorNode extends Node {
|
||||
public Object execute(VirtualFrame giveMeAStackFrame, Object payload) {
|
||||
return DataflowError.withoutTrace(payload, this);
|
||||
public Object execute(VirtualFrame giveMeAStackFrame, State state, Object payload) {
|
||||
return DataflowError.withoutTrace(state, payload, this);
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,15 @@ import org.enso.interpreter.runtime.data.atom.AtomConstructor;
|
||||
public class Context extends Builtin {
|
||||
@Override
|
||||
protected List<Cons> getDeclaredConstructors() {
|
||||
return List.of(new Cons(INPUT_NAME), new Cons(OUTPUT_NAME));
|
||||
return List.of(new Cons(INPUT_NAME), new Cons(OUTPUT_NAME), new Cons(DATAFLOW_STACK_TRACE_NAME));
|
||||
}
|
||||
|
||||
public static final String INPUT_NAME = "Input";
|
||||
|
||||
public static final String OUTPUT_NAME = "Output";
|
||||
|
||||
public static final String DATAFLOW_STACK_TRACE_NAME = "Dataflow_Stack_Trace";
|
||||
|
||||
public AtomConstructor getInput() {
|
||||
return getConstructors()[0];
|
||||
}
|
||||
@ -23,4 +25,8 @@ public class Context extends Builtin {
|
||||
public AtomConstructor getOutput() {
|
||||
return getConstructors()[1];
|
||||
}
|
||||
|
||||
public AtomConstructor getDataflowStackTrace() {
|
||||
return getConstructors()[2];
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.enso.interpreter.runtime.EnsoContext;
|
||||
import org.enso.interpreter.runtime.data.Type;
|
||||
import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers;
|
||||
import org.enso.interpreter.runtime.library.dispatch.TypesLibrary;
|
||||
import org.enso.interpreter.runtime.state.State;
|
||||
|
||||
/**
|
||||
* A runtime object representing an arbitrary, user-created dataflow error.
|
||||
@ -29,14 +30,6 @@ public final class DataflowError extends AbstractTruffleException {
|
||||
/** Signals (local) values that haven't yet been initialized */
|
||||
public static final DataflowError UNINITIALIZED = new DataflowError(null, (Node) null);
|
||||
|
||||
private static final boolean assertsOn;
|
||||
|
||||
static {
|
||||
var b = false;
|
||||
assert b = true;
|
||||
assertsOn = b;
|
||||
}
|
||||
|
||||
private final Object payload;
|
||||
private final boolean ownTrace;
|
||||
|
||||
@ -49,9 +42,10 @@ public final class DataflowError extends AbstractTruffleException {
|
||||
* @param location the node in which the error was created
|
||||
* @return a new dataflow error
|
||||
*/
|
||||
public static DataflowError withoutTrace(Object payload, Node location) {
|
||||
public static DataflowError withoutTrace(State state, Object payload, Node location) {
|
||||
assert payload != null;
|
||||
if (assertsOn) {
|
||||
boolean attachFullStackTrace = state == null ? true : state.currentEnvironment().hasContextEnabled("Dataflow_Stack_Trace");
|
||||
if (attachFullStackTrace) {
|
||||
var result = new DataflowError(payload, UNLIMITED_STACK_TRACE, location);
|
||||
TruffleStackTrace.fillIn(result);
|
||||
return result;
|
||||
@ -61,6 +55,10 @@ public final class DataflowError extends AbstractTruffleException {
|
||||
}
|
||||
}
|
||||
|
||||
public static DataflowError withoutTrace(Object payload, Node location) {
|
||||
return withoutTrace(null, payload, location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new dataflow error with the provided stack trace.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user