How to use the ethereum-types.OpCode.MLoad function in ethereum-types

To help you get started, we’ve selected a few ethereum-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / sol-profiler / src / cost_utils.ts View on Github external
reportMemoryCost(traceInfo: TraceInfo): number {
        const structLogs = traceInfo.trace.structLogs;
        const MEMORY_OPCODES = [OpCode.MLoad, OpCode.MStore, OpCode.MStore8];
        const CALL_DATA_OPCODES = [OpCode.CallDataCopy];
        const memoryLogs = _.filter(structLogs, structLog =>
            _.includes([...MEMORY_OPCODES, ...CALL_DATA_OPCODES], structLog.op),
        );
        const memoryLocationsAccessed = _.map(memoryLogs, structLog => {
            if (_.includes(CALL_DATA_OPCODES, structLog.op)) {
                const memoryOffsetStackOffset = constants.opCodeToParamToStackOffset[structLog.op as any].memoryOffset;
                const lengthStackOffset = constants.opCodeToParamToStackOffset[structLog.op as any].length;
                const memOffset = parseInt(
                    structLog.stack[structLog.stack.length - memoryOffsetStackOffset - 1],
                    HEX_BASE,
                );
                const length = parseInt(structLog.stack[structLog.stack.length - lengthStackOffset - 1], HEX_BASE);
                return memOffset + length;
            } else {
                const memoryLocationStackOffset = constants.opCodeToParamToStackOffset[structLog.op].offset;