export enum MsgType { EOM = 0x00 , REQ = 0x01 , REP = 0x02 , ERR = 0x03 , NFY = 0x04 } export enum DvalIB { EOM = MsgType . EOM , REQ = MsgType . REQ , REP = MsgType . REP , ERR = MsgType . ERR , NFY = MsgType . NFY , INT32 = 0x10 , STR32 = 0x11 , STR16 = 0x12 , BUF32 = 0x13 , BUF16 = 0x14 , UNUSED = 0x15 , UNDEFINED = 0x16 , NULL = 0x17 , TRUE = 0x18 , FALSE = 0x19 , NUMBER = 0x1a , OBJECT = 0x1b , POINTER = 0x1c , LIGHTFUNC = 0x1d , HEAPPTR = 0x1e , STRV_MIN = 0x60 , STRV_MAX = 0x7f , INTV_SM_MIN = 0x80 , INTV_SM_MAX = 0xbf , INTV_LRG_MIN = 0xc0 , INTV_LRG_MAX = 0xff } export enum NotifyType { STATUS = 0x01 , PRINT = 0x02 , ALERT = 0x03 , LOG = 0x04 , THROW = 0x05 , DETACHING = 0x06 , APP_MSG = 0x07 } export enum CmdType { BASICINFO = 0x10 , TRIGGERSTATUS = 0x11 , PAUSE = 0x12 , RESUME = 0x13 , STEPINTO = 0x14 , STEPOVER = 0x15 , STEPOUT = 0x16 , LISTBREAK = 0x17 , ADDBREAK = 0x18 , DELBREAK = 0x19 , GETVAR = 0x1a , PUTVAR = 0x1b , GETCALLSTACK = 0x1c , GETLOCALS = 0x1d , EVAL = 0x1e , DETACH = 0x1f , DUMPHEAP = 0x20 , GETBYTECODE = 0x21 , APPCOMMAND = 0x22 , GETHEAPOBJINFO = 0x23 , GETOBJPROPDESC = 0x24 , GETOBJPROPDESCRANGE = 0x25 , GETSCOPEKEYS = 0x7f } export enum PropDescFlag { ATTR_WRITABLE = 0x01 , ATTR_ENUMERABLE = 0x02 , ATTR_CONFIGURABLE = 0x04 , ATTR_ACCESSOR = 0x08 , VIRTUAL = 0x10 , INTERNAL = 0x100 } export enum ErrorType { UNKNOWN = 0x00 , UNSUPPORTED = 0x01 , TOOMANY = 0x02 , NOTFOUND = 0x03 , APP_ERROR = 0x04 } export const ERR_TYPE_MAP = [ "Unknown or unspecified error" , "Unsupported command" , "Too many" , "Not found" , "Application error (e.g. AppRequest-related error)" ] ; export enum DValKind { EOM = 0 , REQ , REP , ERR , NFY , int , str , buf , ptr , tval , unused , undef , nul , num } export enum TValueType { UNUSED , UNDEFINED , NULL , BOOLEAN , NUMBER , STRING , BUFFER , OBJECT , POINTER , LIGHTFUNC } export class TValPointer { public size : number ; public lopart : number ; public hipart : number ; public constructor ( size , lopart , hipart ) { this . size = size ; this . lopart = lopart ; this . hipart = hipart ; } public isNull ( ) { return this . size === 0 ; } public static NullPtr ( ) { return new TValPointer ( 0 , 0 , 0 ) ; } public static TryConvert ( obj ) { if ( obj instanceof TValPointer ) { return < TValPointer > obj ; } else if ( obj instanceof TValObject ) { return ( < TValObject > obj ) . ptr ; } else if ( obj instanceof TValLightFunc ) { return ( < TValLightFunc > obj ) . ptr ; } else if ( obj instanceof TValue ) { return TValPointer . TryConvert ( ( < TValue > obj ) . val ) ; } else { return null ; } } public toString ( ) { return this . size === 4 ? `0x${ this . toPaddedHex ( this . lopart ) }` : `0x${ this . toPaddedHex ( this . hipart ) }${ this . toPaddedHex ( this . lopart ) }` ; } private toPaddedHex ( n ) { let s = n . toString ( 16 ) ; let z = "" ; let c = 8 - s . length ; for ( let i = 0 ; i < c ; i ++ ) { z += "0" ; } return z + s ; } } export class TValObject { public classID : number ; public ptr : TValPointer ; public constructor ( classID , ptr ) { this . classID = classID ; this . ptr = ptr ; } public toString ( ) { return `{ cls: ${ this . classID }, ptr: ${ this . ptr . toString ( ) } }` ; } } export class TValLightFunc { public flags : number ; public ptr : TValPointer ; public constructor ( flags , ptr ) { this . flags = flags ; this . ptr = ptr ; } public toString ( ) { return `{ flags: ${ this . flags }, ptr: ${ this . ptr . toString ( ) } }` ; } } export type TValueUnion = boolean | number | string | TValPointer | TValObject | TValLightFunc | Buffer ; export class TValue { type : TValueType ; val : TValueUnion ; constructor ( type , val ) { this . type = type ; this . val = val ; } public static Unused ( ) { return new TValue ( TValueType . UNUSED , undefined ) ; } public static Undefined ( ) { return new TValue ( TValueType . UNDEFINED , undefined ) ; } public static Null ( ) { return new TValue ( TValueType . NULL , null ) ; } public static Bool ( val ) { return new TValue ( TValueType . BOOLEAN , val ) ; } public static Number ( val ) { return new TValue ( TValueType . NUMBER , val ) ; } public static String ( val ) { return new TValue ( TValueType . STRING , val ) ; } public static Buffer ( val ) { return new TValue ( TValueType . BUFFER , val ) ; } public static Object ( classID , ptr ) { return new TValue ( TValueType . OBJECT , new TValObject ( classID , ptr ) ) ; } public static Pointer ( ptr ) { return new TValue ( TValueType . POINTER , ptr ) ; } public static LightFunc ( val ) { return new TValue ( TValueType . LIGHTFUNC , val ) ; } } export type DValueUnion = boolean | number | string | Buffer | TValPointer | TValObject | TValLightFunc ; export class DValue { public type : DValKind ; public value : DValueUnion ; constructor ( type , value ) { this . type = type ; this . value = value ; } } export class Property { flags : number ; key : string | number ; value : DValueUnion ; getter : TValObject ; setter : TValObject ; public get isAccessor ( ) : boolean { return ( this . flags & PropDescFlag . ATTR_ACCESSOR ) !== 0 ; } }