UNPKG

@bscotch/gml-parser

Version:

A parser for GML (GameMaker Language) files for programmatic manipulation and analysis of GameMaker projects.

50 lines 4.01 kB
import type { Signifier } from './signifiers.js'; import { KnownTypesMap } from './types.feather.js'; import { Type, TypeStore } from './types.js'; import { PrimitiveName } from './types.primitives.js'; export declare function isTypeOfKind<T extends PrimitiveName>(item: any, kind: T): item is Type<T>; export declare function isTypeStoreOfKind<T extends PrimitiveName>(item: any, kind: T): item is TypeStore<T>; export declare function isTypeOrStoreOfKind<T extends PrimitiveName>(item: any, kind: T): item is Type<T> | TypeStore<T>; /** * Given some kind of type collection, find the first one matching * a given kind. */ export declare function getTypeOfKind<T extends PrimitiveName>(from: undefined | Signifier | Type | TypeStore | (Type | TypeStore)[], kind: T | ReadonlyArray<T>): { [Kind in T]: Type<Kind>; }[T] | undefined; export declare function getTypesOfKind<T extends PrimitiveName>(from: undefined | Signifier | Type | TypeStore | (Type | TypeStore)[], kind: T | ReadonlyArray<T>): { [Kind in T]: Type<Kind>; }[T][]; /** Get the typestore of item, if present. Else get the type on item. */ export declare function getTypeStoreOrType(item: Signifier | Type | TypeStore | Type[]): TypeStore | Type[]; /** Things that can be converted into an array of types */ export type Typeable = Signifier | Type | TypeStore | (Type | TypeStore)[]; export declare function getTypes(items: Typeable | undefined): Type[]; export declare function isTypeInstance(item: any): item is Type; export declare function isTypeStore(item: any): item is TypeStore; /** * Returns `true` if `narrowed` is a subtype of `type`, * meaning that it is a subset/narrowed/compatible/same type * compared to otherType. * * Identical types also return `true`. */ export declare function narrows(narrowType: Type | TypeStore | Type[], broadType: Type | TypeStore | Type[]): boolean; /** * For types inferred from expressions, normalize away utility * types like `InstanceType` and `ObjectType`, and perform any * other type-normalization tasks. Returns a new TypeStore, so * if maintaining reference links is essential this function should * not be used. */ export declare function normalizeType(inferred: Typeable, knownTypes: KnownTypesMap): TypeStore; /** * Given an expected type that might include generics, and an inferred * type that should map onto it, update a generics map linking generics * to inferred types by name. */ export declare function updateGenericsMap(expected: Typeable, inferred: Typeable, knownTypes: KnownTypesMap, /** Map of generics by name to their *inferred type* */ generics?: Map<string, TypeStore>): Map<string, TypeStore<"Real" | "Undefined" | "Enum" | "Function" | "Array" | "Bool" | "Pointer" | "String" | "Struct" | "ArgumentIdentity" | "Any" | "Asset.GMAnimCurve" | "Asset.GMAudioGroup" | "Asset.GMFont" | "Asset.GMObject" | "Asset.GMParticleSystem" | "Asset.GMPath" | "Asset.GMRoom" | "Asset.GMScript" | "Asset.GMSequence" | "Asset.GMShader" | "Asset.GMSound" | "Asset.GMSprite" | "Asset.GMTileSet" | "Asset.GMTimeline" | "Asset.Script" | "Id.AudioEmitter" | "Id.AudioListener" | "Id.AudioSyncGroup" | "Id.BackgroundElement" | "Id.BinaryFile" | "Id.Buffer" | "Id.Camera" | "Id.DsGrid" | "Id.DsList" | "Id.DsMap" | "Id.DsPriority" | "Id.DsQueue" | "Id.DsStack" | "Id.ExternalCall" | "Id.Gif" | "Id.Instance" | "Id.Layer" | "Id.MpGrid" | "Id.ParticleEmitter" | "Id.ParticleSystem" | "Id.ParticleType" | "Id.PhysicsIndex" | "Id.PhysicsParticleGroup" | "Id.Sampler" | "Id.SequenceElement" | "Id.Socket" | "Id.Sound" | "Id.SpriteElement" | "Id.Surface" | "Id.TextFile" | "Id.Texture" | "Id.TileElementId" | "Id.TileMapElement" | "Id.TimeSource" | "Id.Uniform" | "Id.VertexBuffer" | "Id.VertexFormat" | "Mixed" | "EnumMember" | "Unknown" | "Never" | "InstanceType" | "ObjectType" | "StaticType">>; export declare function replaceGenerics(startingType: Typeable, knownTypes: KnownTypesMap, generics: Map<string, TypeStore>): TypeStore; //# sourceMappingURL=types.checks.d.ts.map