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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/constants.dart

Issue 119673004: Version 1.1.0-dev.5.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 dart2js; 5 part of dart2js;
6 6
7 abstract class ConstantVisitor<R> { 7 abstract class ConstantVisitor<R> {
8 R visitFunction(FunctionConstant constant); 8 R visitFunction(FunctionConstant constant);
9 R visitNull(NullConstant constant); 9 R visitNull(NullConstant constant);
10 R visitInt(IntConstant constant); 10 R visitInt(IntConstant constant);
11 R visitDouble(DoubleConstant constant); 11 R visitDouble(DoubleConstant constant);
12 R visitTrue(TrueConstant constant); 12 R visitTrue(TrueConstant constant);
13 R visitFalse(FalseConstant constant); 13 R visitFalse(FalseConstant constant);
14 R visitString(StringConstant constant); 14 R visitString(StringConstant constant);
15 R visitList(ListConstant constant); 15 R visitList(ListConstant constant);
16 R visitMap(MapConstant constant); 16 R visitMap(MapConstant constant);
17 R visitConstructed(ConstructedConstant constant); 17 R visitConstructed(ConstructedConstant constant);
18 R visitType(TypeConstant constant); 18 R visitType(TypeConstant constant);
19 R visitInterceptor(InterceptorConstant constant); 19 R visitInterceptor(InterceptorConstant constant);
20 R visitDummyReceiver(DummyReceiverConstant constant);
21 } 20 }
22 21
23 abstract class Constant { 22 abstract class Constant {
24 const Constant(); 23 const Constant();
25 24
26 bool isNull() => false; 25 bool isNull() => false;
27 bool isBool() => false; 26 bool isBool() => false;
28 bool isTrue() => false; 27 bool isTrue() => false;
29 bool isFalse() => false; 28 bool isFalse() => false;
30 bool isInt() => false; 29 bool isInt() => false;
31 bool isDouble() => false; 30 bool isDouble() => false;
32 bool isNum() => false; 31 bool isNum() => false;
33 bool isString() => false; 32 bool isString() => false;
34 bool isList() => false; 33 bool isList() => false;
35 bool isMap() => false; 34 bool isMap() => false;
36 bool isConstructedObject() => false; 35 bool isConstructedObject() => false;
37 bool isFunction() => false; 36 bool isFunction() => false;
38 /** Returns true if the constant is null, a bool, a number or a string. */ 37 /** Returns true if the constant is null, a bool, a number or a string. */
39 bool isPrimitive() => false; 38 bool isPrimitive() => false;
40 /** Returns true if the constant is a list, a map or a constructed object. */ 39 /** Returns true if the constant is a list, a map or a constructed object. */
41 bool isObject() => false; 40 bool isObject() => false;
42 bool isType() => false; 41 bool isType() => false;
43 bool isSentinel() => false; 42 bool isSentinel() => false;
44 bool isInterceptor() => false; 43 bool isInterceptor() => false;
45 bool isDummyReceiver() => false;
46 44
47 bool isNaN() => false; 45 bool isNaN() => false;
48 bool isMinusZero() => false; 46 bool isMinusZero() => false;
49 47
50 // TODO(johnniwinther): Replace with a 'type' getter. 48 // TODO(johnniwinther): Replace with a 'type' getter.
51 DartType computeType(Compiler compiler); 49 DartType computeType(Compiler compiler);
52 50
53 ti.TypeMask computeMask(Compiler compiler); 51 ti.TypeMask computeMask(Compiler compiler);
54 52
55 List<Constant> getDependencies(); 53 List<Constant> getDependencies();
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 531
534 ti.TypeMask computeMask(Compiler compiler) { 532 ti.TypeMask computeMask(Compiler compiler) {
535 return compiler.typesTask.nonNullType; 533 return compiler.typesTask.nonNullType;
536 } 534 }
537 535
538 String toString() { 536 String toString() {
539 return 'InterceptorConstant(${Error.safeToString(dispatchedType)})'; 537 return 'InterceptorConstant(${Error.safeToString(dispatchedType)})';
540 } 538 }
541 } 539 }
542 540
543 class DummyReceiverConstant extends Constant {
544 final ti.TypeMask typeMask;
545
546 DummyReceiverConstant(this.typeMask);
547
548 bool isDummyReceiver() => true;
549
550 bool operator ==(other) {
551 return other is DummyReceiverConstant
552 && typeMask == other.typeMask;
553 }
554
555 get hashCode => typeMask.hashCode;
556
557 List<Constant> getDependencies() => const <Constant>[];
558
559 accept(ConstantVisitor visitor) => visitor.visitDummyReceiver(this);
560
561 DartType computeType(Compiler compiler) => compiler.types.dynamicType;
562
563 ti.TypeMask computeMask(Compiler compiler) => typeMask;
564
565 String toString() {
566 return 'DummyReceiverConstant($typeMask)';
567 }
568 }
569
570 class ConstructedConstant extends ObjectConstant { 541 class ConstructedConstant extends ObjectConstant {
571 final List<Constant> fields; 542 final List<Constant> fields;
572 final int hashCode; 543 final int hashCode;
573 544
574 ConstructedConstant(DartType type, List<Constant> fields) 545 ConstructedConstant(DartType type, List<Constant> fields)
575 : this.fields = fields, 546 : this.fields = fields,
576 hashCode = computeHash(type, fields), 547 hashCode = computeHash(type, fields),
577 super(type) { 548 super(type) {
578 assert(type != null); 549 assert(type != null);
579 } 550 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 if (i > 0) sb.write(','); 604 if (i > 0) sb.write(',');
634 sb.write(Error.safeToString(field.name)); 605 sb.write(Error.safeToString(field.name));
635 sb.write('='); 606 sb.write('=');
636 sb.write(Error.safeToString(value)); 607 sb.write(Error.safeToString(value));
637 i++; 608 i++;
638 }); 609 });
639 sb.write('))'); 610 sb.write('))');
640 return sb.toString(); 611 return sb.toString();
641 } 612 }
642 } 613 }
OLDNEW
« no previous file with comments | « dart/runtime/vm/vm.gypi ('k') | dart/sdk/lib/_internal/compiler/implementation/ir/ir_pickler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698