aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/source_maps.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-09 23:44:44 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-03-12 10:37:29 +0800
commit3b158cb72649c19a6b569821d23672ea7454b45b (patch)
tree2d204372607c43ebe9629c265f841acbd5084a44 /packages/sol-cov/src/source_maps.ts
parent2298a34c37b373e265d3b4b4665d195cfa1c67fd (diff)
downloaddexon-sol-tools-3b158cb72649c19a6b569821d23672ea7454b45b.tar
dexon-sol-tools-3b158cb72649c19a6b569821d23672ea7454b45b.tar.gz
dexon-sol-tools-3b158cb72649c19a6b569821d23672ea7454b45b.tar.bz2
dexon-sol-tools-3b158cb72649c19a6b569821d23672ea7454b45b.tar.lz
dexon-sol-tools-3b158cb72649c19a6b569821d23672ea7454b45b.tar.xz
dexon-sol-tools-3b158cb72649c19a6b569821d23672ea7454b45b.tar.zst
dexon-sol-tools-3b158cb72649c19a6b569821d23672ea7454b45b.zip
Address feedback
Diffstat (limited to 'packages/sol-cov/src/source_maps.ts')
-rw-r--r--packages/sol-cov/src/source_maps.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/sol-cov/src/source_maps.ts b/packages/sol-cov/src/source_maps.ts
index 795b15a9b..9b3ea9e24 100644
--- a/packages/sol-cov/src/source_maps.ts
+++ b/packages/sol-cov/src/source_maps.ts
@@ -11,7 +11,7 @@ export interface SourceLocation {
fileIndex: number;
}
-export const getLocationByOffset = (str: string) => {
+export function getLocationByOffset(str: string): LocationByOffset {
const locationByOffset: LocationByOffset = {};
let currentOffset = 0;
for (const char of str.split('')) {
@@ -24,11 +24,16 @@ export const getLocationByOffset = (str: string) => {
currentOffset++;
}
return locationByOffset;
-};
+}
// Parses a sourcemap string
// The solidity sourcemap format is documented here: https://github.com/ethereum/solidity/blob/develop/docs/miscellaneous.rst#source-mappings
-export const parseSourceMap = (sourceCodes: string[], srcMap: string, bytecodeHex: string, sources: string[]) => {
+export function parseSourceMap(
+ sourceCodes: string[],
+ srcMap: string,
+ bytecodeHex: string,
+ sources: string[],
+): { [programCounter: number]: SourceRange } {
const bytecode = Uint8Array.from(Buffer.from(bytecodeHex, 'hex'));
const pcToInstructionIndex: { [programCounter: number]: number } = getPcToInstructionIndexMapping(bytecode);
const locationByOffsetByFileIndex = _.map(sourceCodes, getLocationByOffset);
@@ -74,4 +79,4 @@ export const parseSourceMap = (sourceCodes: string[], srcMap: string, bytecodeHe
pcsToSourceRange[pc] = instructionIndexToSourceRange[instructionIndex];
}
return pcsToSourceRange;
-};
+}