Skip to content

Commit

Permalink
Revert "[move] Enable serialization of source maps into json (#18727)"
Browse files Browse the repository at this point in the history
This reverts commit 65e9b4a.
  • Loading branch information
tzakian committed Sep 13, 2024
1 parent 71ac187 commit 89a546c
Show file tree
Hide file tree
Showing 82 changed files with 43 additions and 3,344 deletions.
18 changes: 0 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 1 addition & 23 deletions external-crates/move/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion external-crates/move/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ module-generation = { path = "crates/module-generation" }
move-abstract-interpreter = { path = "crates/move-abstract-interpreter" }
move-abstract-stack = { path = "crates/move-abstract-stack" }
move-binary-format = { path = "crates/move-binary-format" }
move-trace-format = { path = "crates/move-trace-format" }
move-borrow-graph = { path = "crates/move-borrow-graph" }
move-bytecode-source-map = { path = "crates/move-bytecode-source-map" }
move-bytecode-utils = { path = "crates/move-bytecode-utils" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,11 @@ pub const VERSION_MAX: u32 = VERSION_7;
// TODO(#145): finish v4 compatibility; as of now, only metadata is implemented
pub const VERSION_MIN: u32 = VERSION_5;

/// The corresponding opcode for each bytecode (disregards the argument).
pub fn instruction_opcode(instruction: &Bytecode) -> Opcodes {
/// The encoding of the instruction is the serialized form of it, but disregarding the
/// serialization of the instruction's argument(s).
pub fn instruction_key(instruction: &Bytecode) -> u8 {
use Bytecode::*;
match instruction {
let opcode = match instruction {
Pop => Opcodes::POP,
Ret => Opcodes::RET,
BrTrue(_) => Opcodes::BR_TRUE,
Expand Down Expand Up @@ -620,11 +621,6 @@ pub fn instruction_opcode(instruction: &Bytecode) -> Opcodes {
MutBorrowGlobalGenericDeprecated(_) => Opcodes::MUT_BORROW_GLOBAL_GENERIC_DEPRECATED,
ImmBorrowGlobalDeprecated(_) => Opcodes::IMM_BORROW_GLOBAL_DEPRECATED,
ImmBorrowGlobalGenericDeprecated(_) => Opcodes::IMM_BORROW_GLOBAL_GENERIC_DEPRECATED,
}
}

/// The encoding of the instruction is the serialized form of it, but disregarding the
/// serialization of the instruction's argument(s).
pub fn instruction_key(instruction: &Bytecode) -> u8 {
instruction_opcode(instruction) as u8
};
opcode as u8
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ move-command-line-common.workspace = true
bcs.workspace = true

serde.workspace = true
serde_json.workspace = true

[features]
default = []
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@
use crate::source_map::SourceMap;
use anyhow::{format_err, Result};
use move_ir_types::location::Loc;
use std::{
fs::File,
io::{Read, Write},
path::Path,
};
use std::{fs::File, io::Read, path::Path};

pub type Error = (Loc, String);
pub type Errors = Vec<Error>;

pub fn source_map_from_file(file_path: &Path) -> Result<SourceMap> {
if file_path.extension().is_some_and(|ext| ext == "json") {
return deserialize_from_json(file_path);
}
let mut bytes = Vec::new();
File::open(file_path)
.ok()
Expand All @@ -26,31 +19,3 @@ pub fn source_map_from_file(file_path: &Path) -> Result<SourceMap> {
bcs::from_bytes::<SourceMap>(&bytes)
.map_err(|_| format_err!("Error deserializing into source map"))
}

pub fn serialize_to_json(map: &SourceMap) -> Result<Vec<u8>> {
serde_json::to_vec(map).map_err(|e| format_err!("Error serializing to json: {}", e))
}

pub fn serialize_to_json_file(map: &SourceMap, file_path: &Path) -> Result<()> {
let json = serde_json::to_string_pretty(map)
.map_err(|e| format_err!("Error serializing to json: {}", e))?;
let mut f =
std::fs::File::create(file_path).map_err(|e| format_err!("Error creating file: {}", e))?;
f.write_all(json.as_bytes())
.map_err(|e| format_err!("Error writing to file: {}", e))?;
Ok(())
}

pub fn deserialize_from_json(file_path: &Path) -> Result<SourceMap> {
let mut file = File::open(file_path).map_err(|e| format_err!("Error opening file: {}", e))?;
let mut json = String::new();
file.read_to_string(&mut json)
.map_err(|e| format_err!("Error reading file: {}", e))?;
serde_json::from_str(&json).map_err(|e| format_err!("Error deserializing from json: {}", e))
}

pub fn convert_to_json(file_path: &Path) -> Result<()> {
let map = source_map_from_file(file_path)?;
let json_file_path = file_path.with_extension("json");
serialize_to_json_file(&map, &json_file_path)
}
5 changes: 0 additions & 5 deletions external-crates/move/crates/move-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,5 @@ harness = false
name = "build_testsuite"
harness = false

[[test]]
name = "tracing_testsuite"
harness = false

[features]
tiered-gas = ["move-vm-test-utils/tiered-gas"]
gas-profiler = ["move-vm-runtime/gas-profiler"]
6 changes: 0 additions & 6 deletions external-crates/move/crates/move-cli/src/base/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ pub struct Test {
/// The number of iterations to run each test that uses generated values (only used with #[random_test]).
#[clap(name = "rand-num-iters", long = "rand-num-iters")]
pub rand_num_iters: Option<u64>,

// Enable tracing for tests
#[clap(long = "trace-execution", value_name = "PATH")]
pub trace_execution: Option<Option<String>>,
}

impl Test {
Expand Down Expand Up @@ -112,7 +108,6 @@ impl Test {
compute_coverage: _,
seed,
rand_num_iters,
trace_execution,
} = self;
UnitTestingConfig {
gas_limit,
Expand All @@ -123,7 +118,6 @@ impl Test {
verbose: verbose_mode,
seed,
rand_num_iters,
trace_execution,
..UnitTestingConfig::default_with_bound(None)
}
}
Expand Down

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 89a546c

Please sign in to comment.