aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov
diff options
context:
space:
mode:
authorperissology <perissology@protonmail.com>2018-06-21 21:24:50 +0800
committerperissology <perissology@protonmail.com>2018-06-21 21:24:50 +0800
commitc5ea985a7003fef8430555e8477a130262407137 (patch)
tree50333b4d384f808160bb3a646c5155f3f4ecee8b /packages/sol-cov
parent7a41a5249fcb8457cb8beb823ce9a1362cdbfa98 (diff)
downloaddexon-0x-contracts-c5ea985a7003fef8430555e8477a130262407137.tar
dexon-0x-contracts-c5ea985a7003fef8430555e8477a130262407137.tar.gz
dexon-0x-contracts-c5ea985a7003fef8430555e8477a130262407137.tar.bz2
dexon-0x-contracts-c5ea985a7003fef8430555e8477a130262407137.tar.lz
dexon-0x-contracts-c5ea985a7003fef8430555e8477a130262407137.tar.xz
dexon-0x-contracts-c5ea985a7003fef8430555e8477a130262407137.tar.zst
dexon-0x-contracts-c5ea985a7003fef8430555e8477a130262407137.zip
only call getLocationByOffset if source if defined
Diffstat (limited to 'packages/sol-cov')
-rw-r--r--packages/sol-cov/src/source_maps.ts5
1 files changed, 1 insertions, 4 deletions
diff --git a/packages/sol-cov/src/source_maps.ts b/packages/sol-cov/src/source_maps.ts
index c95c7d2b0..39b83ea0d 100644
--- a/packages/sol-cov/src/source_maps.ts
+++ b/packages/sol-cov/src/source_maps.ts
@@ -12,9 +12,6 @@ export interface SourceLocation {
}
export function getLocationByOffset(str: string): LocationByOffset {
- if (_.isUndefined(str)) {
- return {};
- }
const locationByOffset: LocationByOffset = { 0: { line: 1, column: 0 } };
let currentOffset = 0;
for (const char of str.split('')) {
@@ -39,7 +36,7 @@ export function parseSourceMap(
): { [programCounter: number]: SourceRange } {
const bytecode = Uint8Array.from(Buffer.from(bytecodeHex, 'hex'));
const pcToInstructionIndex: { [programCounter: number]: number } = getPcToInstructionIndexMapping(bytecode);
- const locationByOffsetByFileIndex = _.map(sourceCodes, getLocationByOffset);
+ const locationByOffsetByFileIndex = _.map(sourceCodes, (s) => _.isUndefined(s) ? {} : getLocationByOffset(s));
const entries = srcMap.split(';');
let lastParsedEntry: SourceLocation = {} as any;
const instructionIndexToSourceRange: { [instructionIndex: number]: SourceRange } = {};