summary refs log tree commit diff stats
path: root/tests/async/tasync_traceback.nim
Commit message (Expand)AuthorAgeFilesLines
* Fixed testsYuriy Glukhov2018-06-061-5/+21
* Review comments addressed. More thorough line info tracking.Yuriy Glukhov2018-05-101-2/+2
* Fix tasync_traceback test.Dominik Picheta2018-01-111-0/+1
* Use regex to match output of tasync_traceback.Dominik Picheta2018-01-111-60/+69
* Simplify async traceback processing.Dominik Picheta2017-12-281-29/+43
* No need to recurse now that mergeEntries doesn't do any pattern matching.Dominik Picheta2017-12-281-2/+2
* Show only detailed async tracebacks.Dominik Picheta2017-12-281-10/+17
* Rename cb0 to asyncProcName_continue + other improvements to async tracebacks.Dominik Picheta2017-12-281-0/+1
* Go through the re-raise stacks for more detailed tracebacks.Dominik Picheta2017-12-281-3/+44
* Refine the async tracebacks.Dominik Picheta2017-12-281-5/+12
* Implement some simple pattern-based transformation for async tracebacks.Dominik Picheta2017-12-281-0/+46
f89378d563330260c54496cd80bd4e2550e5988c'>f89378d5 ^
f1a6f323 ^
9cf71627 ^
f89378d5 ^
9cf71627 ^
decaddb4 ^
9cf71627 ^

ec926027 ^
9cf71627 ^


64cf0a59 ^

ec926027 ^


df8bb4c3 ^
f6d47435 ^
f1a6f323 ^
ec926027 ^


f6d47435 ^
ec926027 ^


f6d47435 ^
f278a15d ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
                                                                         






                                       
                             
 














                                                                             




                                     

                        
                                











                                                             
 
                                                                        
          
                                                       
                                                                
                                                                                                           

          
                                                  


                                                        

                                                                       


                                            
 
 
                                   


                                                                           
                 


                                      
 



                        
//: So far the recipes we define can't run each other. Let's change that.
:(scenario "calling_recipe")
recipe main [
  f
]
recipe f [
  3:integer <- add 2:literal, 2:literal
]
+mem: storing 4 in location 3

:(before "struct routine {")
// Everytime a recipe runs another, we interrupt it and start running the new
// recipe. When that finishes, we continue this one where we left off.
// This requires maintaining a 'stack' of interrupted recipes or 'calls'.
struct call {
  recipe_number running_recipe;
  size_t pc;
  // End Call Fields
  call(recipe_number r) :running_recipe(r), pc(0) {}
};
typedef stack<call> call_stack;

:(replace{} "struct routine")
struct routine {
  call_stack calls;
  // End Routine Fields
  routine(recipe_number r);
};
:(code)
  routine::routine(recipe_number r) {
    calls.push(call(r));
  }
//: now update routine's helpers
:(replace{} "inline size_t& running_at(routine& rr)")
inline size_t& running_at(routine& rr) {
  return rr.calls.top().pc;
}
:(replace{} "inline string recipe_name(routine& rr)")
inline string recipe_name(routine& rr) {
  return Recipe[rr.calls.top().running_recipe].name;
}
:(replace{} "inline vector<instruction>& steps(routine& rr)")
inline vector<instruction>& steps(routine& rr) {
  return Recipe[rr.calls.top().running_recipe].steps;
}

:(replace{} "default:" following "End Primitive Recipe Implementations")
default: {
  // not a primitive; try to look for a matching recipe
  if (Recipe.find(instructions[pc].operation) == Recipe.end()) {
    raise << "undefined operation " << instructions[pc].operation << ": " << instructions[pc].name << '\n';
    break;
  }
  rr.calls.push(call(instructions[pc].operation));
  continue;  // not done with caller; don't increment pc
}

//: finally, we need to fix the termination conditions for the run loop

:(replace{} "inline bool done(routine& rr)")
inline bool done(routine& rr) {
  return rr.calls.empty();
}

:(before "Running one instruction")
// when we reach the end of one call, we may reach the end of the one below
// it, and the one below that, and so on
while (running_at(rr) >= steps(rr).size()) {
  rr.calls.pop();
  if (rr.calls.empty()) return;
  // todo: no results returned warning
  ++running_at(rr);
}

:(before "End Includes")
#include <stack>
using std::stack;