Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: test/codegen/expect/math/math.js

Issue 962083002: support the JS builtin (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/codegen/expect/convert/convert.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var math; 1 var math;
2 (function(math) { 2 (function(math) {
3 'use strict'; 3 'use strict';
4 let E = 2.718281828459045; 4 let E = 2.718281828459045;
5 let LN10 = 2.302585092994046; 5 let LN10 = 2.302585092994046;
6 let LN2 = 0.6931471805599453; 6 let LN2 = 0.6931471805599453;
7 let LOG2E = 1.4426950408889634; 7 let LOG2E = 1.4426950408889634;
8 let LOG10E = 0.4342944819032518; 8 let LOG10E = 0.4342944819032518;
9 let PI = 3.141592653589793; 9 let PI = 3.141592653589793;
10 let SQRT1_2 = 0.7071067811865476; 10 let SQRT1_2 = 0.7071067811865476;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (b.isNaN) 50 if (b.isNaN)
51 return b; 51 return b;
52 return a; 52 return a;
53 } 53 }
54 if (dart.notNull(b === 0) && dart.notNull(a.isNegative)) 54 if (dart.notNull(b === 0) && dart.notNull(a.isNegative))
55 return b; 55 return b;
56 return a; 56 return a;
57 } 57 }
58 // Function atan2: (num, num) → double 58 // Function atan2: (num, num) → double
59 function atan2(a, b) { 59 function atan2(a, b) {
60 return dart.as(_foreign_helper.JS('double', 'Math.atan2(#, #)', _js_helper.c heckNum(a), _js_helper.checkNum(b)), core.double); 60 return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b));
61 } 61 }
62 // Function pow: (num, num) → num 62 // Function pow: (num, num) → num
63 function pow(x, exponent) { 63 function pow(x, exponent) {
64 _js_helper.checkNum(x); 64 _js_helper.checkNum(x);
65 _js_helper.checkNum(exponent); 65 _js_helper.checkNum(exponent);
66 return dart.as(_foreign_helper.JS('num', 'Math.pow(#, #)', x, exponent), cor e.num); 66 return Math.pow(x, exponent);
67 } 67 }
68 // Function sin: (num) → double 68 // Function sin: (num) → double
69 function sin(x) { 69 function sin(x) {
70 return dart.as(_foreign_helper.JS('double', 'Math.sin(#)', _js_helper.checkN um(x)), core.double); 70 return Math.sin(_js_helper.checkNum(x));
71 } 71 }
72 // Function cos: (num) → double 72 // Function cos: (num) → double
73 function cos(x) { 73 function cos(x) {
74 return dart.as(_foreign_helper.JS('double', 'Math.cos(#)', _js_helper.checkN um(x)), core.double); 74 return Math.cos(_js_helper.checkNum(x));
75 } 75 }
76 // Function tan: (num) → double 76 // Function tan: (num) → double
77 function tan(x) { 77 function tan(x) {
78 return dart.as(_foreign_helper.JS('double', 'Math.tan(#)', _js_helper.checkN um(x)), core.double); 78 return Math.tan(_js_helper.checkNum(x));
79 } 79 }
80 // Function acos: (num) → double 80 // Function acos: (num) → double
81 function acos(x) { 81 function acos(x) {
82 return dart.as(_foreign_helper.JS('double', 'Math.acos(#)', _js_helper.check Num(x)), core.double); 82 return Math.acos(_js_helper.checkNum(x));
83 } 83 }
84 // Function asin: (num) → double 84 // Function asin: (num) → double
85 function asin(x) { 85 function asin(x) {
86 return dart.as(_foreign_helper.JS('double', 'Math.asin(#)', _js_helper.check Num(x)), core.double); 86 return Math.asin(_js_helper.checkNum(x));
87 } 87 }
88 // Function atan: (num) → double 88 // Function atan: (num) → double
89 function atan(x) { 89 function atan(x) {
90 return dart.as(_foreign_helper.JS('double', 'Math.atan(#)', _js_helper.check Num(x)), core.double); 90 return Math.atan(_js_helper.checkNum(x));
91 } 91 }
92 // Function sqrt: (num) → double 92 // Function sqrt: (num) → double
93 function sqrt(x) { 93 function sqrt(x) {
94 return dart.as(_foreign_helper.JS('double', 'Math.sqrt(#)', _js_helper.check Num(x)), core.double); 94 return Math.sqrt(_js_helper.checkNum(x));
95 } 95 }
96 // Function exp: (num) → double 96 // Function exp: (num) → double
97 function exp(x) { 97 function exp(x) {
98 return dart.as(_foreign_helper.JS('double', 'Math.exp(#)', _js_helper.checkN um(x)), core.double); 98 return Math.exp(_js_helper.checkNum(x));
99 } 99 }
100 // Function log: (num) → double 100 // Function log: (num) → double
101 function log(x) { 101 function log(x) {
102 return dart.as(_foreign_helper.JS('double', 'Math.log(#)', _js_helper.checkN um(x)), core.double); 102 return Math.log(_js_helper.checkNum(x));
103 } 103 }
104 let _POW2_32 = 4294967296; 104 let _POW2_32 = 4294967296;
105 class _JSRandom extends dart.Object { 105 class _JSRandom extends dart.Object {
106 _JSRandom() { 106 _JSRandom() {
107 } 107 }
108 nextInt(max) { 108 nextInt(max) {
109 if (dart.notNull(max <= 0) || dart.notNull(max > _POW2_32)) { 109 if (dart.notNull(max <= 0) || dart.notNull(max > _POW2_32)) {
110 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma x}`); 110 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma x}`);
111 } 111 }
112 return dart.as(_foreign_helper.JS("int", "(Math.random() * #) >>> 0", max) , core.int); 112 return Math.random() * max >>> 0;
113 } 113 }
114 nextDouble() { 114 nextDouble() {
115 return dart.as(_foreign_helper.JS("double", "Math.random()"), core.double) ; 115 return Math.random();
116 } 116 }
117 nextBool() { 117 nextBool() {
118 return dart.as(_foreign_helper.JS("bool", "Math.random() < 0.5"), core.boo l); 118 return Math.random() < 0.5;
119 } 119 }
120 } 120 }
121 class _Random extends dart.Object { 121 class _Random extends dart.Object {
122 _Random(seed) { 122 _Random(seed) {
123 this._lo = 0; 123 this._lo = 0;
124 this._hi = 0; 124 this._hi = 0;
125 let empty_seed = 0; 125 let empty_seed = 0;
126 if (seed < 0) { 126 if (seed < 0) {
127 empty_seed = -1; 127 empty_seed = -1;
128 } 128 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 math.exp = exp; 438 math.exp = exp;
439 math.log = log; 439 math.log = log;
440 math.Point = Point; 440 math.Point = Point;
441 math.Point$ = Point$; 441 math.Point$ = Point$;
442 math.Random = Random; 442 math.Random = Random;
443 math.Rectangle = Rectangle; 443 math.Rectangle = Rectangle;
444 math.Rectangle$ = Rectangle$; 444 math.Rectangle$ = Rectangle$;
445 math.MutableRectangle = MutableRectangle; 445 math.MutableRectangle = MutableRectangle;
446 math.MutableRectangle$ = MutableRectangle$; 446 math.MutableRectangle$ = MutableRectangle$;
447 })(math || (math = {})); 447 })(math || (math = {}));
OLDNEW
« no previous file with comments | « test/codegen/expect/convert/convert.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698