Skip to content

Commit

Permalink
Add method call info for infix operators (#7090)
Browse files Browse the repository at this point in the history
close #6374

In order to provide the method pointer information, the `IrToTruffle` pass sets the module name and the type name of the builtin node.
  • Loading branch information
4e6 authored Jun 27, 2023
1 parent 4e5cb9c commit 22259e6
Show file tree
Hide file tree
Showing 17 changed files with 417 additions and 75 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@
- [Add special handling for static method calls on Any][7033]
- [Improve parallel execution of commands and jobs in Language Server][7042]
- [Added retries when executing GraalVM updater][7079]
- [Add method call info for infix operators][7090]

[3227]: https://github.com/enso-org/enso/pull/3227
[3248]: https://github.com/enso-org/enso/pull/3248
Expand Down Expand Up @@ -963,6 +964,7 @@
[7033]: https://github.com/enso-org/enso/pull/7033
[7042]: https://github.com/enso-org/enso/pull/7042
[7079]: https://github.com/enso-org/enso/pull/7079
[7090]: https://github.com/enso-org/enso/pull/7090

# Enso 2.0.0-alpha.18 (2021-10-12)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ type File
## PRIVATE
Internal method to join two path segments together.
resolve : File
resolve self = @Builtin_Method "File.resolve"
resolve self subpath = @Builtin_Method "File.resolve"

## PRIVATE
Convert the file descriptor to a JS_Object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import java.util.UUID;
import java.util.function.Consumer;
import org.enso.interpreter.instrument.profiling.ProfilingInfo;
import org.enso.interpreter.node.EnsoRootNode;
import org.enso.interpreter.node.MethodRootNode;
import org.enso.interpreter.node.callable.FunctionCallInstrumentationNode;
import org.enso.interpreter.node.expression.atom.QualifiedAccessorNode;
import org.enso.interpreter.node.expression.builtin.BuiltinRootNode;
import org.enso.interpreter.runtime.Module;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
Expand Down Expand Up @@ -212,6 +212,7 @@ class FunctionCallInfo {
*/
public FunctionCallInfo(FunctionCallInstrumentationNode.FunctionCall call) {
RootNode rootNode = call.getFunction().getCallTarget().getRootNode();

switch (rootNode) {
case MethodRootNode methodNode -> {
moduleName = methodNode.getModuleScope().getModule().getName();
Expand All @@ -224,12 +225,12 @@ public FunctionCallInfo(FunctionCallInstrumentationNode.FunctionCall call) {
typeName = atomConstructor.getType().getQualifiedName();
functionName = atomConstructor.getName();
}
case EnsoRootNode ensoRootNode -> {
moduleName = ensoRootNode.getModuleScope().getModule().getName();
typeName = null;
functionName = rootNode.getName();
case BuiltinRootNode builtinRootNode -> {
moduleName = builtinRootNode.getModuleName();
typeName = builtinRootNode.getTypeName();
functionName = QualifiedName.fromString(builtinRootNode.getName()).item();
}
case default -> {
default -> {
moduleName = null;
typeName = null;
functionName = rootNode.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ private void onExpressionReturn(Object result, Node node, EventContext context)
// appropriately invalidate all dependent expressions.
if (!isPanic) {
cache.offer(nodeId, result);
cache.putCall(nodeId, call);
}
cache.putType(nodeId, resultType);
cache.putCall(nodeId, call);

passExpressionValueToCallback(expressionValue);
if (isPanic) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,13 @@ class BuiltinTypesTest
val requestId = UUID.randomUUID()

val metadata = new Metadata
val idMain = metadata.addItem(43, 18)
val idMain = metadata.addItem(48, 25)

val code =
"""import Standard.Base.Data.Time.Date
|
|main =
| Date.new 2000
| Date.new_builtin 2000 1 1
|""".stripMargin.linesIterator.mkString("\n")
val contents = metadata.appendToCode(code)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ class RuntimeErrorsTest
TestMessages.error(
contextId,
xId,
Api.MethodCall(
Api.MethodPointer(
"Standard.Base.Error",
"Standard.Base.Error.Error",
"throw"
)
),
Api.ExpressionUpdate.Payload.DataflowError(Seq(xId))
),
TestMessages.error(
Expand Down Expand Up @@ -682,6 +689,13 @@ class RuntimeErrorsTest
TestMessages.error(
contextId,
xId,
Api.MethodCall(
Api.MethodPointer(
"Standard.Base.Error",
"Standard.Base.Error.Error",
"throw"
)
),
Api.ExpressionUpdate.Payload.DataflowError(Seq(xId))
),
TestMessages.update(contextId, yId, ConstantsGen.INTEGER),
Expand Down Expand Up @@ -747,6 +761,13 @@ class RuntimeErrorsTest
TestMessages.error(
contextId,
xId,
Api.MethodCall(
Api.MethodPointer(
"Standard.Base.Error",
"Standard.Base.Error.Error",
"throw"
)
),
Api.ExpressionUpdate.Payload.DataflowError(Seq(xId))
),
TestMessages.error(
Expand Down Expand Up @@ -902,6 +923,13 @@ class RuntimeErrorsTest
TestMessages.error(
contextId,
xId,
Api.MethodCall(
Api.MethodPointer(
"Standard.Base.Error",
"Standard.Base.Error.Error",
"throw"
)
),
Api.ExpressionUpdate.Payload.DataflowError(Seq(xId))
),
TestMessages.error(
Expand Down Expand Up @@ -1039,7 +1067,7 @@ class RuntimeErrorsTest
val requestId = UUID.randomUUID()
val moduleName = "Enso_Test.Test.Main"
val metadata = new Metadata
val xId = metadata.addItem(60, 19)
val xId = metadata.addItem(60, 19, "aa")
val yId = metadata.addItem(88, 5)
val mainResId = metadata.addItem(98, 12)

Expand Down Expand Up @@ -1090,10 +1118,18 @@ class RuntimeErrorsTest
TestMessages.panic(
contextId,
xId,
Api.MethodCall(
Api.MethodPointer(
"Standard.Base.Panic",
"Standard.Base.Panic.Panic",
"throw"
)
),
Api.ExpressionUpdate.Payload.Panic(
"MyError",
Seq(xId)
)
),
Some("Standard.Base.Panic.Panic")
),
TestMessages.panic(
contextId,
Expand Down Expand Up @@ -1318,10 +1354,18 @@ class RuntimeErrorsTest
TestMessages.panic(
contextId,
xId,
Api.MethodCall(
Api.MethodPointer(
"Standard.Base.Panic",
"Standard.Base.Panic.Panic",
"throw"
)
),
Api.ExpressionUpdate.Payload.Panic(
"MyError1",
Seq(xId)
)
),
Some("Standard.Base.Panic.Panic")
),
TestMessages.panic(
contextId,
Expand Down Expand Up @@ -1364,12 +1408,18 @@ class RuntimeErrorsTest
TestMessages.panic(
contextId,
xId,
Api.MethodCall(
Api.MethodPointer(
"Standard.Base.Panic",
"Standard.Base.Panic.Panic",
"throw"
)
),
Api.ExpressionUpdate.Payload.Panic(
"MyError2",
Seq(xId)
),
builtin = false,
typeChanged = false
Some("Standard.Base.Panic.Panic")
),
TestMessages.panic(
contextId,
Expand All @@ -1388,8 +1438,7 @@ class RuntimeErrorsTest
"MyError2",
Seq(xId)
),
builtin = false,
typeChanged = false
builtin = false
),
context.executionComplete(contextId)
)
Expand Down
Loading

0 comments on commit 22259e6

Please sign in to comment.