@jdeighan/coffee-utils 6.0.5 → 6.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/call_stack.coffee +13 -9
- package/src/call_stack.js +16 -11
package/package.json
CHANGED
package/src/call_stack.coffee
CHANGED
@@ -25,27 +25,31 @@ export class CallStack
|
|
25
25
|
call: (funcName, hInfo) ->
|
26
26
|
|
27
27
|
if doDebugStack
|
28
|
-
|
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: (
|
35
|
+
returnFrom: (fName) ->
|
35
36
|
|
36
|
-
if doDebugStack
|
37
|
-
LOG "[RETURN FROM #{funcName}]"
|
38
37
|
if @lStack.length == 0
|
39
|
-
LOG "returnFrom('#{
|
38
|
+
LOG "returnFrom('#{fName}') but stack is empty"
|
40
39
|
return undef
|
41
|
-
|
42
|
-
|
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
|
-
|
47
|
+
|
48
|
+
if (funcName == fName)
|
45
49
|
return hInfo
|
46
50
|
else
|
47
51
|
@dump()
|
48
|
-
LOG "returnFrom('#{
|
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
|
-
|
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(
|
39
|
-
var
|
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('${
|
43
|
+
LOG(`returnFrom('${fName}') but stack is empty`);
|
45
44
|
return undef;
|
46
45
|
}
|
47
|
-
|
48
|
-
|
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
|
-
|
54
|
+
}
|
55
|
+
if (funcName === fName) {
|
51
56
|
return hInfo;
|
52
57
|
} else {
|
53
58
|
this.dump();
|
54
|
-
LOG(`returnFrom('${
|
59
|
+
LOG(`BAD returnFrom('${fName}')`);
|
55
60
|
return undef;
|
56
61
|
}
|
57
62
|
}
|