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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1237 | 1237 |
| 1238 void emitFinishClassesInvocationIfNecessary(CodeBuffer buffer) { | 1238 void emitFinishClassesInvocationIfNecessary(CodeBuffer buffer) { |
| 1239 if (needsDefineClass) { | 1239 if (needsDefineClass) { |
| 1240 buffer.add("$finishClassesName($classesCollector)$N"); | 1240 buffer.add("$finishClassesName($classesCollector)$N"); |
| 1241 // Reset the map. | 1241 // Reset the map. |
| 1242 buffer.add("$classesCollector$_=$_{}$N"); | 1242 buffer.add("$classesCollector$_=$_{}$N"); |
| 1243 } | 1243 } |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 void emitStaticFunctionWithNamer(CodeBuffer buffer, | 1246 void emitStaticFunctionWithNamer(CodeBuffer buffer, |
| 1247 Element element, | 1247 FunctionElement element, |
| 1248 CodeBuffer functionBuffer, | 1248 CodeBuffer functionBuffer, |
| 1249 String functionNamer(Element element)) { | 1249 String functionNamer(Element element)) { |
| 1250 String functionName = functionNamer(element); | 1250 String functionName = functionNamer(element); |
| 1251 buffer.add('$isolateProperties.$functionName$_=$_'); | 1251 buffer.add('$isolateProperties.$functionName$_=$_'); |
| 1252 buffer.add(functionBuffer); | 1252 buffer.add(functionBuffer); |
| 1253 buffer.add('$N$n'); | 1253 buffer.add('$N$n'); |
| 1254 for (TypedefElement typedef in checkedTypedefs) { | |
|
ngeoffray
2012/12/13 12:38:57
This will add is checks to all static functions. Y
karlklose
2012/12/13 13:08:46
Done.
| |
| 1255 FunctionType typedefType = | |
| 1256 typedef.computeType(compiler).unalias(compiler); | |
| 1257 if (compiler.types.isSubtype(element.computeType(compiler), | |
| 1258 typedefType)) { | |
| 1259 String typedefName = namer.getName(typedef); | |
| 1260 buffer.add('$isolateProperties.$functionName' | |
| 1261 '.is\$$typedefName$_=${_}true$N'); | |
| 1262 } | |
| 1263 } | |
| 1254 } | 1264 } |
| 1265 | |
| 1255 void emitStaticFunctionsWithNamer(CodeBuffer buffer, | 1266 void emitStaticFunctionsWithNamer(CodeBuffer buffer, |
| 1256 Map<Element, CodeBuffer> generatedCode, | 1267 Map<Element, CodeBuffer> generatedCode, |
| 1257 String functionNamer(Element element)) { | 1268 String functionNamer(Element element)) { |
| 1258 generatedCode.forEach((Element element, CodeBuffer functionBuffer) { | 1269 generatedCode.forEach((Element element, CodeBuffer functionBuffer) { |
| 1259 if (!element.isInstanceMember() && !element.isField()) { | 1270 if (!element.isInstanceMember() && !element.isField()) { |
| 1260 emitStaticFunctionWithNamer( | 1271 emitStaticFunctionWithNamer( |
| 1261 buffer, element, functionBuffer,functionNamer); | 1272 buffer, element, functionBuffer,functionNamer); |
| 1262 } | 1273 } |
| 1263 }); | 1274 }); |
| 1264 } | 1275 } |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2020 """; | 2031 """; |
| 2021 const String HOOKS_API_USAGE = """ | 2032 const String HOOKS_API_USAGE = """ |
| 2022 // The code supports the following hooks: | 2033 // The code supports the following hooks: |
| 2023 // dartPrint(message) - if this function is defined it is called | 2034 // dartPrint(message) - if this function is defined it is called |
| 2024 // instead of the Dart [print] method. | 2035 // instead of the Dart [print] method. |
| 2025 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2036 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 2026 // method will not be invoked directly. | 2037 // method will not be invoked directly. |
| 2027 // Instead, a closure that will invoke [main] is | 2038 // Instead, a closure that will invoke [main] is |
| 2028 // passed to [dartMainRunner]. | 2039 // passed to [dartMainRunner]. |
| 2029 """; | 2040 """; |
| OLD | NEW |