// which used in the delegate callback.
- (NSInteger)getProperty:(NSString*)property;
+// Takes a partially loaded stack frame and fetches the rest of the information.
+- (void)loadStackFrame:(StackFrame*)frame;
+
@end
// Delegate ////////////////////////////////////////////////////////////////////
- (void)newStackFrame:(StackFrame*)frame;
// Tells the debugger that new source is available for the given frame.
+// TODO: rename to |-frameUpdated:|.
- (void)sourceUpdated:(StackFrame*)frame;
// Callback from |-getProperty:|.
[self recordCallback:@selector(propertiesReceived:) forTransaction:tx];
}
+- (void)loadStackFrame:(StackFrame*)frame
+{
+ if (frame.loaded)
+ return;
+
+ NSNumber* routingNumber = [NSNumber numberWithInt:frame.routingID];
+
+ // Get the source code of the file. Escape % in URL chars.
+ NSString* escapedFilename = [frame.filename stringByReplacingOccurrencesOfString:@"%" withString:@"%%"];
+ NSNumber* transaction = [connection_ sendCommandWithFormat:@"source -f %@", escapedFilename];
+ [self recordCallback:@selector(setSource:) forTransaction:transaction];
+ [callbackContext_ setObject:routingNumber forKey:transaction];
+
+ // Get the names of all the contexts.
+ transaction = [connection_ sendCommandWithFormat:@"context_names -d %d", frame.index];
+ [self recordCallback:@selector(contextsReceived:) forTransaction:transaction];
+ [callbackContext_ setObject:routingNumber forKey:transaction];
+
+ // This frame will be fully loaded.
+ frame.loaded = YES;
+}
+
// Breakpoint Management ///////////////////////////////////////////////////////
#pragma mark Breakpoints
atLine:[[[xmlframe attributeForName:@"lineno"] stringValue] intValue]
inFunction:[[xmlframe attributeForName:@"where"] stringValue]
withVariables:nil];
+ frame.routingID = routingID;
// Only get the complete frame for the first level. The other frames will get
// information loaded lazily when the user clicks on one.
if (frame.index == 0) {
- // Get the source code of the file. Escape % in URL chars.
- NSString* escapedFilename = [frame.filename stringByReplacingOccurrencesOfString:@"%" withString:@"%%"];
- NSNumber* transaction = [connection_ sendCommandWithFormat:@"source -f %@", escapedFilename];
- [self recordCallback:@selector(setSource:) forTransaction:transaction];
- [callbackContext_ setObject:routingNumber forKey:transaction];
-
- // Get the names of all the contexts.
- transaction = [connection_ sendCommandWithFormat:@"context_names -d %d", frame.index];
- [self recordCallback:@selector(contextsReceived:) forTransaction:transaction];
- [callbackContext_ setObject:routingNumber forKey:transaction];
+ [self loadStackFrame:frame];
}
if ([delegate respondsToSelector:@selector(newStackFrame:)])
@interface StackFrame : NSObject
{
+ /**
+ * Whether or not the stack frame has been fully loaded.
+ */
+ BOOL loaded_;
+
/**
* The routing ID used to receive response information from the engine.
*/
NSArray* variables;
}
+@property BOOL loaded;
@property NSUInteger routingID;
@property (readwrite) int index;
@property (readonly, copy) NSString* filename;