Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1480)

Unified Diff: pkg/compiler/lib/src/native/behavior.dart

Issue 1896843002: Store and serialize NativeBehavior in TreeElements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..daa6ddc920cee80e287765dc58fdc1b428087b71 100644
--- a/pkg/compiler/lib/src/native/behavior.dart
+++ b/pkg/compiler/lib/src/native/behavior.dart
@@ -28,6 +28,14 @@ class SpecialType {
static const JsObject = const SpecialType._('=Object');
int get hashCode => name.hashCode;
+
+ static SpecialType fromName(String name) {
+ if (name == '=Object') {
+ return JsObject;
+ } else {
+ throw new UnsupportedError("Unknown SpecialType '$name'.");
+ }
+ }
}
/// Description of the exception behaviour of native code.
@@ -70,6 +78,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 +132,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 +152,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 +518,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();
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend_serialization.dart ('k') | pkg/compiler/lib/src/native/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698