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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 11571004: Implement is-checks for static functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move to emitStaticFunctionGetters. Created 8 years 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1244
1245 void emitStaticFunctionWithNamer(CodeBuffer buffer, 1245 void emitStaticFunctionWithNamer(CodeBuffer buffer,
1246 Element element, 1246 Element element,
1247 CodeBuffer functionBuffer, 1247 CodeBuffer functionBuffer,
1248 String functionNamer(Element element)) { 1248 String functionNamer(Element element)) {
1249 String functionName = functionNamer(element); 1249 String functionName = functionNamer(element);
1250 buffer.add('$isolateProperties.$functionName$_=$_'); 1250 buffer.add('$isolateProperties.$functionName$_=$_');
1251 buffer.add(functionBuffer); 1251 buffer.add(functionBuffer);
1252 buffer.add('$N$n'); 1252 buffer.add('$N$n');
1253 } 1253 }
1254
1254 void emitStaticFunctionsWithNamer(CodeBuffer buffer, 1255 void emitStaticFunctionsWithNamer(CodeBuffer buffer,
1255 Map<Element, CodeBuffer> generatedCode, 1256 Map<Element, CodeBuffer> generatedCode,
1256 String functionNamer(Element element)) { 1257 String functionNamer(Element element)) {
1257 generatedCode.forEach((Element element, CodeBuffer functionBuffer) { 1258 generatedCode.forEach((Element element, CodeBuffer functionBuffer) {
1258 if (!element.isInstanceMember() && !element.isField()) { 1259 if (!element.isInstanceMember() && !element.isField()) {
1259 emitStaticFunctionWithNamer( 1260 emitStaticFunctionWithNamer(
1260 buffer, element, functionBuffer,functionNamer); 1261 buffer, element, functionBuffer,functionNamer);
1261 } 1262 }
1262 }); 1263 });
1263 } 1264 }
(...skipping 22 matching lines...) Expand all
1286 String invocationName = namer.instanceMethodName(callElement); 1287 String invocationName = namer.instanceMethodName(callElement);
1287 String fieldAccess = '$isolateProperties.$staticName'; 1288 String fieldAccess = '$isolateProperties.$staticName';
1288 buffer.add("$fieldAccess.$invocationName$_=$_$fieldAccess$N"); 1289 buffer.add("$fieldAccess.$invocationName$_=$_$fieldAccess$N");
1289 addParameterStubs(callElement, (String name, CodeBuffer value) { 1290 addParameterStubs(callElement, (String name, CodeBuffer value) {
1290 buffer.add('$fieldAccess.$name$_=$_$value$N'); 1291 buffer.add('$fieldAccess.$name$_=$_$value$N');
1291 }); 1292 });
1292 // If a static function is used as a closure we need to add its name 1293 // If a static function is used as a closure we need to add its name
1293 // in case it is used in spawnFunction. 1294 // in case it is used in spawnFunction.
1294 String fieldName = namer.STATIC_CLOSURE_NAME_NAME; 1295 String fieldName = namer.STATIC_CLOSURE_NAME_NAME;
1295 buffer.add('$fieldAccess.$fieldName$_=$_"$staticName"$N'); 1296 buffer.add('$fieldAccess.$fieldName$_=$_"$staticName"$N');
1297 for (TypedefElement typedef in checkedTypedefs) {
1298 FunctionType typedefType =
1299 typedef.computeType(compiler).unalias(compiler);
1300 if (compiler.types.isSubtype(element.computeType(compiler),
ngeoffray 2012/12/13 13:20:37 move element.computeType out of the loop.
1301 typedefType)) {
1302 String typedefName = namer.getName(typedef);
1303 buffer.add('$fieldAccess.is\$$typedefName$_=${_}true$N');
ngeoffray 2012/12/13 13:20:37 Please use namer.operatorIs.
1304 }
1305 }
1296 } 1306 }
1297 } 1307 }
1298 1308
1299 void emitBoundClosureClassHeader(String mangledName, 1309 void emitBoundClosureClassHeader(String mangledName,
1300 String superName, 1310 String superName,
1301 List<String> fieldNames, 1311 List<String> fieldNames,
1302 CodeBuffer buffer) { 1312 CodeBuffer buffer) {
1303 buffer.add('$classesCollector.$mangledName$_=$_' 1313 buffer.add('$classesCollector.$mangledName$_=$_'
1304 '{"":"$superName;${Strings.join(fieldNames,',')}",'); 1314 '{"":"$superName;${Strings.join(fieldNames,',')}",');
1305 } 1315 }
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 """; 2029 """;
2020 const String HOOKS_API_USAGE = """ 2030 const String HOOKS_API_USAGE = """
2021 // The code supports the following hooks: 2031 // The code supports the following hooks:
2022 // dartPrint(message) - if this function is defined it is called 2032 // dartPrint(message) - if this function is defined it is called
2023 // instead of the Dart [print] method. 2033 // instead of the Dart [print] method.
2024 // dartMainRunner(main) - if this function is defined, the Dart [main] 2034 // dartMainRunner(main) - if this function is defined, the Dart [main]
2025 // method will not be invoked directly. 2035 // method will not be invoked directly.
2026 // Instead, a closure that will invoke [main] is 2036 // Instead, a closure that will invoke [main] is
2027 // passed to [dartMainRunner]. 2037 // passed to [dartMainRunner].
2028 """; 2038 """;
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698