Skip to content

Commit

Permalink
Added private make method
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderOMara committed Jan 20, 2025
1 parent 457f5e8 commit 5dec7ad
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions macho/universal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { type Const, pointer, type Ptr } from '@hqtsm/struct';
import {
CPU_ARCH_ABI64,
CPU_SUBTYPE_MASK,
CPU_TYPE_ARM,
FAT_CIGAM,
FAT_MAGIC,
MH_CIGAM,
Expand All @@ -9,13 +11,12 @@ import {
MH_MAGIC_64,
PAGE_SIZE,
} from '../const.ts';
import { FatArch } from '../mach/fatarch.ts';
import { FatHeader } from '../mach/fatheader.ts';
import { MachHeader } from '../mach/machheader.ts';
import type { Reader } from '../util/reader.ts';
import { Architecture } from './architecture.ts';
import { FatArch } from '../mach/fatarch.ts';
import { CPU_ARCH_ABI64 } from '../const.ts';
import { CPU_TYPE_ARM } from '../const.ts';
import type { MachO } from './macho.ts';

/**
* Maximum power of 2 alignment amount.
Expand Down Expand Up @@ -395,6 +396,25 @@ export class Universal {
throw new RangeError('Architecture not found');
}

/**
* Validate type of Mach-O.
*
* @param macho Mach-O instance.
* @returns Mach-O instance.
*/
private make(macho: MachO): MachO {
const type = macho.type();
if (!type) {
throw new RangeError('Unknown type');
}
const { mMachType } = this;
if (mMachType && mMachType !== type) {
throw new RangeError('Mismatched type');
}
this.mMachType = type;
return macho;
}

/**
* Guess type of file.
*
Expand Down

0 comments on commit 5dec7ad

Please sign in to comment.