-
Notifications
You must be signed in to change notification settings - Fork 326
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
Function metadata call #5226
Comments
First of all we should polish content of |
I wonder if this task is still needed (it's very old) - the current implementation rely on Suggestion Database and seems working enough. @Frizi can you confirm? |
Jaroslav Tulach reports a new STANDUP for yesterday (2025-01-13): Progress: .
|
Very important issue related to from Standard.Base import all
type X
W
V a b c
main =
run
run =
w = X.W...
w1 = X.W
ac = Meta.is_atom_constructor w...
at = Meta.is_atom w ...
[ac, at, Meta.meta w, Meta.meta w1] shall print diff --git distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso
index 79f6c30639..834ad909ee 100644
--- distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso
+++ distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso
@@ -299,13 +299,14 @@ atom_with_hole factory = @Tail_Call Meta_Helpers.atom_with_hole_builtin factory
Arguments:
- value: The runtime entity to get the meta representation of.
meta : Any -> Atom | Constructor | Primitive | Polyglot | Unresolved_Symbol | Error
-meta value = if Meta_Helpers.is_atom_builtin value then Atom.Value value else
- if Meta_Helpers.is_atom_constructor_builtin value then Constructor.Value value else
- if Meta_Helpers.is_polyglot_builtin value then Polyglot.Value value else
- if Meta_Helpers.is_unresolved_symbol_builtin value then Unresolved_Symbol.Value value else
- if Meta_Helpers.is_error_builtin value then Error.Value value.catch else
- if Meta_Helpers.is_type_builtin value then Type.Value value.catch else
- Primitive.Value value
+meta ~value =
+ if Meta_Helpers.is_atom_constructor_builtin value... then Constructor.Value value... else
+ if Meta_Helpers.is_atom_builtin value... then Atom.Value value else
+ if Meta_Helpers.is_polyglot_builtin value then Polyglot.Value value else
+ if Meta_Helpers.is_unresolved_symbol_builtin value then Unresolved_Symbol.Value value else
+ if Meta_Helpers.is_error_builtin value then Error.Value value.catch else
+ if Meta_Helpers.is_type_builtin value then Type.Value value.catch else
+ Primitive.Value value
## PRIVATE
ADVANCED
@@ -379,7 +380,7 @@ type Language
Arguments:
- value: The value to check.
is_atom_constructor : Any -> Boolean
-is_atom_constructor value = @Tail_Call Meta_Helpers.is_atom_constructor_builtin value
+is_atom_constructor ~value = @Tail_Call Meta_Helpers.is_atom_constructor_builtin value
## PRIVATE
diff --git engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsAtomConstructorNode.java engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsAtomConstructorNode.java
index 46abd9e29f..c930b91660 100644
--- engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsAtomConstructorNode.java
+++ engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsAtomConstructorNode.java
@@ -3,6 +3,10 @@ package org.enso.interpreter.node.expression.builtin.meta;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.AcceptsError;
import org.enso.interpreter.dsl.BuiltinMethod;
+import org.enso.interpreter.dsl.Suspend;
+import org.enso.interpreter.node.MethodRootNode;
+import org.enso.interpreter.runtime.callable.function.Function;
+import org.enso.interpreter.runtime.data.atom.AtomConstructor;
import org.enso.interpreter.runtime.type.TypesGen;
@BuiltinMethod(
@@ -11,7 +15,18 @@ import org.enso.interpreter.runtime.type.TypesGen;
description = "Checks if the argument is a constructor.",
autoRegister = false)
public class IsAtomConstructorNode extends Node {
- boolean execute(@AcceptsError Object value) {
- return TypesGen.isAtomConstructor(value);
+ boolean execute(@Suspend @AcceptsError Object value) {
+ if (TypesGen.isAtomConstructor(value)) {
+ return true;
+ }
+ if (value instanceof Function fn) {
+ if (AtomConstructor.accessorFor(fn) != null) {
+ return true;
+ }
+ if (MethodRootNode.constructorFor(fn) != null) {
+ return true;
+ }
+ }
+ return false;
}
}
diff --git engine/runtime/src/main/java/org/enso/interpreter/runtime/data/atom/QualifiedAccessorNode.java engine/runtime/src/main/java/org/enso/interpreter/runtime/data/atom/QualifiedAccessorNode.java
index 2be3a62f49..8844ff5a34 100644
--- engine/runtime/src/main/java/org/enso/interpreter/runtime/data/atom/QualifiedAccessorNode.java
+++ engine/runtime/src/main/java/org/enso/interpreter/runtime/data/atom/QualifiedAccessorNode.java
@@ -54,7 +54,7 @@ final class QualifiedAccessorNode extends EnsoRootNode {
} else if (atomConstructor == falseCtor) {
return false;
} else {
- return atomConstructor.newInstance();
+ return atomConstructor.getConstructorFunction();
}
} else {
return atomConstructor; time to productize that code! |
Jaroslav Tulach reports a new STANDUP for yesterday (2025-01-14): Progress: .
|
Jaroslav Tulach reports a new STANDUP for yesterday (2025-01-15): Progress: .
|
Jaroslav Tulach reports a new STANDUP for yesterday (2025-01-16): Progress: .
|
This task is automatically imported from the old Task Issue Board and it was originally created by James Dunkerley.
Original issue is here.
It would be useful to be able to acquire the metadata about a function's parameters.
Ideally would like to be able to get:
This would help us answer the metadata for widget.
Could also use to provide a visualization for a function without all the defaults.
The text was updated successfully, but these errors were encountered: