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

Side by Side Diff: pkg/compiler/lib/src/js_backend/patch_resolver.dart

Issue 2675103003: Refactor BackendHelpers to be reusageable with KernelWorldBuilder (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library dart2js.js_backend.patch_resolver; 5 library dart2js.js_backend.patch_resolver;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Resolution; 8 import '../common/resolution.dart' show Resolution;
9 import '../common/tasks.dart' show CompilerTask; 9 import '../common/tasks.dart' show CompilerTask;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 24 matching lines...) Expand all
35 element = patch; 35 element = patch;
36 } else if (!compiler.backend.isJsInterop(element)) { 36 } else if (!compiler.backend.isJsInterop(element)) {
37 reporter.reportErrorMessage( 37 reporter.reportErrorMessage(
38 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); 38 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION);
39 } 39 }
40 return element; 40 return element;
41 } 41 }
42 42
43 void checkMatchingPatchParameters(FunctionElement origin, 43 void checkMatchingPatchParameters(FunctionElement origin,
44 List<Element> originParameters, List<Element> patchParameters) { 44 List<Element> originParameters, List<Element> patchParameters) {
45 bool isUnnamedListConstructor = origin is ConstructorElement &&
46 compiler.commonElements.isUnnamedListConstructor(origin);
47
45 assert(originParameters.length == patchParameters.length); 48 assert(originParameters.length == patchParameters.length);
46 for (int index = 0; index < originParameters.length; index++) { 49 for (int index = 0; index < originParameters.length; index++) {
47 ParameterElementX originParameter = originParameters[index]; 50 ParameterElementX originParameter = originParameters[index];
48 ParameterElementX patchParameter = patchParameters[index]; 51 ParameterElementX patchParameter = patchParameters[index];
49 // TODO(johnniwinther): Remove the conditional patching when we never 52 // TODO(johnniwinther): Remove the conditional patching when we never
50 // resolve the same method twice. 53 // resolve the same method twice.
51 if (!originParameter.isPatched) { 54 if (!originParameter.isPatched) {
52 originParameter.applyPatch(patchParameter); 55 originParameter.applyPatch(patchParameter);
53 } else { 56 } else {
54 assert(invariant(origin, originParameter.patch == patchParameter, 57 assert(invariant(origin, originParameter.patch == patchParameter,
(...skipping 24 matching lines...) Expand all
79 // elsewhere. 82 // elsewhere.
80 83
81 // The node contains the type, so there is a potential overlap. 84 // The node contains the type, so there is a potential overlap.
82 // Therefore we only check the text if the types are identical. 85 // Therefore we only check the text if the types are identical.
83 String originParameterText = originParameter.node.toString(); 86 String originParameterText = originParameter.node.toString();
84 String patchParameterText = patchParameter.node.toString(); 87 String patchParameterText = patchParameter.node.toString();
85 if (originParameterText != patchParameterText 88 if (originParameterText != patchParameterText
86 // We special case the list constructor because of the 89 // We special case the list constructor because of the
87 // optional parameter. 90 // optional parameter.
88 && 91 &&
89 origin != compiler.commonElements.unnamedListConstructor) { 92 !isUnnamedListConstructor) {
90 reporter.reportError( 93 reporter.reportError(
91 reporter.createMessage( 94 reporter.createMessage(
92 originParameter, MessageKind.PATCH_PARAMETER_MISMATCH, { 95 originParameter, MessageKind.PATCH_PARAMETER_MISMATCH, {
93 'methodName': origin.name, 96 'methodName': origin.name,
94 'originParameter': originParameterText, 97 'originParameter': originParameterText,
95 'patchParameter': patchParameterText 98 'patchParameter': patchParameterText
96 }), 99 }),
97 <DiagnosticMessage>[ 100 <DiagnosticMessage>[
98 reporter.createMessage( 101 reporter.createMessage(
99 patchParameter, 102 patchParameter,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 'originParameterCount': originSignature.optionalParameterCount, 176 'originParameterCount': originSignature.optionalParameterCount,
174 'patchParameterCount': patchSignature.optionalParameterCount 177 'patchParameterCount': patchSignature.optionalParameterCount
175 }); 178 });
176 }); 179 });
177 } else { 180 } else {
178 checkMatchingPatchParameters(origin, originSignature.optionalParameters, 181 checkMatchingPatchParameters(origin, originSignature.optionalParameters,
179 patchSignature.optionalParameters); 182 patchSignature.optionalParameters);
180 } 183 }
181 } 184 }
182 } 185 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | pkg/compiler/lib/src/js_backend/runtime_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698