OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Analysis to determine how to generate code for `LookupMap`s. | 5 /// Analysis to determine how to generate code for `LookupMap`s. |
6 library compiler.src.js_backend.lookup_map_analysis; | 6 library compiler.src.js_backend.lookup_map_analysis; |
7 | 7 |
8 import 'package:pub_semver/pub_semver.dart'; | 8 import 'package:pub_semver/pub_semver.dart'; |
9 | 9 |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 /// This reference will be mutated in place to remove it's entries when the | 399 /// This reference will be mutated in place to remove it's entries when the |
400 /// map is first seen during codegen, and to restore them (or a subset of | 400 /// map is first seen during codegen, and to restore them (or a subset of |
401 /// them) when we have finished discovering which entries are used. This has | 401 /// them) when we have finished discovering which entries are used. This has |
402 /// the side-effect that `orignal.getDependencies()` will be empty during | 402 /// the side-effect that `orignal.getDependencies()` will be empty during |
403 /// most of codegen until we are ready to emit the constants. However, | 403 /// most of codegen until we are ready to emit the constants. However, |
404 /// restoring the entries before emitting code lets us keep the emitter logic | 404 /// restoring the entries before emitting code lets us keep the emitter logic |
405 /// agnostic of this optimization. | 405 /// agnostic of this optimization. |
406 final ConstructedConstantValue original; | 406 final ConstructedConstantValue original; |
407 | 407 |
408 /// Reference to the lookup map analysis to be able to refer to data shared | 408 /// Reference to the lookup map analysis to be able to refer to data shared |
409 /// accross infos. | 409 /// across infos. |
410 final _LookupMapAnalysis analysis; | 410 final _LookupMapAnalysis analysis; |
411 | 411 |
412 /// Whether we have already emitted this constant. | 412 /// Whether we have already emitted this constant. |
413 bool emitted = false; | 413 bool emitted = false; |
414 | 414 |
415 /// Whether the `LookupMap` constant was built using the `LookupMap.pair` | 415 /// Whether the `LookupMap` constant was built using the `LookupMap.pair` |
416 /// constructor. | 416 /// constructor. |
417 bool singlePair; | 417 bool singlePair; |
418 | 418 |
419 /// Entries in the lookup map whose keys have not been seen in the rest of the | 419 /// Entries in the lookup map whose keys have not been seen in the rest of the |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 original.fields[analysis._valueField] = keyValuePairs[1]; | 497 original.fields[analysis._valueField] = keyValuePairs[1]; |
498 } | 498 } |
499 } else { | 499 } else { |
500 original.fields[analysis._entriesField] = | 500 original.fields[analysis._entriesField] = |
501 new ListConstantValue(listType, keyValuePairs); | 501 new ListConstantValue(listType, keyValuePairs); |
502 } | 502 } |
503 } | 503 } |
504 } | 504 } |
505 | 505 |
506 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); | 506 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); |
OLD | NEW |