mirror of
https://github.com/enso-org/enso.git
synced 2024-11-29 05:03:46 +03:00
wip
This commit is contained in:
parent
f470b028a5
commit
2ca3e0a0fa
@ -3,6 +3,7 @@ package org.enso.interpreter.node.expression.builtin.error;
|
|||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.EnsoContext;
|
||||||
import org.enso.interpreter.runtime.error.DataflowError;
|
import org.enso.interpreter.runtime.error.DataflowError;
|
||||||
import org.enso.interpreter.runtime.state.State;
|
import org.enso.interpreter.runtime.state.State;
|
||||||
|
|
||||||
@ -13,6 +14,11 @@ import org.enso.interpreter.runtime.state.State;
|
|||||||
inlineable = true)
|
inlineable = true)
|
||||||
public class ThrowErrorNode extends Node {
|
public class ThrowErrorNode extends Node {
|
||||||
public Object execute(VirtualFrame giveMeAStackFrame, State state, Object payload) {
|
public Object execute(VirtualFrame giveMeAStackFrame, State state, Object payload) {
|
||||||
return DataflowError.withoutTrace(state, payload, this);
|
boolean lala = state.currentEnvironment().hasContextEnabled("Dataflow_Stack_Trace");
|
||||||
|
EnsoContext context = EnsoContext.get(this);
|
||||||
|
String skeys[] = state.currentEnvironment().keys;
|
||||||
|
String ckeys[] = context.getExecutionEnvironment().keys;
|
||||||
|
boolean attachFullStackTrace = context.getExecutionEnvironment().hasContextEnabled("Dataflow_Stack_Trace");
|
||||||
|
return DataflowError.withoutTrace(payload, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ public abstract class BitShiftNode extends IntegerNode {
|
|||||||
} else if (positiveFitsInInt.profile(BigIntegerOps.fitsInInt(that))) {
|
} else if (positiveFitsInInt.profile(BigIntegerOps.fitsInInt(that))) {
|
||||||
return toEnsoNumberNode.execute(BigIntegerOps.bitShiftLeft(self, (int) that));
|
return toEnsoNumberNode.execute(BigIntegerOps.bitShiftLeft(self, (int) that));
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println("AAA doLongShiftLeftExplicit");
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
||||||
}
|
}
|
||||||
@ -75,6 +76,7 @@ public abstract class BitShiftNode extends IntegerNode {
|
|||||||
return self >= 0 ? 0L : -1L;
|
return self >= 0 ? 0L : -1L;
|
||||||
} else {
|
} else {
|
||||||
// Note [Well-Formed BigIntegers]
|
// Note [Well-Formed BigIntegers]
|
||||||
|
System.out.println("AAA doBigInteger");
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
EnsoContext.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import org.enso.interpreter.runtime.EnsoContext;
|
|||||||
import org.enso.interpreter.runtime.data.Type;
|
import org.enso.interpreter.runtime.data.Type;
|
||||||
import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers;
|
import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers;
|
||||||
import org.enso.interpreter.runtime.library.dispatch.TypesLibrary;
|
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.
|
* A runtime object representing an arbitrary, user-created dataflow error.
|
||||||
@ -42,9 +41,10 @@ public final class DataflowError extends AbstractTruffleException {
|
|||||||
* @param location the node in which the error was created
|
* @param location the node in which the error was created
|
||||||
* @return a new dataflow error
|
* @return a new dataflow error
|
||||||
*/
|
*/
|
||||||
public static DataflowError withoutTrace(State state, Object payload, Node location) {
|
public static DataflowError withoutTrace(Object payload, Node location) {
|
||||||
assert payload != null;
|
assert payload != null;
|
||||||
boolean attachFullStackTrace = state == null ? true : state.currentEnvironment().hasContextEnabled("Dataflow_Stack_Trace");
|
EnsoContext context = EnsoContext.get(location);
|
||||||
|
boolean attachFullStackTrace = context.getExecutionEnvironment().hasContextEnabled("Dataflow_Stack_Trace");
|
||||||
if (attachFullStackTrace) {
|
if (attachFullStackTrace) {
|
||||||
var result = new DataflowError(payload, UNLIMITED_STACK_TRACE, location);
|
var result = new DataflowError(payload, UNLIMITED_STACK_TRACE, location);
|
||||||
TruffleStackTrace.fillIn(result);
|
TruffleStackTrace.fillIn(result);
|
||||||
@ -55,10 +55,6 @@ 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.
|
* Construct a new dataflow error with the provided stack trace.
|
||||||
*
|
*
|
||||||
|
@ -11,8 +11,8 @@ public class ExecutionEnvironment {
|
|||||||
// Ideally we would "just" use a map here. But that leads
|
// Ideally we would "just" use a map here. But that leads
|
||||||
// to native image build problems. This in turn leads to
|
// to native image build problems. This in turn leads to
|
||||||
// TruffleBoundary annotations which in turn leads to slow path.
|
// TruffleBoundary annotations which in turn leads to slow path.
|
||||||
private final String[] keys;
|
public final String[] keys;
|
||||||
private final Boolean[] permissions;
|
public final Boolean[] permissions;
|
||||||
|
|
||||||
public static final String LIVE_ENVIRONMENT_NAME = "live";
|
public static final String LIVE_ENVIRONMENT_NAME = "live";
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ deep_b = deep_c
|
|||||||
deep_a = deep_b
|
deep_a = deep_b
|
||||||
|
|
||||||
add_specs suite_builder = suite_builder.group "Stack traces" group_builder->
|
add_specs suite_builder = suite_builder.group "Stack traces" group_builder->
|
||||||
group_builder.specify "should capture traces correctly" <|
|
group_builder.specify "should capture traces correctly" pending="a" <|
|
||||||
modname = Meta.get_simple_type_name Stack_Traces_Spec
|
modname = Meta.get_simple_type_name Stack_Traces_Spec
|
||||||
stack = My_Type.foo
|
stack = My_Type.foo
|
||||||
names = [modname + ".bar", modname + ".baz", "Number.foo", modname + ".foo", "My_Type.foo"]
|
names = [modname + ".bar", modname + ".baz", "Number.foo", modname + ".foo", "My_Type.foo"]
|
||||||
@ -42,6 +42,22 @@ add_specs suite_builder = suite_builder.group "Stack traces" group_builder->
|
|||||||
(deep_stack_trace.length > 5) . should_be_true
|
(deep_stack_trace.length > 5) . should_be_true
|
||||||
deep_stack_trace.take 5 . map .name . should_equal names
|
deep_stack_trace.take 5 . map .name . should_equal names
|
||||||
|
|
||||||
|
group_builder.specify "should respect Runtime.Context.Dataflow_Stack_Trace (for error thrown from Enso)" pending="a" <|
|
||||||
|
thrower =
|
||||||
|
big_integer = 922337203685477580700000
|
||||||
|
12 << big_integer
|
||||||
|
shallow_stack_trace = thrower.stack_trace
|
||||||
|
shallow_stack_trace.each (x-> IO.println "ST "+x.to_text)
|
||||||
|
IO.println "===="
|
||||||
|
#shallow_stack_trace.length . should_equal 1
|
||||||
|
#shallow_stack_trace.at 0 . name . should_equal (names.at 0)
|
||||||
|
|
||||||
|
Context.Dataflow_Stack_Trace.with_enabled <|
|
||||||
|
deep_stack_trace = deep_a.stack_trace
|
||||||
|
deep_stack_trace .each (x-> IO.println "ST "+x.to_text)
|
||||||
|
#(deep_stack_trace.length > 5) . should_be_true
|
||||||
|
#deep_stack_trace.take 5 . map .name . should_equal names
|
||||||
|
|
||||||
main =
|
main =
|
||||||
suite = Test.build suite_builder->
|
suite = Test.build suite_builder->
|
||||||
add_specs suite_builder
|
add_specs suite_builder
|
||||||
|
Loading…
Reference in New Issue
Block a user