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