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

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

Issue 226953003: Revert "Compute frontend/backend specific constants." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 25 matching lines...) Expand all
36 assert(selector.namedArgumentCount == 0); 36 assert(selector.namedArgumentCount == 0);
37 return; 37 return;
38 } 38 }
39 if (parameters.optionalParametersAreNamed 39 if (parameters.optionalParametersAreNamed
40 && selector.namedArgumentCount == parameters.optionalParameterCount) { 40 && selector.namedArgumentCount == parameters.optionalParameterCount) {
41 // If the selector has the same number of named arguments as the element, 41 // If the selector has the same number of named arguments as the element,
42 // we don't need to add a stub. The call site will hit the method 42 // we don't need to add a stub. The call site will hit the method
43 // directly. 43 // directly.
44 return; 44 return;
45 } 45 }
46 JavaScriptConstantCompiler handler = backend.constants; 46 ConstantHandler handler = compiler.constantHandler;
47 List<String> names = selector.getOrderedNamedArguments(); 47 List<String> names = selector.getOrderedNamedArguments();
48 48
49 String invocationName = namer.invocationName(selector); 49 String invocationName = namer.invocationName(selector);
50 if (alreadyGenerated.contains(invocationName)) return; 50 if (alreadyGenerated.contains(invocationName)) return;
51 alreadyGenerated.add(invocationName); 51 alreadyGenerated.add(invocationName);
52 52
53 bool isInterceptedMethod = backend.isInterceptedMethod(member); 53 bool isInterceptedMethod = backend.isInterceptedMethod(member);
54 54
55 // If the method is intercepted, we need to also pass the actual receiver. 55 // If the method is intercepted, we need to also pass the actual receiver.
56 int extraArgumentCount = isInterceptedMethod ? 1 : 0; 56 int extraArgumentCount = isInterceptedMethod ? 1 : 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } else { 92 } else {
93 int index = names.indexOf(element.name); 93 int index = names.indexOf(element.name);
94 if (index != -1) { 94 if (index != -1) {
95 indexOfLastOptionalArgumentInParameters = count; 95 indexOfLastOptionalArgumentInParameters = count;
96 // The order of the named arguments is not the same as the 96 // The order of the named arguments is not the same as the
97 // one in the real method (which is in Dart source order). 97 // one in the real method (which is in Dart source order).
98 argumentsBuffer[count] = js(jsName); 98 argumentsBuffer[count] = js(jsName);
99 parametersBuffer[optionalParameterStart + index] = 99 parametersBuffer[optionalParameterStart + index] =
100 new jsAst.Parameter(jsName); 100 new jsAst.Parameter(jsName);
101 } else { 101 } else {
102 Constant value = handler.getConstantForVariable(element); 102 Constant value = handler.initialVariableValues[element];
103 if (value == null) { 103 if (value == null) {
104 argumentsBuffer[count] = task.constantReference(new NullConstant()); 104 argumentsBuffer[count] = task.constantReference(new NullConstant());
105 } else { 105 } else {
106 if (!value.isNull) { 106 if (!value.isNull) {
107 // If the value is the null constant, we should not pass it 107 // If the value is the null constant, we should not pass it
108 // down to the native method. 108 // down to the native method.
109 indexOfLastOptionalArgumentInParameters = count; 109 indexOfLastOptionalArgumentInParameters = count;
110 } 110 }
111 argumentsBuffer[count] = task.constantReference(value); 111 argumentsBuffer[count] = task.constantReference(value);
112 } 112 }
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 ..add(optionalParameterCount) 498 ..add(optionalParameterCount)
499 ..add(memberTypeExpression) 499 ..add(memberTypeExpression)
500 ..addAll(task.metadataEmitter.reifyDefaultArguments(member)); 500 ..addAll(task.metadataEmitter.reifyDefaultArguments(member));
501 501
502 if (canBeReflected || canBeApplied) { 502 if (canBeReflected || canBeApplied) {
503 parameters.forEachParameter((Element parameter) { 503 parameters.forEachParameter((Element parameter) {
504 expressions.add(task.metadataEmitter.reifyName(parameter.name)); 504 expressions.add(task.metadataEmitter.reifyName(parameter.name));
505 if (backend.mustRetainMetadata) { 505 if (backend.mustRetainMetadata) {
506 List<MetadataAnnotation> annotations = parameter.metadata.toList(); 506 List<MetadataAnnotation> annotations = parameter.metadata.toList();
507 Iterable<int> metadataIndices = 507 Iterable<int> metadataIndices =
508 annotations.map((MetadataAnnotation annotation) { 508 annotations.map((MetadataAnnotation a) {
509 Constant constant = 509 compiler.constantHandler.addCompileTimeConstantForEmission(a.value);
510 backend.constants.getConstantForMetadata(annotation); 510 return task.metadataEmitter.reifyMetadata(a);
511 backend.constants.addCompileTimeConstantForEmission(constant);
512 return task.metadataEmitter.reifyMetadata(annotation);
513 }); 511 });
514 expressions.add(metadataIndices.isNotEmpty ? metadataIndices.toList() 512 expressions.add(metadataIndices.isNotEmpty ? metadataIndices.toList()
515 : js('[]')); 513 : js('[]'));
516 } 514 }
517 }); 515 });
518 } 516 }
519 if (canBeReflected) { 517 if (canBeReflected) {
520 jsAst.LiteralString reflectionName; 518 jsAst.LiteralString reflectionName;
521 if (member.isConstructor()) { 519 if (member.isConstructor()) {
522 String reflectionNameString = task.getReflectionName(member, name); 520 String reflectionNameString = task.getReflectionName(member, name);
(...skipping 10 matching lines...) Expand all
533 expressions.add(js.string(member.name)); 531 expressions.add(js.string(member.name));
534 } 532 }
535 533
536 builder.addProperty(name, js.toExpression(expressions)); 534 builder.addProperty(name, js.toExpression(expressions));
537 } 535 }
538 536
539 void addMemberField(VariableElement member, ClassBuilder builder) { 537 void addMemberField(VariableElement member, ClassBuilder builder) {
540 // For now, do nothing. 538 // For now, do nothing.
541 } 539 }
542 } 540 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698