mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-29 05:34:21 +08:00
This CL introduces support for writing inputs to wasm tests in wat format. This will allow removing dependencies on opaque binary resources that can't be regenerated without changing hardcoded offsets in all tests. Referencing binary and/or source file offsets will now be possible through special comments left in the wat source. Bug: 1328729 Change-Id: I6369c86ca57860fd9803b894797f63c36c65d554 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3666419 Commit-Queue: Philip Pfaffe <pfaffe@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
23 lines
891 B
JavaScript
23 lines
891 B
JavaScript
// Copyright 2022 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as fs from 'fs';
|
|
import * as sourceMap from 'source-map';
|
|
|
|
if (process.argv.length !== 4) {
|
|
throw new Error(`usage: ${process.argv[1]} <input.map> <offset>`);
|
|
}
|
|
|
|
const offset = Number(process.argv[3] || 0);
|
|
const sourceMapContents = JSON.parse(fs.readFileSync(process.argv[2], 'utf-8'));
|
|
const sourceMapConsumer = new sourceMap.SourceMapConsumer(sourceMapContents);
|
|
|
|
const sourceMappings = [];
|
|
sourceMapConsumer.eachMapping(({source, generatedLine, generatedColumn, originalLine, originalColumn}) => {
|
|
const bytecodeOffset = generatedColumn - offset;
|
|
sourceMappings.push({source, generatedLine, generatedColumn, originalLine, originalColumn, bytecodeOffset});
|
|
});
|
|
|
|
console.log(JSON.stringify(sourceMappings));
|