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
Mirrors and runtime information for current function #11916
Comments
This comment was originally written by off...@mikemitterer.at If someone is able to correct the typo in the headline... pls change it. |
This comment was originally written by @mezoni This is a compile-time constant but not the runtime.
|
I am assuming this is in the context of dart2js, correct? Added Area-Dart2JS, Library-Mirrors, Triaged labels. |
Changed the title to: "Mirrors and runtime information for current function". |
Mike, it sounds to me that you're looking for a new method in the mirror API that could look something like this: /** Am I understanding you correctly? cc @gbracha. |
This comment was originally written by @a14n His original question on stackoverflow : http://stackoverflow.com/questions/17741543/how-do-i-get-a-methodmirror-for-the-current-function I think he is looking for an equivalent of the JS "arguments.callee" returning a MethodMirror. |
This comment was originally written by off...@mikemitterer.at Yeah #6 is almost right. The difference to callee is that it gives you a reference to the calling function - I just need it's name. If I have the name - sure, then #5 would be necessary. BTW: #2 File name, Line number usw. would also be very helpful |
I doubt we will expose access to anything like JavaScript's arguments.callee in Dart. |
This comment was originally written by @mezoni
Something similar. void foo(int a, int b) { abstract class Function { external static Function callee(); external static Symbol getName(Function function); external static apply(Function function, List positionalArguments, Or maybe another class for this purpose. |
FWIW MethodMirror methodMirror = reflect(functionOne).function; should work, because reflecting a function gives you a ClosureMirror, which is a specialization of InstanceMirror that supports the function accessor. We are shaking out the bugs in this area, so it might not work in JS yet, or even in every case on the VM (but it does for a top level function). So I don't think reflectFunction is necessary. Removed Type-Defect label. |
This issue was originally filed by off...@mikemitterer.at
What steps will reproduce the problem?
class RestSimulator {
@path("/var")
void functionOne() {
final Type type = this.runtimeType;
final InstanceMirror instanceMirror = reflect(this);
final ClassMirror classMirror = instanceMirror.type;
final MethodMirror methodMirror = ?????
var metadata = methodMirror.metadata;
var path = metadata.first.reflectee;
print(path.toString()):
}
}
What is the expected output? What do you see instead?
I want a MethodMirror for "functionOne" but without doing something like:
final MethodMirror methodMirror = xxx.functions[const Symbol('functionOne')];
The MethodName (Symbol) of the current function should be available at runtime.
What version of the product are you using? On what operating system?
Dart Editor version 0.6.5_r25017
Dart SDK version 0.6.5.0_r25017
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: