| 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 class NativeEmitter { | 7 class NativeEmitter { |
| 8 | 8 |
| 9 CodeEmitterTask emitter; | 9 CodeEmitterTask emitter; |
| 10 CodeBuffer nativeBuffer; | 10 CodeBuffer nativeBuffer; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 js.use('Object').dot('prototype').dot(methodName).dot('call') | 255 js.use('Object').dot('prototype').dot(methodName).dot('call') |
| 256 .callWith( | 256 .callWith( |
| 257 <js.Expression>[js.use('this')]..addAll( | 257 <js.Expression>[js.use('this')]..addAll( |
| 258 parameters.mappedBy((param) => js.use(param.name)))))); | 258 parameters.mappedBy((param) => js.use(param.name)))))); |
| 259 } | 259 } |
| 260 | 260 |
| 261 js.Block generateMethodBodyWithPrototypeCheckForElement( | 261 js.Block generateMethodBodyWithPrototypeCheckForElement( |
| 262 FunctionElement element, | 262 FunctionElement element, |
| 263 js.Block body, | 263 js.Block body, |
| 264 List<js.Parameter> parameters) { | 264 List<js.Parameter> parameters) { |
| 265 String methodName; | 265 ElementKind kind = element.kind; |
| 266 Namer namer = backend.namer; | 266 if (kind != ElementKind.FUNCTION && |
| 267 if (element.kind == ElementKind.FUNCTION) { | 267 kind != ElementKind.GETTER && |
| 268 methodName = namer.instanceMethodName(element); | 268 kind != ElementKind.SETTER) { |
| 269 } else if (element.kind == ElementKind.GETTER) { | 269 compiler.internalError("unexpected kind: '$kind'", element: element); |
| 270 methodName = namer.getterName(element.getLibrary(), element.name); | |
| 271 } else if (element.kind == ElementKind.SETTER) { | |
| 272 methodName = namer.setterName(element.getLibrary(), element.name); | |
| 273 } else { | |
| 274 compiler.internalError("unexpected kind: '${element.kind}'", | |
| 275 element: element); | |
| 276 } | 270 } |
| 277 | 271 |
| 272 String methodName = backend.namer.getName(element); |
| 278 return new js.Block( | 273 return new js.Block( |
| 279 [generateMethodBodyWithPrototypeCheck(methodName, body, parameters)]); | 274 [generateMethodBodyWithPrototypeCheck(methodName, body, parameters)]); |
| 280 } | 275 } |
| 281 | 276 |
| 282 | 277 |
| 283 void emitDynamicDispatchMetadata() { | 278 void emitDynamicDispatchMetadata() { |
| 284 if (classesWithDynamicDispatch.isEmpty) return; | 279 if (classesWithDynamicDispatch.isEmpty) return; |
| 285 int length = classesWithDynamicDispatch.length; | 280 int length = classesWithDynamicDispatch.length; |
| 286 if (!compiler.enableMinification) { | 281 if (!compiler.enableMinification) { |
| 287 nativeBuffer.add('// $length dynamic classes.\n'); | 282 nativeBuffer.add('// $length dynamic classes.\n'); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 if (emitter.compiler.enableMinification) targetBuffer.add(';'); | 531 if (emitter.compiler.enableMinification) targetBuffer.add(';'); |
| 537 targetBuffer.add(js.prettyPrint( | 532 targetBuffer.add(js.prettyPrint( |
| 538 new js.ExpressionStatement(init), compiler)); | 533 new js.ExpressionStatement(init), compiler)); |
| 539 targetBuffer.add('\n'); | 534 targetBuffer.add('\n'); |
| 540 } | 535 } |
| 541 | 536 |
| 542 targetBuffer.add(nativeBuffer); | 537 targetBuffer.add(nativeBuffer); |
| 543 targetBuffer.add('\n'); | 538 targetBuffer.add('\n'); |
| 544 } | 539 } |
| 545 } | 540 } |
| OLD | NEW |