Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #library("debug"); | |
| 2 #import("introspection.dart"); | |
|
hausner
2011/12/21 21:53:19
Can you import a source file? Should this be #sour
gbracha
2011/12/22 18:29:59
introspection should be a library.
| |
| 3 | |
| 4 /** A mirror on the entire stack of an isolate. | |
| 5 // questions about being active, suspending, resuming may perhaps belong to the isolate? | |
| 6 | |
| 7 The methods in this interface are synchronous wrappers around async message send s. | |
| 8 We could make the all return a future instead. Ideally, I would declare them as | |
| 9 async methods. | |
| 10 */ | |
| 11 interface StackMirror extends Mirror { | |
| 12 /** Return a mirror on the activation at the top of the stack. | |
| 13 | |
| 14 */ | |
| 15 ActivationMirror top(); | |
| 16 | |
| 17 /** Return the otal number of frames in the stack. */ | |
| 18 int length(); | |
| 19 | |
| 20 | |
| 21 /** | |
| 22 Call the function at the current point in the calling frame, and stop at the fir st pc in that function. | |
|
hausner
2011/12/21 21:53:19
In this description you are implying that there is
gbracha
2011/12/22 18:29:59
I like stepInto and stepOver as well. As for stepp
| |
| 23 | |
| 24 Open issue 1: Return void, or an ActivationMirror representing the activation wh ere we | |
| 25 have landed. Arguably, that activation is always the top-of-stack (TOS); but wha t's | |
| 26 the harm in returning the activation we're at after the operation | |
| 27 instead of forcing you to ask for TOS? So I propose we return the TOS after the call. | |
| 28 | |
| 29 Open issue 2: Should this take an ActivationMirror as an argument. | |
| 30 One can argue that no argument is needed, as TOS (top-of-stack) is implicit. | |
| 31 However, it's nice to able to restart from an earlier point. Hence, there is an | |
| 32 optional argument that specifies what activation to start out from. | |
| 33 If it's null, we use TOS. | |
|
hausner
2011/12/21 21:53:19
Alternatively, step and next could be methods of t
gbracha
2011/12/22 18:29:59
Yes, but why?
hausner
2011/12/23 00:22:16
Because then you don't have the issue you mention
gbracha
2011/12/23 00:41:23
Good point.
| |
| 34 | |
| 35 */ | |
| 36 ActivationMirror step([ActivationMirror callingFrame]); | |
| 37 // this was stepInto; renamed per Lars' request. | |
| 38 | |
| 39 /** | |
| 40 Call the function at the current point in the calling frame, and stop at the pc | |
| 41 immediately after the call. | |
| 42 Open issues are similar to those in 'step' above. However, here we very clearly want to | |
| 43 be able to specify a calling frame. | |
| 44 */ | |
| 45 ActivationMirror next([ActivationMirror callingFrame]); | |
| 46 // This was stepOver; renamed per Lars' request. | |
| 47 | |
| 48 | |
| 49 // not needed - no first class control construct: | |
| 50 // void stepIntoClosure(ActivationMirror activation); | |
| 51 | |
| 52 /** Resume execution. | |
| 53 This method is asynchronous (not a synchronous wrapper). | |
| 54 Does it belong on the isolate? | |
| 55 */ | |
| 56 void restart(); | |
| 57 } | |
| 58 | |
| 59 | |
| 60 /** Scope mirrors represent subscopes in function bodies. These could be entire bodies, or blocks within a surrounding body or block, recursively. | |
| 61 | |
| 62 Again, methods here are synchronous wrappers. | |
| 63 */ | |
| 64 interface ScopeMirror extends ObjectMirror { | |
| 65 /** Names of all locals. Is this redundant with accessors defined by ObjectMirro r? */ | |
| 66 List<String> localNames(); | |
| 67 | |
| 68 | |
| 69 /** The enclosing scope/context. | |
| 70 For subscopes, its the surrounding ScopeMirror or ActivationMirror. For an activ ation, it would be the receiver. | |
| 71 */ | |
| 72 ObjectMirror enclosingScope(); | |
| 73 | |
| 74 /** The program counter. the natural representation is a token, which already ca ptures the location information: character index, file etc. | |
| 75 */ | |
| 76 Token pc(); | |
|
hausner
2011/12/21 21:53:19
I don't see Token defined anywhere. What can I do
gbracha
2011/12/22 18:29:59
Indeed. It should be much the same as in the parse
mattsh
2011/12/22 21:00:05
I'm hoping in Dart we can make an nice UI for step
hausner
2011/12/23 00:22:16
No, but there can be ActivationFrames on the stack
gbracha
2011/12/23 00:41:23
Of course.
gbracha
2011/12/23 00:41:23
If no source code is available, one should be able
mattsh
2011/12/23 00:50:19
Right. I guess I was picturing that in this expre
| |
| 77 | |
| 78 /** Returns a list of length 2, representing the range of program counters for t he | |
| 79 reflectee. | |
| 80 */ | |
| 81 List<Token> pcRange(); | |
| 82 } | |
| 83 | |
| 84 | |
| 85 /** A mirror on a stack frame. | |
| 86 It gives us access to its local variables, parameters, subscopes, the ability to set the PC etc. | |
| 87 | |
| 88 All methods here are synchoronous wrappers again. | |
| 89 | |
| 90 */ | |
| 91 interface ActivationMirror extends ScopeMirror{ | |
| 92 | |
| 93 /** a mirror on the receiver of this activation | |
| 94 If it's a static method return null (not a mirror on null!). | |
| 95 Alternately, dispense with this method and require 'this' be looked up among th e locals? */ | |
| 96 ObjectMirror receiverMirror(); | |
| 97 | |
| 98 /** Return the frame that called the reflectee. */ | |
| 99 ActivationMirror caller(); | |
| 100 | |
| 101 /** | |
| 102 Return an mirror on the activation that would catch the exception represented by | |
| 103 o, if it were thrown. Returns null if none. The argument o must be either a va lue | |
| 104 (in which case it will be used as the exception) or an object mirror (in which | |
| 105 case o's reflectee will be used as the exception to be thrown). | |
| 106 | |
| 107 There is no easy way to implement this based on other primitives, but | |
| 108 the VM has the ability to do this without actually throwing an exception. | |
| 109 | |
| 110 */ | |
| 111 ActivationMirror handlerFor(Object o); // if I threw o, where would I land? | |
| 112 | |
| 113 | |
| 114 | |
| 115 /** A mirror on the function the reflectee is an activation of. | |
| 116 // could be closure. Therefore the return type is | |
| 117 // potentially MethodMirror | ClosureMirror. So maybe we should define a common | |
| 118 // supertype for those two. | |
| 119 | |
| 120 This method is not asynchronous. We should be able to embded this data in the | |
| 121 activation mirror. | |
| 122 */ | |
| 123 MethodMirror method(); | |
| 124 | |
| 125 /** | |
| 126 Return to the caller of the reflectee. The value returned is o, if o is a value, or | |
| 127 o's reflectee if o is an objetc mirror; o must be either a value or an object mi rror. | |
| 128 */ | |
| 129 returnObject(Object o, ActivationMirror); // terminate this frame and return o. | |
| 130 } | |
| OLD | NEW |