import { getOpcode } from "./opcodes" ; import { LibSdbTypes } from "../types/types" ; export function nameOpCodes ( raw ) { let result = new Map < number , LibSdbTypes . EvmInstruction > ( ) ; for ( let i = 0 ; i < raw . length ; i ++ ) { let pc = i ; let curOpCode = getOpcode ( raw [ pc ] , false ) ; if ( curOpCode . name . slice ( 0 , 4 ) === 'PUSH' ) { let jumpNum = raw [ pc ] - 0x5f ; i += jumpNum ; } result . set ( pc , < LibSdbTypes . EvmInstruction > { index : result . size , opcode : curOpCode } ) ; } return result ; } export function pad ( num , size ) { let s = num + '' ; while ( s . length < size ) { s = '0' + s ; } return s ; } export function log ( num , base ) { return Math . log ( num ) / Math . log ( base ) ; } export function roundLog ( num , base ) { return Math . ceil ( log ( num , base ) ) ; }