| 893 | |
| 894 | var baseMaxWorkDepth = 20, reduceMaxWorkDepth = 0.0001; |
| 895 | function withWorklist(f) { |
| 896 | if (cx.workList) return f(cx.workList); |
| 897 | |
| 898 | var list = [], depth = 0; |
| 899 | var add = cx.workList = function(type, target, weight) { |
| 900 | if (depth < baseMaxWorkDepth - reduceMaxWorkDepth * list.length) |
| 901 | list.push(type, target, weight, depth); |
| 902 | }; |
| 903 | var ret = f(add); |
| 904 | for (var i = 0; i < list.length; i += 4) { |
| 905 | if (timeout && +new Date >= timeout) |
| 906 | throw new exports.TimedOut(); |
| 907 | depth = list[i + 3] + 1; |
| 908 | list[i + 1].addType(list[i], list[i + 2]); |
| 909 | } |
| 910 | cx.workList = null; |
| 911 | return ret; |
| 912 | } |
| 913 | |
| 914 | function withSuper(ctor, obj, f) { |
| 915 | var oldCtor = cx.curSuperCtor, oldObj = cx.curSuper |