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

Side by Side Diff: frog/value.dart

Issue 8590017: Fix "is Object" to always be true in Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: take2 after syncing Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « frog/type.dart ('k') | tests/co19/co19-frog.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Represents a meta-value for code generation. 6 * Represents a meta-value for code generation.
7 */ 7 */
8 class Value { 8 class Value {
9 /** The [Type] of the [Value]. */ 9 /** The [Type] of the [Value]. */
10 Type type; 10 Type type;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 * 384 *
385 * - If a primitive type, then uses the JavaScript typeof. 385 * - If a primitive type, then uses the JavaScript typeof.
386 * - If it's a non-generic class, use instanceof. 386 * - If it's a non-generic class, use instanceof.
387 * - Otherwise add a fake member to test for. This value is generated 387 * - Otherwise add a fake member to test for. This value is generated
388 * as a function so that it can be called for a runtime failure. 388 * as a function so that it can be called for a runtime failure.
389 */ 389 */
390 Value instanceOf(MethodGenerator context, Type toType, SourceSpan span, 390 Value instanceOf(MethodGenerator context, Type toType, SourceSpan span,
391 [bool isTrue=true, bool forceCheck=false]) { 391 [bool isTrue=true, bool forceCheck=false]) {
392 // TODO(jimhug): Optimize away tests that will always pass unless 392 // TODO(jimhug): Optimize away tests that will always pass unless
393 // forceCheck is true. 393 // forceCheck is true.
394
394 if (toType.isVar) { 395 if (toType.isVar) {
395 world.error('can not resolve type', span); 396 world.error('can not resolve type', span);
396 return new EvaluatedValue(world.nonNullBool, true, 'true', null);
397 }
398
399 if (toType is ParameterType) {
400 return new EvaluatedValue(world.nonNullBool, true, 'true', null);
401 } 397 }
402 398
403 String testCode = null; 399 String testCode = null;
400 if (toType.isVar || toType.isObject || toType is ParameterType) {
401 // Note: everything is an Object, including null.
402 if (needsTemp) {
403 return new Value(world.nonNullBool, '($code, true)', span);
Siggi Cherem (dart-lang) 2011/11/17 16:55:57 can you explain to me a bit more ($code, true)? is
Jennifer Messerly 2011/11/17 18:18:51 Yes, exactly.
404 } else {
405 return new EvaluatedValue(world.nonNullBool, true, 'true', null);
406 }
407 }
408
404 if (toType.library.isCore) { 409 if (toType.library.isCore) {
405 var typeofName = toType.typeofName; 410 var typeofName = toType.typeofName;
406 if (typeofName != null) { 411 if (typeofName != null) {
407 testCode = "(typeof($code) ${isTrue ? '==' : '!='} '$typeofName')"; 412 testCode = "(typeof($code) ${isTrue ? '==' : '!='} '$typeofName')";
408 } 413 }
409 } 414 }
410 if (toType.isClass && toType is !ConcreteType) { 415 if (toType.isClass && toType is !ConcreteType) {
411 toType.markUsed(); 416 toType.markUsed();
412 testCode = '($code instanceof ${toType.jsname})'; 417 testCode = '($code instanceof ${toType.jsname})';
413 if (!isTrue) { 418 if (!isTrue) {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 699
695 // Then look for members in my library. 700 // Then look for members in my library.
696 member = home.library.lookup(name, span); 701 member = home.library.lookup(name, span);
697 if (member != null) { 702 if (member != null) {
698 return member; 703 return member;
699 } 704 }
700 705
701 return null; 706 return null;
702 } 707 }
703 } 708 }
OLDNEW
« no previous file with comments | « frog/type.dart ('k') | tests/co19/co19-frog.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698