| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 world._addMember(member); | 107 world._addMember(member); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 // TODO(jimhug): Cache and share the types as interfaces? | 111 // TODO(jimhug): Cache and share the types as interfaces? |
| 112 Type getOrAddFunctionType(String name, FunctionDefinition func, Type inType) { | 112 Type getOrAddFunctionType(String name, FunctionDefinition func, Type inType) { |
| 113 final def = new FunctionTypeDefinition(func, null, func.span); | 113 final def = new FunctionTypeDefinition(func, null, func.span); |
| 114 final type = new DefinedType(name, this, def, false); | 114 final type = new DefinedType(name, this, def, false); |
| 115 type.addMethod('\$call', func); | 115 type.addMethod('\$call', func); |
| 116 type.members['\$call'].resolve(inType); | 116 type.members['\$call'].resolve(inType); |
| 117 // Functions should implement Function. See "Function Types" in the spec. | 117 // Function types implement the Function interface. |
| 118 type.interfaces = [world.functionType]; | 118 type.interfaces = [world.functionType]; |
| 119 return type; | 119 return type; |
| 120 } | 120 } |
| 121 | 121 |
| 122 /** Adds a type to the library. */ | 122 /** Adds a type to the library. */ |
| 123 Type addType(String name, Node definition, bool isClass) { | 123 Type addType(String name, Node definition, bool isClass) { |
| 124 if (types.containsKey(name)) { | 124 if (types.containsKey(name)) { |
| 125 var existingType = types[name]; | 125 var existingType = types[name]; |
| 126 if (isCore && existingType.definition == null) { | 126 if (isCore && existingType.definition == null) { |
| 127 // TODO(jimhug): Validate compatibility with natives. | 127 // TODO(jimhug): Validate compatibility with natives. |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 396 |
| 397 void visitFunctionDefinition(FunctionDefinition node) { | 397 void visitFunctionDefinition(FunctionDefinition node) { |
| 398 currentType.addMethod(node.name.name, node); | 398 currentType.addMethod(node.name.name, node); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void visitFunctionTypeDefinition(FunctionTypeDefinition node) { | 401 void visitFunctionTypeDefinition(FunctionTypeDefinition node) { |
| 402 var type = library.addType(node.func.name.name, node, false); | 402 var type = library.addType(node.func.name.name, node, false); |
| 403 type.addMethod('\$call', node.func); | 403 type.addMethod('\$call', node.func); |
| 404 } | 404 } |
| 405 } | 405 } |
| OLD | NEW |