| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of native; | 5 part of native; |
| 6 | 6 |
| 7 /// This class is a temporary work-around until we get a more powerful DartType. | 7 /// This class is a temporary work-around until we get a more powerful DartType. |
| 8 class SpecialType { | 8 class SpecialType { |
| 9 final String name; | 9 final String name; |
| 10 const SpecialType._(this.name); | 10 const SpecialType._(this.name); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 new ThrowBehaviorVisitor().analyze(behavior.codeTemplate.ast); | 513 new ThrowBehaviorVisitor().analyze(behavior.codeTemplate.ast); |
| 514 } | 514 } |
| 515 | 515 |
| 516 return behavior; | 516 return behavior; |
| 517 } | 517 } |
| 518 | 518 |
| 519 static void _fillNativeBehaviorOfBuiltinOrEmbeddedGlobal( | 519 static void _fillNativeBehaviorOfBuiltinOrEmbeddedGlobal( |
| 520 NativeBehavior behavior, | 520 NativeBehavior behavior, |
| 521 Send jsBuiltinOrEmbeddedGlobalCall, | 521 Send jsBuiltinOrEmbeddedGlobalCall, |
| 522 Compiler compiler, | 522 Compiler compiler, |
| 523 ResolverVisitor resolver, | 523 ForeignResolver resolver, |
| 524 {bool isBuiltin, | 524 {bool isBuiltin, |
| 525 List<String> validTags}) { | 525 List<String> validTags}) { |
| 526 // The first argument of a JS-embedded global call is a string encoding | 526 // The first argument of a JS-embedded global call is a string encoding |
| 527 // the type of the code. | 527 // the type of the code. |
| 528 // | 528 // |
| 529 // 'Type1|Type2'. A union type. | 529 // 'Type1|Type2'. A union type. |
| 530 // '=Object'. A JavaScript Object, no subtype. | 530 // '=Object'. A JavaScript Object, no subtype. |
| 531 | 531 |
| 532 String builtinOrGlobal = isBuiltin ? "builtin" : "embedded global"; | 532 String builtinOrGlobal = isBuiltin ? "builtin" : "embedded global"; |
| 533 | 533 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 resolveType: resolveType, | 579 resolveType: resolveType, |
| 580 setSideEffects: setSideEffects, | 580 setSideEffects: setSideEffects, |
| 581 typesReturned: behavior.typesReturned, | 581 typesReturned: behavior.typesReturned, |
| 582 typesInstantiated: behavior.typesInstantiated, | 582 typesInstantiated: behavior.typesInstantiated, |
| 583 objectType: compiler.objectClass.computeType(compiler), | 583 objectType: compiler.objectClass.computeType(compiler), |
| 584 nullType: compiler.nullClass.computeType(compiler)); | 584 nullType: compiler.nullClass.computeType(compiler)); |
| 585 } | 585 } |
| 586 | 586 |
| 587 static NativeBehavior ofJsBuiltinCall(Send jsBuiltinCall, | 587 static NativeBehavior ofJsBuiltinCall(Send jsBuiltinCall, |
| 588 Compiler compiler, | 588 Compiler compiler, |
| 589 ResolverVisitor resolver) { | 589 ForeignResolver resolver) { |
| 590 NativeBehavior behavior = new NativeBehavior(); | 590 NativeBehavior behavior = new NativeBehavior(); |
| 591 behavior.sideEffects.setTo(new SideEffects()); | 591 behavior.sideEffects.setTo(new SideEffects()); |
| 592 | 592 |
| 593 _fillNativeBehaviorOfBuiltinOrEmbeddedGlobal( | 593 _fillNativeBehaviorOfBuiltinOrEmbeddedGlobal( |
| 594 behavior, jsBuiltinCall, compiler, resolver, isBuiltin: true); | 594 behavior, jsBuiltinCall, compiler, resolver, isBuiltin: true); |
| 595 | 595 |
| 596 return behavior; | 596 return behavior; |
| 597 } | 597 } |
| 598 | 598 |
| 599 static NativeBehavior ofJsEmbeddedGlobalCall(Send jsEmbeddedGlobalCall, | 599 static NativeBehavior ofJsEmbeddedGlobalCall(Send jsEmbeddedGlobalCall, |
| 600 Compiler compiler, | 600 Compiler compiler, |
| 601 ResolverVisitor resolver) { | 601 ForeignResolver resolver) { |
| 602 NativeBehavior behavior = new NativeBehavior(); | 602 NativeBehavior behavior = new NativeBehavior(); |
| 603 // TODO(sra): Allow the use site to override these defaults. | 603 // TODO(sra): Allow the use site to override these defaults. |
| 604 // Embedded globals are usually pre-computed data structures or JavaScript | 604 // Embedded globals are usually pre-computed data structures or JavaScript |
| 605 // functions that never change. | 605 // functions that never change. |
| 606 behavior.sideEffects.setTo(new SideEffects.empty()); | 606 behavior.sideEffects.setTo(new SideEffects.empty()); |
| 607 behavior.throwBehavior = NativeThrowBehavior.NEVER; | 607 behavior.throwBehavior = NativeThrowBehavior.NEVER; |
| 608 | 608 |
| 609 _fillNativeBehaviorOfBuiltinOrEmbeddedGlobal( | 609 _fillNativeBehaviorOfBuiltinOrEmbeddedGlobal( |
| 610 behavior, jsEmbeddedGlobalCall, compiler, resolver, | 610 behavior, jsEmbeddedGlobalCall, compiler, resolver, |
| 611 isBuiltin: false, | 611 isBuiltin: false, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 MessageKind.GENERIC, | 774 MessageKind.GENERIC, |
| 775 {'text': "Type '$typeString' not found."}); | 775 {'text': "Type '$typeString' not found."}); |
| 776 return const DynamicType(); | 776 return const DynamicType(); |
| 777 } | 777 } |
| 778 | 778 |
| 779 static _errorNode(locationNodeOrElement, compiler) { | 779 static _errorNode(locationNodeOrElement, compiler) { |
| 780 if (locationNodeOrElement is Node) return locationNodeOrElement; | 780 if (locationNodeOrElement is Node) return locationNodeOrElement; |
| 781 return locationNodeOrElement.parseNode(compiler); | 781 return locationNodeOrElement.parseNode(compiler); |
| 782 } | 782 } |
| 783 } | 783 } |
| OLD | NEW |