Skip to content

Commit

Permalink
[fix] Format
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Oct 22, 2024
1 parent c16bbb3 commit d75e031
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 119 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions third_party/move/evm/move-to-yul/tests/testsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ fn test_runner(path: &Path) -> datatest_stable::Result<()> {
"Evm".to_string(),
NumericalAddress::parse_str("0x2").unwrap(),
);
let flags = move_compiler::Flags::empty()
.set_sources_shadow_deps(true);
let flags = move_compiler::Flags::empty().set_sources_shadow_deps(true);
let known_attributes = attr_derivation::get_known_attributes_for_flavor(&flags);
let env = run_model_builder_with_options_and_compilation_flags(
vec![PackagePaths {
Expand Down
1 change: 0 additions & 1 deletion third_party/move/move-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ hex = { workspace = true }
once_cell = { workspace = true }
petgraph = { workspace = true }
regex = { workspace = true }
sha3 = { workspace = true }
tempfile = { workspace = true }

bcs = { workspace = true }
Expand Down
118 changes: 4 additions & 114 deletions third_party/move/move-compiler/src/attr_derivation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
attr_derivation::{
evm_deriver::{add_attributes_for_evm, derive_for_evm},
},
attr_derivation::evm_deriver::{add_attributes_for_evm, derive_for_evm},
parser::ast::{
Attribute, AttributeValue, Attribute_, Attributes, CallKind, Definition, Exp, Exp_,
Function, FunctionBody_, FunctionName, FunctionSignature, LeadingNameAccess_,
NameAccessChain, NameAccessChain_, StructDefinition, StructLayout, StructName, Type, Type_,
Value_, Var, Visibility,
Attribute, AttributeValue, Attribute_, Attributes, Definition, Function, FunctionBody_,
FunctionName, FunctionSignature, NameAccessChain, NameAccessChain_, Type, Type_, Var,
Visibility,
},
shared::{
known_attributes::{AttributeKind, KnownAttribute},
Expand All @@ -24,7 +21,6 @@ use std::collections::BTreeSet;
mod evm_deriver;

const EVM_FLAVOR: &str = "evm";
const EVENT_ATTR: &str = "event";

/// Entry point for deriving definitions from attributes for the given module. Depending on the
/// flavor specified via the flags, this is dispatching to the according attribute processor.
Expand Down Expand Up @@ -124,48 +120,6 @@ pub(crate) fn new_native_fun(
}
}

/// Helper to create a new function declaration.
pub(crate) fn new_fun(
loc: Loc,
name: FunctionName,
attributes: Attributes,
visibility: Visibility,
entry: Option<Loc>,
signature: FunctionSignature,
def: Exp,
) -> Function {
Function {
attributes: vec![attributes],
loc,
visibility,
entry,
signature,
access_specifiers: None,
name,
inline: false,
body: sp(
loc,
FunctionBody_::Defined((vec![], vec![], None, Box::new(Some(def)))),
),
}
}

/// Helper to create a new struct declaration.
pub(crate) fn new_struct(loc: Loc, name: StructName, layout: StructLayout) -> StructDefinition {
StructDefinition {
attributes: vec![sp(
// #[event]
loc,
vec![new_attr(loc, EVENT_ATTR, vec![])],
)],
loc,
abilities: vec![],
name,
type_parameters: vec![],
layout,
}
}

/// Helper to create a new named variable.
pub(crate) fn new_var(loc: Loc, name: &str) -> Var {
Var(sp(loc, Symbol::from(name)))
Expand All @@ -183,67 +137,3 @@ pub(crate) fn new_simple_type(loc: Loc, ty_str: &str, ty_args: Vec<Type>) -> Typ
pub(crate) fn new_simple_name(loc: Loc, name: &str) -> NameAccessChain {
sp(loc, NameAccessChain_::One(sp(loc, Symbol::from(name))))
}

/// Helper to create a full name.
pub(crate) fn new_full_name(
loc: Loc,
addr_alias: &str,
module: &str,
name: &str,
) -> NameAccessChain {
let leading = sp(
loc,
LeadingNameAccess_::Name(sp(loc, Symbol::from(addr_alias))),
);
sp(
loc,
NameAccessChain_::Three(
sp(loc, (leading, sp(loc, Symbol::from(module)))),
sp(loc, Symbol::from(name)),
),
)
}

/// Helper to create a call exp.
pub(crate) fn new_call_exp(loc: Loc, fun: NameAccessChain, args: Vec<Exp>) -> Exp {
sp(loc, Exp_::Call(fun, CallKind::Regular, None, sp(loc, args)))
}

pub(crate) fn new_borrow_exp(loc: Loc, arg: Exp) -> Exp {
sp(loc, Exp_::Borrow(false, Box::new(arg)))
}

/// Helper to create a name exp.
pub(crate) fn new_simple_name_exp(loc: Loc, name: Name) -> Exp {
sp(loc, Exp_::Name(sp(loc, NameAccessChain_::One(name)), None))
}

/// Helper to create an expression for denoting a vector<u8> value.
#[allow(unused)]
pub(crate) fn new_vec_u8(loc: Loc, vec: &[u8]) -> Exp {
let values = vec
.iter()
.map(|x| {
sp(
loc,
Exp_::Value(sp(loc, Value_::Num(Symbol::from(x.to_string())))),
)
})
.collect();
sp(
loc,
Exp_::Vector(
loc,
Some(vec![new_simple_type(loc, "u8", vec![])]),
sp(loc, values),
),
)
}

/// Helper to create new u64.
pub(crate) fn new_u64(loc: Loc, val: u64) -> Exp {
sp(
loc,
Exp_::Value(sp(loc, Value_::Num(Symbol::from(val.to_string())))),
)
}
2 changes: 1 addition & 1 deletion third_party/move/tools/move-cli/src/base/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Build {
let architecture = config.architecture.unwrap_or(Architecture::Move);

match architecture {
Architecture::Move | Architecture::AsyncMove => {
Architecture::Move => {
config.compile_package(&rerooted_path, &mut std::io::stdout())?;
},

Expand Down

0 comments on commit d75e031

Please sign in to comment.