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