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

Unified Diff: lib/compiler/implementation/js_backend/emitter.dart

Issue 10917285: Stub implementation of patch invariants for the patch refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 3 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
« no previous file with comments | « lib/compiler/implementation/js_backend/backend.dart ('k') | lib/compiler/implementation/patch_parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/js_backend/emitter.dart
diff --git a/lib/compiler/implementation/js_backend/emitter.dart b/lib/compiler/implementation/js_backend/emitter.dart
index 5f1c11866ca6aff2efa614df5a7cac197d20b4dd..71fae4791c242fbf664147a524141f48b49af7c8 100644
--- a/lib/compiler/implementation/js_backend/emitter.dart
+++ b/lib/compiler/implementation/js_backend/emitter.dart
@@ -498,8 +498,14 @@ function(prototype, staticName, fieldName, getterName, lazyValue) {
: namer.getName(member);
}
+ /**
+ * Documentation wanted -- johnniwinther
+ *
+ * Invariant: [member] must be a declaration element.
+ */
void addInstanceMember(Element member,
DefineMemberFunction defineInstanceMember) {
+ assert(invariant(member, member.isDeclaration));
// TODO(floitsch): we don't need to deal with members of
// uninstantiated classes, that have been overwritten by subclasses.
@@ -544,7 +550,13 @@ function(prototype, staticName, fieldName, getterName, lazyValue) {
}
}
+ /**
+ * Documentation wanted -- johnniwinther
+ *
+ * Invariant: [classElement] must be a declaration element.
+ */
List<String> emitClassFields(ClassElement classElement, CodeBuffer buffer) {
+ assert(invariant(classElement, classElement.isDeclaration));
// If the class is never instantiated we still need to set it up for
// inheritance purposes, but we can simplify its JavaScript constructor.
bool isInstantiated =
@@ -554,6 +566,7 @@ function(prototype, staticName, fieldName, getterName, lazyValue) {
bool isFirstField = true;
void addField(ClassElement enclosingClass, Element member) {
assert(!member.isNative());
+ assert(invariant(classElement, member.isDeclaration));
LibraryElement library = member.getLibrary();
SourceString name = member.name;
@@ -618,9 +631,15 @@ function(prototype, staticName, fieldName, getterName, lazyValue) {
return checkedSetters;
}
+ /**
+ * Documentation wanted -- johnniwinther
+ *
+ * Invariant: [classElement] must be a declaration element.
+ */
void emitInstanceMembers(ClassElement classElement,
CodeBuffer buffer,
bool needsLeadingComma) {
+ assert(invariant(classElement, classElement.isDeclaration));
bool needsComma = needsLeadingComma;
void defineInstanceMember(String name, CodeBuffer memberBuffer) {
if (needsComma) buffer.add(',');
@@ -632,6 +651,7 @@ function(prototype, staticName, fieldName, getterName, lazyValue) {
classElement.forEachMember(includeBackendMembers: true,
f: (ClassElement enclosing, Element member) {
+ assert(invariant(classElement, member.isDeclaration));
if (member.isInstanceMember()) {
addInstanceMember(member, defineInstanceMember);
}
@@ -660,7 +680,13 @@ function(prototype, staticName, fieldName, getterName, lazyValue) {
}
}
+ /**
+ * Documentation wanted -- johnniwinther
+ *
+ * Invariant: [classElement] must be a declaration element.
+ */
void generateClass(ClassElement classElement, CodeBuffer buffer) {
+ assert(invariant(classElement, classElement.isDeclaration));
if (classElement.isNative()) {
nativeEmitter.generateNativeClass(classElement);
return;
@@ -856,8 +882,14 @@ function(prototype, staticName, fieldName, getterName, lazyValue) {
}
}
+ /**
+ * Documentation wanted -- johnniwinther
+ *
+ * Invariant: [member] must be a declaration element.
+ */
void emitDynamicFunctionGetter(FunctionElement member,
DefineMemberFunction defineInstanceMember) {
+ assert(invariant(member, member.isDeclaration));
// For every method that has the same name as a property-get we create a
// getter that returns a bound closure. Say we have a class 'A' with method
// 'foo' and somewhere in the code there is a dynamic property get of
@@ -940,24 +972,31 @@ $classesCollector.$mangledName = {'':
defineInstanceMember(getterName, getterBuffer);
}
+ /**
+ * Documentation wanted -- johnniwinther
+ *
+ * Invariant: [member] must be a declaration element.
+ */
void emitCallStubForGetter(Element member,
Set<Selector> selectors,
DefineMemberFunction defineInstanceMember) {
+ assert(invariant(member, member.isDeclaration));
+ LibraryElement memberLibrary = member.getLibrary();
String getter;
if (member.isGetter()) {
getter = "this.${namer.getterName(member.getLibrary(), member.name)}()";
} else {
- String name = namer.instanceFieldName(member.getLibrary(), member.name);
+ String name = namer.instanceFieldName(memberLibrary, member.name);
getter = "this.$name";
}
for (Selector selector in selectors) {
if (selector.applies(member, compiler)) {
String invocationName =
- namer.instanceMethodInvocationName(member.getLibrary(), member.name,
+ namer.instanceMethodInvocationName(memberLibrary, member.name,
selector);
SourceString callName = Namer.CLOSURE_INVOCATION_NAME;
String closureCallName =
- namer.instanceMethodInvocationName(member.getLibrary(), callName,
+ namer.instanceMethodInvocationName(memberLibrary, callName,
selector);
List<String> arguments = <String>[];
for (int i = 0; i < selector.argumentCount; i++) {
@@ -1049,8 +1088,14 @@ $classesCollector.$mangledName = {'':
''');
}
+ /**
+ * Documentation wanted -- johnniwinther
+ *
+ * Invariant: [member] must be a declaration element.
+ */
void emitExtraAccessors(Element member,
DefineMemberFunction defineInstanceMember) {
+ assert(invariant(member, member.isDeclaration));
if (member.isGetter() || member.isField()) {
Set<Selector> selectors = compiler.codegenWorld.invokedNames[member.name];
if (selectors !== null && !selectors.isEmpty()) {
« no previous file with comments | « lib/compiler/implementation/js_backend/backend.dart ('k') | lib/compiler/implementation/patch_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698