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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 // If a method is overridden, we must check if the prototype of | 332 // If a method is overridden, we must check if the prototype of |
333 // 'this' has the method available. Otherwise, we may end up | 333 // 'this' has the method available. Otherwise, we may end up |
334 // calling the method from the super class. If the method is not | 334 // calling the method from the super class. If the method is not |
335 // available, we make a direct call to Object.prototype.$methodName. | 335 // available, we make a direct call to Object.prototype.$methodName. |
336 // This method will patch the prototype of 'this' to the real method. | 336 // This method will patch the prototype of 'this' to the real method. |
337 void generateMethodWithPrototypeCheck(Compiler compiler, | 337 void generateMethodWithPrototypeCheck(Compiler compiler, |
338 StringBuffer buffer, | 338 StringBuffer buffer, |
339 String methodName, | 339 String methodName, |
340 String code, | 340 String code, |
341 String parameters) { | 341 String parameters) { |
342 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 342 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
343 buffer.add("('$methodName')) {\n"); | 343 buffer.add("('$methodName')) {\n"); |
344 buffer.add(" $code"); | 344 buffer.add(" $code"); |
345 buffer.add(" } else {\n"); | 345 buffer.add(" } else {\n"); |
346 buffer.add(" return Object.prototype.$methodName.call(this"); | 346 buffer.add(" return Object.prototype.$methodName.call(this"); |
347 buffer.add(parameters == '' ? '' : ', $parameters'); | 347 buffer.add(parameters == '' ? '' : ', $parameters'); |
348 buffer.add(");\n"); | 348 buffer.add(");\n"); |
349 buffer.add(" }\n"); | 349 buffer.add(" }\n"); |
350 } | 350 } |
OLD | NEW |