Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method call info for infix operators #7090

Merged
merged 18 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised the case for EnsoRootNode is removed and nothing gets broken!?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnsoRootNode does not contain enough information to build the method pointer. We can simply skip it

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