@jdeighan/coffee-utils 6.0.5 → 6.0.6

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "6.0.5",
4
+ "version": "6.0.6",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -25,27 +25,31 @@ export class CallStack
25
25
  call: (funcName, hInfo) ->
26
26
 
27
27
  if doDebugStack
28
- LOG "[CALL #{funcName}]"
28
+ prefix = ' '.repeat(@lStack.length)
29
+ LOG "#{prefix}[CALL #{funcName}]"
29
30
  @lStack.push({funcName, hInfo})
30
31
  return
31
32
 
32
33
  # ........................................................................
33
34
 
34
- returnFrom: (funcName) ->
35
+ returnFrom: (fName) ->
35
36
 
36
- if doDebugStack
37
- LOG "[RETURN FROM #{funcName}]"
38
37
  if @lStack.length == 0
39
- LOG "returnFrom('#{funcName}') but stack is empty"
38
+ LOG "returnFrom('#{fName}') but stack is empty"
40
39
  return undef
41
- TOSfName = @lStack[@lStack.length-1].funcName
42
- if funcName == TOSfName
40
+ if doDebugStack
41
+ prefix = ' '.repeat(@lStack.length-1)
42
+ LOG "#{prefix}[RETURN FROM #{fName}]"
43
+ {funcName, hInfo} = @lStack.pop()
44
+ while (funcName != fName) && (@lStack.length > 0)
45
+ LOG "[MISSING RETURN FROM #{funcName} (return from #{fName})]"
43
46
  {funcName, hInfo} = @lStack.pop()
44
- assert funcName==TOSfName, "Bad func name on stack"
47
+
48
+ if (funcName == fName)
45
49
  return hInfo
46
50
  else
47
51
  @dump()
48
- LOG "returnFrom('#{funcName}') but TOS is '#{TOSfName}'"
52
+ LOG "BAD returnFrom('#{fName}')"
49
53
  return undef
50
54
 
51
55
  # ........................................................................
package/src/call_stack.js CHANGED
@@ -28,30 +28,35 @@ export var CallStack = class CallStack {
28
28
 
29
29
  // ........................................................................
30
30
  call(funcName, hInfo) {
31
+ var prefix;
31
32
  if (doDebugStack) {
32
- LOG(`[CALL ${funcName}]`);
33
+ prefix = ' '.repeat(this.lStack.length);
34
+ LOG(`${prefix}[CALL ${funcName}]`);
33
35
  }
34
36
  this.lStack.push({funcName, hInfo});
35
37
  }
36
38
 
37
39
  // ........................................................................
38
- returnFrom(funcName) {
39
- var TOSfName, hInfo;
40
- if (doDebugStack) {
41
- LOG(`[RETURN FROM ${funcName}]`);
42
- }
40
+ returnFrom(fName) {
41
+ var funcName, hInfo, prefix;
43
42
  if (this.lStack.length === 0) {
44
- LOG(`returnFrom('${funcName}') but stack is empty`);
43
+ LOG(`returnFrom('${fName}') but stack is empty`);
45
44
  return undef;
46
45
  }
47
- TOSfName = this.lStack[this.lStack.length - 1].funcName;
48
- if (funcName === TOSfName) {
46
+ if (doDebugStack) {
47
+ prefix = ' '.repeat(this.lStack.length - 1);
48
+ LOG(`${prefix}[RETURN FROM ${fName}]`);
49
+ }
50
+ ({funcName, hInfo} = this.lStack.pop());
51
+ while ((funcName !== fName) && (this.lStack.length > 0)) {
52
+ LOG(`[MISSING RETURN FROM ${funcName} (return from ${fName})]`);
49
53
  ({funcName, hInfo} = this.lStack.pop());
50
- assert(funcName === TOSfName, "Bad func name on stack");
54
+ }
55
+ if (funcName === fName) {
51
56
  return hInfo;
52
57
  } else {
53
58
  this.dump();
54
- LOG(`returnFrom('${funcName}') but TOS is '${TOSfName}'`);
59
+ LOG(`BAD returnFrom('${fName}')`);
55
60
  return undef;
56
61
  }
57
62
  }