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

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

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 2 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /// This class should morph into something that makes it easy to build 7 /// This class should morph into something that makes it easy to build
8 /// JavaScript representations of libraries, class-sides, and instance-sides. 8 /// JavaScript representations of libraries, class-sides, and instance-sides.
9 /// Initially, it is just a placeholder for code that is moved from 9 /// Initially, it is just a placeholder for code that is moved from
10 /// [CodeEmitterTask]. 10 /// [CodeEmitterTask].
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } else { 89 } else {
90 int index = names.indexOf(element.name); 90 int index = names.indexOf(element.name);
91 if (index != -1) { 91 if (index != -1) {
92 indexOfLastOptionalArgumentInParameters = count; 92 indexOfLastOptionalArgumentInParameters = count;
93 // The order of the named arguments is not the same as the 93 // The order of the named arguments is not the same as the
94 // one in the real method (which is in Dart source order). 94 // one in the real method (which is in Dart source order).
95 argumentsBuffer[count] = js('#', jsName); 95 argumentsBuffer[count] = js('#', jsName);
96 parametersBuffer[optionalParameterStart + index] = 96 parametersBuffer[optionalParameterStart + index] =
97 new jsAst.Parameter(jsName); 97 new jsAst.Parameter(jsName);
98 } else { 98 } else {
99 Constant value = handler.getConstantForVariable(element); 99 ConstExp constant = handler.getConstantForVariable(element);
100 if (value == null) { 100 if (constant == null) {
101 argumentsBuffer[count] = task.constantReference(new NullConstant()); 101 argumentsBuffer[count] = task.constantReference(new NullConstant());
102 } else { 102 } else {
103 Constant value = constant.value;
103 if (!value.isNull) { 104 if (!value.isNull) {
104 // If the value is the null constant, we should not pass it 105 // If the value is the null constant, we should not pass it
105 // down to the native method. 106 // down to the native method.
106 indexOfLastOptionalArgumentInParameters = count; 107 indexOfLastOptionalArgumentInParameters = count;
107 } 108 }
108 argumentsBuffer[count] = task.constantReference(value); 109 argumentsBuffer[count] = task.constantReference(value);
109 } 110 }
110 } 111 }
111 } 112 }
112 count++; 113 count++;
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 task.metadataEmitter.reifyDefaultArguments(member).map(js.number)); 510 task.metadataEmitter.reifyDefaultArguments(member).map(js.number));
510 511
511 if (canBeReflected || canBeApplied) { 512 if (canBeReflected || canBeApplied) {
512 parameters.forEachParameter((Element parameter) { 513 parameters.forEachParameter((Element parameter) {
513 expressions.add( 514 expressions.add(
514 js.number(task.metadataEmitter.reifyName(parameter.name))); 515 js.number(task.metadataEmitter.reifyName(parameter.name)));
515 if (backend.mustRetainMetadata) { 516 if (backend.mustRetainMetadata) {
516 Iterable<int> metadataIndices = 517 Iterable<int> metadataIndices =
517 parameter.metadata.map((MetadataAnnotation annotation) { 518 parameter.metadata.map((MetadataAnnotation annotation) {
518 Constant constant = 519 Constant constant =
519 backend.constants.getConstantForMetadata(annotation); 520 backend.constants.getConstantForMetadata(annotation).value;
520 backend.constants.addCompileTimeConstantForEmission(constant); 521 backend.constants.addCompileTimeConstantForEmission(constant);
521 return task.metadataEmitter.reifyMetadata(annotation); 522 return task.metadataEmitter.reifyMetadata(annotation);
522 }); 523 });
523 expressions.add( 524 expressions.add(
524 new jsAst.ArrayInitializer.from(metadataIndices.map(js.number))); 525 new jsAst.ArrayInitializer.from(metadataIndices.map(js.number)));
525 } 526 }
526 }); 527 });
527 } 528 }
528 if (canBeReflected) { 529 if (canBeReflected) {
529 jsAst.LiteralString reflectionName; 530 jsAst.LiteralString reflectionName;
(...skipping 16 matching lines...) Expand all
546 jsAst.ArrayInitializer arrayInit = 547 jsAst.ArrayInitializer arrayInit =
547 new jsAst.ArrayInitializer.from(expressions); 548 new jsAst.ArrayInitializer.from(expressions);
548 compiler.dumpInfoTask.registerElementAst(member, 549 compiler.dumpInfoTask.registerElementAst(member,
549 builder.addProperty(name, arrayInit)); 550 builder.addProperty(name, arrayInit));
550 } 551 }
551 552
552 void addMemberField(VariableElement member, ClassBuilder builder) { 553 void addMemberField(VariableElement member, ClassBuilder builder) {
553 // For now, do nothing. 554 // For now, do nothing.
554 } 555 }
555 } 556 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698