lookup field in getstatic/putstatic

This commit is contained in:
Andreas Gal 2014-07-29 03:43:12 -07:00
Родитель 66403f1e7d
Коммит 68032ec1b1
2 изменённых файлов: 9 добавлений и 7 удалений

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

@ -25,6 +25,7 @@ var ClassInfo = function(classBytes) {
this.fields = [];
classImage.fields.forEach(function(f) {
self.fields.push({
classInfo: self,
access_flags: f.access_flags,
name: cp[f.name_index].bytes,
signature: cp[f.descriptor_index].bytes,

15
vm.js
Просмотреть файл

@ -859,22 +859,23 @@ VM.execute = function(ctx) {
var className = cp[cp[cp[idx].class_index].name_index].bytes;
var fieldName = cp[cp[cp[idx].name_and_type_index].name_index].bytes;
var signature = cp[cp[cp[idx].name_and_type_index].signature_index].bytes;
var classInfo = CLASSES.getClass(className);
classInitCheck(classInfo, frame.ip-3);
var value = classInfo.staticFields[fieldName];
var field = CLASSES.getField(className, fieldName, signature, true);
classInitCheck(field.classInfo, frame.ip-3);
var value = field.classInfo.staticFields[field.name];
if (typeof value === "undefined") {
value = util.defaultValue(signature);
value = util.defaultValue(field.signature);
}
stack.pushType(signature, value);
stack.pushType(field.signature, value);
break;
case 0xb3: // putstatic
var idx = frame.read16();
var className = cp[cp[cp[idx].class_index].name_index].bytes;
var fieldName = cp[cp[cp[idx].name_and_type_index].name_index].bytes;
var signature = cp[cp[cp[idx].name_and_type_index].signature_index].bytes;
var field = CLASSES.getField(className, fieldName, signature, true);
var classInfo = CLASSES.getClass(className);
classInitCheck(classInfo, frame.ip-3);
classInfo.staticFields[fieldName] = stack.popType(signature);
classInitCheck(field.classInfo, frame.ip-3);
field.classInfo.staticFields[field.name] = stack.popType(field.signature);
break;
case 0xbb: // new
var idx = frame.read16();