caller_escape.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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(re)
  13. {
  14. if (re)
  15. {
  16. nested2();
  17. }
  18. return param + param2;
  19. }
  20. recurse++;
  21. if (recurse < 10)
  22. {
  23. return nested1(param + param2 + recurse);
  24. }
  25. if (box)
  26. {
  27. escape();
  28. return nested2() + blah();
  29. }
  30. return nested2();
  31. }
  32. WScript.Echo(nested1());
  33. function blah() { return "blah"; }
  34. }
  35. function escape()
  36. {
  37. glo = escape.caller;
  38. }
  39. test("test1");
  40. test("test2"); // JIT
  41. box = true;
  42. test("test3" )
  43. WScript.Echo(glo());