зеркало из https://github.com/mozilla/pluotsorbet.git
Remove tags directly handled in the interpreter from ConstantPool::resolve; remove unused constantValue getter from FieldInfo
This commit is contained in:
Родитель
819eb8b7b0
Коммит
f4883da4d4
47
vm/parser.ts
47
vm/parser.ts
|
@ -238,7 +238,7 @@ module J2ME {
|
|||
var o = this.offset + offset;
|
||||
return b[o] << 8 | b[o + 1];
|
||||
}
|
||||
|
||||
|
||||
clone() {
|
||||
return new ByteStream(this.buffer, this.offset);
|
||||
}
|
||||
|
@ -593,27 +593,12 @@ module J2ME {
|
|||
var s = this, r = this.resolved[i];
|
||||
if (r === undefined) {
|
||||
var tag = this.seekTag(i);
|
||||
release || Debug.assert(expectedTag === TAGS.CONSTANT_Any || expectedTag === tag || (expectedTag === TAGS.CONSTANT_Methodref && tag === TAGS.CONSTANT_InterfaceMethodref), "bad expectedTag in resolve");
|
||||
release || Debug.assert(expectedTag === TAGS.CONSTANT_Any || expectedTag === tag ||
|
||||
(expectedTag === TAGS.CONSTANT_Methodref && tag === TAGS.CONSTANT_InterfaceMethodref), "bad expectedTag in resolve");
|
||||
switch (s.readU1()) {
|
||||
case TAGS.CONSTANT_Integer:
|
||||
r = this.resolved[i] = s.readS4();
|
||||
break;
|
||||
case TAGS.CONSTANT_Float:
|
||||
r = this.resolved[i] = IntegerUtilities.int32ToFloat(s.readS4());
|
||||
break;
|
||||
case TAGS.CONSTANT_String:
|
||||
r = this.resolved[i] = $.newStringConstant(ByteStream.UTF8toUTF16(this.resolveUtf8(s.readU2())));
|
||||
break;
|
||||
case TAGS.CONSTANT_Long:
|
||||
var high = s.readS4();
|
||||
var low = s.readS4();
|
||||
// REDUX
|
||||
//r = this.resolved[i] = Long.fromBits(low, high);
|
||||
Debug.error("TODO constant pool longs");
|
||||
break;
|
||||
case TAGS.CONSTANT_Double:
|
||||
r = this.resolved[i] = IntegerUtilities.int64ToDouble(s.readS4(), s.readS4());
|
||||
break;
|
||||
case TAGS.CONSTANT_String:
|
||||
r = this.resolved[i] = $.newStringConstant(ByteStream.UTF8toUTF16(this.resolveUtf8(s.readU2())));
|
||||
break;
|
||||
case TAGS.CONSTANT_Utf8:
|
||||
r = this.resolved[i] = s.readInternedBytes(s.readU2());
|
||||
break;
|
||||
|
@ -643,7 +628,7 @@ module J2ME {
|
|||
this.resolved[i] = r;
|
||||
break;
|
||||
default:
|
||||
assert(false, "bad type in resolve");
|
||||
assert(false, "bad type (" + expectedTag + ") in resolve");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -672,7 +657,6 @@ module J2ME {
|
|||
public utf8Signature: Uint8Array;
|
||||
public mangledName: string = null;
|
||||
public accessFlags: ACCESS_FLAGS;
|
||||
private _constantvalue_index: number = -1;
|
||||
fTableIndex: number = -1;
|
||||
|
||||
constructor(classInfo: ClassInfo, offset: number) {
|
||||
|
@ -700,20 +684,11 @@ module J2ME {
|
|||
var o = s.offset;
|
||||
var attribute_name = this.classInfo.constantPool.resolveUtf8(attribute_name_index);
|
||||
if (strcmp(attribute_name, UTF8.ConstantValue)) {
|
||||
release || assert(attribute_length === 2, "Attribute length of ConstantValue must be 2.")
|
||||
this._constantvalue_index = s.readU2();
|
||||
release || assert(attribute_length === 2, "Attribute length of ConstantValue must be 2.");
|
||||
}
|
||||
s.seek(o + attribute_length);
|
||||
}
|
||||
}
|
||||
|
||||
get constantValue(): any {
|
||||
if (this._constantvalue_index >= 0) {
|
||||
// This is not a very frequently called method, so no need to cache the resolved value.
|
||||
return this.classInfo.constantPool.resolve(this._constantvalue_index, TAGS.CONSTANT_Any);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class SourceLocation {
|
||||
|
@ -1461,7 +1436,7 @@ module J2ME {
|
|||
if (i >= 0) {
|
||||
return c.getFieldByIndex(i);
|
||||
}
|
||||
|
||||
|
||||
if (isStatic) {
|
||||
var interfaces = c.getAllInterfaces();
|
||||
for (var n = 0; n < interfaces.length; ++n) {
|
||||
|
@ -1511,7 +1486,7 @@ module J2ME {
|
|||
this.resolvedFlags |= ResolvedFlags.Interfaces;
|
||||
return <ClassInfo []>this.interfaces;
|
||||
}
|
||||
|
||||
|
||||
getAllInterfaces(): ClassInfo [] {
|
||||
if (this.allInterfaces) {
|
||||
return this.allInterfaces;
|
||||
|
@ -1647,7 +1622,7 @@ module J2ME {
|
|||
this.bytesPerElement = bytesPerElement;
|
||||
this.complete();
|
||||
}
|
||||
|
||||
|
||||
static initialize() {
|
||||
// Primitive array classes require the java_lang_Object to exists before they can be created.
|
||||
PrimitiveArrayClassInfo.Z = new PrimitiveArrayClassInfo(PrimitiveClassInfo.Z, "ZArray", 1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче