Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/SourceMap

primitives/SourceMap

Type Aliases

SourceMap

SourceMap = object
Defined in: src/primitives/SourceMap/SourceMapType.ts:26 Solidity source map Semicolon-separated entries mapping bytecode to source locations. Format: “s:l:f:j:m;s:l:f:j:m;…”

Properties

entries
readonly entries: readonly SourceMapEntry[]
Defined in: src/primitives/SourceMap/SourceMapType.ts:30 Parsed entries
raw
readonly raw: string
Defined in: src/primitives/SourceMap/SourceMapType.ts:28 Raw source map string

SourceMapEntry

SourceMapEntry = object
Defined in: src/primitives/SourceMap/SourceMapType.ts:7 Solidity source map entry Maps bytecode positions to source code locations. Format: s:l:f:j:m (start:length:fileIndex:jump:modifierDepth)

Properties

fileIndex
readonly fileIndex: number
Defined in: src/primitives/SourceMap/SourceMapType.ts:13 Source file index
jump
readonly jump: "i" | "o" | "-"
Defined in: src/primitives/SourceMap/SourceMapType.ts:15 Jump type: ‘i’ (into), ‘o’ (out), ’-’ (regular)
length
readonly length: number
Defined in: src/primitives/SourceMap/SourceMapType.ts:11 Length in source code
modifierDepth?
readonly optional modifierDepth: number
Defined in: src/primitives/SourceMap/SourceMapType.ts:17 Modifier depth (optional)
start
readonly start: number
Defined in: src/primitives/SourceMap/SourceMapType.ts:9 Byte offset in source code

Functions

from()

from(raw): SourceMap
Defined in: src/primitives/SourceMap/from.js:17 Create SourceMap from source map string

Parameters

raw
string Source map string (semicolon-separated entries)

Returns

SourceMap SourceMap

See

Since

0.0.0

Example

import * as SourceMap from './primitives/SourceMap/index.js';
const map = SourceMap.from("0:50:0:-;51:100:0:-;");

getEntryAt()

getEntryAt(sourceMap, pc): SourceMapEntry | undefined
Defined in: src/primitives/SourceMap/getEntryAt.js:14 Get source map entry for specific bytecode position

Parameters

sourceMap
SourceMap SourceMap
pc
number Program counter (bytecode offset)

Returns

SourceMapEntry | undefined Entry at position

Example

import * as SourceMap from './primitives/SourceMap/index.js';
const map = SourceMap.from("0:50:0:-;51:100:0:-;");
const entry = SourceMap.getEntryAt(map, 1);

parse()

parse(raw): SourceMap
Defined in: src/primitives/SourceMap/parse.js:17 Parse source map string into entries Solidity source map format: “s:l:f:j:m;s:l:f:j:m;…” Fields can be omitted to inherit from previous entry (compression).

Parameters

raw
string Source map string

Returns

SourceMap Parsed source map

Example

import * as SourceMap from './primitives/SourceMap/index.js';
const map = SourceMap.parse("0:50:0:-;51:100:0:-;151:25:0:o");
console.log(map.entries.length); // 3

toEntries()

toEntries(raw): readonly SourceMapEntry[]
Defined in: src/primitives/SourceMap/toEntries.js:15 Convert source map string to array of entries

Parameters

raw
string Source map string

Returns

readonly SourceMapEntry[] Parsed entries

Example

import * as SourceMap from './primitives/SourceMap/index.js';
const entries = SourceMap.toEntries("0:50:0:-;51:100:0:-;");
console.log(entries[0].start); // 0

toString()

toString(sourceMap): string
Defined in: src/primitives/SourceMap/toString.js:16 Convert source map to compressed string format Applies compression: omits fields that match previous entry.

Parameters

sourceMap
SourceMap SourceMap

Returns

string Compressed source map string

Example

import * as SourceMap from './primitives/SourceMap/index.js';
const map = SourceMap.from("0:50:0:-;51:100:0:-;");
const str = SourceMap.toString(map);