| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.js_emitter.full_emitter; | 5 part of dart2js.js_emitter.full_emitter; |
| 6 | 6 |
| 7 class NsmEmitter extends CodeEmitterHelper { | 7 class NsmEmitter extends CodeEmitterHelper { |
| 8 final ClosedWorld closedWorld; | 8 final ClosedWorld closedWorld; |
| 9 final List<Selector> trivialNsmHandlers = <Selector>[]; | 9 final List<Selector> trivialNsmHandlers = <Selector>[]; |
| 10 | 10 |
| 11 NsmEmitter(this.closedWorld); | 11 NsmEmitter(this.closedWorld); |
| 12 | 12 |
| 13 /// If this is true then we can generate the noSuchMethod handlers at startup | 13 /// If this is true then we can generate the noSuchMethod handlers at startup |
| 14 /// time, instead of them being emitted as part of the Object class. | 14 /// time, instead of them being emitted as part of the Object class. |
| 15 bool get generateTrivialNsmHandlers => true; | 15 bool get generateTrivialNsmHandlers => true; |
| 16 | 16 |
| 17 // If we need fewer than this many noSuchMethod handlers we can save space by | 17 // If we need fewer than this many noSuchMethod handlers we can save space by |
| 18 // just emitting them in JS, rather than emitting the JS needed to generate | 18 // just emitting them in JS, rather than emitting the JS needed to generate |
| 19 // them at run time. | 19 // them at run time. |
| 20 static const VERY_FEW_NO_SUCH_METHOD_HANDLERS = 10; | 20 static const VERY_FEW_NO_SUCH_METHOD_HANDLERS = 10; |
| 21 | 21 |
| 22 static const MAX_MINIFIED_LENGTH_FOR_DIFF_ENCODING = 4; | 22 static const MAX_MINIFIED_LENGTH_FOR_DIFF_ENCODING = 4; |
| 23 | 23 |
| 24 void emitNoSuchMethodHandlers(AddPropertyFunction addProperty) { | 24 void emitNoSuchMethodHandlers(AddPropertyFunction addProperty) { |
| 25 ClassStubGenerator generator = new ClassStubGenerator( | 25 ClassStubGenerator generator = new ClassStubGenerator( |
| 26 namer, backend, codegenWorld, closedWorld, | 26 namer, backend, codegenWorldBuilder, closedWorld, |
| 27 enableMinification: compiler.options.enableMinification); | 27 enableMinification: compiler.options.enableMinification); |
| 28 | 28 |
| 29 // Keep track of the JavaScript names we've already added so we | 29 // Keep track of the JavaScript names we've already added so we |
| 30 // do not introduce duplicates (bad for code size). | 30 // do not introduce duplicates (bad for code size). |
| 31 Map<jsAst.Name, Selector> addedJsNames = | 31 Map<jsAst.Name, Selector> addedJsNames = |
| 32 generator.computeSelectorsForNsmHandlers(); | 32 generator.computeSelectorsForNsmHandlers(); |
| 33 | 33 |
| 34 // Set flag used by generateMethod helper below. If we have very few | 34 // Set flag used by generateMethod helper below. If we have very few |
| 35 // handlers we use addProperty for them all, rather than try to generate | 35 // handlers we use addProperty for them all, rather than try to generate |
| 36 // them at runtime. | 36 // them at runtime. |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 | 392 |
| 393 String get value { | 393 String get value { |
| 394 if (_cachedValue == null) { | 394 if (_cachedValue == null) { |
| 395 _cachedValue = _computeDiffEncoding(); | 395 _cachedValue = _computeDiffEncoding(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 return _cachedValue; | 398 return _cachedValue; |
| 399 } | 399 } |
| 400 } | 400 } |
| OLD | NEW |