-
Hello, thank you for jint - great project :-) I would like to determine, which functions are declared in a script. My approach would be to DIFF the existing global function names (like var engine = new Engine();
engine.Execute(@"
function hello() {
};
"); Is there any way to get a list that contains Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You need to go through the AST tree produced by Esprima. Get A simpler solution might be just inheriting from |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick response. Unfortunately this is way too complex for my use case, but I think I found another solution that might not require this at all.
That might be a good option, if I cannot work around this problem the other way. Just for the sake of completeness: I thought it would be as easy as this: https://stackoverflow.com/questions/28367663/how-to-get-all-variables-and-functions-names-from-the-global-scope-in-jint Thank you and keep up the good work. |
Beta Was this translation helpful? Give feedback.
-
@lahma I found another possibility. Just for the sake of completeness, I use a combination and function names and global namespace injection for my use case ( function musicbrainz(metadata, parameters) {
// ...
}
tone.RegisterTagger("musicbrainz");
Works pretty good. Now I can create custom audio tagger logic via JavaScript. Thanks for that :-) For more information see: https://github.com/sandreas/tone#custom-scripted-taggers-experimental |
Beta Was this translation helpful? Give feedback.
You need to go through the AST tree produced by Esprima. Get
Script
instance fromJavaScriptParser
's Parse, then walk it recursive. Here's an example of that.A simpler solution might be just inheriting from
AstVisitor
and override theVisitFunctionDeclaration
, that will be called for every function.