Chromium Code Reviews| Index: pkg/compiler/lib/src/native/behavior.dart |
| diff --git a/pkg/compiler/lib/src/native/behavior.dart b/pkg/compiler/lib/src/native/behavior.dart |
| index 903aecc52ffab31d900843c0b26a431f960f64e3..673bf42e3ca20004e0fd7df3db29a8871b5b5ac5 100644 |
| --- a/pkg/compiler/lib/src/native/behavior.dart |
| +++ b/pkg/compiler/lib/src/native/behavior.dart |
| @@ -28,6 +28,15 @@ class SpecialType { |
| static const JsObject = const SpecialType._('=Object'); |
| int get hashCode => name.hashCode; |
| + |
| + static SpecialType fromName(String name) { |
| + switch (name) { |
| + case '=Object': |
| + return JsObject; |
| + default: |
|
Siggi Cherem (dart-lang)
2016/04/18 16:48:54
do you expect to add more cases in the future?
If
Johnni Winther
2016/04/20 10:12:55
I don't know. Stephen might. Making it an if-else
|
| + throw new UnsupportedError("Unknown SpecialType '$name'."); |
| + } |
| + } |
| } |
| /// Description of the exception behaviour of native code. |
| @@ -70,6 +79,21 @@ class NativeThrowBehavior { |
| if (this == MUST) return 'must'; |
| return 'NativeThrowBehavior($_bits)'; |
| } |
| + |
| + /// Canonical list of marker values. |
| + /// |
| + /// Added to make [NativeThrowBehavior] enum-like. |
| + static const List<NativeThrowBehavior> values = const <NativeThrowBehavior>[ |
| + NEVER, |
| + MAY_THROW_ONLY_ON_FIRST_ARGUMENT_ACCESS, |
| + MAY, |
| + MUST, |
| + ]; |
| + |
| + /// Index to this marker within [values]. |
| + /// |
| + /// Added to make [NativeThrowBehavior] enum-like. |
| + int get index => values.indexOf(this); |
| } |
| /** |
| @@ -109,11 +133,12 @@ class NativeBehavior { |
| /// [DartType]s or [SpecialType]s instantiated by the native element. |
| final List typesInstantiated = []; |
| + String codeTemplateText; |
| // If this behavior is for a JS expression, [codeTemplate] contains the |
| // parsed tree. |
| js.Template codeTemplate; |
| - final SideEffects sideEffects = new SideEffects.empty(); |
| + final SideEffects sideEffects; |
| NativeThrowBehavior throwBehavior = NativeThrowBehavior.MAY; |
| @@ -128,6 +153,10 @@ class NativeBehavior { |
| static NativeBehavior get CHANGES_OTHER => NativeBehavior._makeChangesOther(); |
| static NativeBehavior get DEPENDS_OTHER => NativeBehavior._makeDependsOther(); |
| + NativeBehavior() : sideEffects = new SideEffects.empty(); |
| + |
| + NativeBehavior.internal(this.sideEffects); |
| + |
| String toString() { |
| return 'NativeBehavior(' |
| 'returns: ${typesReturned}' |
| @@ -490,8 +519,8 @@ class NativeBehavior { |
| return behavior; |
| } |
| - behavior.codeTemplate = |
| - js.js.parseForeignJS(codeArgument.dartString.slowToString()); |
| + behavior.codeTemplateText = codeArgument.dartString.slowToString(); |
| + behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); |
| String specString = specArgument.dartString.slowToString(); |