OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class LibraryImport { | 5 class LibraryImport { |
6 String prefix; | 6 String prefix; |
7 Library library; | 7 Library library; |
8 LibraryImport(this.library, [this.prefix = null]); | 8 LibraryImport(this.library, [this.prefix = null]); |
9 } | 9 } |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 Element get enclosingElement() => null; | 39 Element get enclosingElement() => null; |
40 Library get library() => this; | 40 Library get library() => this; |
41 | 41 |
42 bool get isNative() => topType.isNative; | 42 bool get isNative() => topType.isNative; |
43 | 43 |
44 bool get isCore() => this == world.corelib; | 44 bool get isCore() => this == world.corelib; |
45 bool get isCoreImpl() => this == world.coreimpl; | 45 bool get isCoreImpl() => this == world.coreimpl; |
46 | 46 |
| 47 // TODO(jmesserly): we shouldn't be special casing DOM anywhere. |
| 48 bool get isDom() => this == world.dom; |
| 49 |
47 SourceSpan get span() => new SourceSpan(baseSource, 0, 0); | 50 SourceSpan get span() => new SourceSpan(baseSource, 0, 0); |
48 | 51 |
49 String makeFullPath(String filename) { | 52 String makeFullPath(String filename) { |
50 if (filename.startsWith('dart:')) return filename; | 53 if (filename.startsWith('dart:')) return filename; |
51 // TODO(jmesserly): replace with node.js path.resolve | 54 // TODO(jmesserly): replace with node.js path.resolve |
52 if (filename.startsWith('/')) return filename; | 55 if (filename.startsWith('/')) return filename; |
53 if (filename.startsWith('file:///')) return filename; | 56 if (filename.startsWith('file:///')) return filename; |
54 if (filename.startsWith('http://')) return filename; | 57 if (filename.startsWith('http://')) return filename; |
55 return joinPaths(sourceDir, filename); | 58 return joinPaths(sourceDir, filename); |
56 } | 59 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 m.resolve(); | 118 m.resolve(); |
116 // Function types implement the Function interface. | 119 // Function types implement the Function interface. |
117 type.interfaces = [world.functionType]; | 120 type.interfaces = [world.functionType]; |
118 return type; | 121 return type; |
119 } | 122 } |
120 | 123 |
121 /** Adds a type to the library. */ | 124 /** Adds a type to the library. */ |
122 DefinedType addType(String name, Node definition, bool isClass) { | 125 DefinedType addType(String name, Node definition, bool isClass) { |
123 if (types.containsKey(name)) { | 126 if (types.containsKey(name)) { |
124 var existingType = types[name]; | 127 var existingType = types[name]; |
125 if (isCore && existingType.definition == null) { | 128 if ((isCore || isCoreImpl) && existingType.definition == null) { |
126 // TODO(jimhug): Validate compatibility with natives. | 129 // TODO(jimhug): Validate compatibility with natives. |
127 existingType.setDefinition(definition); | 130 existingType.setDefinition(definition); |
128 } else { | 131 } else { |
129 world.warning('duplicate definition of $name', definition.span, | 132 world.warning('duplicate definition of $name', definition.span, |
130 existingType.span); | 133 existingType.span); |
131 } | 134 } |
132 } else { | 135 } else { |
133 types[name] = new DefinedType(name, this, definition, isClass); | 136 types[name] = new DefinedType(name, this, definition, isClass); |
134 } | 137 } |
135 | 138 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 483 |
481 void visitFunctionDefinition(FunctionDefinition node) { | 484 void visitFunctionDefinition(FunctionDefinition node) { |
482 currentType.addMethod(node.name.name, node); | 485 currentType.addMethod(node.name.name, node); |
483 } | 486 } |
484 | 487 |
485 void visitFunctionTypeDefinition(FunctionTypeDefinition node) { | 488 void visitFunctionTypeDefinition(FunctionTypeDefinition node) { |
486 var type = library.addType(node.func.name.name, node, false); | 489 var type = library.addType(node.func.name.name, node, false); |
487 type.addMethod(':call', node.func); | 490 type.addMethod(':call', node.func); |
488 } | 491 } |
489 } | 492 } |
OLD | NEW |