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('native'); | 5 #library('native'); |
6 #import('dart:uri'); | 6 #import('dart:uri'); |
7 #import('leg.dart'); | 7 #import('leg.dart'); |
8 #import('elements/elements.dart'); | 8 #import('elements/elements.dart'); |
9 #import('scanner/scannerlib.dart'); | 9 #import('scanner/scannerlib.dart'); |
10 #import('ssa/ssa.dart'); | 10 #import('ssa/ssa.dart'); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 // If a method is overridden, we must check if the prototype of | 327 // If a method is overridden, we must check if the prototype of |
328 // 'this' has the method available. Otherwise, we may end up | 328 // 'this' has the method available. Otherwise, we may end up |
329 // calling the method from the super class. If the method is not | 329 // calling the method from the super class. If the method is not |
330 // available, we make a direct call to Object.prototype.$methodName. | 330 // available, we make a direct call to Object.prototype.$methodName. |
331 // This method will patch the prototype of 'this' to the real method. | 331 // This method will patch the prototype of 'this' to the real method. |
332 void generateMethodWithPrototypeCheck(Compiler compiler, | 332 void generateMethodWithPrototypeCheck(Compiler compiler, |
333 StringBuffer buffer, | 333 StringBuffer buffer, |
334 String methodName, | 334 String methodName, |
335 String code, | 335 String code, |
336 String parameters) { | 336 String parameters) { |
337 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 337 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
338 buffer.add("('$methodName')) {\n"); | 338 buffer.add("('$methodName')) {\n"); |
339 buffer.add(" $code"); | 339 buffer.add(" $code"); |
340 buffer.add(" } else {\n"); | 340 buffer.add(" } else {\n"); |
341 buffer.add(" return Object.prototype.$methodName.call(this"); | 341 buffer.add(" return Object.prototype.$methodName.call(this"); |
342 buffer.add(parameters == '' ? '' : ', $parameters'); | 342 buffer.add(parameters == '' ? '' : ', $parameters'); |
343 buffer.add(");\n"); | 343 buffer.add(");\n"); |
344 buffer.add(" }\n"); | 344 buffer.add(" }\n"); |
345 } | 345 } |
OLD | NEW |