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

Side by Side Diff: tool/input_sdk/private/js_number.dart

Issue 1173903003: fixes #216, JSNumber members (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart._interceptors; 5 part of dart._interceptors;
6 6
7 /** 7 /**
8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler 8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler
9 * recognizes this class as an interceptor, and changes references to 9 * recognizes this class as an interceptor, and changes references to
10 * [:this:] to actually use the receiver of the method, which is 10 * [:this:] to actually use the receiver of the method, which is
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 336
337 /** 337 /**
338 * The interceptor class for [int]s. 338 * The interceptor class for [int]s.
339 * 339 *
340 * This class implements double since in JavaScript all numbers are doubles, so 340 * This class implements double since in JavaScript all numbers are doubles, so
341 * while we want to treat `2.0` as an integer for some operations, its 341 * while we want to treat `2.0` as an integer for some operations, its
342 * interceptor should answer `true` to `is double`. 342 * interceptor should answer `true` to `is double`.
343 */ 343 */
344 // TODO(jmesserly): for dev_compiler all numbers will get `int` members at 344 // TODO(jmesserly): for dev_compiler all numbers will get `int` members at
345 // runtime for dynamic dispatch. We can fix by checking it at dispatch time. 345 // runtime for dynamic dispatch. We can fix by checking it at dispatch time.
346 // TODO(jmesserly): merge with JSNumber? That would simplify generated code,
347 // and dart_runtime's extension mechanism.
346 @JsPeerInterface(name: 'Number') 348 @JsPeerInterface(name: 'Number')
347 class JSInt extends JSNumber implements int, double { 349 class JSInt extends JSNumber implements int, double {
348 const JSInt(); 350 const JSInt();
349 351
350 bool get isEven => (this & 1) == 0; 352 bool get isEven => (this & 1) == 0;
351 353
352 bool get isOdd => (this & 1) == 1; 354 bool get isOdd => (this & 1) == 1;
353 355
354 int toUnsigned(int width) { 356 int toUnsigned(int width) {
355 return this & ((1 << width) - 1); 357 return this & ((1 << width) - 1);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 418 }
417 419
418 class JSDouble extends JSNumber implements double { 420 class JSDouble extends JSNumber implements double {
419 const JSDouble(); 421 const JSDouble();
420 Type get runtimeType => double; 422 Type get runtimeType => double;
421 } 423 }
422 424
423 class JSPositiveInt extends JSInt {} 425 class JSPositiveInt extends JSInt {}
424 class JSUInt32 extends JSPositiveInt {} 426 class JSUInt32 extends JSPositiveInt {}
425 class JSUInt31 extends JSUInt32 {} 427 class JSUInt31 extends JSUInt32 {}
OLDNEW
« lib/runtime/dart/_interceptors.js ('K') | « lib/src/codegen/js_codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698