tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

fold-constant-index-access.js (1055B)


      1 // Constant folding optimizes the element access with string that contains
      2 // 32-bit unsignned integer.
      3 // The result shouldn't be visible to the script, and the optimization shouldn't
      4 // change the behavior.
      5 
      6 // Asserts that the property name and the value are same.
      7 var validator = new Proxy({}, {
      8  set(that, prop, value) {
      9    assertEq(prop, value);
     10  }
     11 });
     12 
     13 // Optimizable cases.
     14 validator["0"] = "0";
     15 validator["1"] = "1";
     16 validator["10"] = "10";
     17 validator["123"] = "123";
     18 
     19 // Not optimizable cases.
     20 
     21 // More than UINT32_MAX.
     22 validator["4294967296"] = "4294967296";
     23 validator["10000000000000"] = "10000000000000";
     24 
     25 // Leading 0.
     26 validator["01"] = "01";
     27 validator["0000001"] = "0000001";
     28 
     29 // Sign.
     30 validator["+1"] = "+1";
     31 validator["-1"] = "-1";
     32 
     33 // Non-decimal
     34 validator["0b1"] = "0b1";
     35 validator["0o1"] = "0o1";
     36 validator["0x1"] = "0x1";
     37 
     38 // Non-integer.
     39 validator["1.1"] = "1.1";
     40 validator["1."] = "1.";
     41 validator[".1"] = ".1";
     42 validator["0.1"] = "0.1";
     43 
     44 // Extra character.
     45 validator["1a"] = "1a";
     46 validator["1 "] = "1 ";
     47 validator[" 1"] = " 1";