constTest.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. function AsmModule(stdlib,foreign,buffer) {
  6. "use asm";
  7. var fround = stdlib.Math.fround;
  8. var a = 2.0;
  9. const b = 1;
  10. var c = fround(1.0);
  11. const d = fround(1);
  12. function f1(){
  13. var e = d;
  14. var f = fround(4);
  15. e = fround(e+c);
  16. return fround(e);
  17. }
  18. function f2(){
  19. return d;
  20. }
  21. return {
  22. f1 : f1,
  23. f2 : f2
  24. };
  25. }
  26. var stdlib = {Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,Infinity:Infinity, NaN:NaN}
  27. var env = {}
  28. var buffer = new ArrayBuffer(1<<20);
  29. var asmModule = AsmModule(stdlib,env,buffer);
  30. print(asmModule.f1());
  31. print(asmModule.f2());