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

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

Issue 10911062: Codegen support for the argument definition test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 | « lib/compiler/implementation/closure.dart ('k') | lib/compiler/implementation/enqueue.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;
11 bool isFalse() => false; 11 bool isFalse() => false;
12 bool isInt() => false; 12 bool isInt() => false;
13 bool isDouble() => false; 13 bool isDouble() => false;
14 bool isNum() => false; 14 bool isNum() => false;
15 bool isString() => false; 15 bool isString() => false;
16 bool isList() => false; 16 bool isList() => false;
17 bool isMap() => false; 17 bool isMap() => false;
18 bool isConstructedObject() => false; 18 bool isConstructedObject() => false;
19 bool isFunction() => false; 19 bool isFunction() => false;
20 /** Returns true if the constant is null, a bool, a number or a string. */ 20 /** Returns true if the constant is null, a bool, a number or a string. */
21 bool isPrimitive() => false; 21 bool isPrimitive() => false;
22 /** Returns true if the constant is a list, a map or a constructed object. */ 22 /** Returns true if the constant is a list, a map or a constructed object. */
23 bool isObject() => false; 23 bool isObject() => false;
24 bool isSentinel() => false;
24 25
25 bool isNaN() => false; 26 bool isNaN() => false;
26 27
27 abstract void _writeJsCode(CodeBuffer buffer, ConstantHandler handler); 28 abstract void _writeJsCode(CodeBuffer buffer, ConstantHandler handler);
28 /** 29 /**
29 * Unless the constant can be emitted multiple times (as for numbers and 30 * Unless the constant can be emitted multiple times (as for numbers and
30 * strings) adds its canonical name to the buffer. 31 * strings) adds its canonical name to the buffer.
31 */ 32 */
32 abstract void _writeCanonicalizedJsCode(CodeBuffer buffer, 33 abstract void _writeCanonicalizedJsCode(CodeBuffer buffer,
33 ConstantHandler handler); 34 ConstantHandler handler);
34 abstract List<Constant> getDependencies(); 35 abstract List<Constant> getDependencies();
35 } 36 }
36 37
38 class SentinelConstant extends Constant {
39 const SentinelConstant();
40 static final SENTINEL = const SentinelConstant();
41
42 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) {
43 handler.compiler.internalError(
44 "The parameter sentinel constant does not need specific JS code");
45 }
46
47 void _writeCanonicalizedJsCode(CodeBuffer buffer, ConstantHandler handler) {
48 buffer.add(handler.compiler.namer.CURRENT_ISOLATE);
49 }
50
51 List<Constant> getDependencies() => const <Constant>[];
52
53 // Just use a randome value.
54 int hashCode() => 9264297841582447;
55
56 bool isSentinel() => true;
57 }
58
37 class FunctionConstant extends Constant { 59 class FunctionConstant extends Constant {
38 Element element; 60 Element element;
39 61
40 FunctionConstant(this.element); 62 FunctionConstant(this.element);
41 63
42 bool isFunction() => true; 64 bool isFunction() => true;
43 65
44 bool operator ==(var other) { 66 bool operator ==(var other) {
45 if (other is !FunctionConstant) return false; 67 if (other is !FunctionConstant) return false;
46 return other.element === element; 68 return other.element === element;
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 Constant fieldValue = fieldValues[field]; 1232 Constant fieldValue = fieldValues[field];
1211 if (fieldValue === null) { 1233 if (fieldValue === null) {
1212 // Use the default value. 1234 // Use the default value.
1213 fieldValue = compiler.compileVariable(field); 1235 fieldValue = compiler.compileVariable(field);
1214 } 1236 }
1215 jsNewArguments.add(fieldValue); 1237 jsNewArguments.add(fieldValue);
1216 }); 1238 });
1217 return jsNewArguments; 1239 return jsNewArguments;
1218 } 1240 }
1219 } 1241 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/closure.dart ('k') | lib/compiler/implementation/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698