Don't use forEach in class constructor.

This commit is contained in:
Michael Bebenita 2014-12-18 14:24:08 -08:00
Родитель 205115200c
Коммит 9818bbbb5e
1 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -212,26 +212,30 @@ module J2ME {
var self = this;
this.interfaces = [];
classImage.interfaces.forEach(function (i) {
var int = CLASSES.loadClass(cp[cp[i].name_index].bytes);
for (var i = 0; i < classImage.interfaces.length; i++) {
var j = classImage.interfaces[i];
var int = CLASSES.loadClass(cp[cp[j].name_index].bytes);
self.interfaces.push(int);
self.interfaces = self.interfaces.concat(int.interfaces);
});
}
this.fields = [];
classImage.fields.forEach(function (f) {
for (var i = 0; i < classImage.fields.length; i++) {
var f = classImage.fields[i];
var field = new FieldInfo(self, f.access_flags, cp[f.name_index].bytes, cp[f.descriptor_index].bytes);
f.attributes.forEach(function (attribute) {
if (cp[attribute.attribute_name_index].bytes === "ConstantValue")
field.constantValue = new DataView(attribute.info).getUint16(0, false);
});
self.fields.push(field);
});
}
enterTimeline("methods");
this.methods = [];
classImage.methods.forEach(function (m) {
self.methods.push(new MethodInfo({
for (var i = 0; i < classImage.methods.length; i++) {
var m = classImage.methods[i];
this.methods.push(new MethodInfo({
name: cp[m.name_index].bytes,
signature: cp[m.signature_index].bytes,
classInfo: self,
@ -241,11 +245,12 @@ module J2ME {
isStatic: AccessFlags.isStatic(m.access_flags),
isSynchronized: AccessFlags.isSynchronized(m.access_flags)
}));
});
}
leaveTimeline("methods");
var classes = this.classes = [];
classImage.attributes.forEach(function (a) {
for (var i = 0; i < classImage.attributes.length; i++) {
var a = classImage.attributes[i];
if (a.info.type === ATTRIBUTE_TYPES.InnerClasses) {
a.info.classes.forEach(function (c) {
classes.push(cp[cp[c.inner_class_info_index].name_index].bytes);
@ -255,7 +260,7 @@ module J2ME {
} else if (a.info.type === ATTRIBUTE_TYPES.SourceFile) {
self.sourceFile = cp[a.info.sourcefile_index].bytes;
}
});
}
}
public complete() {