mirror of
https://github.com/enso-org/enso.git
synced 2024-12-24 17:01:38 +03:00
Fix many of the deprecated warnings in the engine build (#3321)
Cleaning up the deprecated access to Context and Language
This commit is contained in:
parent
4653bfeeab
commit
58fe42a20c
@ -16,10 +16,10 @@ import java.net.URI;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ToJavaStringNode;
|
import org.enso.interpreter.node.expression.builtin.text.util.ToJavaStringNode;
|
||||||
import org.enso.interpreter.node.expression.debug.CaptureResultScopeNode;
|
import org.enso.interpreter.node.expression.debug.CaptureResultScopeNode;
|
||||||
import org.enso.interpreter.node.expression.debug.EvalNode;
|
import org.enso.interpreter.node.expression.debug.EvalNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.CallerInfo;
|
import org.enso.interpreter.runtime.callable.CallerInfo;
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
@ -184,7 +184,7 @@ public class ReplDebuggerInstrument extends TruffleInstrument {
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnter(VirtualFrame frame) {
|
protected void onEnter(VirtualFrame frame) {
|
||||||
CallerInfo lastScope = Function.ArgumentsHelper.getCallerInfo(frame.getArguments());
|
CallerInfo lastScope = Function.ArgumentsHelper.getCallerInfo(frame.getArguments());
|
||||||
Object lastReturn = lookupContextReference(Language.class).get().getNothing().newInstance();
|
Object lastReturn = Context.get(this).getNothing().newInstance();
|
||||||
// Note [Safe Access to State in the Debugger Instrument]
|
// Note [Safe Access to State in the Debugger Instrument]
|
||||||
Object lastState = Function.ArgumentsHelper.getState(frame.getArguments());
|
Object lastState = Function.ArgumentsHelper.getState(frame.getArguments());
|
||||||
nodeState = new ReplExecutionEventNodeState(lastReturn, lastState, lastScope);
|
nodeState = new ReplExecutionEventNodeState(lastReturn, lastState, lastScope);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.enso.interpreter.node;
|
package org.enso.interpreter.node;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage;
|
|
||||||
import com.oracle.truffle.api.frame.FrameSlot;
|
import com.oracle.truffle.api.frame.FrameSlot;
|
||||||
import com.oracle.truffle.api.frame.FrameSlotKind;
|
import com.oracle.truffle.api.frame.FrameSlotKind;
|
||||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
@ -11,7 +9,6 @@ import org.enso.interpreter.Language;
|
|||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.scope.LocalScope;
|
import org.enso.interpreter.runtime.scope.LocalScope;
|
||||||
import org.enso.interpreter.runtime.scope.ModuleScope;
|
import org.enso.interpreter.runtime.scope.ModuleScope;
|
||||||
import org.enso.pkg.QualifiedName;
|
|
||||||
|
|
||||||
/** A common base class for all kinds of root node in Enso. */
|
/** A common base class for all kinds of root node in Enso. */
|
||||||
@NodeInfo(shortName = "Root", description = "A root node for Enso computations")
|
@NodeInfo(shortName = "Root", description = "A root node for Enso computations")
|
||||||
@ -20,8 +17,6 @@ public abstract class EnsoRootNode extends RootNode {
|
|||||||
private final SourceSection sourceSection;
|
private final SourceSection sourceSection;
|
||||||
private final LocalScope localScope;
|
private final LocalScope localScope;
|
||||||
private final ModuleScope moduleScope;
|
private final ModuleScope moduleScope;
|
||||||
private @CompilerDirectives.CompilationFinal TruffleLanguage.ContextReference<Context>
|
|
||||||
contextReference;
|
|
||||||
private final FrameSlot stateFrameSlot;
|
private final FrameSlot stateFrameSlot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,12 +49,7 @@ public abstract class EnsoRootNode extends RootNode {
|
|||||||
* @return a reference to the language context
|
* @return a reference to the language context
|
||||||
*/
|
*/
|
||||||
public Context getContext() {
|
public Context getContext() {
|
||||||
if (contextReference == null) {
|
return Context.get(this);
|
||||||
CompilerDirectives.transferToInterpreterAndInvalidate();
|
|
||||||
contextReference = lookupContextReference(Language.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return contextReference.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ public class ProgramRootNode extends RootNode {
|
|||||||
if (module == null) {
|
if (module == null) {
|
||||||
CompilerDirectives.transferToInterpreterAndInvalidate();
|
CompilerDirectives.transferToInterpreterAndInvalidate();
|
||||||
QualifiedName name = QualifiedName.simpleName(canonicalizeName(sourceCode.getName()));
|
QualifiedName name = QualifiedName.simpleName(canonicalizeName(sourceCode.getName()));
|
||||||
Context ctx = lookupContextReference(Language.class).get();
|
Context ctx = Context.get(this);
|
||||||
if (sourceCode.getPath() != null) {
|
if (sourceCode.getPath() != null) {
|
||||||
TruffleFile src = ctx.getTruffleFile(new File(sourceCode.getPath()));
|
TruffleFile src = ctx.getTruffleFile(new File(sourceCode.getPath()));
|
||||||
Package<TruffleFile> pkg = ctx.getPackageOf(src).orElse(null);
|
Package<TruffleFile> pkg = ctx.getPackageOf(src).orElse(null);
|
||||||
|
@ -2,15 +2,12 @@ package org.enso.interpreter.node.callable;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.RootCallTarget;
|
import com.oracle.truffle.api.RootCallTarget;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.GenerateUncached;
|
import com.oracle.truffle.api.dsl.GenerateUncached;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.DirectCallNode;
|
import com.oracle.truffle.api.nodes.DirectCallNode;
|
||||||
import com.oracle.truffle.api.nodes.IndirectCallNode;
|
import com.oracle.truffle.api.nodes.IndirectCallNode;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
|
||||||
import org.enso.interpreter.runtime.callable.CallerInfo;
|
import org.enso.interpreter.runtime.callable.CallerInfo;
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
import org.enso.interpreter.runtime.state.Stateful;
|
import org.enso.interpreter.runtime.state.Stateful;
|
||||||
|
@ -6,7 +6,6 @@ import com.oracle.truffle.api.dsl.GenerateUncached;
|
|||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.frame.MaterializedFrame;
|
import com.oracle.truffle.api.frame.MaterializedFrame;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode;
|
import org.enso.interpreter.node.BaseNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
||||||
import org.enso.interpreter.node.callable.thunk.ThunkExecutorNode;
|
import org.enso.interpreter.node.callable.thunk.ThunkExecutorNode;
|
||||||
@ -173,8 +172,7 @@ public abstract class IndirectInvokeCallableNode extends Node {
|
|||||||
InvokeCallableNode.DefaultsExecutionMode defaultsExecutionMode,
|
InvokeCallableNode.DefaultsExecutionMode defaultsExecutionMode,
|
||||||
InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode,
|
InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode,
|
||||||
BaseNode.TailStatus isTail) {
|
BaseNode.TailStatus isTail) {
|
||||||
Context ctx = lookupContextReference(Language.class).get();
|
Atom error = Context.get(this).getBuiltins().error().makeNotInvokableError(callable);
|
||||||
Atom error = ctx.getBuiltins().error().makeNotInvokableError(callable);
|
|
||||||
throw new PanicException(error, this);
|
throw new PanicException(error, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,18 @@
|
|||||||
package org.enso.interpreter.node.callable;
|
package org.enso.interpreter.node.callable;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage;
|
|
||||||
import com.oracle.truffle.api.dsl.*;
|
import com.oracle.truffle.api.dsl.*;
|
||||||
import com.oracle.truffle.api.frame.MaterializedFrame;
|
import com.oracle.truffle.api.frame.MaterializedFrame;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
|
||||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||||
import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
||||||
import com.oracle.truffle.api.library.CachedLibrary;
|
import com.oracle.truffle.api.library.CachedLibrary;
|
||||||
import com.oracle.truffle.api.nodes.ExplodeLoop;
|
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.BranchProfile;
|
import com.oracle.truffle.api.profiles.BranchProfile;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
import com.oracle.truffle.api.profiles.ConditionProfile;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode;
|
import org.enso.interpreter.node.BaseNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
||||||
import org.enso.interpreter.node.callable.resolver.AnyResolverNode;
|
|
||||||
import org.enso.interpreter.node.callable.resolver.DataflowErrorResolverNode;
|
|
||||||
import org.enso.interpreter.node.callable.resolver.HostMethodCallNode;
|
import org.enso.interpreter.node.callable.resolver.HostMethodCallNode;
|
||||||
import org.enso.interpreter.node.callable.thunk.ThunkExecutorNode;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
|
||||||
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
import org.enso.interpreter.runtime.data.ArrayRope;
|
import org.enso.interpreter.runtime.data.ArrayRope;
|
||||||
|
@ -1,21 +1,17 @@
|
|||||||
package org.enso.interpreter.node.callable;
|
package org.enso.interpreter.node.callable;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.GenerateUncached;
|
import com.oracle.truffle.api.dsl.GenerateUncached;
|
||||||
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.dsl.*;
|
import com.oracle.truffle.api.dsl.*;
|
||||||
import com.oracle.truffle.api.frame.MaterializedFrame;
|
import com.oracle.truffle.api.frame.MaterializedFrame;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
|
||||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||||
import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
||||||
import com.oracle.truffle.api.library.CachedLibrary;
|
import com.oracle.truffle.api.library.CachedLibrary;
|
||||||
import com.oracle.truffle.api.nodes.ExplodeLoop;
|
import com.oracle.truffle.api.nodes.ExplodeLoop;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
import com.oracle.truffle.api.profiles.ConditionProfile;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode;
|
import org.enso.interpreter.node.BaseNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
||||||
import org.enso.interpreter.node.callable.resolver.*;
|
import org.enso.interpreter.node.callable.resolver.*;
|
||||||
@ -23,15 +19,12 @@ import org.enso.interpreter.node.callable.thunk.ThunkExecutorNode;
|
|||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||||
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
|
||||||
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
|
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
import org.enso.interpreter.runtime.data.Array;
|
import org.enso.interpreter.runtime.data.Array;
|
||||||
import org.enso.interpreter.runtime.data.ArrayRope;
|
import org.enso.interpreter.runtime.data.ArrayRope;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
import org.enso.interpreter.runtime.data.text.Text;
|
||||||
import org.enso.interpreter.runtime.error.*;
|
import org.enso.interpreter.runtime.error.*;
|
||||||
import org.enso.interpreter.runtime.library.dispatch.MethodDispatchLibrary;
|
import org.enso.interpreter.runtime.library.dispatch.MethodDispatchLibrary;
|
||||||
import org.enso.interpreter.runtime.number.EnsoBigInteger;
|
|
||||||
import org.enso.interpreter.runtime.state.Stateful;
|
import org.enso.interpreter.runtime.state.Stateful;
|
||||||
|
|
||||||
@GenerateUncached
|
@GenerateUncached
|
||||||
|
@ -2,11 +2,9 @@ package org.enso.interpreter.node.callable;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.*;
|
import com.oracle.truffle.api.dsl.*;
|
||||||
import com.oracle.truffle.api.nodes.ExplodeLoop;
|
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
import org.enso.interpreter.Constants;
|
import org.enso.interpreter.Constants;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode;
|
import org.enso.interpreter.node.BaseNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;
|
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;
|
||||||
@ -59,14 +57,17 @@ public abstract class InteropApplicationNode extends Node {
|
|||||||
InvokeCallableNode.ArgumentsExecutionMode.PRE_EXECUTED);
|
InvokeCallableNode.ArgumentsExecutionMode.PRE_EXECUTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context getContext() {
|
||||||
|
return Context.get(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Specialization(
|
@Specialization(
|
||||||
guards = {"!context.isInlineCachingDisabled()", "arguments.length == cachedArgsLength"},
|
guards = {"!getContext().isInlineCachingDisabled()", "arguments.length == cachedArgsLength"},
|
||||||
limit = Constants.CacheSizes.FUNCTION_INTEROP_LIBRARY)
|
limit = Constants.CacheSizes.FUNCTION_INTEROP_LIBRARY)
|
||||||
Object callCached(
|
Object callCached(
|
||||||
Function function,
|
Function function,
|
||||||
Object state,
|
Object state,
|
||||||
Object[] arguments,
|
Object[] arguments,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached("arguments.length") int cachedArgsLength,
|
@Cached("arguments.length") int cachedArgsLength,
|
||||||
@Cached("buildSorter(cachedArgsLength)") InvokeFunctionNode sorterNode,
|
@Cached("buildSorter(cachedArgsLength)") InvokeFunctionNode sorterNode,
|
||||||
@Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) {
|
@Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) {
|
||||||
|
@ -2,7 +2,6 @@ package org.enso.interpreter.node.callable;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.GenerateUncached;
|
import com.oracle.truffle.api.dsl.GenerateUncached;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.interop.ArityException;
|
import com.oracle.truffle.api.interop.ArityException;
|
||||||
@ -10,15 +9,12 @@ import com.oracle.truffle.api.nodes.ExplodeLoop;
|
|||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
import org.enso.interpreter.Constants;
|
import org.enso.interpreter.Constants;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode.TailStatus;
|
import org.enso.interpreter.node.BaseNode.TailStatus;
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode;
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode.DefaultsExecutionMode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode.DefaultsExecutionMode;
|
||||||
import org.enso.interpreter.node.callable.InvokeConversionNode;
|
|
||||||
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
|
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
|
||||||
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
||||||
|
|
||||||
/** A helper node to handle conversion application for the interop library. */
|
/** A helper node to handle conversion application for the interop library. */
|
||||||
|
@ -2,20 +2,15 @@ package org.enso.interpreter.node.callable;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.GenerateUncached;
|
import com.oracle.truffle.api.dsl.GenerateUncached;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.interop.ArityException;
|
import com.oracle.truffle.api.interop.ArityException;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
import org.bouncycastle.asn1.tsp.ArchiveTimeStamp;
|
|
||||||
import org.enso.interpreter.Constants;
|
import org.enso.interpreter.Constants;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode;
|
|
||||||
import org.enso.interpreter.node.BaseNode.TailStatus;
|
import org.enso.interpreter.node.BaseNode.TailStatus;
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode;
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode.DefaultsExecutionMode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode.DefaultsExecutionMode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
|
|
||||||
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
|
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||||
@ -65,14 +60,17 @@ public abstract class InteropMethodCallNode extends Node {
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context getContext() {
|
||||||
|
return Context.get(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Specialization(
|
@Specialization(
|
||||||
guards = {"!context.isInlineCachingDisabled()", "arguments.length == cachedArgsLength"},
|
guards = {"!getContext().isInlineCachingDisabled()", "arguments.length == cachedArgsLength"},
|
||||||
limit = Constants.CacheSizes.FUNCTION_INTEROP_LIBRARY)
|
limit = Constants.CacheSizes.FUNCTION_INTEROP_LIBRARY)
|
||||||
Object callCached(
|
Object callCached(
|
||||||
UnresolvedSymbol method,
|
UnresolvedSymbol method,
|
||||||
Object state,
|
Object state,
|
||||||
Object[] arguments,
|
Object[] arguments,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached("arguments.length") int cachedArgsLength,
|
@Cached("arguments.length") int cachedArgsLength,
|
||||||
@Cached("buildSorter(cachedArgsLength)") InvokeMethodNode sorterNode,
|
@Cached("buildSorter(cachedArgsLength)") InvokeMethodNode sorterNode,
|
||||||
@Cached("build()") HostValueToEnsoNode hostValueToEnsoNode)
|
@Cached("build()") HostValueToEnsoNode hostValueToEnsoNode)
|
||||||
@ -81,7 +79,7 @@ public abstract class InteropMethodCallNode extends Node {
|
|||||||
for (int i = 0; i < cachedArgsLength; i++) {
|
for (int i = 0; i < cachedArgsLength; i++) {
|
||||||
args[i] = hostValueToEnsoNode.execute(arguments[i]);
|
args[i] = hostValueToEnsoNode.execute(arguments[i]);
|
||||||
}
|
}
|
||||||
if (arguments.length == 0) throw ArityException.create(1, 0);
|
if (arguments.length == 0) throw ArityException.create(1, -1, 0);
|
||||||
return sorterNode.execute(null, state, method, args[0], args).getValue();
|
return sorterNode.execute(null, state, method, args[0], args).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +95,7 @@ public abstract class InteropMethodCallNode extends Node {
|
|||||||
for (int i = 0; i < arguments.length; i++) {
|
for (int i = 0; i < arguments.length; i++) {
|
||||||
args[i] = hostValueToEnsoNode.execute(arguments[i]);
|
args[i] = hostValueToEnsoNode.execute(arguments[i]);
|
||||||
}
|
}
|
||||||
if (arguments.length == 0) throw ArityException.create(1, 0);
|
if (arguments.length == 0) throw ArityException.create(1, -1, 0);
|
||||||
return indirectInvokeMethodNode
|
return indirectInvokeMethodNode
|
||||||
.execute(
|
.execute(
|
||||||
null,
|
null,
|
||||||
|
@ -10,7 +10,6 @@ import com.oracle.truffle.api.source.SourceSection;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import org.enso.interpreter.Constants;
|
import org.enso.interpreter.Constants;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode;
|
import org.enso.interpreter.node.BaseNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;
|
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;
|
||||||
import org.enso.interpreter.node.callable.thunk.ThunkExecutorNode;
|
import org.enso.interpreter.node.callable.thunk.ThunkExecutorNode;
|
||||||
@ -86,7 +85,6 @@ public abstract class InvokeCallableNode extends BaseNode {
|
|||||||
@Child private InvokeConversionNode invokeConversionNode;
|
@Child private InvokeConversionNode invokeConversionNode;
|
||||||
@Child private ThunkExecutorNode thisExecutor;
|
@Child private ThunkExecutorNode thisExecutor;
|
||||||
@Child private ThunkExecutorNode thatExecutor;
|
@Child private ThunkExecutorNode thatExecutor;
|
||||||
private final ConditionProfile functionErrorProfile = ConditionProfile.createCountingProfile();
|
|
||||||
|
|
||||||
private final boolean canApplyThis;
|
private final boolean canApplyThis;
|
||||||
private final boolean canApplyThat;
|
private final boolean canApplyThat;
|
||||||
|
@ -11,10 +11,8 @@ import com.oracle.truffle.api.nodes.Node;
|
|||||||
import com.oracle.truffle.api.profiles.BranchProfile;
|
import com.oracle.truffle.api.profiles.BranchProfile;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
import com.oracle.truffle.api.profiles.ConditionProfile;
|
||||||
import com.oracle.truffle.api.source.SourceSection;
|
import com.oracle.truffle.api.source.SourceSection;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.BaseNode;
|
import org.enso.interpreter.node.BaseNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;
|
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;
|
||||||
import org.enso.interpreter.node.callable.resolver.AnyResolverNode;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
||||||
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
||||||
@ -196,7 +194,6 @@ public abstract class InvokeConversionNode extends BaseNode {
|
|||||||
Object _this,
|
Object _this,
|
||||||
Object that,
|
Object that,
|
||||||
Object[] arguments,
|
Object[] arguments,
|
||||||
@CachedLibrary(limit = "10") MethodDispatchLibrary methods,
|
|
||||||
@CachedLibrary(limit = "1") MethodDispatchLibrary textDispatch,
|
@CachedLibrary(limit = "1") MethodDispatchLibrary textDispatch,
|
||||||
@CachedLibrary(limit = "10") InteropLibrary interop) {
|
@CachedLibrary(limit = "10") InteropLibrary interop) {
|
||||||
try {
|
try {
|
||||||
|
@ -62,15 +62,18 @@ public abstract class InvokeFunctionNode extends BaseNode {
|
|||||||
return InvokeFunctionNodeGen.create(schema, defaultsExecutionMode, argumentsExecutionMode);
|
return InvokeFunctionNodeGen.create(schema, defaultsExecutionMode, argumentsExecutionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context getContext() {
|
||||||
|
return Context.get(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Specialization(
|
@Specialization(
|
||||||
guards = {"!context.isInlineCachingDisabled()", "function.getSchema() == cachedSchema"},
|
guards = {"!getContext().isInlineCachingDisabled()", "function.getSchema() == cachedSchema"},
|
||||||
limit = Constants.CacheSizes.ARGUMENT_SORTER_NODE)
|
limit = Constants.CacheSizes.ARGUMENT_SORTER_NODE)
|
||||||
Stateful invokeCached(
|
Stateful invokeCached(
|
||||||
Function function,
|
Function function,
|
||||||
VirtualFrame callerFrame,
|
VirtualFrame callerFrame,
|
||||||
Object state,
|
Object state,
|
||||||
Object[] arguments,
|
Object[] arguments,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached("function.getSchema()") FunctionSchema cachedSchema,
|
@Cached("function.getSchema()") FunctionSchema cachedSchema,
|
||||||
@Cached("generate(cachedSchema, getSchema())")
|
@Cached("generate(cachedSchema, getSchema())")
|
||||||
CallArgumentInfo.ArgumentMapping argumentMapping,
|
CallArgumentInfo.ArgumentMapping argumentMapping,
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package org.enso.interpreter.node.callable.resolver;
|
package org.enso.interpreter.node.callable.resolver;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.*;
|
import com.oracle.truffle.api.dsl.*;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
import org.enso.interpreter.runtime.error.DataflowError;
|
|
||||||
|
|
||||||
@GenerateUncached
|
@GenerateUncached
|
||||||
@ReportPolymorphism
|
@ReportPolymorphism
|
||||||
@ -14,20 +11,19 @@ public abstract class AnyResolverNode extends BaseResolverNode {
|
|||||||
public abstract Function execute(UnresolvedSymbol symbol, Object _this);
|
public abstract Function execute(UnresolvedSymbol symbol, Object _this);
|
||||||
|
|
||||||
@Specialization(
|
@Specialization(
|
||||||
guards = {"!context.isInlineCachingDisabled()", "cachedSymbol == symbol", "function != null"},
|
guards = {"!getContext().isInlineCachingDisabled()", "cachedSymbol == symbol", "function != null"},
|
||||||
limit = "CACHE_SIZE")
|
limit = "CACHE_SIZE")
|
||||||
Function resolveCached(
|
Function resolveCached(
|
||||||
UnresolvedSymbol symbol,
|
UnresolvedSymbol symbol,
|
||||||
Object _this,
|
Object _this,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached("symbol") UnresolvedSymbol cachedSymbol,
|
@Cached("symbol") UnresolvedSymbol cachedSymbol,
|
||||||
@Cached("resolveMethodOnAny(context, cachedSymbol)") Function function) {
|
@Cached("resolveMethodOnAny(cachedSymbol)") Function function) {
|
||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization(replaces = "resolveCached")
|
@Specialization(replaces = "resolveCached")
|
||||||
Function resolve(
|
Function resolve(
|
||||||
UnresolvedSymbol symbol, Object _this, @CachedContext(Language.class) Context context) {
|
UnresolvedSymbol symbol, Object _this) {
|
||||||
return throwIfNull(context, resolveMethodOnAny(context, symbol), _this, symbol);
|
return throwIfNull(resolveMethodOnAny(symbol), _this, symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,33 +3,33 @@ package org.enso.interpreter.node.callable.resolver;
|
|||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Bool;
|
|
||||||
import org.enso.interpreter.runtime.builtin.Number;
|
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||||
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
|
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
|
|
||||||
public class BaseResolverNode extends Node {
|
public class BaseResolverNode extends Node {
|
||||||
protected static final int CACHE_SIZE = 10;
|
protected static final int CACHE_SIZE = 10;
|
||||||
|
|
||||||
protected Function throwIfNull(
|
protected Context getContext() {
|
||||||
Context context, Function function, Object _this, UnresolvedSymbol sym) {
|
return Context.get(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Function throwIfNull(Function function, Object _this, UnresolvedSymbol sym) {
|
||||||
if (function == null) {
|
if (function == null) {
|
||||||
CompilerDirectives.transferToInterpreter();
|
CompilerDirectives.transferToInterpreter();
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
context.getBuiltins().error().makeNoSuchMethodError(_this, sym), this);
|
getContext().getBuiltins().error().makeNoSuchMethodError(_this, sym), this);
|
||||||
}
|
}
|
||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CompilerDirectives.TruffleBoundary
|
@CompilerDirectives.TruffleBoundary
|
||||||
Function resolveMethodOnError(Context context, UnresolvedSymbol symbol) {
|
Function resolveMethodOnError(UnresolvedSymbol symbol) {
|
||||||
return symbol.resolveFor(context.getBuiltins().dataflowError().constructor());
|
return symbol.resolveFor(getContext().getBuiltins().dataflowError().constructor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@CompilerDirectives.TruffleBoundary
|
@CompilerDirectives.TruffleBoundary
|
||||||
Function resolveMethodOnAny(Context context, UnresolvedSymbol symbol) {
|
Function resolveMethodOnAny(UnresolvedSymbol symbol) {
|
||||||
return symbol.resolveFor(context.getBuiltins().any());
|
return symbol.resolveFor(getContext().getBuiltins().any());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.callable.resolver;
|
package org.enso.interpreter.node.callable.resolver;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.GenerateUncached;
|
import com.oracle.truffle.api.dsl.GenerateUncached;
|
||||||
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
import org.enso.interpreter.runtime.error.DataflowError;
|
import org.enso.interpreter.runtime.error.DataflowError;
|
||||||
@ -18,22 +15,20 @@ public abstract class DataflowErrorResolverNode extends BaseResolverNode {
|
|||||||
public abstract Function execute(UnresolvedSymbol symbol, DataflowError _this);
|
public abstract Function execute(UnresolvedSymbol symbol, DataflowError _this);
|
||||||
|
|
||||||
@Specialization(
|
@Specialization(
|
||||||
guards = {"!context.isInlineCachingDisabled()", "cachedSymbol == symbol"},
|
guards = {"!getContext().isInlineCachingDisabled()", "cachedSymbol == symbol"},
|
||||||
limit = "CACHE_SIZE")
|
limit = "CACHE_SIZE")
|
||||||
Function resolveCached(
|
Function resolveCached(
|
||||||
UnresolvedSymbol symbol,
|
UnresolvedSymbol symbol,
|
||||||
DataflowError _this,
|
DataflowError _this,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached("symbol") UnresolvedSymbol cachedSymbol,
|
@Cached("symbol") UnresolvedSymbol cachedSymbol,
|
||||||
@Cached("resolveMethodOnError(context, cachedSymbol)") Function function) {
|
@Cached("resolveMethodOnError(cachedSymbol)") Function function) {
|
||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization(replaces = "resolveCached")
|
@Specialization(replaces = "resolveCached")
|
||||||
Function resolve(
|
Function resolve(
|
||||||
UnresolvedSymbol symbol,
|
UnresolvedSymbol symbol,
|
||||||
DataflowError _this,
|
DataflowError _this) {
|
||||||
@CachedContext(Language.class) Context context) {
|
return resolveMethodOnError(symbol);
|
||||||
return resolveMethodOnError(context, symbol);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.oracle.truffle.api.interop.*;
|
|||||||
import com.oracle.truffle.api.library.CachedLibrary;
|
import com.oracle.truffle.api.library.CachedLibrary;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.BranchProfile;
|
import com.oracle.truffle.api.profiles.BranchProfile;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
|
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -101,7 +100,6 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
Object _this,
|
Object _this,
|
||||||
Object[] args,
|
Object[] args,
|
||||||
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members,
|
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
||||||
try {
|
try {
|
||||||
return hostValueToEnsoNode.execute(members.invokeMember(_this, symbol, args));
|
return hostValueToEnsoNode.execute(members.invokeMember(_this, symbol, args));
|
||||||
@ -110,11 +108,11 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
"Impossible to reach here. The member is checked to be invocable.");
|
"Impossible to reach here. The member is checked to be invocable.");
|
||||||
} catch (ArityException e) {
|
} catch (ArityException e) {
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
context.getBuiltins().error().makeArityError(e.getExpectedArity(), e.getActualArity()),
|
Context.get(this).getBuiltins().error().makeArityError(e.getExpectedMinArity(), e.getExpectedMaxArity(), e.getActualArity()),
|
||||||
this);
|
this);
|
||||||
} catch (UnsupportedTypeException e) {
|
} catch (UnsupportedTypeException e) {
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
context.getBuiltins().error().makeUnsupportedArgumentsError(e.getSuppliedValues()), this);
|
Context.get(this).getBuiltins().error().makeUnsupportedArgumentsError(e.getSuppliedValues()), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,12 +123,11 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
Object _this,
|
Object _this,
|
||||||
Object[] args,
|
Object[] args,
|
||||||
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members,
|
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached HostValueToEnsoNode hostValueToEnsoNode,
|
@Cached HostValueToEnsoNode hostValueToEnsoNode,
|
||||||
@Cached BranchProfile errorProfile) {
|
@Cached BranchProfile errorProfile) {
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
errorProfile.enter();
|
errorProfile.enter();
|
||||||
throw new PanicException(context.getBuiltins().error().makeArityError(0, args.length), this);
|
throw new PanicException(Context.get(this).getBuiltins().error().makeArityError(0, 0, args.length), this);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return hostValueToEnsoNode.execute(members.readMember(_this, symbol));
|
return hostValueToEnsoNode.execute(members.readMember(_this, symbol));
|
||||||
@ -147,7 +144,6 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
Object _this,
|
Object _this,
|
||||||
Object[] args,
|
Object[] args,
|
||||||
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary instances,
|
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary instances,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
||||||
try {
|
try {
|
||||||
return hostValueToEnsoNode.execute(instances.instantiate(_this, args));
|
return hostValueToEnsoNode.execute(instances.instantiate(_this, args));
|
||||||
@ -156,11 +152,11 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
"Impossible to reach here. The member is checked to be instantiable.");
|
"Impossible to reach here. The member is checked to be instantiable.");
|
||||||
} catch (ArityException e) {
|
} catch (ArityException e) {
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
context.getBuiltins().error().makeArityError(e.getExpectedArity(), e.getActualArity()),
|
Context.get(this).getBuiltins().error().makeArityError(e.getExpectedMinArity(), e.getExpectedMaxArity(), e.getActualArity()),
|
||||||
this);
|
this);
|
||||||
} catch (UnsupportedTypeException e) {
|
} catch (UnsupportedTypeException e) {
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
context.getBuiltins().error().makeUnsupportedArgumentsError(e.getSuppliedValues()), this);
|
Context.get(this).getBuiltins().error().makeUnsupportedArgumentsError(e.getSuppliedValues()), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,12 +167,11 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
Object _this,
|
Object _this,
|
||||||
Object[] args,
|
Object[] args,
|
||||||
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary arrays,
|
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary arrays,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@Cached BranchProfile errorProfile,
|
@Cached BranchProfile errorProfile,
|
||||||
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
errorProfile.enter();
|
errorProfile.enter();
|
||||||
throw new PanicException(ctx.getBuiltins().error().makeArityError(0, args.length), this);
|
throw new PanicException(Context.get(this).getBuiltins().error().makeArityError(0, 0, args.length), this);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return hostValueToEnsoNode.execute(arrays.getArraySize(_this));
|
return hostValueToEnsoNode.execute(arrays.getArraySize(_this));
|
||||||
@ -194,16 +189,15 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary arrays,
|
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary arrays,
|
||||||
@Cached BranchProfile arityErrorProfile,
|
@Cached BranchProfile arityErrorProfile,
|
||||||
@Cached BranchProfile typeErrorProfile,
|
@Cached BranchProfile typeErrorProfile,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
arityErrorProfile.enter();
|
arityErrorProfile.enter();
|
||||||
throw new PanicException(ctx.getBuiltins().error().makeArityError(1, args.length), this);
|
throw new PanicException(Context.get(this).getBuiltins().error().makeArityError(1, 1, args.length), this);
|
||||||
}
|
}
|
||||||
if (!(args[0] instanceof Long)) {
|
if (!(args[0] instanceof Long)) {
|
||||||
typeErrorProfile.enter();
|
typeErrorProfile.enter();
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
ctx.getBuiltins().error().makeInvalidArrayIndexError(_this, args[0]), this);
|
Context.get(this).getBuiltins().error().makeInvalidArrayIndexError(_this, args[0]), this);
|
||||||
}
|
}
|
||||||
long idx = (Long) args[0];
|
long idx = (Long) args[0];
|
||||||
try {
|
try {
|
||||||
@ -212,7 +206,7 @@ public abstract class HostMethodCallNode extends Node {
|
|||||||
throw new IllegalStateException("Impossible to reach here, _this is checked to be an array");
|
throw new IllegalStateException("Impossible to reach here, _this is checked to be an array");
|
||||||
} catch (InvalidArrayIndexException e) {
|
} catch (InvalidArrayIndexException e) {
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
ctx.getBuiltins().error().makeInvalidArrayIndexError(_this, idx), this);
|
Context.get(this).getBuiltins().error().makeInvalidArrayIndexError(_this, idx), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package org.enso.interpreter.node.controlflow.caseexpr;
|
package org.enso.interpreter.node.controlflow.caseexpr;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.TruffleLanguage;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.NodeChild;
|
import com.oracle.truffle.api.dsl.NodeChild;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.frame.FrameUtil;
|
import com.oracle.truffle.api.frame.FrameUtil;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||||
import com.oracle.truffle.api.nodes.ExplodeLoop;
|
import com.oracle.truffle.api.nodes.ExplodeLoop;
|
||||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.ExpressionNode;
|
import org.enso.interpreter.node.ExpressionNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.ArrayRope;
|
import org.enso.interpreter.runtime.data.ArrayRope;
|
||||||
@ -83,7 +80,6 @@ public abstract class CaseNode extends ExpressionNode {
|
|||||||
*
|
*
|
||||||
* @param frame the stack frame in which to execute
|
* @param frame the stack frame in which to execute
|
||||||
* @param object the object being matched against
|
* @param object the object being matched against
|
||||||
* @param ctx the language context reference
|
|
||||||
* @return the result of executing the case expression on {@code object}
|
* @return the result of executing the case expression on {@code object}
|
||||||
*/
|
*/
|
||||||
@Specialization(
|
@Specialization(
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package org.enso.interpreter.node.controlflow.caseexpr;
|
package org.enso.interpreter.node.controlflow.caseexpr;
|
||||||
|
|
||||||
import com.oracle.truffle.api.RootCallTarget;
|
import com.oracle.truffle.api.RootCallTarget;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
import com.oracle.truffle.api.profiles.ConditionProfile;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
|
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
|
||||||
@ -41,13 +39,12 @@ public abstract class PolyglotBranchNode extends BranchNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization(guards = "isPolyglotObject(context,obj)")
|
@Specialization(guards = "isPolyglotObject(obj)")
|
||||||
void doLiteral(
|
void doLiteral(
|
||||||
VirtualFrame frame,
|
VirtualFrame frame,
|
||||||
Object state,
|
Object state,
|
||||||
Object obj,
|
Object obj) {
|
||||||
@CachedContext(Language.class) Context context) {
|
if (polyglotProfile.profile(isPolyglotObject(obj))) {
|
||||||
if (polyglotProfile.profile(isPolyglotObject(context, obj))) {
|
|
||||||
accept(frame, state, new Object[0]);
|
accept(frame, state, new Object[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +52,7 @@ public abstract class PolyglotBranchNode extends BranchNode {
|
|||||||
@Fallback
|
@Fallback
|
||||||
void doFallback(VirtualFrame frame, Object state, Object target) {}
|
void doFallback(VirtualFrame frame, Object state, Object target) {}
|
||||||
|
|
||||||
boolean isPolyglotObject(Context context, Object o) {
|
boolean isPolyglotObject(Object o) {
|
||||||
return context.getEnvironment().isHostObject(o);
|
return Context.get(this).getEnvironment().isHostObject(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.bool;
|
package org.enso.interpreter.node.expression.builtin.bool;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
@ -29,8 +26,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
boolean doAtom(
|
boolean doAtom(
|
||||||
Atom _this,
|
Atom _this,
|
||||||
Atom that,
|
Atom that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getBooleanConstructor()") AtomConstructor boolCons
|
||||||
@Cached("getBooleanConstructor(ctxRef)") AtomConstructor boolCons
|
|
||||||
) {
|
) {
|
||||||
var thisCons = _this.getConstructor();
|
var thisCons = _this.getConstructor();
|
||||||
var thatCons = that.getConstructor();
|
var thatCons = that.getConstructor();
|
||||||
@ -42,7 +38,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomConstructor getBooleanConstructor(ContextReference<Context> ctxRef) {
|
AtomConstructor getBooleanConstructor() {
|
||||||
return ctxRef.get().getBuiltins().bool().getBool();
|
return Context.get(this).getBuiltins().bool().getBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.bool;
|
package org.enso.interpreter.node.expression.builtin.bool;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
import com.oracle.truffle.api.profiles.ConditionProfile;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
import org.enso.interpreter.dsl.Suspend;
|
import org.enso.interpreter.dsl.Suspend;
|
||||||
@ -29,11 +27,11 @@ public abstract class IfThenNode extends Node {
|
|||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Stateful doExecute(
|
Stateful doExecute(
|
||||||
Object state, boolean _this, Object if_true, @CachedContext(Language.class) Context context) {
|
Object state, boolean _this, Object if_true) {
|
||||||
if (condProfile.profile(_this)) {
|
if (condProfile.profile(_this)) {
|
||||||
return leftThunkExecutorNode.executeThunk(if_true, state, BaseNode.TailStatus.TAIL_DIRECT);
|
return leftThunkExecutorNode.executeThunk(if_true, state, BaseNode.TailStatus.TAIL_DIRECT);
|
||||||
} else {
|
} else {
|
||||||
return new Stateful(state, context.getNothing().newInstance());
|
return new Stateful(state, Context.get(this).getNothing().newInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.debug;
|
package org.enso.interpreter.node.expression.builtin.debug;
|
||||||
|
|
||||||
import com.oracle.truffle.api.debug.DebuggerTags;
|
import com.oracle.truffle.api.debug.DebuggerTags;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||||
import com.oracle.truffle.api.instrumentation.GenerateWrapper;
|
import com.oracle.truffle.api.instrumentation.GenerateWrapper;
|
||||||
@ -9,7 +8,6 @@ import com.oracle.truffle.api.instrumentation.InstrumentableNode;
|
|||||||
import com.oracle.truffle.api.instrumentation.ProbeNode;
|
import com.oracle.truffle.api.instrumentation.ProbeNode;
|
||||||
import com.oracle.truffle.api.instrumentation.Tag;
|
import com.oracle.truffle.api.instrumentation.Tag;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -46,9 +44,8 @@ public abstract class DebugBreakpointNode extends Node implements Instrumentable
|
|||||||
VirtualFrame frame,
|
VirtualFrame frame,
|
||||||
CallerInfo callerInfo,
|
CallerInfo callerInfo,
|
||||||
Object state,
|
Object state,
|
||||||
Object _this,
|
Object _this) {
|
||||||
@CachedContext(Language.class) Context context) {
|
return new Stateful(state, Context.get(this).getNothing().newInstance());
|
||||||
return new Stateful(state, context.getNothing().newInstance());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.error;
|
package org.enso.interpreter.node.expression.builtin.error;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.exception.AbstractTruffleException;
|
import com.oracle.truffle.api.exception.AbstractTruffleException;
|
||||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||||
import com.oracle.truffle.api.library.CachedLibrary;
|
import com.oracle.truffle.api.library.CachedLibrary;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.BranchProfile;
|
import com.oracle.truffle.api.profiles.BranchProfile;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
import org.enso.interpreter.dsl.Suspend;
|
import org.enso.interpreter.dsl.Suspend;
|
||||||
@ -38,8 +35,7 @@ public abstract class RecoverPanicNode extends Node {
|
|||||||
@MonadicState Object state,
|
@MonadicState Object state,
|
||||||
Object _this,
|
Object _this,
|
||||||
Object action,
|
Object action,
|
||||||
@CachedLibrary(limit = "5") InteropLibrary exceptions,
|
@CachedLibrary(limit = "5") InteropLibrary exceptions) {
|
||||||
@CachedContext(Language.class) Context ctx) {
|
|
||||||
try {
|
try {
|
||||||
return thunkExecutorNode.executeThunk(action, state, BaseNode.TailStatus.NOT_TAIL);
|
return thunkExecutorNode.executeThunk(action, state, BaseNode.TailStatus.NOT_TAIL);
|
||||||
} catch (PanicException e) {
|
} catch (PanicException e) {
|
||||||
@ -49,7 +45,7 @@ public abstract class RecoverPanicNode extends Node {
|
|||||||
return new Stateful(
|
return new Stateful(
|
||||||
state,
|
state,
|
||||||
DataflowError.withTrace(
|
DataflowError.withTrace(
|
||||||
ctx.getBuiltins().error().makePolyglotError(e), (AbstractTruffleException) e));
|
Context.get(this).getBuiltins().error().makePolyglotError(e), (AbstractTruffleException) e));
|
||||||
}
|
}
|
||||||
unknownExceptionProfile.enter();
|
unknownExceptionProfile.enter();
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -17,10 +17,20 @@ public abstract class ArityErrorToDisplayTextNode extends Node {
|
|||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Text doAtom(Atom _this) {
|
Text doAtom(Atom _this) {
|
||||||
|
Object[] fields = _this.getFields();
|
||||||
|
|
||||||
|
Text expected = Text.create(String.valueOf(fields[0]));
|
||||||
|
if (!fields[0].equals(fields[1])) {
|
||||||
|
expected = expected.add("-");
|
||||||
|
if (!fields[1].equals(-1)) {
|
||||||
|
expected = expected.add(String.valueOf(fields[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Text.create("Wrong number of arguments. Expected ")
|
return Text.create("Wrong number of arguments. Expected ")
|
||||||
.add(String.valueOf(_this.getFields()[0]))
|
.add(expected)
|
||||||
.add(", but got ")
|
.add(", but got ")
|
||||||
.add(String.valueOf(_this.getFields()[1]))
|
.add(String.valueOf(fields[2]))
|
||||||
.add(".");
|
.add(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
|||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.BranchProfile;
|
import com.oracle.truffle.api.profiles.BranchProfile;
|
||||||
import org.enso.interpreter.Constants;
|
import org.enso.interpreter.Constants;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public class GetArraySizeNode extends Node {
|
|||||||
return library.getArraySize(array);
|
return library.getArraySize(array);
|
||||||
} catch (UnsupportedMessageException e) {
|
} catch (UnsupportedMessageException e) {
|
||||||
err.enter();
|
err.enter();
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
builtins.error().makeTypeError(builtins.mutable().array(), array, "array"), this);
|
builtins.error().makeTypeError(builtins.mutable().array(), array, "array"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.interop.generic;
|
package org.enso.interpreter.node.expression.builtin.interop.generic;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.interop.java.AddToClassPathNodeGen;
|
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
|
|
||||||
@ -26,10 +23,9 @@ public abstract class IsLanguageInstalledNode extends Node {
|
|||||||
boolean doExecute(
|
boolean doExecute(
|
||||||
Object _this,
|
Object _this,
|
||||||
Object language_name,
|
Object language_name,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached ExpectStringNode expectStringNode) {
|
@Cached ExpectStringNode expectStringNode) {
|
||||||
String name = expectStringNode.execute(language_name);
|
String name = expectStringNode.execute(language_name);
|
||||||
return context.getEnvironment().getPublicLanguages().get(name) != null;
|
return Context.get(this).getEnvironment().getPublicLanguages().get(name) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract boolean execute(Object _this, Object language_name);
|
abstract boolean execute(Object _this, Object language_name);
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.interop.java;
|
package org.enso.interpreter.node.expression.builtin.interop.java;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -25,8 +23,8 @@ public abstract class AddToClassPathNode extends Node {
|
|||||||
Object doExecute(
|
Object doExecute(
|
||||||
Object _this,
|
Object _this,
|
||||||
Object path,
|
Object path,
|
||||||
@CachedContext(Language.class) Context context,
|
|
||||||
@Cached ExpectStringNode expectStringNode) {
|
@Cached ExpectStringNode expectStringNode) {
|
||||||
|
Context context = Context.get(this);
|
||||||
context
|
context
|
||||||
.getEnvironment()
|
.getEnvironment()
|
||||||
.addToHostClassPath(context.getTruffleFile(new File(expectStringNode.execute(path))));
|
.addToHostClassPath(context.getTruffleFile(new File(expectStringNode.execute(path))));
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.interop.java;
|
package org.enso.interpreter.node.expression.builtin.interop.java;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -19,9 +17,8 @@ public abstract class LookupClassNode extends Node {
|
|||||||
Object doExecute(
|
Object doExecute(
|
||||||
Object _this,
|
Object _this,
|
||||||
Object name,
|
Object name,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@Cached("build()") ExpectStringNode expectStringNode) {
|
@Cached("build()") ExpectStringNode expectStringNode) {
|
||||||
return ctx.getEnvironment().lookupHostSymbol(expectStringNode.execute(name));
|
return Context.get(this).getEnvironment().lookupHostSymbol(expectStringNode.execute(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract Object execute(Object _this, Object name);
|
abstract Object execute(Object _this, Object name);
|
||||||
|
@ -4,7 +4,6 @@ import com.oracle.truffle.api.dsl.*;
|
|||||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||||
import com.oracle.truffle.api.library.CachedLibrary;
|
import com.oracle.truffle.api.library.CachedLibrary;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
import org.enso.interpreter.runtime.data.text.Text;
|
||||||
@ -61,9 +60,8 @@ public abstract class HostValueToEnsoNode extends Node {
|
|||||||
@Specialization(guards = {"o != null", "nulls.isNull(o)"})
|
@Specialization(guards = {"o != null", "nulls.isNull(o)"})
|
||||||
Atom doNull(
|
Atom doNull(
|
||||||
Object o,
|
Object o,
|
||||||
@CachedLibrary(limit = "3") InteropLibrary nulls,
|
@CachedLibrary(limit = "3") InteropLibrary nulls) {
|
||||||
@CachedContext(Language.class) Context ctx) {
|
return Context.get(this).getBuiltins().nothing().newInstance();
|
||||||
return ctx.getBuiltins().nothing().newInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.io;
|
package org.enso.interpreter.node.expression.builtin.io;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleFile;
|
import com.oracle.truffle.api.TruffleFile;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ToJavaStringNode;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.EnsoFile;
|
import org.enso.interpreter.runtime.data.EnsoFile;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
|
||||||
|
|
||||||
@BuiltinMethod(
|
@BuiltinMethod(
|
||||||
type = "Prim_Io",
|
type = "Prim_Io",
|
||||||
@ -24,9 +19,10 @@ public abstract class GetCwdNode extends Node {
|
|||||||
abstract Object execute(Object _this);
|
abstract Object execute(Object _this);
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doExecute(Object _this, @CachedContext(Language.class) Context ctx) {
|
Object doExecute(Object _this) {
|
||||||
TruffleFile file = ctx.getEnvironment().getCurrentWorkingDirectory();
|
Context context = Context.get(this);
|
||||||
|
TruffleFile file = context.getEnvironment().getCurrentWorkingDirectory();
|
||||||
EnsoFile ensoFile = new EnsoFile(file);
|
EnsoFile ensoFile = new EnsoFile(file);
|
||||||
return ctx.getEnvironment().asGuestValue(ensoFile);
|
return context.getEnvironment().asGuestValue(ensoFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,12 @@ package org.enso.interpreter.node.expression.builtin.io;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.TruffleFile;
|
import com.oracle.truffle.api.TruffleFile;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.EnsoFile;
|
import org.enso.interpreter.runtime.data.EnsoFile;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
|
||||||
|
|
||||||
@BuiltinMethod(
|
@BuiltinMethod(
|
||||||
type = "Prim_Io",
|
type = "Prim_Io",
|
||||||
@ -28,11 +25,11 @@ public abstract class GetFileNode extends Node {
|
|||||||
Object doGetFile(
|
Object doGetFile(
|
||||||
Object _this,
|
Object _this,
|
||||||
Object path,
|
Object path,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@Cached("build()") ExpectStringNode expectStringNode) {
|
@Cached("build()") ExpectStringNode expectStringNode) {
|
||||||
String pathStr = expectStringNode.execute(path);
|
String pathStr = expectStringNode.execute(path);
|
||||||
TruffleFile file = ctx.getEnvironment().getPublicTruffleFile(pathStr);
|
var context= Context.get(this);
|
||||||
|
TruffleFile file = context.getEnvironment().getPublicTruffleFile(pathStr);
|
||||||
EnsoFile ensoFile = new EnsoFile(file);
|
EnsoFile ensoFile = new EnsoFile(file);
|
||||||
return ctx.getEnvironment().asGuestValue(ensoFile);
|
return context.getEnvironment().asGuestValue(ensoFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package org.enso.interpreter.node.expression.builtin.io;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||||
@ -10,7 +9,6 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
|||||||
import com.oracle.truffle.api.library.CachedLibrary;
|
import com.oracle.truffle.api.library.CachedLibrary;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.AcceptsError;
|
import org.enso.interpreter.dsl.AcceptsError;
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
@ -40,8 +38,8 @@ public abstract class PrintErrNode extends Node {
|
|||||||
Object state,
|
Object state,
|
||||||
Object self,
|
Object self,
|
||||||
Object message,
|
Object message,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@CachedLibrary(limit = "10") InteropLibrary strings) {
|
@CachedLibrary(limit = "10") InteropLibrary strings) {
|
||||||
|
Context ctx = Context.get(this);
|
||||||
try {
|
try {
|
||||||
print(ctx.getErr(), strings.asString(message));
|
print(ctx.getErr(), strings.asString(message));
|
||||||
} catch (UnsupportedMessageException e) {
|
} catch (UnsupportedMessageException e) {
|
||||||
@ -56,12 +54,12 @@ public abstract class PrintErrNode extends Node {
|
|||||||
Object state,
|
Object state,
|
||||||
Object self,
|
Object self,
|
||||||
Object message,
|
Object message,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@CachedLibrary(limit = "10") InteropLibrary strings,
|
@CachedLibrary(limit = "10") InteropLibrary strings,
|
||||||
@Cached("buildSymbol(ctx)") UnresolvedSymbol symbol,
|
@Cached("buildSymbol()") UnresolvedSymbol symbol,
|
||||||
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode,
|
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode,
|
||||||
@Cached ExpectStringNode expectStringNode) {
|
@Cached ExpectStringNode expectStringNode) {
|
||||||
Stateful str = invokeCallableNode.execute(symbol, frame, state, new Object[] {message});
|
Stateful str = invokeCallableNode.execute(symbol, frame, state, new Object[] {message});
|
||||||
|
Context ctx = Context.get(this);
|
||||||
print(ctx.getErr(), expectStringNode.execute(str.getValue()));
|
print(ctx.getErr(), expectStringNode.execute(str.getValue()));
|
||||||
return new Stateful(str.getState(), ctx.getNothing().newInstance());
|
return new Stateful(str.getState(), ctx.getNothing().newInstance());
|
||||||
}
|
}
|
||||||
@ -82,7 +80,7 @@ public abstract class PrintErrNode extends Node {
|
|||||||
InvokeCallableNode.ArgumentsExecutionMode.PRE_EXECUTED);
|
InvokeCallableNode.ArgumentsExecutionMode.PRE_EXECUTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnresolvedSymbol buildSymbol(Context ctx) {
|
UnresolvedSymbol buildSymbol() {
|
||||||
return UnresolvedSymbol.build("to_text", ctx.getBuiltins().getScope());
|
return UnresolvedSymbol.build("to_text", Context.get(this).getBuiltins().getScope());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package org.enso.interpreter.node.expression.builtin.io;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||||
@ -10,7 +9,6 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
|||||||
import com.oracle.truffle.api.library.CachedLibrary;
|
import com.oracle.truffle.api.library.CachedLibrary;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.AcceptsError;
|
import org.enso.interpreter.dsl.AcceptsError;
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
@ -39,8 +37,8 @@ public abstract class PrintlnNode extends Node {
|
|||||||
Object state,
|
Object state,
|
||||||
Object self,
|
Object self,
|
||||||
Object message,
|
Object message,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@CachedLibrary(limit = "10") InteropLibrary strings) {
|
@CachedLibrary(limit = "10") InteropLibrary strings) {
|
||||||
|
Context ctx = Context.get(this);
|
||||||
try {
|
try {
|
||||||
print(ctx.getOut(), strings.asString(message));
|
print(ctx.getOut(), strings.asString(message));
|
||||||
} catch (UnsupportedMessageException e) {
|
} catch (UnsupportedMessageException e) {
|
||||||
@ -55,12 +53,12 @@ public abstract class PrintlnNode extends Node {
|
|||||||
Object state,
|
Object state,
|
||||||
Object self,
|
Object self,
|
||||||
Object message,
|
Object message,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@CachedLibrary(limit = "10") InteropLibrary strings,
|
@CachedLibrary(limit = "10") InteropLibrary strings,
|
||||||
@Cached("buildSymbol(ctx)") UnresolvedSymbol symbol,
|
@Cached("buildSymbol()") UnresolvedSymbol symbol,
|
||||||
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode,
|
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode,
|
||||||
@Cached ExpectStringNode expectStringNode) {
|
@Cached ExpectStringNode expectStringNode) {
|
||||||
Stateful str = invokeCallableNode.execute(symbol, frame, state, new Object[] {message});
|
Stateful str = invokeCallableNode.execute(symbol, frame, state, new Object[] {message});
|
||||||
|
Context ctx = Context.get(this);
|
||||||
print(ctx.getOut(), expectStringNode.execute(str.getValue()));
|
print(ctx.getOut(), expectStringNode.execute(str.getValue()));
|
||||||
return new Stateful(str.getState(), ctx.getNothing().newInstance());
|
return new Stateful(str.getState(), ctx.getNothing().newInstance());
|
||||||
}
|
}
|
||||||
@ -74,8 +72,8 @@ public abstract class PrintlnNode extends Node {
|
|||||||
out.println(str);
|
out.println(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnresolvedSymbol buildSymbol(Context ctx) {
|
UnresolvedSymbol buildSymbol() {
|
||||||
return UnresolvedSymbol.build("to_text", ctx.getBuiltins().getScope());
|
return UnresolvedSymbol.build("to_text", Context.get(this).getBuiltins().getScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
InvokeCallableNode buildInvokeCallableNode() {
|
InvokeCallableNode buildInvokeCallableNode() {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.io;
|
package org.enso.interpreter.node.expression.builtin.io;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
import org.enso.interpreter.runtime.data.text.Text;
|
||||||
@ -22,9 +20,9 @@ public abstract class ReadlnNode extends Node {
|
|||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
@TruffleBoundary
|
@TruffleBoundary
|
||||||
Text doRead(Object _this, @CachedContext(Language.class) Context ctx) {
|
Text doRead(Object _this) {
|
||||||
try {
|
try {
|
||||||
return Text.create(ctx.getInReader().readLine());
|
return Text.create(Context.get(this).getInReader().readLine());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PanicException("Empty input stream", this);
|
throw new PanicException("Empty input stream", this);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.meta;
|
package org.enso.interpreter.node.expression.builtin.meta;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
import org.enso.interpreter.runtime.data.text.Text;
|
||||||
@ -23,8 +21,8 @@ public abstract class GetPolyglotLanguageNode extends Node {
|
|||||||
abstract Text execute(Object _this, Object value);
|
abstract Text execute(Object _this, Object value);
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Text doExecute(Object _this, Object value, @CachedContext(Language.class) Context context) {
|
Text doExecute(Object _this, Object value) {
|
||||||
if (context.getEnvironment().isHostObject(value)) {
|
if (Context.get(this).getEnvironment().isHostObject(value)) {
|
||||||
return java;
|
return java;
|
||||||
} else {
|
} else {
|
||||||
return unknown;
|
return unknown;
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.meta;
|
package org.enso.interpreter.node.expression.builtin.meta;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Constants;
|
import org.enso.interpreter.Constants;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
import org.enso.interpreter.runtime.data.text.Text;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
|
|
||||||
@ -40,7 +37,7 @@ public abstract class GetUnresolvedSymbolNameNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Text doFallback(Object _this, Object symbol) {
|
Text doFallback(Object _this, Object symbol) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
builtins.error().makeTypeError("Unresolved_Symbol", symbol, "symbol"), this);
|
builtins.error().makeTypeError("Unresolved_Symbol", symbol, "symbol"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,11 @@ package org.enso.interpreter.node.expression.builtin.meta;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
|
||||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
import org.enso.interpreter.runtime.scope.ModuleScope;
|
import org.enso.interpreter.runtime.scope.ModuleScope;
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ public abstract class GetUnresolvedSymbolScopeNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
ModuleScope doFallback(Object _this, Object symbol) {
|
ModuleScope doFallback(Object _this, Object symbol) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
builtins.error().makeTypeError("Unresolved_Symbol", symbol, "symbol"), this);
|
builtins.error().makeTypeError("Unresolved_Symbol", symbol, "symbol"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.meta;
|
package org.enso.interpreter.node.expression.builtin.meta;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.AcceptsError;
|
import org.enso.interpreter.dsl.AcceptsError;
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -20,7 +18,7 @@ public abstract class IsPolyglotNode extends Node {
|
|||||||
abstract boolean execute(Object _this, @AcceptsError Object value);
|
abstract boolean execute(Object _this, @AcceptsError Object value);
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
boolean doExecute(Object _this, Object value, @CachedContext(Language.class) Context context) {
|
boolean doExecute(Object _this, Object value) {
|
||||||
return context.getEnvironment().isHostObject(value);
|
return Context.get(this).getEnvironment().isHostObject(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.mutable;
|
package org.enso.interpreter.node.expression.builtin.mutable;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
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 com.oracle.truffle.api.nodes.NodeInfo;
|
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode;
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode;
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode.DefaultsExecutionMode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode.DefaultsExecutionMode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
|
import org.enso.interpreter.runtime.builtin.Ordering;
|
||||||
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -38,16 +36,19 @@ public abstract class ComparatorNode extends Node {
|
|||||||
|
|
||||||
abstract int execute(VirtualFrame frame, Object comparator, Object l, Object r);
|
abstract int execute(VirtualFrame frame, Object comparator, Object l, Object r);
|
||||||
|
|
||||||
|
Ordering getOrdering() {
|
||||||
|
return Context.get(this).getBuiltins().ordering();
|
||||||
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
int execute(
|
int execute(
|
||||||
VirtualFrame frame,
|
VirtualFrame frame,
|
||||||
Object comparator,
|
Object comparator,
|
||||||
Object l,
|
Object l,
|
||||||
Object r,
|
Object r,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering().newLess()") Atom less,
|
||||||
@Cached("ctxRef.get().getBuiltins().ordering().newLess()") Atom less,
|
@Cached("getOrdering().newEqual()") Atom equal,
|
||||||
@Cached("ctxRef.get().getBuiltins().ordering().newEqual()") Atom equal,
|
@Cached("getOrdering().newGreater()") Atom greater) {
|
||||||
@Cached("ctxRef.get().getBuiltins().ordering().newGreater()") Atom greater) {
|
|
||||||
Stateful result = invokeNode.execute(comparator, frame, EmptyMap.create(), new Object[] {l, r});
|
Stateful result = invokeNode.execute(comparator, frame, EmptyMap.create(), new Object[] {l, r});
|
||||||
Object atom = result.getValue();
|
Object atom = result.getValue();
|
||||||
if (atom == less) {
|
if (atom == less) {
|
||||||
@ -58,9 +59,9 @@ public abstract class ComparatorNode extends Node {
|
|||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
CompilerDirectives.transferToInterpreter();
|
CompilerDirectives.transferToInterpreter();
|
||||||
var ordering = ctxRef.get().getBuiltins().ordering().ordering();
|
var ordering = getOrdering().ordering();
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
ctxRef.get().getBuiltins().error().makeTypeError(ordering, atom, "comparator"), this);
|
Context.get(this).getBuiltins().error().makeTypeError(ordering, atom, "comparator"), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.mutable;
|
package org.enso.interpreter.node.expression.builtin.mutable;
|
||||||
|
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.data.Array;
|
import org.enso.interpreter.runtime.data.Array;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -17,7 +17,7 @@ public class GetAtNode extends Node {
|
|||||||
try {
|
try {
|
||||||
return _this.getItems()[(int) index];
|
return _this.getItems()[(int) index];
|
||||||
} catch (IndexOutOfBoundsException exception) {
|
} catch (IndexOutOfBoundsException exception) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
throw new PanicException(builtins.error().makeInvalidArrayIndexError(_this, index), this);
|
throw new PanicException(builtins.error().makeInvalidArrayIndexError(_this, index), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.mutable;
|
package org.enso.interpreter.node.expression.builtin.mutable;
|
||||||
|
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.AcceptsError;
|
import org.enso.interpreter.dsl.AcceptsError;
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.data.Array;
|
import org.enso.interpreter.runtime.data.Array;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -19,7 +19,7 @@ public class SetAtNode extends Node {
|
|||||||
_this.getItems()[(int) index] = value;
|
_this.getItems()[(int) index] = value;
|
||||||
return _this;
|
return _this;
|
||||||
} catch (IndexOutOfBoundsException exception) {
|
} catch (IndexOutOfBoundsException exception) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
throw new PanicException(builtins.error().makeInvalidArrayIndexError(_this, index), this);
|
throw new PanicException(builtins.error().makeInvalidArrayIndexError(_this, index), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.mutable;
|
package org.enso.interpreter.node.expression.builtin.mutable;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||||
import com.oracle.truffle.api.nodes.LoopNode;
|
import com.oracle.truffle.api.nodes.LoopNode;
|
||||||
@ -11,13 +8,11 @@ import com.oracle.truffle.api.nodes.Node;
|
|||||||
import com.oracle.truffle.api.profiles.BranchProfile;
|
import com.oracle.truffle.api.profiles.BranchProfile;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.callable.dispatch.CallOptimiserNode;
|
import org.enso.interpreter.node.callable.dispatch.CallOptimiserNode;
|
||||||
import org.enso.interpreter.node.callable.dispatch.SimpleCallOptimiserNode;
|
import org.enso.interpreter.node.callable.dispatch.SimpleCallOptimiserNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
|
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
import org.enso.interpreter.runtime.data.Array;
|
import org.enso.interpreter.runtime.data.Array;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -40,36 +35,33 @@ public abstract class SortNode extends Node {
|
|||||||
Object doSortFunction(
|
Object doSortFunction(
|
||||||
VirtualFrame frame,
|
VirtualFrame frame,
|
||||||
Array _this,
|
Array _this,
|
||||||
Function comparator,
|
Function comparator) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
Context context = Context.get(this);
|
||||||
Comparator<Object> compare = getComparator(comparator, ctxRef);
|
Comparator<Object> compare = getComparator(comparator, context);
|
||||||
return runSort(compare, _this, ctxRef);
|
return runSort(compare, _this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doSortCallable(
|
Object doSortCallable(
|
||||||
VirtualFrame frame,
|
VirtualFrame frame,
|
||||||
Array _this,
|
Array _this,
|
||||||
Object comparator,
|
Object comparator) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
Comparator<Object> compare = (l, r) -> comparatorNode.execute(frame, comparator, l, r);
|
Comparator<Object> compare = (l, r) -> comparatorNode.execute(frame, comparator, l, r);
|
||||||
return runSort(compare, _this, ctxRef);
|
return runSort(compare, _this, Context.get(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(
|
Object doAtomThis(
|
||||||
VirtualFrame frame,
|
VirtualFrame frame,
|
||||||
Atom _this,
|
Atom _this,
|
||||||
Object that,
|
Object that) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
return Context.get(this).getBuiltins().nothing().newInstance();
|
||||||
@Cached("ctxRef.get().getBuiltins().mutable().array()") AtomConstructor array) {
|
|
||||||
return ctxRef.get().getBuiltins().nothing().newInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object runSort(Comparator<Object> compare, Array _this, ContextReference<Context> ctxRef) {
|
Object runSort(Comparator<Object> compare, Array _this, Context context) {
|
||||||
doSort(_this.getItems(), compare);
|
doSort(_this.getItems(), compare);
|
||||||
LoopNode.reportLoopCount(this, _this.length());
|
LoopNode.reportLoopCount(this, _this.length());
|
||||||
return ctxRef.get().getBuiltins().nothing().newInstance();
|
return context.getBuiltins().nothing().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TruffleBoundary
|
@TruffleBoundary
|
||||||
@ -77,24 +69,24 @@ public abstract class SortNode extends Node {
|
|||||||
Arrays.sort(items, compare);
|
Arrays.sort(items, compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortComparator getComparator(Function comp, ContextReference<Context> ctxRef) {
|
private SortComparator getComparator(Function comp, Context context) {
|
||||||
return new SortComparator(comp, ctxRef, this);
|
return new SortComparator(comp, context, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SortComparator implements Comparator<Object> {
|
private class SortComparator implements Comparator<Object> {
|
||||||
private final Function compFn;
|
private final Function compFn;
|
||||||
private final ContextReference<Context> ctxRef;
|
private final Context context;
|
||||||
private final Atom less;
|
private final Atom less;
|
||||||
private final Atom equal;
|
private final Atom equal;
|
||||||
private final Atom greater;
|
private final Atom greater;
|
||||||
private final SortNode outerThis;
|
private final SortNode outerThis;
|
||||||
|
|
||||||
SortComparator(Function compFn, ContextReference<Context> ctxRef, SortNode outerThis) {
|
SortComparator(Function compFn, Context context, SortNode outerThis) {
|
||||||
this.compFn = compFn;
|
this.compFn = compFn;
|
||||||
this.ctxRef = ctxRef;
|
this.context = context;
|
||||||
this.less = ctxRef.get().getBuiltins().ordering().newLess();
|
this.less = context.getBuiltins().ordering().newLess();
|
||||||
this.equal = ctxRef.get().getBuiltins().ordering().newEqual();
|
this.equal = context.getBuiltins().ordering().newEqual();
|
||||||
this.greater = ctxRef.get().getBuiltins().ordering().newGreater();
|
this.greater = context.getBuiltins().ordering().newGreater();
|
||||||
this.outerThis = outerThis;
|
this.outerThis = outerThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,9 +107,9 @@ public abstract class SortNode extends Node {
|
|||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
resultProfile.enter();
|
resultProfile.enter();
|
||||||
var ordering = ctxRef.get().getBuiltins().ordering().ordering();
|
var ordering = context.getBuiltins().ordering().ordering();
|
||||||
throw new PanicException(
|
throw new PanicException(
|
||||||
ctxRef.get().getBuiltins().error().makeTypeError(ordering, res, "result"), outerThis);
|
context.getBuiltins().error().makeTypeError(ordering, res, "result"), outerThis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -39,7 +39,7 @@ public abstract class AddNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(EnsoBigInteger _this, Object that) {
|
Object doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -35,15 +33,15 @@ public abstract class BitAndNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -25,7 +25,7 @@ public abstract class BitNotNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this) {
|
Object doOther(Object _this) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -35,15 +33,15 @@ public abstract class BitOrNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.ImportStatic;
|
import com.oracle.truffle.api.dsl.ImportStatic;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
import com.oracle.truffle.api.profiles.ConditionProfile;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -41,13 +38,12 @@ public abstract class BitShiftNode extends Node {
|
|||||||
@Specialization(guards = "that >= 0", replaces = "doBigIntShiftLeft")
|
@Specialization(guards = "that >= 0", replaces = "doBigIntShiftLeft")
|
||||||
Object doBigIntShiftLeftExplicit(
|
Object doBigIntShiftLeftExplicit(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
long that,
|
long that) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
if (fitsInIntProfileLeftShift.profile(BigIntegerOps.fitsInInt(that))) {
|
if (fitsInIntProfileLeftShift.profile(BigIntegerOps.fitsInInt(that))) {
|
||||||
return doBigIntShiftLeft(_this, that);
|
return doBigIntShiftLeft(_this, that);
|
||||||
} else {
|
} else {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getShiftAmountTooLargeError(), this);
|
Context.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,27 +64,26 @@ public abstract class BitShiftNode extends Node {
|
|||||||
@Specialization
|
@Specialization
|
||||||
Object doBigIntThat(
|
Object doBigIntThat(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
EnsoBigInteger that,
|
EnsoBigInteger that) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
if (!BigIntegerOps.nonNegative(that.getValue())) {
|
if (!BigIntegerOps.nonNegative(that.getValue())) {
|
||||||
return BigIntegerOps.nonNegative(_this.getValue()) ? 0L : -1L;
|
return BigIntegerOps.nonNegative(_this.getValue()) ? 0L : -1L;
|
||||||
} else {
|
} else {
|
||||||
// Note [Well-Formed BigIntegers]
|
// Note [Well-Formed BigIntegers]
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getShiftAmountTooLargeError(), this);
|
Context.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -37,15 +35,15 @@ public abstract class BitShiftRightNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class)Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -35,15 +33,15 @@ public abstract class BitXorNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -31,8 +28,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doLong(
|
Atom doLong(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
long that,
|
long that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
return ordering.fromJava(BigIntegerOps.compareTo(_this.getValue(), that));
|
return ordering.fromJava(BigIntegerOps.compareTo(_this.getValue(), that));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +36,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doBigInt(
|
Atom doBigInt(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
EnsoBigInteger that,
|
EnsoBigInteger that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
return ordering.fromJava(BigIntegerOps.compareTo(_this.getValue(), that.getValue()));
|
return ordering.fromJava(BigIntegerOps.compareTo(_this.getValue(), that.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,23 +44,21 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doDecimal(
|
Atom doDecimal(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
double that,
|
double that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
return ordering.fromJava(BigIntegerOps.compareTo(_this.getValue(), that));
|
return ordering.fromJava(BigIntegerOps.compareTo(_this.getValue(), that));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Atom doOther(
|
Atom doOther(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
Object that,
|
Object that) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
CompilerDirectives.transferToInterpreter();
|
CompilerDirectives.transferToInterpreter();
|
||||||
var number = ctxRef.get().getBuiltins().number().getNumber().newInstance();
|
var number = Context.get(this).getBuiltins().number().getNumber().newInstance();
|
||||||
var typeError = ctxRef.get().getBuiltins().error().makeTypeError(that, number, "that");
|
var typeError = Context.get(this).getBuiltins().error().makeTypeError(that, number, "that");
|
||||||
throw new PanicException(typeError, this);
|
throw new PanicException(typeError, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ordering getOrdering(ContextReference<Context> ctxRef) {
|
Ordering getOrdering() {
|
||||||
return ctxRef.get().getBuiltins().ordering();
|
return Context.get(this).getBuiltins().ordering();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -29,13 +26,12 @@ public abstract class DivNode extends Node {
|
|||||||
@Specialization
|
@Specialization
|
||||||
Object doLong(
|
Object doLong(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
long that,
|
long that) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
try {
|
try {
|
||||||
return toEnsoNumberNode.execute(BigIntegerOps.divide(_this.getValue(), that));
|
return toEnsoNumberNode.execute(BigIntegerOps.divide(_this.getValue(), that));
|
||||||
} catch (ArithmeticException e) {
|
} catch (ArithmeticException e) {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getDivideByZeroError(), this);
|
Context.get(this).getBuiltins().error().getDivideByZeroError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +43,7 @@ public abstract class DivNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(EnsoBigInteger _this, Object that) {
|
Object doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class DivideNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
double doOther(EnsoBigInteger _this, Object that) {
|
double doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -37,8 +34,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
boolean doAtom(
|
boolean doAtom(
|
||||||
Atom _this,
|
Atom _this,
|
||||||
Atom that,
|
Atom that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getBigIntegerConstructor()") AtomConstructor bigIntCons) {
|
||||||
@Cached("getBigIntegerConstructor(ctxRef)") AtomConstructor bigIntCons) {
|
|
||||||
var thisCons = _this.getConstructor();
|
var thisCons = _this.getConstructor();
|
||||||
var thatCons = that.getConstructor();
|
var thatCons = that.getConstructor();
|
||||||
return (thatCons == bigIntCons) && (thisCons == thatCons);
|
return (thatCons == bigIntCons) && (thisCons == thatCons);
|
||||||
@ -49,7 +45,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomConstructor getBigIntegerConstructor(ContextReference<Context> ctxRef) {
|
AtomConstructor getBigIntegerConstructor() {
|
||||||
return ctxRef.get().getBuiltins().number().getBigInteger();
|
return Context.get(this).getBuiltins().number().getBigInteger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class GreaterNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(EnsoBigInteger _this, Object that) {
|
boolean doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class GreaterOrEqualNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(EnsoBigInteger _this, Object that) {
|
boolean doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class LessNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(EnsoBigInteger _this, Object that) {
|
boolean doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class LessOrEqualNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(EnsoBigInteger _this, Object that) {
|
boolean doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -29,13 +26,12 @@ public abstract class ModNode extends Node {
|
|||||||
@Specialization
|
@Specialization
|
||||||
Object doLong(
|
Object doLong(
|
||||||
EnsoBigInteger _this,
|
EnsoBigInteger _this,
|
||||||
long that,
|
long that) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
try {
|
try {
|
||||||
return toEnsoNumberNode.execute(BigIntegerOps.modulo(_this.getValue(), that));
|
return toEnsoNumberNode.execute(BigIntegerOps.modulo(_this.getValue(), that));
|
||||||
} catch (ArithmeticException e) {
|
} catch (ArithmeticException e) {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getDivideByZeroError(), this);
|
Context.get(this).getBuiltins().error().getDivideByZeroError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +43,7 @@ public abstract class ModNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(EnsoBigInteger _this, Object that) {
|
Object doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -39,7 +39,7 @@ public abstract class MultiplyNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(EnsoBigInteger _this, Object that) {
|
Object doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -52,7 +52,7 @@ public abstract class PowNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(EnsoBigInteger _this, Object that) {
|
Object doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -39,7 +39,7 @@ public abstract class SubtractNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(EnsoBigInteger _this, Object that) {
|
Object doOther(EnsoBigInteger _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class AddNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
double doOther(double _this, Object that) {
|
double doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.decimal;
|
package org.enso.interpreter.node.expression.builtin.number.decimal;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -28,8 +25,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doLong(
|
Atom doLong(
|
||||||
double _this,
|
double _this,
|
||||||
long that,
|
long that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
if (_this == that) {
|
if (_this == that) {
|
||||||
return ordering.newEqual();
|
return ordering.newEqual();
|
||||||
} else if (_this > that) {
|
} else if (_this > that) {
|
||||||
@ -43,8 +39,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doBigInt(
|
Atom doBigInt(
|
||||||
double _this,
|
double _this,
|
||||||
EnsoBigInteger that,
|
EnsoBigInteger that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
return ordering.fromJava(BigIntegerOps.compareTo(_this, that.getValue()));
|
return ordering.fromJava(BigIntegerOps.compareTo(_this, that.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +47,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doDecimal(
|
Atom doDecimal(
|
||||||
double _this,
|
double _this,
|
||||||
double that,
|
double that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
if (_this == that) {
|
if (_this == that) {
|
||||||
return ordering.newEqual();
|
return ordering.newEqual();
|
||||||
} else if (_this > that) {
|
} else if (_this > that) {
|
||||||
@ -65,14 +59,14 @@ public abstract class CompareToNode extends Node {
|
|||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Atom doOther(
|
Atom doOther(
|
||||||
double _this, Object that, @CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
double _this, Object that) {
|
||||||
CompilerDirectives.transferToInterpreter();
|
CompilerDirectives.transferToInterpreter();
|
||||||
var number = ctxRef.get().getBuiltins().number().getNumber().newInstance();
|
var number = Context.get(this).getBuiltins().number().getNumber().newInstance();
|
||||||
var typeError = ctxRef.get().getBuiltins().error().makeTypeError(that, number, "that");
|
var typeError = Context.get(this).getBuiltins().error().makeTypeError(that, number, "that");
|
||||||
throw new PanicException(typeError, this);
|
throw new PanicException(typeError, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ordering getOrdering(ContextReference<Context> ctxRef) {
|
Ordering getOrdering() {
|
||||||
return ctxRef.get().getBuiltins().ordering();
|
return Context.get(this).getBuiltins().ordering();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class DivideNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
double doOther(double _this, Object that) {
|
double doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.decimal;
|
package org.enso.interpreter.node.expression.builtin.number.decimal;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -41,8 +38,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
boolean doAtom(
|
boolean doAtom(
|
||||||
Atom _this,
|
Atom _this,
|
||||||
Atom that,
|
Atom that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getDecimalConstructor()") AtomConstructor decimalCons) {
|
||||||
@Cached("getDecimalConstructor(ctxRef)") AtomConstructor decimalCons) {
|
|
||||||
var thatCons = that.getConstructor();
|
var thatCons = that.getConstructor();
|
||||||
var thisCons = _this.getConstructor();
|
var thisCons = _this.getConstructor();
|
||||||
return (thatCons == decimalCons) && (thisCons == thatCons);
|
return (thatCons == decimalCons) && (thisCons == thatCons);
|
||||||
@ -53,7 +49,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomConstructor getDecimalConstructor(ContextReference<Context> ctxRef) {
|
AtomConstructor getDecimalConstructor() {
|
||||||
return ctxRef.get().getBuiltins().number().getDecimal();
|
return Context.get(this).getBuiltins().number().getDecimal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class GreaterNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(double _this, Object that) {
|
boolean doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class GreaterOrEqualNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(double _this, Object that) {
|
boolean doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class LessNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(double _this, Object that) {
|
boolean doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -37,7 +37,7 @@ public abstract class LessOrEqualNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(double _this, Object that) {
|
boolean doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class MultiplyNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
double doOther(double _this, Object that) {
|
double doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class PowNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
double doOther(double _this, Object that) {
|
double doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.decimal;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class SubtractNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
double doOther(double _this, Object that) {
|
double doOther(double _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -44,7 +44,7 @@ public abstract class AddNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(long _this, Object that) {
|
Object doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -35,15 +33,15 @@ public abstract class BitAndNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -24,7 +24,7 @@ public abstract class BitNotNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this) {
|
Object doOther(Object _this) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -35,15 +33,15 @@ public abstract class BitOrNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.ImportStatic;
|
import com.oracle.truffle.api.dsl.ImportStatic;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import com.oracle.truffle.api.profiles.ConditionProfile;
|
import com.oracle.truffle.api.profiles.ConditionProfile;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -42,14 +39,14 @@ public abstract class BitShiftNode extends Node {
|
|||||||
|
|
||||||
@Specialization(guards = "that >= 0", replaces = "doLongShiftLeft")
|
@Specialization(guards = "that >= 0", replaces = "doLongShiftLeft")
|
||||||
Object doLongShiftLeftExplicit(
|
Object doLongShiftLeftExplicit(
|
||||||
long _this, long that, @CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
long _this, long that) {
|
||||||
if (canShiftLeftInLongProfile.profile(canShiftLeftInLong(_this, that))) {
|
if (canShiftLeftInLongProfile.profile(canShiftLeftInLong(_this, that))) {
|
||||||
return doLongShiftLeft(_this, that);
|
return doLongShiftLeft(_this, that);
|
||||||
} else if (positiveFitsInInt.profile(BigIntegerOps.fitsInInt(that))) {
|
} else if (positiveFitsInInt.profile(BigIntegerOps.fitsInInt(that))) {
|
||||||
return toEnsoNumberNode.execute(BigIntegerOps.bitShiftLeft(_this, (int) that));
|
return toEnsoNumberNode.execute(BigIntegerOps.bitShiftLeft(_this, (int) that));
|
||||||
} else {
|
} else {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getShiftAmountTooLargeError(), this);
|
Context.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,14 +71,13 @@ public abstract class BitShiftNode extends Node {
|
|||||||
@Specialization
|
@Specialization
|
||||||
Object doBigInteger(
|
Object doBigInteger(
|
||||||
long _this,
|
long _this,
|
||||||
EnsoBigInteger that,
|
EnsoBigInteger that) {
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
if (!BigIntegerOps.nonNegative(that.getValue())) {
|
if (!BigIntegerOps.nonNegative(that.getValue())) {
|
||||||
return _this >= 0 ? 0L : -1L;
|
return _this >= 0 ? 0L : -1L;
|
||||||
} else {
|
} else {
|
||||||
// Note [Well-Formed BigIntegers]
|
// Note [Well-Formed BigIntegers]
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getShiftAmountTooLargeError(), this);
|
Context.get(this).getBuiltins().error().getShiftAmountTooLargeError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,15 +88,15 @@ public abstract class BitShiftNode extends Node {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -34,15 +32,15 @@ public abstract class BitShiftRightNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
@ -35,15 +33,15 @@ public abstract class BitXorNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doAtomThis(Atom _this, Object that, @CachedContext(Language.class) Context ctx) {
|
Object doAtomThis(Atom _this, Object that) {
|
||||||
Builtins builtins = ctx.getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, _this, "this"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(Object _this, Object that) {
|
Object doOther(Object _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -31,8 +28,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doLong(
|
Atom doLong(
|
||||||
long _this,
|
long _this,
|
||||||
long that,
|
long that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
if (_this == that) {
|
if (_this == that) {
|
||||||
return ordering.newEqual();
|
return ordering.newEqual();
|
||||||
} else if (_this > that) {
|
} else if (_this > that) {
|
||||||
@ -46,8 +42,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doBigInt(
|
Atom doBigInt(
|
||||||
long _this,
|
long _this,
|
||||||
EnsoBigInteger that,
|
EnsoBigInteger that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
return ordering.fromJava(BigIntegerOps.compareTo(_this, that.getValue()));
|
return ordering.fromJava(BigIntegerOps.compareTo(_this, that.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +50,7 @@ public abstract class CompareToNode extends Node {
|
|||||||
Atom doDecimal(
|
Atom doDecimal(
|
||||||
long _this,
|
long _this,
|
||||||
double that,
|
double that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getOrdering()") Ordering ordering) {
|
||||||
@Cached("getOrdering(ctxRef)") Ordering ordering) {
|
|
||||||
if (_this == that) {
|
if (_this == that) {
|
||||||
return ordering.newEqual();
|
return ordering.newEqual();
|
||||||
} else if (_this > that) {
|
} else if (_this > that) {
|
||||||
@ -68,14 +62,14 @@ public abstract class CompareToNode extends Node {
|
|||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Atom doOther(
|
Atom doOther(
|
||||||
long _this, Object that, @CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
long _this, Object that) {
|
||||||
CompilerDirectives.transferToInterpreter();
|
CompilerDirectives.transferToInterpreter();
|
||||||
var number = ctxRef.get().getBuiltins().number().getNumber().newInstance();
|
var number = Context.get(this).getBuiltins().number().getNumber().newInstance();
|
||||||
var typeError = ctxRef.get().getBuiltins().error().makeTypeError(that, number, "that");
|
var typeError = Context.get(this).getBuiltins().error().makeTypeError(that, number, "that");
|
||||||
throw new PanicException(typeError, this);
|
throw new PanicException(typeError, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ordering getOrdering(ContextReference<Context> ctxRef) {
|
Ordering getOrdering() {
|
||||||
return ctxRef.get().getBuiltins().ordering();
|
return Context.get(this).getBuiltins().ordering();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
@ -23,13 +20,12 @@ public abstract class DivNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doLong(
|
Object doLong(long _this, long that) {
|
||||||
long _this, long that, @CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
try {
|
try {
|
||||||
return _this / that;
|
return _this / that;
|
||||||
} catch (ArithmeticException e) {
|
} catch (ArithmeticException e) {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getDivideByZeroError(), this);
|
Context.get(this).getBuiltins().error().getDivideByZeroError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +37,7 @@ public abstract class DivNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(long _this, Object that) {
|
Object doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class DivideNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
double doOther(long _this, Object that) {
|
double doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
@ -35,8 +32,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
boolean doAtom(
|
boolean doAtom(
|
||||||
Atom _this,
|
Atom _this,
|
||||||
Atom that,
|
Atom that,
|
||||||
@CachedContext(Language.class) ContextReference<Context> ctxRef,
|
@Cached("getSmallIntegerConstructor()") AtomConstructor smallIntCons) {
|
||||||
@Cached("getSmallIntegerConstructor(ctxRef)") AtomConstructor smallIntCons) {
|
|
||||||
var thisCons = _this.getConstructor();
|
var thisCons = _this.getConstructor();
|
||||||
var thatCons = that.getConstructor();
|
var thatCons = that.getConstructor();
|
||||||
return (thatCons == smallIntCons) && (thisCons == thatCons);
|
return (thatCons == smallIntCons) && (thisCons == thatCons);
|
||||||
@ -47,7 +43,7 @@ public abstract class EqualsNode extends Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomConstructor getSmallIntegerConstructor(ContextReference<Context> ctxRef) {
|
AtomConstructor getSmallIntegerConstructor() {
|
||||||
return ctxRef.get().getBuiltins().number().getBigInteger();
|
return Context.get(this).getBuiltins().number().getBigInteger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class GreaterNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(long _this, Object that) {
|
boolean doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class GreaterOrEqualNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(long _this, Object that) {
|
boolean doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class LessNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(long _this, Object that) {
|
boolean doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -36,7 +36,7 @@ public abstract class LessOrEqualNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
boolean doOther(long _this, Object that) {
|
boolean doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
@ -23,13 +20,12 @@ public abstract class ModNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doLong(
|
Object doLong(long _this, long that) {
|
||||||
long _this, long that, @CachedContext(Language.class) ContextReference<Context> ctxRef) {
|
|
||||||
try {
|
try {
|
||||||
return _this % that;
|
return _this % that;
|
||||||
} catch (ArithmeticException e) {
|
} catch (ArithmeticException e) {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().getDivideByZeroError(), this);
|
Context.get(this).getBuiltins().error().getDivideByZeroError(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +37,7 @@ public abstract class ModNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(long _this, Object that) {
|
Object doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom integer = builtins.number().getInteger().newInstance();
|
Atom integer = builtins.number().getInteger().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(integer, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -44,7 +44,7 @@ public abstract class MultiplyNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(long _this, Object that) {
|
Object doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,15 @@ import com.oracle.truffle.api.dsl.Fallback;
|
|||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
import org.enso.interpreter.runtime.number.EnsoBigInteger;
|
import org.enso.interpreter.runtime.number.EnsoBigInteger;
|
||||||
|
|
||||||
@BuiltinMethod(type = "Small_Integer", name = "^", description = "Exponentation of numbers.")
|
@BuiltinMethod(type = "Small_Integer", name = "^", description = "Exponentiation of numbers.")
|
||||||
public abstract class PowNode extends Node {
|
public abstract class PowNode extends Node {
|
||||||
private @Child ToEnsoNumberNode toEnsoNumberNode = ToEnsoNumberNode.build();
|
private @Child ToEnsoNumberNode toEnsoNumberNode = ToEnsoNumberNode.build();
|
||||||
private @Child org.enso.interpreter.node.expression.builtin.number.smallInteger.MultiplyNode
|
private @Child org.enso.interpreter.node.expression.builtin.number.smallInteger.MultiplyNode
|
||||||
@ -73,7 +73,7 @@ public abstract class PowNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(long _this, Object that) {
|
Object doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger;
|
|||||||
import com.oracle.truffle.api.dsl.Fallback;
|
import com.oracle.truffle.api.dsl.Fallback;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
|
||||||
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
|
||||||
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||||
import org.enso.interpreter.runtime.error.PanicException;
|
import org.enso.interpreter.runtime.error.PanicException;
|
||||||
@ -44,7 +44,7 @@ public abstract class SubtractNode extends Node {
|
|||||||
|
|
||||||
@Fallback
|
@Fallback
|
||||||
Object doOther(long _this, Object that) {
|
Object doOther(long _this, Object that) {
|
||||||
Builtins builtins = lookupContextReference(Language.class).get().getBuiltins();
|
Builtins builtins = Context.get(this).getBuiltins();
|
||||||
Atom number = builtins.number().getNumber().newInstance();
|
Atom number = builtins.number().getNumber().newInstance();
|
||||||
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
throw new PanicException(builtins.error().makeTypeError(number, that, "that"), this);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.resource;
|
package org.enso.interpreter.node.expression.builtin.resource;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.ManagedResource;
|
import org.enso.interpreter.runtime.data.ManagedResource;
|
||||||
@ -21,8 +19,8 @@ public abstract class FinalizeNode extends Node {
|
|||||||
abstract Object execute(Object _this, ManagedResource resource);
|
abstract Object execute(Object _this, ManagedResource resource);
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doClose(
|
Object doClose(Object _this, ManagedResource resource) {
|
||||||
Object _this, ManagedResource resource, @CachedContext(Language.class) Context context) {
|
Context context = Context.get(this);
|
||||||
context.getResourceManager().close(resource);
|
context.getResourceManager().close(resource);
|
||||||
return context.getBuiltins().nothing().newInstance();
|
return context.getBuiltins().nothing().newInstance();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.resource;
|
package org.enso.interpreter.node.expression.builtin.resource;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.function.Function;
|
import org.enso.interpreter.runtime.callable.function.Function;
|
||||||
@ -27,8 +25,7 @@ public abstract class RegisterNode extends Node {
|
|||||||
ManagedResource doRegister(
|
ManagedResource doRegister(
|
||||||
Object _this,
|
Object _this,
|
||||||
Object resource,
|
Object resource,
|
||||||
Function function,
|
Function function) {
|
||||||
@CachedContext(Language.class) Context context) {
|
return Context.get(this).getResourceManager().register(resource, function);
|
||||||
return context.getResourceManager().register(resource, function);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.resource;
|
package org.enso.interpreter.node.expression.builtin.resource;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.ManagedResource;
|
import org.enso.interpreter.runtime.data.ManagedResource;
|
||||||
@ -24,8 +22,8 @@ public abstract class TakeNode extends Node {
|
|||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doTake(
|
Object doTake(
|
||||||
Object _this, ManagedResource resource, @CachedContext(Language.class) Context context) {
|
Object _this, ManagedResource resource) {
|
||||||
context.getResourceManager().take(resource);
|
Context.get(this).getResourceManager().take(resource);
|
||||||
return resource.getResource();
|
return resource.getResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.resource;
|
package org.enso.interpreter.node.expression.builtin.resource;
|
||||||
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
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.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
import org.enso.interpreter.node.callable.InvokeCallableNode;
|
import org.enso.interpreter.node.callable.InvokeCallableNode;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
|
import org.enso.interpreter.runtime.ResourceManager;
|
||||||
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
||||||
import org.enso.interpreter.runtime.data.ManagedResource;
|
import org.enso.interpreter.runtime.data.ManagedResource;
|
||||||
import org.enso.interpreter.runtime.state.Stateful;
|
import org.enso.interpreter.runtime.state.Stateful;
|
||||||
@ -43,14 +42,14 @@ public abstract class WithNode extends Node {
|
|||||||
VirtualFrame frame,
|
VirtualFrame frame,
|
||||||
Object _this,
|
Object _this,
|
||||||
ManagedResource resource,
|
ManagedResource resource,
|
||||||
Object action,
|
Object action) {
|
||||||
@CachedContext(Language.class) Context context) {
|
ResourceManager resourceManager = Context.get(this).getResourceManager();
|
||||||
context.getResourceManager().park(resource);
|
resourceManager.park(resource);
|
||||||
try {
|
try {
|
||||||
return invokeCallableNode.execute(
|
return invokeCallableNode.execute(
|
||||||
action, frame, state, new Object[] {resource.getResource()});
|
action, frame, state, new Object[] {resource.getResource()});
|
||||||
} finally {
|
} finally {
|
||||||
context.getResourceManager().unpark(resource);
|
resourceManager.unpark(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.runtime;
|
package org.enso.interpreter.node.expression.builtin.runtime;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
|
||||||
|
|
||||||
@BuiltinMethod(type = "Runtime", name = "gc", description = "Forces garbage collection")
|
@BuiltinMethod(type = "Runtime", name = "gc", description = "Forces garbage collection")
|
||||||
public abstract class GCNode extends Node {
|
public abstract class GCNode extends Node {
|
||||||
@ -21,9 +17,9 @@ public abstract class GCNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doGc(Object _this, @CachedContext(Language.class) Context context) {
|
Object doGc(Object _this) {
|
||||||
runGC();
|
runGC();
|
||||||
return context.getBuiltins().nothing().newInstance();
|
return Context.get(this).getBuiltins().nothing().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@CompilerDirectives.TruffleBoundary
|
@CompilerDirectives.TruffleBoundary
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.special;
|
package org.enso.interpreter.node.expression.builtin.special;
|
||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
import org.enso.interpreter.dsl.Suspend;
|
import org.enso.interpreter.dsl.Suspend;
|
||||||
@ -22,7 +20,8 @@ public abstract class RunThreadNode extends Node {
|
|||||||
|
|
||||||
@CompilerDirectives.TruffleBoundary
|
@CompilerDirectives.TruffleBoundary
|
||||||
@Specialization
|
@Specialization
|
||||||
Thread doExecute(Object state, Object th, @CachedContext(Language.class) Context ctx) {
|
Thread doExecute(Object state, Object th) {
|
||||||
|
Context ctx = Context.get(this);
|
||||||
Thread thread =
|
Thread thread =
|
||||||
ctx.getEnvironment()
|
ctx.getEnvironment()
|
||||||
.createThread(
|
.createThread(
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.state;
|
package org.enso.interpreter.node.expression.builtin.state;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.ImportStatic;
|
import com.oracle.truffle.api.dsl.ImportStatic;
|
||||||
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.dsl.MonadicState;
|
import org.enso.interpreter.dsl.MonadicState;
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
@ -50,12 +47,11 @@ public abstract class GetStateNode extends Node {
|
|||||||
Object doMultiUncached(
|
Object doMultiUncached(
|
||||||
SmallMap state,
|
SmallMap state,
|
||||||
Object _this,
|
Object _this,
|
||||||
Object key,
|
Object key) {
|
||||||
@CachedContext(Language.class) TruffleLanguage.ContextReference<Context> ctxRef) {
|
|
||||||
int idx = state.indexOf(key);
|
int idx = state.indexOf(key);
|
||||||
if (idx == SmallMap.NOT_FOUND) {
|
if (idx == SmallMap.NOT_FOUND) {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().uninitializedState().newInstance(key), this);
|
Context.get(this).getBuiltins().error().uninitializedState().newInstance(key), this);
|
||||||
} else {
|
} else {
|
||||||
return state.getValues()[idx];
|
return state.getValues()[idx];
|
||||||
}
|
}
|
||||||
@ -63,15 +59,15 @@ public abstract class GetStateNode extends Node {
|
|||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doEmpty(
|
Object doEmpty(
|
||||||
EmptyMap state, Object _this, Object key, @CachedContext(Language.class) Context ctx) {
|
EmptyMap state, Object _this, Object key) {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctx.getBuiltins().error().uninitializedState().newInstance(key), this);
|
Context.get(this).getBuiltins().error().uninitializedState().newInstance(key), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Specialization
|
@Specialization
|
||||||
Object doSingletonError(
|
Object doSingletonError(
|
||||||
SingletonMap state, Object _this, Object key, @CachedContext(Language.class) Context ctx) {
|
SingletonMap state, Object _this, Object key) {
|
||||||
return DataflowError.withoutTrace(
|
return DataflowError.withoutTrace(
|
||||||
ctx.getBuiltins().error().uninitializedState().newInstance(key), this);
|
Context.get(this).getBuiltins().error().uninitializedState().newInstance(key), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package org.enso.interpreter.node.expression.builtin.state;
|
package org.enso.interpreter.node.expression.builtin.state;
|
||||||
|
|
||||||
import com.oracle.truffle.api.TruffleLanguage;
|
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.ImportStatic;
|
import com.oracle.truffle.api.dsl.ImportStatic;
|
||||||
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
@ -55,14 +53,13 @@ public abstract class PutStateNode extends Node {
|
|||||||
SmallMap state,
|
SmallMap state,
|
||||||
Object _this,
|
Object _this,
|
||||||
Object key,
|
Object key,
|
||||||
Object new_state,
|
Object new_state) {
|
||||||
@CachedContext(Language.class) TruffleLanguage.ContextReference<Context> ctxRef) {
|
|
||||||
int index = state.indexOf(key);
|
int index = state.indexOf(key);
|
||||||
if (index == SmallMap.NOT_FOUND) {
|
if (index == SmallMap.NOT_FOUND) {
|
||||||
return new Stateful(
|
return new Stateful(
|
||||||
state,
|
state,
|
||||||
DataflowError.withoutTrace(
|
DataflowError.withoutTrace(
|
||||||
ctxRef.get().getBuiltins().error().uninitializedState().newInstance(key), this));
|
Context.get(this).getBuiltins().error().uninitializedState().newInstance(key), this));
|
||||||
} else {
|
} else {
|
||||||
return doExistingMultiCached(state, _this, key, new_state, key, state.getKeys(), index);
|
return doExistingMultiCached(state, _this, key, new_state, key, state.getKeys(), index);
|
||||||
}
|
}
|
||||||
@ -73,11 +70,10 @@ public abstract class PutStateNode extends Node {
|
|||||||
Object state,
|
Object state,
|
||||||
Object _this,
|
Object _this,
|
||||||
Object key,
|
Object key,
|
||||||
Object new_state,
|
Object new_state) {
|
||||||
@CachedContext(Language.class) Context ctx) {
|
|
||||||
return new Stateful(
|
return new Stateful(
|
||||||
state,
|
state,
|
||||||
DataflowError.withoutTrace(
|
DataflowError.withoutTrace(
|
||||||
ctx.getBuiltins().error().uninitializedState().newInstance(key), this));
|
Context.get(this).getBuiltins().error().uninitializedState().newInstance(key), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,11 @@ package org.enso.interpreter.node.expression.builtin.system;
|
|||||||
|
|
||||||
import com.oracle.truffle.api.CompilerDirectives;
|
import com.oracle.truffle.api.CompilerDirectives;
|
||||||
import com.oracle.truffle.api.dsl.Cached;
|
import com.oracle.truffle.api.dsl.Cached;
|
||||||
import com.oracle.truffle.api.dsl.CachedContext;
|
|
||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import com.oracle.truffle.api.io.TruffleProcessBuilder;
|
import com.oracle.truffle.api.io.TruffleProcessBuilder;
|
||||||
import com.oracle.truffle.api.nodes.Node;
|
import com.oracle.truffle.api.nodes.Node;
|
||||||
import org.enso.interpreter.Language;
|
|
||||||
import org.enso.interpreter.dsl.BuiltinMethod;
|
import org.enso.interpreter.dsl.BuiltinMethod;
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode;
|
||||||
import org.enso.interpreter.node.expression.builtin.text.util.ToJavaStringNode;
|
|
||||||
import org.enso.interpreter.runtime.Context;
|
import org.enso.interpreter.runtime.Context;
|
||||||
import org.enso.interpreter.runtime.data.Array;
|
import org.enso.interpreter.runtime.data.Array;
|
||||||
import org.enso.interpreter.runtime.data.text.Text;
|
import org.enso.interpreter.runtime.data.text.Text;
|
||||||
@ -46,8 +43,8 @@ public abstract class CreateProcessNode extends Node {
|
|||||||
boolean redirectIn,
|
boolean redirectIn,
|
||||||
boolean redirectOut,
|
boolean redirectOut,
|
||||||
boolean redirectErr,
|
boolean redirectErr,
|
||||||
@CachedContext(Language.class) Context ctx,
|
|
||||||
@Cached ExpectStringNode expectStringNode) {
|
@Cached ExpectStringNode expectStringNode) {
|
||||||
|
Context ctx = Context.get(this);
|
||||||
String[] cmd = new String[arguments.getItems().length + 1];
|
String[] cmd = new String[arguments.getItems().length + 1];
|
||||||
cmd[0] = expectStringNode.execute(command);
|
cmd[0] = expectStringNode.execute(command);
|
||||||
for (int i = 1; i <= arguments.getItems().length; i++) {
|
for (int i = 1; i <= arguments.getItems().length; i++) {
|
||||||
@ -114,8 +111,8 @@ public abstract class CreateProcessNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long exitCode = p.exitValue();
|
long exitCode = p.exitValue();
|
||||||
Text returnOut = Text.create(new String(out.toByteArray()));
|
Text returnOut = Text.create(out.toString());
|
||||||
Text returnErr = Text.create(new String(err.toByteArray()));
|
Text returnErr = Text.create(err.toString());
|
||||||
|
|
||||||
return ctx.getBuiltins()
|
return ctx.getBuiltins()
|
||||||
.system()
|
.system()
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user