box.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. var glo;
  6. var box = false;
  7. function test(param)
  8. {
  9. var recurse = 0;
  10. function nested1(param2)
  11. {
  12. function nested2()
  13. {
  14. return param + param2;
  15. }
  16. recurse++;
  17. if (recurse < 10)
  18. {
  19. return nested1(param + param2 + recurse);
  20. }
  21. if (box)
  22. {
  23. escape();
  24. return glo();
  25. }
  26. return nested2();
  27. }
  28. WScript.Echo(nested1());
  29. function blah() { return "blah"; }
  30. function escape() { glo = blah; }
  31. }
  32. test("test1");
  33. test("test2"); // JIT
  34. box = true;
  35. test("test3" )
  36. WScript.Echo(glo());