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

Unified Diff: pkg/compiler/lib/src/js_model/closure.dart

Issue 3010473002: Adding JRecord and boxing mechanics.
Patch Set: .. Created 3 years, 4 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/js_model/closure.dart
diff --git a/pkg/compiler/lib/src/js_model/closure.dart b/pkg/compiler/lib/src/js_model/closure.dart
index 8ecb8b571bcc1c56b316a461e344d038ef51e98f..fc4cf00e70092dd25077b4c03035e04966a61684 100644
--- a/pkg/compiler/lib/src/js_model/closure.dart
+++ b/pkg/compiler/lib/src/js_model/closure.dart
@@ -388,14 +388,14 @@ class KernelClosureClass extends JsScopeInfo
@override
void forEachBoxedVariable(f(Local local, JField field)) {
for (Local l in localToFieldMap.keys) {
- if (localToFieldMap[l] is JBoxedField) f(l, localToFieldMap[l]);
+ if (localToFieldMap[l] is JRecord) f(l, localToFieldMap[l]);
}
}
void forEachFreeVariable(f(Local variable, JField field)) {
for (Local l in localToFieldMap.keys) {
var jField = localToFieldMap[l];
- if (jField is! JBoxedField && jField is! BoxLocal) f(l, jField);
+ if (jField is! JRecord && jField is! BoxLocal) f(l, jField);
}
}
@@ -437,18 +437,39 @@ class JClosureField extends JField {
isStatic: false);
}
-/// A ClosureField that has been "boxed" to prevent name shadowing with the
+/// A container for variables declared in a particular scope that are accessed
+/// elsewhere.
+// TODO(efortuna, johnniwinther): Don't implement JClass. This isn't actually a
+// class.
+class JRecordContainer implements JClass {
+ final JLibrary library;
+ final String name;
+
+ /// Index into the classData, classList and classEnvironment lists where this
+ /// entity is stored in [JsToFrontendMapImpl].
+ final int classIndex;
+
+ JRecordContainer(this.library, this.classIndex, this.name);
+
+ bool get isAbstract => false;
+
+ bool get isClosure => false;
+
+ String toString() => '${jsElementPrefix}record_container($name)';
+}
+
+/// A variable that has been "boxed" to prevent name shadowing with the
/// original variable and ensure that this variable is updated/read with the
/// most recent value.
/// This corresponds to BoxFieldElement; we reuse BoxLocal from the original
/// algorithm to correspond to the actual name of the variable.
-class JBoxedField extends JField {
+class JRecord extends JField {
final BoxLocal box;
- JBoxedField(String name, int memberIndex, this.box, JClass containingClass,
- bool isConst, bool isAssignable)
+ JRecord(String name, int memberIndex, this.box, JClass containingClass,
+ bool isConst)
: super(memberIndex, containingClass.library, containingClass,
new Name(name, containingClass.library),
- isAssignable: isAssignable, isConst: isConst);
+ isStatic: false, isAssignable: true, isConst: isConst);
}
class ClosureClassDefinition implements ClassDefinition {
@@ -548,6 +569,21 @@ class ClosureMemberDefinition implements MemberDefinition {
'ClosureMemberDefinition(kind:$kind,member:$member,location:$location)';
}
+class RecordContainerDefinition implements ClassDefinition {
+ final ClassEntity cls;
+ final SourceSpan location;
+
+ RecordContainerDefinition(this.cls, this.location);
+
+ ClassKind get kind => ClassKind.container;
+
+ ir.Node get node =>
+ throw new UnsupportedError('RecordContainerDefinition.node for $cls');
+
+ String toString() =>
+ 'RecordContainerDefinition(kind:$kind,cls:$cls,location:$location)';
+}
+
/// Collection of scope data collected for a single member.
class ScopeModel {
/// Collection [ScopeInfo] data for the member.
« no previous file with comments | « pkg/compiler/lib/src/js_backend/field_naming_mixin.dart ('k') | pkg/compiler/lib/src/kernel/element_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698