Chromium Code Reviews| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1262 if (member.isAbstract(compiler)) return; | 1262 if (member.isAbstract(compiler)) return; |
| 1263 jsAst.Expression code = backend.generatedCode[member]; | 1263 jsAst.Expression code = backend.generatedCode[member]; |
| 1264 if (code == null) return; | 1264 if (code == null) return; |
| 1265 String name = namer.getName(member); | 1265 String name = namer.getName(member); |
| 1266 if (backend.isInterceptedMethod(member)) { | 1266 if (backend.isInterceptedMethod(member)) { |
| 1267 interceptorInvocationNames.add(name); | 1267 interceptorInvocationNames.add(name); |
| 1268 } | 1268 } |
| 1269 code = extendWithMetadata(member, code); | 1269 code = extendWithMetadata(member, code); |
| 1270 builder.addProperty(name, code); | 1270 builder.addProperty(name, code); |
| 1271 String reflectionName = getReflectionName(member, name); | 1271 String reflectionName = getReflectionName(member, name); |
| 1272 if (reflectionName != null) { | 1272 if (reflectionName != null && backend.isAccessibleByReflection(member)) { |
|
ahe
2013/08/26 20:41:15
I thought we determined that not having a reflecti
| |
| 1273 builder.addProperty('+$reflectionName', js('0')); | 1273 builder.addProperty('+$reflectionName', js('0')); |
| 1274 } | 1274 } |
| 1275 code = backend.generatedBailoutCode[member]; | 1275 code = backend.generatedBailoutCode[member]; |
| 1276 if (code != null) { | 1276 if (code != null) { |
| 1277 builder.addProperty(namer.getBailoutName(member), code); | 1277 builder.addProperty(namer.getBailoutName(member), code); |
| 1278 } | 1278 } |
| 1279 FunctionElement function = member; | 1279 FunctionElement function = member; |
| 1280 FunctionSignature parameters = function.computeSignature(compiler); | 1280 FunctionSignature parameters = function.computeSignature(compiler); |
| 1281 if (!parameters.optionalParameters.isEmpty) { | 1281 if (!parameters.optionalParameters.isEmpty) { |
| 1282 addParameterStubs(member, builder.addProperty); | 1282 addParameterStubs(member, builder.addProperty); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1975 if (hasStatics) { | 1975 if (hasStatics) { |
| 1976 builder.addProperty('static', new jsAst.Blob(statics)); | 1976 builder.addProperty('static', new jsAst.Blob(statics)); |
| 1977 } | 1977 } |
| 1978 | 1978 |
| 1979 // TODO(ahe): This method (generateClass) should return a jsAst.Expression. | 1979 // TODO(ahe): This method (generateClass) should return a jsAst.Expression. |
| 1980 if (!buffer.isEmpty) { | 1980 if (!buffer.isEmpty) { |
| 1981 buffer.write(',$n$n'); | 1981 buffer.write(',$n$n'); |
| 1982 } | 1982 } |
| 1983 buffer.write('$className:$_'); | 1983 buffer.write('$className:$_'); |
| 1984 buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler)); | 1984 buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler)); |
| 1985 if (backend.shouldRetainName(classElement.name)) { | 1985 if (backend.shouldRetainName(classElement.name) && |
| 1986 backend.isAccessibleByReflection(classElement)) { | |
| 1986 String reflectionName = getReflectionName(classElement, className); | 1987 String reflectionName = getReflectionName(classElement, className); |
| 1987 List<int> interfaces = <int>[]; | 1988 List<int> interfaces = <int>[]; |
| 1988 for (DartType interface in classElement.interfaces) { | 1989 for (DartType interface in classElement.interfaces) { |
| 1989 interfaces.add(reifyType(interface)); | 1990 interfaces.add(reifyType(interface)); |
| 1990 } | 1991 } |
| 1991 buffer.write(',$n$n"+$reflectionName": $interfaces'); | 1992 buffer.write(',$n$n"+$reflectionName": $interfaces'); |
| 1992 } | 1993 } |
| 1993 } | 1994 } |
| 1994 | 1995 |
| 1995 bool get getterAndSetterCanBeImplementedByFieldSpec => true; | 1996 bool get getterAndSetterCanBeImplementedByFieldSpec => true; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2279 .where(isStaticFunction) | 2280 .where(isStaticFunction) |
| 2280 .toSet(); | 2281 .toSet(); |
| 2281 | 2282 |
| 2282 for (Element element in Elements.sortedByPosition(elements)) { | 2283 for (Element element in Elements.sortedByPosition(elements)) { |
| 2283 CodeBuffer buffer = bufferForElement(element, eagerBuffer); | 2284 CodeBuffer buffer = bufferForElement(element, eagerBuffer); |
| 2284 jsAst.Expression code = backend.generatedCode[element]; | 2285 jsAst.Expression code = backend.generatedCode[element]; |
| 2285 String name = namer.getName(element); | 2286 String name = namer.getName(element); |
| 2286 code = extendWithMetadata(element, code); | 2287 code = extendWithMetadata(element, code); |
| 2287 emitStaticFunction(buffer, name, code); | 2288 emitStaticFunction(buffer, name, code); |
| 2288 String reflectionName = getReflectionName(element, name); | 2289 String reflectionName = getReflectionName(element, name); |
| 2289 if (reflectionName != null) { | 2290 if (reflectionName != null && |
| 2291 backend.isAccessibleByReflection(element)) { | |
| 2290 buffer.write(',$n$n"+$reflectionName":${_}0'); | 2292 buffer.write(',$n$n"+$reflectionName":${_}0'); |
| 2291 } | 2293 } |
| 2292 jsAst.Expression bailoutCode = backend.generatedBailoutCode[element]; | 2294 jsAst.Expression bailoutCode = backend.generatedBailoutCode[element]; |
| 2293 if (bailoutCode != null) { | 2295 if (bailoutCode != null) { |
| 2294 pendingElementsWithBailouts.remove(element); | 2296 pendingElementsWithBailouts.remove(element); |
| 2295 emitStaticFunction(buffer, namer.getBailoutName(element), bailoutCode); | 2297 emitStaticFunction(buffer, namer.getBailoutName(element), bailoutCode); |
| 2296 } | 2298 } |
| 2297 } | 2299 } |
| 2298 | 2300 |
| 2299 if (!pendingElementsWithBailouts.isEmpty) { | 2301 if (!pendingElementsWithBailouts.isEmpty) { |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4152 | 4154 |
| 4153 const String HOOKS_API_USAGE = """ | 4155 const String HOOKS_API_USAGE = """ |
| 4154 // The code supports the following hooks: | 4156 // The code supports the following hooks: |
| 4155 // dartPrint(message) - if this function is defined it is called | 4157 // dartPrint(message) - if this function is defined it is called |
| 4156 // instead of the Dart [print] method. | 4158 // instead of the Dart [print] method. |
| 4157 // dartMainRunner(main) - if this function is defined, the Dart [main] | 4159 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 4158 // method will not be invoked directly. | 4160 // method will not be invoked directly. |
| 4159 // Instead, a closure that will invoke [main] is | 4161 // Instead, a closure that will invoke [main] is |
| 4160 // passed to [dartMainRunner]. | 4162 // passed to [dartMainRunner]. |
| 4161 """; | 4163 """; |
| OLD | NEW |