-
Notifications
You must be signed in to change notification settings - Fork 327
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
Reducing helper methods in Standard.Base.Meta
#12031
Merged
Merged
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
d2ce49c
Moving @Builtin_Method definitions outside of Meta
JaroslavTulach a18693e
Merge remote-tracking branch 'origin/develop' into wip/jtulach/MetaHe…
JaroslavTulach 531ecdf
Moving Meta_Helpers into Internal namespace
JaroslavTulach 4ae769b
Reverting changes in tests. Meta.is_a has to work.
JaroslavTulach 9770c1a
Adjustiments to call Meta.is_a even it is not builtin
JaroslavTulach 17fdff4
Dispatch on non-associated type continues to prefer virtual method on…
JaroslavTulach 0c074ac
Making constructors of Meta types private reveals issues in checking …
JaroslavTulach 4ef7d8b
Type is always public even it has no public constructors
JaroslavTulach fd5d2af
Meta.Constructor can be converted to qualified accessor Function
JaroslavTulach ab9287f
Merging with develop
JaroslavTulach b4f4483
Getting the Base_Tests to compile
JaroslavTulach 2eef96b
All Base_Tests are passing again
JaroslavTulach 530f3af
Note in changelog
JaroslavTulach b4116c8
Merge remote-tracking branch 'origin/develop' into wip/jtulach/MetaHe…
JaroslavTulach 30e5005
Merging with latest develop that includes #12052
JaroslavTulach d426ab3
Type.Atom... yields Meta.AtomConstructor
JaroslavTulach 7aacc66
Enforcing runtime type checks with inline signatures
JaroslavTulach 3516a2d
More inline signatures
JaroslavTulach 47f8e34
Fixing inline signatures to let test/Base_Tests pass
JaroslavTulach 11eafee
Moving (most of) Instrumentor from public API
JaroslavTulach 5331e49
Removing Meta.get_source_location and replacing it with Standard.Base…
JaroslavTulach 5ff29d1
Fixing Meta.meta Panic . name
JaroslavTulach 8c6ddd6
Single builtin to get Meta's kind of a value
JaroslavTulach 110d9d4
No need for UnresolvedXyz in the Types list
JaroslavTulach 6eab870
Merge remote-tracking branch 'origin/develop' into wip/jtulach/MetaHe…
JaroslavTulach 5716344
Meta signature test
JaroslavTulach dc5d820
Robust when --in-project distribution/lib/Standard/Base/0.0.0-dev/
JaroslavTulach 2f78b17
Moving value_for_uuid into Runtime
JaroslavTulach 33bdcbd
Merge remote-tracking branch 'origin/develop' into wip/jtulach/MetaHe…
JaroslavTulach 67fcec2
Tests accessing Instrumentor need to run with --disable-private-check
JaroslavTulach 2f8d126
Moving the signature snapshot into its own file
JaroslavTulach e776053
Adjusting micro's Meta to match current builtins
JaroslavTulach 4daed89
Better resolution of a conflict in changelog
JaroslavTulach a394c4e
Any value can be converted .to Meta.Type
JaroslavTulach 57d19a7
Generate conversion methods into signature files
JaroslavTulach ba13b0d
Use value.to Meta.Type . qualified_name to obtain qualified type name…
JaroslavTulach 90d2e2a
Fixing indentation of documentation
JaroslavTulach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Instrumentor.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
private | ||
|
||
import project.Any.Any | ||
import project.Data.Text.Text | ||
import project.Function.Function | ||
import project.Meta | ||
import project.Internal.Meta_Helpers | ||
import project.Data.Vector.Vector | ||
import project.Nothing.Nothing | ||
import project.Runtime.Managed_Resource.Managed_Resource | ||
|
||
## PRIVATE | ||
ADVANCED | ||
|
||
Builder to create instrumentation for a function | ||
type Instrumentor | ||
private Value impl | ||
|
||
## PRIVATE | ||
ADVANCED | ||
|
||
Registers callback to be executed at the begining of node/expression | ||
execution. The callback `fn` gets UUID of the node/expression that is | ||
being executed and can return `Nothing` to continue regular execution | ||
or anything else to skip the execution and just return given value. | ||
|
||
Arguments: | ||
- fn: The callback function accepting UUID. | ||
on_enter self (fn : Text -> Any | Nothing) = | ||
new = Meta_Helpers.instrumentor_builtin "onEnter" [ self.impl, fn ] | ||
Instrumentor.Value new | ||
|
||
## PRIVATE | ||
ADVANCED | ||
|
||
Registers callback to be executed when a node/expression evaluation | ||
is over. The callback `fn` gets UUID and the computed value (or value | ||
of `expression` if specified). Usually | ||
the value is _cached_ and returned from `on_enter` callback next time | ||
the same expression is evaluated. | ||
|
||
> Example | ||
Specify `expression` to _"inline evaluate"_ it. | ||
see_a_b uuid:Text ~result = | ||
if uuid == "expected-uuid" then | ||
IO.println "evalutated to "+result.to_text | ||
|
||
Meta.meta .fn . instrument . on_return fn=see_a_b expression="a+b" . activate | ||
|
||
Arguments: | ||
- fn: The callback function accepting UUID and computed value | ||
- expression: Expression to evaluate on_return - by default Nothing - | ||
e.g. to provide the return value of the function | ||
on_return self (fn : Text -> Any -> Nothing) expression:(Text | Nothing)=Nothing = | ||
new = Meta_Helpers.instrumentor_builtin "onReturn" [ self.impl, fn, expression ] | ||
Instrumentor.Value new | ||
|
||
## PRIVATE | ||
ADVANCED | ||
|
||
Registers callback to be executed when a node/expression representing function is about to be called. | ||
The callback `fn` shall accept three arguments. The UUID to identify the expression, the function to be | ||
invoked and the arguments to pass to the function. The callback can return `Nothing` | ||
(in such case the function gets executed with provided arguments) or some other value, | ||
which is then returned instead of calling the function. | ||
|
||
Arguments: | ||
- fn: The callback function accepting UUID and function value | ||
on_call self (fn : Text -> Function -> Vector Any -> Any | Nothing) = | ||
new = Meta_Helpers.instrumentor_builtin "onCall" [ self.impl, fn ] | ||
Instrumentor.Value new | ||
|
||
## PRIVATE | ||
ADVANCED | ||
|
||
Activates configured instrumentor. Returns managed resource to | ||
deactivate the instrumentor later. | ||
|
||
Arguments: | ||
- value: The value of the atom in the meta representation. | ||
activate self = | ||
finalize_instrumentor impl = Meta_Helpers.instrumentor_builtin "deactivate" [ impl ] | ||
create action = (Meta_Helpers.instrumentor_builtin action [ self.impl, finalize_instrumentor ]) : Managed_Resource | ||
create "activate" | ||
|
||
|
||
## ADVANCED | ||
GROUP Metadata | ||
ICON metadata | ||
|
||
Starts building an instrumentation for a given node | ||
Meta.Unresolved_Symbol.instrument self -> Instrumentor = Instrumentor.Value (Meta_Helpers.instrumentor_builtin "newBuilder" [ self.impl ]) | ||
JaroslavTulach marked this conversation as resolved.
Show resolved
Hide resolved
|
25 changes: 25 additions & 0 deletions
25
distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Meta_Helpers.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
private | ||
|
||
get_atom_constructor_builtin atom = @Builtin_Method "Meta.get_atom_constructor" | ||
get_atom_fields_builtin atom = @Builtin_Method "Meta.get_atom_fields" | ||
get_type_constructors_builtin typ factory = @Builtin_Method "Meta.get_type_constructors" | ||
get_type_methods_builtin typ = @Builtin_Method "Meta.get_type_methods" | ||
get_polyglot_language_builtin value = @Builtin_Method "Meta.get_polyglot_language" | ||
create_unresolved_symbol_builtin name symbol = @Builtin_Method "Meta.create_unresolved_symbol" | ||
get_unresolved_symbol_name_builtin symbol = @Builtin_Method "Meta.get_unresolved_symbol_name" | ||
get_constructor_fields_builtin atom_constructor = @Builtin_Method "Meta.get_constructor_fields" | ||
get_constructor_name_builtin atom_constructor = @Builtin_Method "Meta.get_constructor_name" | ||
new_atom_builtin constructor fields = @Builtin_Method "Meta.new_atom" | ||
atom_with_hole_builtin factory = @Builtin_Method "Meta.atom_with_hole_builtin" | ||
is_same_object_builtin value_1 value_2 = @Builtin_Method "Meta.is_same_object" | ||
is_a_builtin value typ = @Builtin_Method "Meta.is_a" | ||
type_of_builtin value = @Builtin_Method "Meta.type_of" | ||
get_annotation_builtin target method parameter_name = @Builtin_Method "Meta.get_annotation" | ||
find_atom_constructor_builtin value = @Builtin_Method "Meta.find_atom_constructor" | ||
get_kind_builtin value = @Builtin_Method "Meta.get_kind_builtin" | ||
get_simple_type_name_builtin value = @Builtin_Method "Meta.get_simple_type_name" | ||
get_qualified_type_name_builtin value = @Builtin_Method "Meta.get_qualified_type_name" | ||
get_short_type_name_builtin typ = @Builtin_Method "Meta.get_short_type_name" | ||
get_constructor_declaring_type_builtin constructor = @Builtin_Method "Meta.get_constructor_declaring_type" | ||
instrumentor_builtin op args = @Builtin_Method "Meta.instrumentor_builtin" | ||
find_type_by_qualified_name_builtin fqn = @Builtin_Method "Meta.find_type_by_qualified_name" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instrumentor
is a nice concept, but probably not something we want to expose from a public API. It is still fine to have it and test it, but makingprivate
and moving theInstrumentor_Spec
intotest/Base_Internal_Tests
.Y.js+Insight (as being worked on by @4e6) should be the future of instrumentation and it doesn't need the
Meta_Helpers.instrumentor_builtin
as it is using GraalVM Insight directly.