2
0

negindex.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. //===============================================
  6. // No fast path - because its a negative index
  7. //===============================================
  8. var a = new Array();
  9. a[3221225472] = 3; // Index 0xC0000000
  10. // non type-specialized case
  11. index = -1073741824; // Index 0xC0000000, but signed
  12. WScript.Echo(a[index]);
  13. // int const case
  14. WScript.Echo(a[-1073741824]);
  15. // Type Specialized case
  16. var G = 1;
  17. function foo()
  18. {
  19. var i = 0;
  20. if (G) i = -1073741824;
  21. WScript.Echo(a[i]);
  22. }
  23. foo();
  24. //===============================================
  25. // Fast path
  26. //===============================================
  27. var b = new Array();
  28. a[3] = 3;
  29. WScript.Echo(a[3]);
  30. function foo2()
  31. {
  32. var i = 0;
  33. if (G) i = 3;
  34. WScript.Echo(a[i]);
  35. }
  36. foo2();