| OLD | NEW |
| 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 library js_backend.backend; | 5 library js_backend.backend; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart' | 8 import '../common/backend_api.dart' |
| 9 show ForeignResolver, NativeRegistry, ImpactTransformer; | 9 show ForeignResolver, NativeRegistry, ImpactTransformer; |
| 10 import '../common/codegen.dart' show CodegenWorkItem; | 10 import '../common/codegen.dart' show CodegenWorkItem; |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 String getGeneratedCode(Element element) { | 935 String getGeneratedCode(Element element) { |
| 936 assert(invariant(element, element.isDeclaration)); | 936 assert(invariant(element, element.isDeclaration)); |
| 937 return jsAst.prettyPrint(generatedCode[element], compiler.options); | 937 return jsAst.prettyPrint(generatedCode[element], compiler.options); |
| 938 } | 938 } |
| 939 | 939 |
| 940 /// Generates the output and returns the total size of the generated code. | 940 /// Generates the output and returns the total size of the generated code. |
| 941 int assembleProgram(ClosedWorld closedWorld) { | 941 int assembleProgram(ClosedWorld closedWorld) { |
| 942 int programSize = emitter.assembleProgram(namer, closedWorld); | 942 int programSize = emitter.assembleProgram(namer, closedWorld); |
| 943 noSuchMethodRegistry.emitDiagnostic(reporter); | 943 noSuchMethodRegistry.emitDiagnostic(reporter); |
| 944 int totalMethodCount = generatedCode.length; | 944 int totalMethodCount = generatedCode.length; |
| 945 if (totalMethodCount != mirrorsCodegenAnalysis.preMirrorsMethodCount) { | 945 // TODO(johnniwinther): Support `preMirrorsMethodCount` for entities. |
| 946 if (mirrorsCodegenAnalysis.preMirrorsMethodCount != null && |
| 947 totalMethodCount != mirrorsCodegenAnalysis.preMirrorsMethodCount) { |
| 946 int mirrorCount = | 948 int mirrorCount = |
| 947 totalMethodCount - mirrorsCodegenAnalysis.preMirrorsMethodCount; | 949 totalMethodCount - mirrorsCodegenAnalysis.preMirrorsMethodCount; |
| 948 double percentage = (mirrorCount / totalMethodCount) * 100; | 950 double percentage = (mirrorCount / totalMethodCount) * 100; |
| 949 DiagnosticMessage hint = | 951 DiagnosticMessage hint = |
| 950 reporter.createMessage(compiler.mainApp, MessageKind.MIRROR_BLOAT, { | 952 reporter.createMessage(compiler.mainApp, MessageKind.MIRROR_BLOAT, { |
| 951 'count': mirrorCount, | 953 'count': mirrorCount, |
| 952 'total': totalMethodCount, | 954 'total': totalMethodCount, |
| 953 'percentage': percentage.round() | 955 'percentage': percentage.round() |
| 954 }); | 956 }); |
| 955 | 957 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 MethodElement helperForMainArity() => commonElements.mainHasTooManyParameters; | 1182 MethodElement helperForMainArity() => commonElements.mainHasTooManyParameters; |
| 1181 | 1183 |
| 1182 /// Enable deferred loading. Returns `true` if the backend supports deferred | 1184 /// Enable deferred loading. Returns `true` if the backend supports deferred |
| 1183 /// loading. | 1185 /// loading. |
| 1184 bool enableDeferredLoadingIfSupported(Spannable node) => true; | 1186 bool enableDeferredLoadingIfSupported(Spannable node) => true; |
| 1185 | 1187 |
| 1186 /// Enable compilation of code with compile time errors. Returns `true` if | 1188 /// Enable compilation of code with compile time errors. Returns `true` if |
| 1187 /// supported by the backend. | 1189 /// supported by the backend. |
| 1188 bool enableCodegenWithErrorsIfSupported(Spannable node) => true; | 1190 bool enableCodegenWithErrorsIfSupported(Spannable node) => true; |
| 1189 | 1191 |
| 1190 jsAst.Expression rewriteAsync( | 1192 jsAst.Expression rewriteAsync(MethodElement element, jsAst.Expression code) { |
| 1191 FunctionElement element, jsAst.Expression code) { | |
| 1192 AsyncRewriterBase rewriter = null; | 1193 AsyncRewriterBase rewriter = null; |
| 1193 jsAst.Name name = namer.methodPropertyName(element); | 1194 jsAst.Name name = namer.methodPropertyName(element); |
| 1194 switch (element.asyncMarker) { | 1195 switch (element.asyncMarker) { |
| 1195 case AsyncMarker.ASYNC: | 1196 case AsyncMarker.ASYNC: |
| 1196 rewriter = new AsyncRewriter(reporter, element, | 1197 rewriter = new AsyncRewriter(reporter, element, |
| 1197 asyncStart: | 1198 asyncStart: |
| 1198 emitter.staticFunctionAccess(commonElements.asyncHelperStart), | 1199 emitter.staticFunctionAccess(commonElements.asyncHelperStart), |
| 1199 asyncAwait: | 1200 asyncAwait: |
| 1200 emitter.staticFunctionAccess(commonElements.asyncHelperAwait), | 1201 emitter.staticFunctionAccess(commonElements.asyncHelperAwait), |
| 1201 asyncReturn: | 1202 asyncReturn: |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 | 1366 |
| 1366 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { | 1367 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { |
| 1367 return !selector.isGetter; | 1368 return !selector.isGetter; |
| 1368 } | 1369 } |
| 1369 | 1370 |
| 1370 /// Returns `true` if [member] is called from a subclass via `super`. | 1371 /// Returns `true` if [member] is called from a subclass via `super`. |
| 1371 bool isAliasedSuperMember(MemberEntity member) { | 1372 bool isAliasedSuperMember(MemberEntity member) { |
| 1372 return _aliasedSuperMembers.contains(member); | 1373 return _aliasedSuperMembers.contains(member); |
| 1373 } | 1374 } |
| 1374 } | 1375 } |
| OLD | NEW |