scope.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /***********************************************************************
  2. A JavaScript tokenizer / parser / beautifier / compressor.
  3. https://github.com/mishoo/UglifyJS2
  4. -------------------------------- (C) ---------------------------------
  5. Author: Mihai Bazon
  6. <mihai.bazon@gmail.com>
  7. http://mihai.bazon.net/blog
  8. Distributed under the BSD license:
  9. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions
  12. are met:
  13. * Redistributions of source code must retain the above
  14. copyright notice, this list of conditions and the following
  15. disclaimer.
  16. * Redistributions in binary form must reproduce the above
  17. copyright notice, this list of conditions and the following
  18. disclaimer in the documentation and/or other materials
  19. provided with the distribution.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  21. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  24. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  25. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  29. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  30. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. SUCH DAMAGE.
  32. ***********************************************************************/
  33. "use strict";
  34. function SymbolDef(scope, index, orig) {
  35. this.name = orig.name;
  36. this.orig = [ orig ];
  37. this.scope = scope;
  38. this.references = [];
  39. this.global = false;
  40. this.mangled_name = null;
  41. this.undeclared = false;
  42. this.constant = false;
  43. this.index = index;
  44. this.id = SymbolDef.next_id++;
  45. };
  46. SymbolDef.next_id = 1;
  47. SymbolDef.prototype = {
  48. unmangleable: function(options) {
  49. if (!options) options = {};
  50. return (this.global && !options.toplevel)
  51. || this.undeclared
  52. || (!options.eval && (this.scope.uses_eval || this.scope.uses_with))
  53. || (options.keep_fnames
  54. && (this.orig[0] instanceof AST_SymbolLambda
  55. || this.orig[0] instanceof AST_SymbolDefun));
  56. },
  57. mangle: function(options) {
  58. var cache = options.cache && options.cache.props;
  59. if (this.global && cache && cache.has(this.name)) {
  60. this.mangled_name = cache.get(this.name);
  61. }
  62. else if (!this.mangled_name && !this.unmangleable(options)) {
  63. var s = this.scope;
  64. if (!options.screw_ie8 && this.orig[0] instanceof AST_SymbolLambda)
  65. s = s.parent_scope;
  66. this.mangled_name = s.next_mangled(options, this);
  67. if (this.global && cache) {
  68. cache.set(this.name, this.mangled_name);
  69. }
  70. }
  71. }
  72. };
  73. AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
  74. options = defaults(options, {
  75. screw_ie8: false,
  76. cache: null
  77. });
  78. // pass 1: setup scope chaining and handle definitions
  79. var self = this;
  80. var scope = self.parent_scope = null;
  81. var labels = new Dictionary();
  82. var defun = null;
  83. var last_var_had_const_pragma = false;
  84. var nesting = 0;
  85. var tw = new TreeWalker(function(node, descend){
  86. if (options.screw_ie8 && node instanceof AST_Catch) {
  87. var save_scope = scope;
  88. scope = new AST_Scope(node);
  89. scope.init_scope_vars(nesting);
  90. scope.parent_scope = save_scope;
  91. descend();
  92. scope = save_scope;
  93. return true;
  94. }
  95. if (node instanceof AST_Scope) {
  96. node.init_scope_vars(nesting);
  97. var save_scope = node.parent_scope = scope;
  98. var save_defun = defun;
  99. var save_labels = labels;
  100. defun = scope = node;
  101. labels = new Dictionary();
  102. ++nesting; descend(); --nesting;
  103. scope = save_scope;
  104. defun = save_defun;
  105. labels = save_labels;
  106. return true; // don't descend again in TreeWalker
  107. }
  108. if (node instanceof AST_LabeledStatement) {
  109. var l = node.label;
  110. if (labels.has(l.name)) {
  111. throw new Error(string_template("Label {name} defined twice", l));
  112. }
  113. labels.set(l.name, l);
  114. descend();
  115. labels.del(l.name);
  116. return true; // no descend again
  117. }
  118. if (node instanceof AST_With) {
  119. for (var s = scope; s; s = s.parent_scope)
  120. s.uses_with = true;
  121. return;
  122. }
  123. if (node instanceof AST_Symbol) {
  124. node.scope = scope;
  125. }
  126. if (node instanceof AST_Label) {
  127. node.thedef = node;
  128. node.references = [];
  129. }
  130. if (node instanceof AST_SymbolLambda) {
  131. defun.def_function(node);
  132. }
  133. else if (node instanceof AST_SymbolDefun) {
  134. // Careful here, the scope where this should be defined is
  135. // the parent scope. The reason is that we enter a new
  136. // scope when we encounter the AST_Defun node (which is
  137. // instanceof AST_Scope) but we get to the symbol a bit
  138. // later.
  139. (node.scope = defun.parent_scope).def_function(node);
  140. }
  141. else if (node instanceof AST_Var) {
  142. last_var_had_const_pragma = node.has_const_pragma();
  143. }
  144. else if (node instanceof AST_SymbolVar
  145. || node instanceof AST_SymbolConst) {
  146. var def = defun.def_variable(node);
  147. def.constant = node instanceof AST_SymbolConst || last_var_had_const_pragma;
  148. def.init = tw.parent().value;
  149. }
  150. else if (node instanceof AST_SymbolCatch) {
  151. (options.screw_ie8 ? scope : defun)
  152. .def_variable(node);
  153. }
  154. else if (node instanceof AST_LabelRef) {
  155. var sym = labels.get(node.name);
  156. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  157. name: node.name,
  158. line: node.start.line,
  159. col: node.start.col
  160. }));
  161. node.thedef = sym;
  162. }
  163. });
  164. self.walk(tw);
  165. // pass 2: find back references and eval
  166. var func = null;
  167. var globals = self.globals = new Dictionary();
  168. var tw = new TreeWalker(function(node, descend){
  169. if (node instanceof AST_Lambda) {
  170. var prev_func = func;
  171. func = node;
  172. descend();
  173. func = prev_func;
  174. return true;
  175. }
  176. if (node instanceof AST_LoopControl && node.label) {
  177. node.label.thedef.references.push(node);
  178. return true;
  179. }
  180. if (node instanceof AST_SymbolRef) {
  181. var name = node.name;
  182. if (name == "eval" && tw.parent() instanceof AST_Call) {
  183. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  184. s.uses_eval = true;
  185. }
  186. }
  187. var sym = node.scope.find_variable(name);
  188. if (!sym) {
  189. var g;
  190. if (globals.has(name)) {
  191. g = globals.get(name);
  192. } else {
  193. g = new SymbolDef(self, globals.size(), node);
  194. g.undeclared = true;
  195. g.global = true;
  196. globals.set(name, g);
  197. }
  198. node.thedef = g;
  199. if (func && name == "arguments") {
  200. func.uses_arguments = true;
  201. }
  202. } else {
  203. node.thedef = sym;
  204. }
  205. node.reference();
  206. return true;
  207. }
  208. });
  209. self.walk(tw);
  210. if (options.cache) {
  211. this.cname = options.cache.cname;
  212. }
  213. });
  214. AST_Scope.DEFMETHOD("init_scope_vars", function(nesting){
  215. this.variables = new Dictionary(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  216. this.functions = new Dictionary(); // map name to AST_SymbolDefun (functions defined in this scope)
  217. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  218. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  219. this.parent_scope = null; // the parent scope
  220. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  221. this.cname = -1; // the current index for mangling functions/variables
  222. this.nesting = nesting; // the nesting level of this scope (0 means toplevel)
  223. });
  224. AST_Lambda.DEFMETHOD("init_scope_vars", function(){
  225. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  226. this.uses_arguments = false;
  227. var symbol = new AST_VarDef({ name: "arguments", start: this.start, end: this.end });
  228. var def = new SymbolDef(this, this.variables.size(), symbol);
  229. this.variables.set(symbol.name, def);
  230. });
  231. AST_SymbolRef.DEFMETHOD("reference", function() {
  232. var def = this.definition();
  233. def.references.push(this);
  234. var s = this.scope;
  235. while (s) {
  236. push_uniq(s.enclosed, def);
  237. if (s === def.scope) break;
  238. s = s.parent_scope;
  239. }
  240. this.frame = this.scope.nesting - def.scope.nesting;
  241. });
  242. AST_Scope.DEFMETHOD("find_variable", function(name){
  243. if (name instanceof AST_Symbol) name = name.name;
  244. return this.variables.get(name)
  245. || (this.parent_scope && this.parent_scope.find_variable(name));
  246. });
  247. AST_Scope.DEFMETHOD("def_function", function(symbol){
  248. this.functions.set(symbol.name, this.def_variable(symbol));
  249. });
  250. AST_Scope.DEFMETHOD("def_variable", function(symbol){
  251. var def;
  252. if (!this.variables.has(symbol.name)) {
  253. def = new SymbolDef(this, this.variables.size(), symbol);
  254. this.variables.set(symbol.name, def);
  255. def.global = !this.parent_scope;
  256. } else {
  257. def = this.variables.get(symbol.name);
  258. def.orig.push(symbol);
  259. }
  260. return symbol.thedef = def;
  261. });
  262. AST_Scope.DEFMETHOD("next_mangled", function(options){
  263. var ext = this.enclosed;
  264. out: while (true) {
  265. var m = base54(++this.cname);
  266. if (!is_identifier(m)) continue; // skip over "do"
  267. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  268. // shadow a name excepted from mangling.
  269. if (options.except.indexOf(m) >= 0) continue;
  270. // we must ensure that the mangled name does not shadow a name
  271. // from some parent scope that is referenced in this or in
  272. // inner scopes.
  273. for (var i = ext.length; --i >= 0;) {
  274. var sym = ext[i];
  275. var name = sym.mangled_name || (sym.unmangleable(options) && sym.name);
  276. if (m == name) continue out;
  277. }
  278. return m;
  279. }
  280. });
  281. AST_Function.DEFMETHOD("next_mangled", function(options, def){
  282. // #179, #326
  283. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  284. // a function expression's argument cannot shadow the function expression's name
  285. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  286. while (true) {
  287. var name = AST_Lambda.prototype.next_mangled.call(this, options, def);
  288. if (!(tricky_def && tricky_def.mangled_name == name))
  289. return name;
  290. }
  291. });
  292. AST_Scope.DEFMETHOD("references", function(sym){
  293. if (sym instanceof AST_Symbol) sym = sym.definition();
  294. return this.enclosed.indexOf(sym) < 0 ? null : sym;
  295. });
  296. AST_Symbol.DEFMETHOD("unmangleable", function(options){
  297. return this.definition().unmangleable(options);
  298. });
  299. // property accessors are not mangleable
  300. AST_SymbolAccessor.DEFMETHOD("unmangleable", function(){
  301. return true;
  302. });
  303. // labels are always mangleable
  304. AST_Label.DEFMETHOD("unmangleable", function(){
  305. return false;
  306. });
  307. AST_Symbol.DEFMETHOD("unreferenced", function(){
  308. return this.definition().references.length == 0
  309. && !(this.scope.uses_eval || this.scope.uses_with);
  310. });
  311. AST_Symbol.DEFMETHOD("undeclared", function(){
  312. return this.definition().undeclared;
  313. });
  314. AST_LabelRef.DEFMETHOD("undeclared", function(){
  315. return false;
  316. });
  317. AST_Label.DEFMETHOD("undeclared", function(){
  318. return false;
  319. });
  320. AST_Symbol.DEFMETHOD("definition", function(){
  321. return this.thedef;
  322. });
  323. AST_Symbol.DEFMETHOD("global", function(){
  324. return this.definition().global;
  325. });
  326. AST_Var.DEFMETHOD("has_const_pragma", function() {
  327. var comments_before = this.start && this.start.comments_before;
  328. var lastComment = comments_before && comments_before[comments_before.length - 1];
  329. return lastComment && /@const\b/.test(lastComment.value);
  330. });
  331. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options){
  332. return defaults(options, {
  333. except : [],
  334. eval : false,
  335. sort : false, // Ignored. Flag retained for backwards compatibility.
  336. toplevel : false,
  337. screw_ie8 : false,
  338. keep_fnames : false
  339. });
  340. });
  341. AST_Toplevel.DEFMETHOD("mangle_names", function(options){
  342. options = this._default_mangler_options(options);
  343. // Never mangle arguments
  344. options.except.push('arguments');
  345. // We only need to mangle declaration nodes. Special logic wired
  346. // into the code generator will display the mangled name if it's
  347. // present (and for AST_SymbolRef-s it'll use the mangled name of
  348. // the AST_SymbolDeclaration that it points to).
  349. var lname = -1;
  350. var to_mangle = [];
  351. if (options.cache) {
  352. this.globals.each(function(symbol){
  353. if (options.except.indexOf(symbol.name) < 0) {
  354. to_mangle.push(symbol);
  355. }
  356. });
  357. }
  358. var tw = new TreeWalker(function(node, descend){
  359. if (node instanceof AST_LabeledStatement) {
  360. // lname is incremented when we get to the AST_Label
  361. var save_nesting = lname;
  362. descend();
  363. lname = save_nesting;
  364. return true; // don't descend again in TreeWalker
  365. }
  366. if (node instanceof AST_Scope) {
  367. var p = tw.parent(), a = [];
  368. node.variables.each(function(symbol){
  369. if (options.except.indexOf(symbol.name) < 0) {
  370. a.push(symbol);
  371. }
  372. });
  373. to_mangle.push.apply(to_mangle, a);
  374. return;
  375. }
  376. if (node instanceof AST_Label) {
  377. var name;
  378. do name = base54(++lname); while (!is_identifier(name));
  379. node.mangled_name = name;
  380. return true;
  381. }
  382. if (options.screw_ie8 && node instanceof AST_SymbolCatch) {
  383. to_mangle.push(node.definition());
  384. return;
  385. }
  386. });
  387. this.walk(tw);
  388. to_mangle.forEach(function(def){ def.mangle(options) });
  389. if (options.cache) {
  390. options.cache.cname = this.cname;
  391. }
  392. });
  393. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options){
  394. options = this._default_mangler_options(options);
  395. var tw = new TreeWalker(function(node){
  396. if (node instanceof AST_Constant)
  397. base54.consider(node.print_to_string());
  398. else if (node instanceof AST_Return)
  399. base54.consider("return");
  400. else if (node instanceof AST_Throw)
  401. base54.consider("throw");
  402. else if (node instanceof AST_Continue)
  403. base54.consider("continue");
  404. else if (node instanceof AST_Break)
  405. base54.consider("break");
  406. else if (node instanceof AST_Debugger)
  407. base54.consider("debugger");
  408. else if (node instanceof AST_Directive)
  409. base54.consider(node.value);
  410. else if (node instanceof AST_While)
  411. base54.consider("while");
  412. else if (node instanceof AST_Do)
  413. base54.consider("do while");
  414. else if (node instanceof AST_If) {
  415. base54.consider("if");
  416. if (node.alternative) base54.consider("else");
  417. }
  418. else if (node instanceof AST_Var)
  419. base54.consider("var");
  420. else if (node instanceof AST_Const)
  421. base54.consider("const");
  422. else if (node instanceof AST_Lambda)
  423. base54.consider("function");
  424. else if (node instanceof AST_For)
  425. base54.consider("for");
  426. else if (node instanceof AST_ForIn)
  427. base54.consider("for in");
  428. else if (node instanceof AST_Switch)
  429. base54.consider("switch");
  430. else if (node instanceof AST_Case)
  431. base54.consider("case");
  432. else if (node instanceof AST_Default)
  433. base54.consider("default");
  434. else if (node instanceof AST_With)
  435. base54.consider("with");
  436. else if (node instanceof AST_ObjectSetter)
  437. base54.consider("set" + node.key);
  438. else if (node instanceof AST_ObjectGetter)
  439. base54.consider("get" + node.key);
  440. else if (node instanceof AST_ObjectKeyVal)
  441. base54.consider(node.key);
  442. else if (node instanceof AST_New)
  443. base54.consider("new");
  444. else if (node instanceof AST_This)
  445. base54.consider("this");
  446. else if (node instanceof AST_Try)
  447. base54.consider("try");
  448. else if (node instanceof AST_Catch)
  449. base54.consider("catch");
  450. else if (node instanceof AST_Finally)
  451. base54.consider("finally");
  452. else if (node instanceof AST_Symbol && node.unmangleable(options))
  453. base54.consider(node.name);
  454. else if (node instanceof AST_Unary || node instanceof AST_Binary)
  455. base54.consider(node.operator);
  456. else if (node instanceof AST_Dot)
  457. base54.consider(node.property);
  458. });
  459. this.walk(tw);
  460. base54.sort();
  461. });
  462. var base54 = (function() {
  463. var string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
  464. var chars, frequency;
  465. function reset() {
  466. frequency = Object.create(null);
  467. chars = string.split("").map(function(ch){ return ch.charCodeAt(0) });
  468. chars.forEach(function(ch){ frequency[ch] = 0 });
  469. }
  470. base54.consider = function(str){
  471. for (var i = str.length; --i >= 0;) {
  472. var code = str.charCodeAt(i);
  473. if (code in frequency) ++frequency[code];
  474. }
  475. };
  476. base54.sort = function() {
  477. chars = mergeSort(chars, function(a, b){
  478. if (is_digit(a) && !is_digit(b)) return 1;
  479. if (is_digit(b) && !is_digit(a)) return -1;
  480. return frequency[b] - frequency[a];
  481. });
  482. };
  483. base54.reset = reset;
  484. reset();
  485. base54.get = function(){ return chars };
  486. base54.freq = function(){ return frequency };
  487. function base54(num) {
  488. var ret = "", base = 54;
  489. num++;
  490. do {
  491. num--;
  492. ret += String.fromCharCode(chars[num % base]);
  493. num = Math.floor(num / base);
  494. base = 64;
  495. } while (num > 0);
  496. return ret;
  497. };
  498. return base54;
  499. })();
  500. AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
  501. options = defaults(options, {
  502. undeclared : false, // this makes a lot of noise
  503. unreferenced : true,
  504. assign_to_global : true,
  505. func_arguments : true,
  506. nested_defuns : true,
  507. eval : true
  508. });
  509. var tw = new TreeWalker(function(node){
  510. if (options.undeclared
  511. && node instanceof AST_SymbolRef
  512. && node.undeclared())
  513. {
  514. // XXX: this also warns about JS standard names,
  515. // i.e. Object, Array, parseInt etc. Should add a list of
  516. // exceptions.
  517. AST_Node.warn("Undeclared symbol: {name} [{file}:{line},{col}]", {
  518. name: node.name,
  519. file: node.start.file,
  520. line: node.start.line,
  521. col: node.start.col
  522. });
  523. }
  524. if (options.assign_to_global)
  525. {
  526. var sym = null;
  527. if (node instanceof AST_Assign && node.left instanceof AST_SymbolRef)
  528. sym = node.left;
  529. else if (node instanceof AST_ForIn && node.init instanceof AST_SymbolRef)
  530. sym = node.init;
  531. if (sym
  532. && (sym.undeclared()
  533. || (sym.global() && sym.scope !== sym.definition().scope))) {
  534. AST_Node.warn("{msg}: {name} [{file}:{line},{col}]", {
  535. msg: sym.undeclared() ? "Accidental global?" : "Assignment to global",
  536. name: sym.name,
  537. file: sym.start.file,
  538. line: sym.start.line,
  539. col: sym.start.col
  540. });
  541. }
  542. }
  543. if (options.eval
  544. && node instanceof AST_SymbolRef
  545. && node.undeclared()
  546. && node.name == "eval") {
  547. AST_Node.warn("Eval is used [{file}:{line},{col}]", node.start);
  548. }
  549. if (options.unreferenced
  550. && (node instanceof AST_SymbolDeclaration || node instanceof AST_Label)
  551. && !(node instanceof AST_SymbolCatch)
  552. && node.unreferenced()) {
  553. AST_Node.warn("{type} {name} is declared but not referenced [{file}:{line},{col}]", {
  554. type: node instanceof AST_Label ? "Label" : "Symbol",
  555. name: node.name,
  556. file: node.start.file,
  557. line: node.start.line,
  558. col: node.start.col
  559. });
  560. }
  561. if (options.func_arguments
  562. && node instanceof AST_Lambda
  563. && node.uses_arguments) {
  564. AST_Node.warn("arguments used in function {name} [{file}:{line},{col}]", {
  565. name: node.name ? node.name.name : "anonymous",
  566. file: node.start.file,
  567. line: node.start.line,
  568. col: node.start.col
  569. });
  570. }
  571. if (options.nested_defuns
  572. && node instanceof AST_Defun
  573. && !(tw.parent() instanceof AST_Scope)) {
  574. AST_Node.warn("Function {name} declared in nested statement \"{type}\" [{file}:{line},{col}]", {
  575. name: node.name.name,
  576. type: tw.parent().TYPE,
  577. file: node.start.file,
  578. line: node.start.line,
  579. col: node.start.col
  580. });
  581. }
  582. });
  583. this.walk(tw);
  584. });