@awayfl/avm2
Version:
Virtual machine for executing AS3 code
99 lines • 3.32 kB
TypeScript
import { ABCFile } from '../abc/lazy/ABCFile';
import { ExceptionInfo } from '../abc/lazy/ExceptionInfo';
import { MethodInfo } from '../abc/lazy/MethodInfo';
import { Multiname } from '../abc/lazy/Multiname';
import { Instruction } from './Instruction';
export declare const enum VAR_KIND {
CONST = "const",
VAR = "var",
LOOKUP = "lookup",
ALIAS = "alias"
}
interface IVar {
pos?: number;
}
interface IConstData extends IVar {
kind: VAR_KIND.CONST;
value: any;
}
interface ILookupData extends IVar {
kind: VAR_KIND.LOOKUP;
scope: number;
type: Multiname | null;
}
interface IAliasData extends IVar {
kind: VAR_KIND.ALIAS;
value: any;
type?: Multiname;
}
interface IVarData extends IVar {
kind: VAR_KIND.VAR;
type: Multiname | null;
}
type TVariableArgument = IConstData | IVarData | IAliasData | ILookupData;
export declare class CompilerState {
private _indent;
private _indentLen;
methodInfo: MethodInfo;
abc: ABCFile;
names: Multiname[];
openTryCatchGroups: ExceptionInfo[][];
mainBlock: string[];
headerBlock: string[];
opcodes: Instruction[];
currentOpcode: Instruction;
thisAliases: Set<string>;
constAliases: Record<string, IConstData | IAliasData>;
localAliases: Record<string, string>;
localTypes: Record<number, Array<Multiname>>;
stackAliases: Record<number, TVariableArgument>;
noHoistMultiname: boolean;
get indent(): string;
setStackAlias(stackIndex: number, alias?: TVariableArgument | null): TVariableArgument;
getStackAlias(stackIndex: number): TVariableArgument | null;
get isPossibleGlobalThis(): boolean;
get canUseRealThis(): boolean;
constructor(methodInfo: MethodInfo);
private init;
evalStackIndex(stackOffset: number): number;
moveIndent(offset: number): string;
getMultinameIndex(nameOrIndex: Multiname | number): number;
/**
* Emit constant assigment, and store it in alias tree
* @param stackIndex
* @param value
* @param isConst - value real primitive const value, not a const alias
*/
emitConst(stackIndex: number, value: any, isConst?: boolean): number;
emitGetLocal(stackIndex: number, localIndex: number): number;
/**
* Push line to main code block and prepend indent automatically
* @param line Line to emit to generated code
* @returns line count
*/
emitMain(line?: string): number;
/**
* Push line to head code block WITHOUT ident, because it not track it
* @param line Line to emit to generated code
* @returns line count
*/
emitHead(line: string, indent?: string): number;
/**
* Emit block begin ({) and move indent right
* @param value string that was emited instead of {
*/
emitBeginMain(value?: string): number;
/**
* Emit block end } and move indent left
*/
emitEndMain(): number;
killConstAliasInstruction(aliases: string[]): void;
getConstAliasMeta(stackOffset: number): IConstData | IAliasData;
getConstAlias(alias: string): string;
isThisAlias(alias: string): boolean;
pushThisAlias(alias: string, from?: string): boolean;
dropAllAliases(): void;
popAnyAlias(stackOrLocal: string): boolean;
}
export {};
//# sourceMappingURL=CompilerState.d.ts.map