Small Cleanup
This commit is contained in:
parent
95e24d13fa
commit
fbdd1e2798
@ -134,7 +134,13 @@ export class Size {
|
||||
this.#pointerAligned = pointerAligned;
|
||||
}
|
||||
|
||||
has() {
|
||||
return this.#size !== null;
|
||||
}
|
||||
get() {
|
||||
if (this.#size === null) {
|
||||
throw new Error('No Size Specified');
|
||||
}
|
||||
return this.#size;
|
||||
}
|
||||
set(size: number, isExact: boolean) {
|
||||
|
@ -63,15 +63,17 @@ export class Struct {
|
||||
let size;
|
||||
if (this.#size.isExact()) {
|
||||
// Exact Size Is Specified
|
||||
size = this.#size.get()!;
|
||||
size = this.#size.get();
|
||||
} else {
|
||||
// Specified Size Is A Lower Bound
|
||||
size = this.#getRealSize();
|
||||
if (this.#size.has()) {
|
||||
const specifiedSize = this.#size.get();
|
||||
if (specifiedSize !== null && specifiedSize > size) {
|
||||
if (specifiedSize > size) {
|
||||
size = specifiedSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (round) {
|
||||
size = this.#roundSize(size);
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ export class VTable implements Property {
|
||||
// Check
|
||||
#check() {
|
||||
// Check Size
|
||||
if (this.#size.has()) {
|
||||
const size = this.#size.get();
|
||||
if (size !== null) {
|
||||
const maxMethodCount = size / POINTER_SIZE;
|
||||
if (this.#size.isExact() && maxMethodCount < this.#methods.length) {
|
||||
throw new Error(`VTable Size Too Small: ${toHex(size)}`);
|
||||
@ -112,9 +112,8 @@ export class VTable implements Property {
|
||||
out += `};\n`;
|
||||
|
||||
// Sanity Check Size
|
||||
const rawSize = this.#size.get();
|
||||
const isSizeDefined = this.#size.isExact();
|
||||
const size = isSizeDefined ? rawSize! : (this.#methods.length * POINTER_SIZE);
|
||||
const size = isSizeDefined ? this.#size.get() : (this.#methods.length * POINTER_SIZE);
|
||||
out += assertSize(this.#getName(), size, isSizeDefined);
|
||||
|
||||
// Pointers
|
||||
|
Loading…
Reference in New Issue
Block a user