KWPendingNode.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // Licensed under the terms in License.txt
  3. //
  4. // Copyright 2010 Allen Ding. All rights reserved.
  5. //
  6. #import "KWPendingNode.h"
  7. #import "KWCallSite.h"
  8. #import "KWContextNode.h"
  9. #import "KWExampleNodeVisitor.h"
  10. @implementation KWPendingNode
  11. @synthesize description = _description;
  12. #pragma mark - Initializing
  13. - (id)initWithCallSite:(KWCallSite *)aCallSite context:(KWContextNode *)context description:(NSString *)aDescription {
  14. self = [super init];
  15. if (self) {
  16. _callSite = aCallSite;
  17. _description = [aDescription copy];
  18. _context = context;
  19. }
  20. return self;
  21. }
  22. + (id)pendingNodeWithCallSite:(KWCallSite *)aCallSite context:(KWContextNode *)context description:(NSString *)aDescription {
  23. return [[self alloc] initWithCallSite:aCallSite context:context description:aDescription];
  24. }
  25. #pragma mark - Accepting Visitors
  26. - (void)acceptExampleNodeVisitor:(id<KWExampleNodeVisitor>)aVisitor {
  27. [aVisitor visitPendingNode:self];
  28. }
  29. #pragma mark - Accessing the context stack
  30. - (NSArray *)contextStack
  31. {
  32. NSMutableArray *contextStack = [NSMutableArray array];
  33. KWContextNode *currentContext = _context;
  34. while (currentContext) {
  35. [contextStack addObject:currentContext];
  36. currentContext = currentContext.parentContext;
  37. }
  38. return contextStack;
  39. }
  40. @end