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

Side by Side Diff: dart/lib/compiler/implementation/compile_time_constants.dart

Issue 10880040: Support abstract getters without parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update language.status Created 8 years, 3 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
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/compiler.dart » ('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) 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 class Constant implements Hashable { 5 class Constant implements Hashable {
6 const Constant(); 6 const Constant();
7 7
8 bool isNull() => false; 8 bool isNull() => false;
9 bool isBool() => false; 9 bool isBool() => false;
10 bool isTrue() => false; 10 bool isTrue() => false;
(...skipping 16 matching lines...) Expand all
27 /** 27 /**
28 * Unless the constant can be emitted multiple times (as for numbers and 28 * Unless the constant can be emitted multiple times (as for numbers and
29 * strings) adds its canonical name to the buffer. 29 * strings) adds its canonical name to the buffer.
30 */ 30 */
31 abstract void _writeCanonicalizedJsCode(CodeBuffer buffer, 31 abstract void _writeCanonicalizedJsCode(CodeBuffer buffer,
32 ConstantHandler handler); 32 ConstantHandler handler);
33 abstract List<Constant> getDependencies(); 33 abstract List<Constant> getDependencies();
34 } 34 }
35 35
36 class PrimitiveConstant extends Constant { 36 class PrimitiveConstant extends Constant {
37 abstract get value(); 37 abstract get value;
38 const PrimitiveConstant(); 38 const PrimitiveConstant();
39 bool isPrimitive() => true; 39 bool isPrimitive() => true;
40 40
41 bool operator ==(var other) { 41 bool operator ==(var other) {
42 if (other is !PrimitiveConstant) return false; 42 if (other is !PrimitiveConstant) return false;
43 PrimitiveConstant otherPrimitive = other; 43 PrimitiveConstant otherPrimitive = other;
44 // We use == instead of === so that DartStrings compare correctly. 44 // We use == instead of === so that DartStrings compare correctly.
45 return value == otherPrimitive.value; 45 return value == otherPrimitive.value;
46 } 46 }
47 47
(...skipping 19 matching lines...) Expand all
67 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { 67 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) {
68 buffer.add(JsNull); 68 buffer.add(JsNull);
69 } 69 }
70 70
71 // The magic constant has no meaning. It is just a random value. 71 // The magic constant has no meaning. It is just a random value.
72 int hashCode() => 785965825; 72 int hashCode() => 785965825;
73 DartString toDartString() => const LiteralDartString("null"); 73 DartString toDartString() => const LiteralDartString("null");
74 } 74 }
75 75
76 class NumConstant extends PrimitiveConstant { 76 class NumConstant extends PrimitiveConstant {
77 abstract num get value(); 77 abstract num get value;
78 const NumConstant(); 78 const NumConstant();
79 bool isNum() => true; 79 bool isNum() => true;
80 } 80 }
81 81
82 class IntConstant extends NumConstant { 82 class IntConstant extends NumConstant {
83 final int value; 83 final int value;
84 factory IntConstant(int value) { 84 factory IntConstant(int value) {
85 switch (value) { 85 switch (value) {
86 case 0: return const IntConstant._internal(0); 86 case 0: return const IntConstant._internal(0);
87 case 1: return const IntConstant._internal(1); 87 case 1: return const IntConstant._internal(1);
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 Constant fieldValue = fieldValues[field]; 1170 Constant fieldValue = fieldValues[field];
1171 if (fieldValue === null) { 1171 if (fieldValue === null) {
1172 // Use the default value. 1172 // Use the default value.
1173 fieldValue = compiler.compileVariable(field); 1173 fieldValue = compiler.compileVariable(field);
1174 } 1174 }
1175 jsNewArguments.add(fieldValue); 1175 jsNewArguments.add(fieldValue);
1176 }); 1176 });
1177 return jsNewArguments; 1177 return jsNewArguments;
1178 } 1178 }
1179 } 1179 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698