Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of https://github.com/move-language/move into sup…
Browse files Browse the repository at this point in the history
…port-document-symbol-psl-10
  • Loading branch information
yubing744 committed Jul 31, 2022
2 parents 4695277 + 35009fa commit 49246f6
Show file tree
Hide file tree
Showing 137 changed files with 1,265 additions and 656 deletions.
2 changes: 1 addition & 1 deletion devtools/x-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "x-core"
version = "0.1.0"
authors = ["Diem Association <[email protected]>"]
description = "Core data structures used by x"
edition = "2018"
edition = "2021"
publish = false
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion devtools/x-lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "x-lint"
version = "0.1.0"
authors = ["Diem Association <[email protected]>"]
description = "Lint engine for x"
edition = "2018"
edition = "2021"
publish = false
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion devtools/x/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "x"
version = "0.1.0"
authors = ["Diem Association <[email protected]>"]
description = "Diem extended cargo tasks"
edition = "2018"
edition = "2021"
publish = false
license = "Apache-2.0"

Expand Down
13 changes: 7 additions & 6 deletions devtools/x/src/lint/guppy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use guppy::{
};
use std::{
collections::{BTreeMap, HashMap},
fmt::Write as FmtWrite,
iter,
};
use x_core::{WorkspaceStatus, XCoreContext};
Expand Down Expand Up @@ -270,9 +271,7 @@ impl<'cfg> ProjectLinter for DirectDepDups<'cfg> {
if versions.len() > 1 {
let mut msg = format!("duplicate direct dependency '{}':\n", direct_dep);
for (version, packages) in versions {
msg.push_str(&format!(" * {} (", version));
msg.push_str(&packages.join(", "));
msg.push_str(")\n");
writeln!(&mut msg, " * {} ({})", version, &packages.join(", ")).unwrap();
}
out.write(LintLevel::Error, msg);
}
Expand Down Expand Up @@ -361,12 +360,14 @@ impl<'cfg> PackageLinter for OverlayFeatures<'cfg> {
if !overlays.is_empty() {
let mut msg = "overlay features enabled by default:\n".to_string();
for (from_feature, to_package, to_feature) in overlays {
msg.push_str(&format!(
" * {} -> {}/{}\n",
writeln!(
&mut msg,
" * {} -> {}/{}",
feature_str(from_feature),
to_package,
feature_str(to_feature)
));
)
.unwrap();
}
msg.push_str("Use a line in the [features] section instead.\n");
out.write(LintLevel::Error, msg);
Expand Down
2 changes: 1 addition & 1 deletion language/benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
homepage = "https://diem.com"
license = "Apache-2.0"
publish = false
edition = "2018"
edition = "2021"

[dependencies]
anyhow = "1.0.52"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "CLI frontend for the Move compiler and VM (with Diem Framework)"
authors = ["Diem Association <[email protected]>"]
license = "Apache-2.0"
publish = false
edition = "2018"
edition = "2021"

[dependencies]
anyhow = "1.0.52"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "diem-crypto-derive"
version = "0.0.3"
authors = ["Diem Association <[email protected]>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[lib]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "diem-crypto"
version = "0.0.3"
authors = ["Diem Association <[email protected]>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "diem-framework-natives"
version = "0.0.0"
authors = ["Diem Association <[email protected]>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions language/documentation/tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ module 0xCAFE::BasicCoin {
// address value of `0xC0FFEE`.
#[test(account = @0xC0FFEE)]
fun test_mint_10(account: signer) acquires Coin {
let addr = signer::address_of(&account);
let addr = 0x1::signer::address_of(&account);
mint(account, 10);
// Make sure there is a `Coin` resource under `addr` with a value of `10`.
// We can access this resource and its value since we are in the
Expand Down Expand Up @@ -571,7 +571,7 @@ source ~/.profile
```
## Step 7: Use the Move prover<span id="Step7"><span>
Smart contracts deployed on the blockchain may maniputate high-value assets. As a technique that uses strict
Smart contracts deployed on the blockchain may manipulate high-value assets. As a technique that uses strict
mathematical methods to describe behavior and reason correctness of computer systems, formal verification
has been used in blockchains to prevent bugs in smart contracts. [
The Move prover](https://github.com/move-language/move/blob/main/language/move-prover/doc/user/prover-guide.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ module NamedAddr::BasicCoin {
}

#[test(account = @0x1)]
#[expected_failure(abort_code = 518)] // Can specify an abort code
#[expected_failure(abort_code = 2)] // Can specify an abort code
fun publish_balance_already_exists(account: signer) {
publish_balance(&account);
publish_balance(&account);
}

// EXERCISE: Write `balance_dne` test here!
// EXERCISE: Write `balance_of_dne` test here!

#[test]
#[expected_failure]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module NamedAddr::BasicCoin {
}

#[test(account = @0x1)]
#[expected_failure(abort_code = 518)] // Can specify an abort code
#[expected_failure(abort_code = 2)] // Can specify an abort code
fun publish_balance_already_exists(account: signer) {
publish_balance(&account);
publish_balance(&account);
Expand Down
2 changes: 1 addition & 1 deletion language/evm/extract-ethereum-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Diem Association <[email protected]>"]
description = "Extract Etherem ABI"
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-ethereum-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Diem Association <[email protected]>"]
description = "Move Ethereum ABI"
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-to-yul/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Diem Association <[email protected]>"]
description = "Move Solidity Generator"
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions language/evm/move-to-yul/src/abi_move_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ pub(crate) fn generate_abi_move_metadata(ctx: &Context, receive: bool, fallback:
let st_env = ctx.env.get_struct(key.to_qualified_id());
event_map.insert(
st_env.get_identifier().unwrap().to_string(),
from_event_sig(ctx.event_signature_map.borrow().get(&key).unwrap()),
from_event_sig(ctx.event_signature_map.borrow().get(key).unwrap()),
);
}

// Callable functions
let mut func_map = BTreeMap::new();
for (key, (solidity_sig, attr)) in ctx.callable_function_map.borrow().iter() {
let fun = ctx.env.get_function(key.to_qualified_id());
let abi_sig = from_solidity_sig(&solidity_sig, Some(*attr), "function");
let abi_sig = from_solidity_sig(solidity_sig, Some(*attr), "function");
func_map.insert(fun.get_identifier().to_string(), abi_sig);
}

Expand Down
5 changes: 2 additions & 3 deletions language/evm/move-to-yul/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ impl<'a> Context<'a> {
fn get_target_structs(&self, p: impl Fn(&StructEnv) -> bool) -> Vec<StructEnv<'a>> {
self.env
.get_modules()
.map(|m| m.into_structs().filter(|f| p(f)))
.flatten()
.flat_map(|m| m.into_structs().filter(|f| p(f)))
.collect()
}

Expand Down Expand Up @@ -608,7 +607,7 @@ impl<'a> Context<'a> {
.get_local_name(idx)
.display(target.symbol_pool())
.to_string()
.replace("#", "_")
.replace('#', "_")
}

/// Make name for a result.
Expand Down
18 changes: 9 additions & 9 deletions language/evm/move-to-yul/src/dispatcher_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ impl Generator {
/// Generate optional receive function.
fn optional_receive(&mut self, ctx: &Context, receive: &Option<FunctionEnv<'_>>) -> bool {
if let Some(receive) = receive {
ctx.check_no_generics(&receive);
if !attributes::is_payable_fun(&receive) {
ctx.check_no_generics(receive);
if !attributes::is_payable_fun(receive) {
ctx.env
.error(&receive.get_loc(), "receive function must be payable")
}
Expand Down Expand Up @@ -309,8 +309,8 @@ impl Generator {
fallback: &Option<FunctionEnv<'_>>,
) {
if let Some(fallback) = fallback {
ctx.check_no_generics(&fallback);
if !attributes::is_payable_fun(&fallback) {
ctx.check_no_generics(fallback);
if !attributes::is_payable_fun(fallback) {
self.generate_call_value_check(ctx, REVERT_ERR_NON_PAYABLE_FUN);
}
let fun_id = &fallback
Expand Down Expand Up @@ -560,7 +560,7 @@ impl Generator {
);
});
head_pos += ty_size;
let memory_func = ctx.memory_store_builtin_fun(&move_ty);
let memory_func = ctx.memory_store_builtin_fun(move_ty);
if local_typ_var.len() == 1 {
gen.call_builtin(
ctx,
Expand Down Expand Up @@ -1454,7 +1454,7 @@ impl Generator {
{
let is_static = ty.is_static();
let local_typ_var = vec![ret_var[stack_pos].clone()];
let memory_func = ctx.memory_load_builtin_fun(&move_ty);
let memory_func = ctx.memory_load_builtin_fun(move_ty);
if local_typ_var.len() == 1 {
emitln!(
ctx.writer,
Expand All @@ -1474,7 +1474,7 @@ impl Generator {
ctx,
&ty.clone(),
&SignatureDataLocation::Memory,
&move_ty,
move_ty,
sub_option.clone()
),
local_typ_var[0].clone()
Expand All @@ -1488,7 +1488,7 @@ impl Generator {
ctx,
&ty.clone(),
&SignatureDataLocation::Memory,
&move_ty,
move_ty,
sub_option.clone()
),
local_typ_var[0].clone(),
Expand All @@ -1507,7 +1507,7 @@ impl Generator {
ctx,
&ty.clone(),
&SignatureDataLocation::Memory,
&move_ty,
move_ty,
sub_option.clone()
),
local_typ_var[0].clone()
Expand Down
1 change: 1 addition & 0 deletions language/evm/move-to-yul/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ impl<'a> FunctionGenerator<'a> {
| EventStoreDiverge
| OpaqueCallBegin(_, _, _)
| OpaqueCallEnd(_, _, _)
| Uninit
| Havoc(_)
| Stop
| TraceGlobalMem(_) => {}
Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-to-yul/src/solidity_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl SolidityType {
let error_msg = "illegal type name";
return Err(anyhow!(error_msg));
}
ctx.check_or_create_struct_abi(&trimmed_ty_str)
ctx.check_or_create_struct_abi(trimmed_ty_str)
}
}

Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-to-yul/src/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ fn define_destroy_empty_fun(

/// Generate equality method for the vector type.
pub(crate) fn equality_fun(gen: &mut Generator, ctx: &Context, ty: &Type) {
let elem_type = get_elem_type(&ty).unwrap();
let elem_type = get_elem_type(ty).unwrap();
if ctx.type_allocates_memory(&elem_type) {
emitln!(
ctx.writer,
Expand Down
16 changes: 10 additions & 6 deletions language/evm/move-to-yul/tests/testsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use move_to_yul::{generator::Generator, options::Options};
use primitive_types::{H160, U256};
use std::{
collections::BTreeMap,
fmt::Write,
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -116,16 +117,19 @@ fn run_tests(
let mut res = String::new();
res.push_str("!! Unit tests\n\n");
for (fun, source) in test_cases {
res.push_str(&format!(
"// test of {}\n",
writeln!(
&mut res,
"// test of {}",
env.get_function(*fun).get_full_name_str()
));
)
.unwrap();
res.push_str(source);
res.push_str(&format!(
"===> Test result of {}: {}\n\n",
writeln!(
&mut res,
"===> Test result of {}: {}\n",
env.get_function(*fun).get_full_name_str(),
execute_test(env, source)?
));
)?;
}
Ok(res)
}
Expand Down
2 changes: 1 addition & 1 deletion language/move-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
homepage = "https://diem.com"
license = "Apache-2.0"
publish = false
edition = "2018"
edition = "2021"

[dependencies]
anyhow = "1.0.52"
Expand Down
30 changes: 30 additions & 0 deletions language/move-analyzer/editors/code/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from 'vscode';
import * as lc from 'vscode-languageclient';
import { log } from './log';
import { sync as commandExistsSync } from 'command-exists';
import { IndentAction } from 'vscode';

/** Information passed along to each VS Code command defined by this extension. */
export class Context {
Expand Down Expand Up @@ -57,6 +58,35 @@ export class Context {
this.extensionContext.subscriptions.push(disposable);
}

/**
* Sets up additional language configuration that's impossible to do via a
* separate language-configuration.json file. See [1] for more information.
*
* This code originates from [2](vscode-rust).
*
* [1]: https://github.com/Microsoft/vscode/issues/11514#issuecomment-244707076
* [2]: https://github.com/rust-lang/vscode-rust/blob/660b412701fe2ea62fad180c40ee4f8a60571c61/src/extension.ts#L287:L287
*/
configureLanguage(): void {
const disposable = vscode.languages.setLanguageConfiguration('move', {
onEnterRules: [
{
// Doc single-line comment
// e.g. ///|
beforeText: /^\s*\/{3}.*$/,
action: { indentAction: IndentAction.None, appendText: '/// ' },
},
{
// Parent doc single-line comment
// e.g. //!|
beforeText: /^\s*\/{2}!.*$/,
action: { indentAction: IndentAction.None, appendText: '//! ' },
},
],
});
this.extensionContext.subscriptions.push(disposable);
}

/**
* Configures and starts the client that interacts with the language server.
*
Expand Down
Loading

0 comments on commit 49246f6

Please sign in to comment.