Skip to content

Commit

Permalink
[move] Fix formatting in disassembler + fix CI runner for Move (#20556)
Browse files Browse the repository at this point in the history
## Description 

Fix CI runner for CI for Move (using `set -e` in `test.sh`).

Fix formatting issues for enums in the disassembler. 

## Test plan 

CI + ran Move tests locally (including failing tests to make sure the
tests fail if any fail)

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
tzakian authored Dec 9, 2024
1 parent fc97843 commit 5a00408
Show file tree
Hide file tree
Showing 30 changed files with 143 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,25 +409,25 @@ impl<'a> Disassembler<'a> {

Self::disassemble_abilites(buffer, enum_handle.abilities)?;

any_writeln!(buffer, " {{")?;

delimited_list(
&enum_definition.variants,
" {",
",",
"}",
"\n}\n",
buffer,
|buffer, variant| {
let variant_name = self
.source_mapper
.bytecode
.identifier_at(variant.variant_name);
any_write!(buffer, "\n\t{variant_name} {{")?;

any_write!(buffer, "\n\t{variant_name} {{ ")?;

delimited_list(
&variant.fields,
"",
", ",
"\n",
"",
buffer,
|buffer, field_definition| {
let type_sig = &field_definition.signature;
Expand All @@ -444,11 +444,11 @@ impl<'a> Disassembler<'a> {
)
},
)?;
any_writeln!(buffer, "}}")

any_write!(buffer, " }}")
},
)?;

any_writeln!(buffer, "}}")?;
Ok(())
}

Expand Down Expand Up @@ -583,7 +583,7 @@ impl<'a> Disassembler<'a> {
.skip(parameter_len)
.enumerate()
{
any_write!(buffer, "\t{name}: ")?;
any_write!(buffer, "L{local_idx}:\t{name}: ")?;
self.disassemble_type_for_local(
buffer,
function_source_map,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ task 0, lines 1-31:
//# print-bytecode
// Move bytecode v6
module 3d10.Example {

struct Coin {
value: u64
}



public value(Arg0: &Coin): u64 {
B0:
0: MoveLoc[0](Arg0: &Coin)
Expand All @@ -18,8 +17,8 @@ B0:
3: MoveLoc[1](loc0: &u64)
4: ReadRef
5: Ret

}

public deposit(Arg0: &mut Coin, Arg1: Coin) {
L0: loc2: &Coin
L1: loc3: u64
Expand Down Expand Up @@ -48,27 +47,26 @@ B0:
19: Unpack[0](Coin)
20: StLoc[7](loc5: u64)
21: Ret

}

}


task 1, lines 33-46:
//# print-bytecode
// Move bytecode v6
module 4d10.M {




entry public f() {
B0:
0: Ret

}

entry public g() {
B0:
0: Call f()
1: Ret

}

}

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ task 0, lines 1-9:
// Move bytecode v6
module 6.m {




entry foo() {
L0: loc0: u64
B0:
0: Ret

}

}


task 1, lines 11-20:
//# print-bytecode
Error: variable redefinition x
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ task 0, lines 1-13:
// Move bytecode v6
module e.Expressions {




binary_add() {
L0: loc0: u64
L1: loc1: u64
Expand All @@ -22,6 +19,7 @@ B0:
6: Add
7: StLoc[2](loc2: u64)
8: Ret

}

}

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ task 0, lines 1-13:
// Move bytecode v6
module 6.m {




entry foo() {
L0: loc0: u64
L1: loc1: &u64
Expand All @@ -19,18 +16,16 @@ B0:
4: MoveLoc[1](loc1: &u64)
5: Pop
6: Ret

}

}


task 1, lines 15-28:
//# print-bytecode
// Move bytecode v6
module 7.m {




entry foo() {
L0: loc0: u64
L1: loc1: &u64
Expand All @@ -43,20 +38,20 @@ B0:
4: ImmBorrowLoc[1](loc1: &u64)
5: StLoc[2](loc2: &u64)
6: Ret

}

}


task 2, lines 30-63:
//# print-bytecode
// Move bytecode v6
module 1d4.M {

struct T {
u: u64
}



f(Arg0: &T) {
B0:
0: MoveLoc[0](Arg0: &T)
Expand All @@ -65,8 +60,8 @@ B0:
3: MoveLoc[1](loc0: &u64)
4: Pop
5: Ret

}

g(Arg0: &mut T) {
B0:
0: MoveLoc[0](Arg0: &mut T)
Expand All @@ -75,8 +70,8 @@ B0:
3: MoveLoc[1](loc0: &u64)
4: Pop
5: Ret

}

public h(Arg0: &mut T) {
B0:
0: MoveLoc[0](Arg0: &mut T)
Expand All @@ -85,42 +80,43 @@ B0:
3: MoveLoc[1](loc0: &mut u64)
4: Pop
5: Ret

}

}


task 3, lines 65-84:
//# print-bytecode
// Move bytecode v6
module 2d4.M {

struct T<Ty0> {
u: Ty0
}



f(Arg0: &T<u64>) {
B0:
0: MoveLoc[0](Arg0: &T<u64>)
1: ImmBorrowFieldGeneric[0](T.u: Ty0)
1: ImmBorrowFieldGeneric[0](T.u: u64)
2: StLoc[1](loc0: &u64)
3: MoveLoc[1](loc0: &u64)
4: Pop
5: Ret

}

g(Arg0: &mut T<u128>) {
B0:
0: MoveLoc[0](Arg0: &mut T<u128>)
1: ImmBorrowFieldGeneric[1](T.u: Ty0)
1: ImmBorrowFieldGeneric[1](T.u: u128)
2: StLoc[1](loc0: &u128)
3: MoveLoc[1](loc0: &u128)
4: Pop
5: Ret

}

}


task 5, lines 97-112:
//# print-bytecode
Error: Unbound struct Self.T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ task 0, lines 1-12:
// Move bytecode v6
module 6.m {




entry foo() {
L0: loc0: u64
L1: loc1: &mut u64
Expand All @@ -20,20 +17,20 @@ B0:
5: MoveLoc[1](loc1: &mut u64)
6: WriteRef
7: Ret

}

}


task 1, lines 14-25:
//# print-bytecode
// Move bytecode v6
module 3d.Foobar {

struct FooCoin {
value: u64
}



public borrow_mut_field(Arg0: &mut FooCoin) {
B0:
0: MoveLoc[0](Arg0: &mut FooCoin)
Expand All @@ -42,20 +39,20 @@ B0:
3: MoveLoc[1](loc0: &mut u64)
4: Pop
5: Ret

}

}


task 2, lines 27-38:
//# print-bytecode
// Move bytecode v6
module 4d.Foobar {

struct FooCoin<Ty0> {
value: u64
}



public borrow_mut_field(Arg0: &mut FooCoin<address>) {
B0:
0: MoveLoc[0](Arg0: &mut FooCoin<address>)
Expand All @@ -64,6 +61,7 @@ B0:
3: MoveLoc[1](loc0: &mut u64)
4: Pop
5: Ret

}

}

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ task 0, lines 1-33:
// Move bytecode v6
module 6.m {




entry foo() {
L0: loc0: vector<u64>
L1: loc1: &vector<u64>
Expand Down Expand Up @@ -60,6 +57,7 @@ B0:
41: MoveLoc[0](loc0: vector<u64>)
42: VecUnpack(1, 0)
43: Ret

}

}

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ task 0, lines 1-13:
// Move bytecode v6
module 6.m {




entry foo() {
L0: loc0: u64
L1: loc1: u64
Expand All @@ -26,6 +23,7 @@ B0:
10: Sub
11: StLoc[2](loc2: u64)
12: Ret

}

}

Loading

0 comments on commit 5a00408

Please sign in to comment.