| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 HInstruction thisInstruction = new HThis(); | 325 HInstruction thisInstruction = new HThis(); |
| 326 builder.add(thisInstruction); | 326 builder.add(thisInstruction); |
| 327 updateLocal(closureData.closureElement, thisInstruction); | 327 updateLocal(closureData.closureElement, thisInstruction); |
| 328 } else if (function.isInstanceMember() | 328 } else if (function.isInstanceMember() |
| 329 || function.isGenerativeConstructor()) { | 329 || function.isGenerativeConstructor()) { |
| 330 // Once closures have been mapped to classes their instance members might | 330 // Once closures have been mapped to classes their instance members might |
| 331 // not have any thisElement if the closure was created inside a static | 331 // not have any thisElement if the closure was created inside a static |
| 332 // context. | 332 // context. |
| 333 ClassElement cls = function.enclosingElement; | 333 ClassElement cls = function.enclosingElement; |
| 334 Type type = cls.computeType(builder.compiler); | 334 Type type = cls.computeType(builder.compiler); |
| 335 HInstruction thisInstruction = new HThis(new HBoundedType(type)); | 335 HInstruction thisInstruction = new HThis(new HBoundedType.nonNull(type)); |
| 336 builder.add(thisInstruction); | 336 builder.add(thisInstruction); |
| 337 directLocals[closureData.thisElement] = thisInstruction; | 337 directLocals[closureData.thisElement] = thisInstruction; |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 bool hasValueForDirectLocal(Element element) { | 341 bool hasValueForDirectLocal(Element element) { |
| 342 assert(element !== null); | 342 assert(element !== null); |
| 343 assert(isAccessedDirectly(element)); | 343 assert(isAccessedDirectly(element)); |
| 344 return directLocals[element] !== null; | 344 return directLocals[element] !== null; |
| 345 } | 345 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 HType cachedTypeOfThis; | 421 HType cachedTypeOfThis; |
| 422 | 422 |
| 423 HInstruction readThis() { | 423 HInstruction readThis() { |
| 424 HInstruction res = readLocal(closureData.thisElement); | 424 HInstruction res = readLocal(closureData.thisElement); |
| 425 if (res.guaranteedType === null) { | 425 if (res.guaranteedType === null) { |
| 426 if (cachedTypeOfThis === null) { | 426 if (cachedTypeOfThis === null) { |
| 427 assert(closureData.isClosure()); | 427 assert(closureData.isClosure()); |
| 428 Element element = closureData.thisElement; | 428 Element element = closureData.thisElement; |
| 429 ClassElement cls = element.enclosingElement.enclosingElement; | 429 ClassElement cls = element.enclosingElement.enclosingElement; |
| 430 Type type = cls.computeType(builder.compiler); | 430 Type type = cls.computeType(builder.compiler); |
| 431 cachedTypeOfThis = new HBoundedType(type); | 431 cachedTypeOfThis = new HBoundedType.nonNull(type); |
| 432 } | 432 } |
| 433 res.guaranteedType = cachedTypeOfThis; | 433 res.guaranteedType = cachedTypeOfThis; |
| 434 } | 434 } |
| 435 return res; | 435 return res; |
| 436 } | 436 } |
| 437 | 437 |
| 438 /** | 438 /** |
| 439 * Sets the [element] to [value]. If the element is boxed or stored in a | 439 * Sets the [element] to [value]. If the element is boxed or stored in a |
| 440 * closure then the method generates code to set the value. | 440 * closure then the method generates code to set the value. |
| 441 */ | 441 */ |
| (...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 computeType(element) { | 2302 computeType(element) { |
| 2303 Element originalElement = elements[node]; | 2303 Element originalElement = elements[node]; |
| 2304 if (originalElement.enclosingElement === compiler.listClass) { | 2304 if (originalElement.enclosingElement === compiler.listClass) { |
| 2305 if (node.arguments.isEmpty()) { | 2305 if (node.arguments.isEmpty()) { |
| 2306 return HType.EXTENDABLE_ARRAY; | 2306 return HType.EXTENDABLE_ARRAY; |
| 2307 } else { | 2307 } else { |
| 2308 return HType.MUTABLE_ARRAY; | 2308 return HType.MUTABLE_ARRAY; |
| 2309 } | 2309 } |
| 2310 } else if (element.isGenerativeConstructor()) { | 2310 } else if (element.isGenerativeConstructor()) { |
| 2311 ClassElement cls = element.enclosingElement; | 2311 ClassElement cls = element.enclosingElement; |
| 2312 return new HExactType(cls.type); | 2312 return new HBoundedType.exact(cls.type); |
| 2313 } else { | 2313 } else { |
| 2314 return HType.UNKNOWN; | 2314 return HType.UNKNOWN; |
| 2315 } | 2315 } |
| 2316 } | 2316 } |
| 2317 | 2317 |
| 2318 Selector selector = elements.getSelector(node); | 2318 Selector selector = elements.getSelector(node); |
| 2319 Element element = elements[node]; | 2319 Element element = elements[node]; |
| 2320 compiler.resolver.resolveMethodElement(element); | 2320 compiler.resolver.resolveMethodElement(element); |
| 2321 FunctionElement functionElement = element; | 2321 FunctionElement functionElement = element; |
| 2322 element = functionElement.defaultImplementation; | 2322 element = functionElement.defaultImplementation; |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3379 <HInstruction>[target, input], | 3379 <HInstruction>[target, input], |
| 3380 HType.STRING)); | 3380 HType.STRING)); |
| 3381 return builder.pop(); | 3381 return builder.pop(); |
| 3382 } | 3382 } |
| 3383 | 3383 |
| 3384 HInstruction result(Node node) { | 3384 HInstruction result(Node node) { |
| 3385 flushLiterals(node); | 3385 flushLiterals(node); |
| 3386 return prefix; | 3386 return prefix; |
| 3387 } | 3387 } |
| 3388 } | 3388 } |
| OLD | NEW |