OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
8 /// | 8 /// |
9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
(...skipping 4219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4230 return hash; | 4230 return hash; |
4231 } | 4231 } |
4232 } | 4232 } |
4233 | 4233 |
4234 // ------------------------------------------------------------------------ | 4234 // ------------------------------------------------------------------------ |
4235 // PROGRAM | 4235 // PROGRAM |
4236 // ------------------------------------------------------------------------ | 4236 // ------------------------------------------------------------------------ |
4237 | 4237 |
4238 /// A way to bundle up all the libraries in a program. | 4238 /// A way to bundle up all the libraries in a program. |
4239 class Program extends TreeNode { | 4239 class Program extends TreeNode { |
4240 final CanonicalName root = new CanonicalName.root(); | 4240 final CanonicalName root; |
4241 | 4241 |
4242 final List<Library> libraries; | 4242 final List<Library> libraries; |
4243 | 4243 |
4244 /// Map from a source file uri to a line-starts table and source code. | 4244 /// Map from a source file uri to a line-starts table and source code. |
4245 /// Given a source file uri and a offset in that file one can translate | 4245 /// Given a source file uri and a offset in that file one can translate |
4246 /// it to a line:column position in that file. | 4246 /// it to a line:column position in that file. |
4247 final Map<String, Source> uriToSource; | 4247 final Map<String, Source> uriToSource; |
4248 | 4248 |
4249 /// Reference to the main method in one of the libraries. | 4249 /// Reference to the main method in one of the libraries. |
4250 Reference mainMethodName; | 4250 Reference mainMethodName; |
4251 | 4251 |
4252 Program([List<Library> libraries, Map<String, Source> uriToSource]) | 4252 Program( |
4253 : libraries = libraries ?? <Library>[], | 4253 {CanonicalName nameRoot, |
| 4254 List<Library> libraries, |
| 4255 Map<String, Source> uriToSource}) |
| 4256 : root = nameRoot ?? new CanonicalName.root(), |
| 4257 libraries = libraries ?? <Library>[], |
4254 uriToSource = uriToSource ?? <String, Source>{} { | 4258 uriToSource = uriToSource ?? <String, Source>{} { |
4255 setParents(this.libraries, this); | 4259 setParents(this.libraries, this); |
4256 } | 4260 } |
4257 | 4261 |
4258 void computeCanonicalNames() { | 4262 void computeCanonicalNames() { |
4259 for (var library in libraries) { | 4263 for (var library in libraries) { |
4260 root.getChildFromUri(library.importUri).bindTo(library.reference); | 4264 root.getChildFromUri(library.importUri).bindTo(library.reference); |
4261 library.computeCanonicalNames(); | 4265 library.computeCanonicalNames(); |
4262 } | 4266 } |
4263 } | 4267 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4501 /// typedef has not been assigned a canonical name yet. | 4505 /// typedef has not been assigned a canonical name yet. |
4502 /// | 4506 /// |
4503 /// Returns `null` if the typedef is `null`. | 4507 /// Returns `null` if the typedef is `null`. |
4504 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) { | 4508 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) { |
4505 if (typedef_ == null) return null; | 4509 if (typedef_ == null) return null; |
4506 if (typedef_.canonicalName == null) { | 4510 if (typedef_.canonicalName == null) { |
4507 throw '$typedef_ has no canonical name'; | 4511 throw '$typedef_ has no canonical name'; |
4508 } | 4512 } |
4509 return typedef_.canonicalName; | 4513 return typedef_.canonicalName; |
4510 } | 4514 } |
OLD | NEW |