| 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("patchparser"); | 5 #library("patchparser"); |
| 6 #import("dart:uri"); | 6 #import("dart:uri"); |
| 7 | 7 |
| 8 #import("tree/tree.dart", prefix: "tree"); | 8 #import("tree/tree.dart", prefix: "tree"); |
| 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. | 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. |
| 10 #import("apiimpl.dart"); | 10 #import("apiimpl.dart"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 scanLibraryElements(library); | 33 scanLibraryElements(library); |
| 34 compiler.onLibraryLoaded(library, uri); | 34 compiler.onLibraryLoaded(library, uri); |
| 35 }); | 35 }); |
| 36 } | 36 } |
| 37 return library; | 37 return library; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void scanLibraryElements(LibraryElement library) { | 40 void scanLibraryElements(LibraryElement library) { |
| 41 measure(() { | 41 measure(() { |
| 42 // TODO(lrn): Possibly recursively handle #source directives in patch. | 42 // TODO(lrn): Possibly recursively handle #source directives in patch. |
| 43 leg.Script script = library.script; | 43 leg.Script script = library.entryCompilationUnit.script; |
| 44 Token tokens = new StringScanner(script.text).tokenize(); | 44 Token tokens = new StringScanner(script.text).tokenize(); |
| 45 Function idGenerator = compiler.getNextFreeClassId; | 45 Function idGenerator = compiler.getNextFreeClassId; |
| 46 PatchListener patchListener = | 46 PatchListener patchListener = |
| 47 new PatchElementListener(compiler, library, idGenerator); | 47 new PatchElementListener(compiler, |
| 48 library.entryCompilationUnit, |
| 49 idGenerator); |
| 48 new PatchParser(patchListener).parseUnit(tokens); | 50 new PatchParser(patchListener).parseUnit(tokens); |
| 49 }); | 51 }); |
| 50 } | 52 } |
| 51 | 53 |
| 52 tree.ClassNode parsePatchClassNode(PartialClassElement element) { | 54 tree.ClassNode parsePatchClassNode(PartialClassElement element) { |
| 53 // Parse [PartialClassElement] using a "patch"-aware parser instead | 55 // Parse [PartialClassElement] using a "patch"-aware parser instead |
| 54 // of calling its [parseNode] method. | 56 // of calling its [parseNode] method. |
| 55 if (element.cachedNode != null) return element.cachedNode; | 57 if (element.cachedNode != null) return element.cachedNode; |
| 56 PatchMemberListener listener = | 58 PatchMemberListener listener = |
| 57 new PatchMemberListener(compiler, element); | 59 new PatchMemberListener(compiler, element); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 210 } |
| 209 } | 211 } |
| 210 | 212 |
| 211 void addMember(Element element) { | 213 void addMember(Element element) { |
| 212 if (isMemberPatch || (isClassPatch && element is ClassElement)) { | 214 if (isMemberPatch || (isClassPatch && element is ClassElement)) { |
| 213 element.addMetadata(popNode()); | 215 element.addMetadata(popNode()); |
| 214 } | 216 } |
| 215 super.addMember(element); | 217 super.addMember(element); |
| 216 } | 218 } |
| 217 } | 219 } |
| OLD | NEW |