-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add another test and fix pylint issues
- Loading branch information
1 parent
5a6ef0d
commit 0165614
Showing
7 changed files
with
98 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.94 KB
...parsing/test_data/compile/using_for_global_user_defined_operator_1.sol-0.8.24-compact.zip
Binary file not shown.
9 changes: 9 additions & 0 deletions
9
...rsing/test_data/expected/using_for_global_user_defined_operator_1.sol-0.8.24-compact.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"BalanceDeltaLibrary": { | ||
"amount0(BalanceDelta)": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: INLINE ASM 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: END INLINE ASM 3\n\"];\n3->4;\n4[label=\"Node Type: RETURN 4\n\"];\n}\n", | ||
"amount1(BalanceDelta)": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: INLINE ASM 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: END INLINE ASM 3\n\"];\n3->4;\n4[label=\"Node Type: RETURN 4\n\"];\n}\n" | ||
}, | ||
"X": { | ||
"get(BalanceDelta)": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n1->2;\n2[label=\"Node Type: NEW VARIABLE 2\n\"];\n}\n" | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/e2e/solc_parsing/test_data/using_for_global_user_defined_operator.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
type BalanceDelta is int256; | ||
|
||
using {add as +, sub as -, eq as ==} for BalanceDelta global; | ||
using BalanceDeltaLibrary for BalanceDelta global; | ||
|
||
function toBalanceDelta(int128 _amount0, int128 _amount1) pure returns (BalanceDelta balanceDelta) { | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
balanceDelta := | ||
or(shl(128, _amount0), and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, _amount1)) | ||
} | ||
} | ||
|
||
function add(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) { | ||
return toBalanceDelta(a.amount0() + b.amount0(), a.amount1() + b.amount1()); | ||
} | ||
|
||
function sub(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) { | ||
return toBalanceDelta(a.amount0() - b.amount0(), a.amount1() - b.amount1()); | ||
} | ||
|
||
function eq(BalanceDelta a, BalanceDelta b) pure returns (bool) { | ||
return a.amount0() == b.amount0() && a.amount1() == b.amount1(); | ||
} | ||
|
||
library BalanceDeltaLibrary { | ||
function amount0(BalanceDelta balanceDelta) internal pure returns (int128 _amount0) { | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
_amount0 := shr(128, balanceDelta) | ||
} | ||
} | ||
|
||
function amount1(BalanceDelta balanceDelta) internal pure returns (int128 _amount1) { | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
_amount1 := balanceDelta | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/e2e/solc_parsing/test_data/using_for_global_user_defined_operator_1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
import {BalanceDelta} from "./using_for_global_user_defined_operator.sol"; | ||
contract X { | ||
|
||
function get(BalanceDelta delta) external { | ||
int128 amount0 = delta.amount0(); | ||
int128 amount1 = delta.amount1(); | ||
} | ||
} |