prettier-plugin-solidity 1.0.0-beta.20 → 1.0.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -13
- package/package.json +12 -12
- package/prettier-plugin-solidity-1.0.0-beta.19.tgz +0 -0
- package/src/binary-operator-printers/index.js +1 -1
- package/src/nodes/Continue.js +5 -0
- package/src/nodes/FunctionCall.js +17 -14
- package/src/nodes/InlineAssemblyStatement.js +17 -1
- package/src/nodes/ModifierDefinition.js +5 -3
- package/src/nodes/UsingForDeclaration.js +19 -3
- package/src/nodes/index.js +2 -2
- package/.github/FUNDING.yml +0 -1
- package/.github/dependabot.yml +0 -23
- package/.github/workflows/CI.yml +0 -83
- package/Foo.sol +0 -404
- package/assets/telegram-badge.svg +0 -29
- package/scripts/generateIndexes.js +0 -16
- package/scripts/makeData.js +0 -23
- package/src/nodes/TypeNameExpression.js +0 -5
- package/tests/config/.prettierrc +0 -5
- package/tests/config/format-test.js +0 -458
- package/tests/config/require-prettier.js +0 -5
- package/tests/config/require-standalone.js +0 -25
- package/tests/config/setup.js +0 -7
- package/tests/config/utils/check-parsers.js +0 -207
- package/tests/config/utils/compile-contract.js +0 -36
- package/tests/config/utils/consistent-end-of-line.js +0 -13
- package/tests/config/utils/create-snapshot.js +0 -98
- package/tests/config/utils/stringify-options-for-title.js +0 -15
- package/tests/config/utils/visualize-end-of-line.js +0 -18
- package/tests/config/utils/visualize-range.js +0 -40
- package/tests/format/AddressPayable/AddressPayable.sol +0 -10
- package/tests/format/AddressPayable/__snapshots__/jsfmt.spec.js.snap +0 -37
- package/tests/format/AddressPayable/jsfmt.spec.js +0 -1
- package/tests/format/AllSolidityFeatures/AllSolidityFeatures.sol +0 -533
- package/tests/format/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap +0 -1146
- package/tests/format/AllSolidityFeatures/jsfmt.spec.js +0 -1
- package/tests/format/Arrays/Arrays.sol +0 -17
- package/tests/format/Arrays/__snapshots__/jsfmt.spec.js.snap +0 -63
- package/tests/format/Arrays/jsfmt.spec.js +0 -1
- package/tests/format/Assembly/Assembly.sol +0 -180
- package/tests/format/Assembly/__snapshots__/jsfmt.spec.js.snap +0 -406
- package/tests/format/Assembly/jsfmt.spec.js +0 -1
- package/tests/format/BasicIterator/BasicIterator.sol +0 -44
- package/tests/format/BasicIterator/__snapshots__/jsfmt.spec.js.snap +0 -102
- package/tests/format/BasicIterator/jsfmt.spec.js +0 -1
- package/tests/format/BinaryOperators/BinaryOperators.sol +0 -186
- package/tests/format/BinaryOperators/Parentheses.sol +0 -132
- package/tests/format/BinaryOperators/__snapshots__/jsfmt.spec.js.snap +0 -952
- package/tests/format/BinaryOperators/jsfmt.spec.js +0 -1
- package/tests/format/BreakingChangesV0.7.4/BreakingChangesV0.7.4.sol +0 -9
- package/tests/format/BreakingChangesV0.7.4/__snapshots__/jsfmt.spec.js.snap +0 -198
- package/tests/format/BreakingChangesV0.7.4/jsfmt.spec.js +0 -14
- package/tests/format/BreakingChangesV0.8.0/BreakingChangesV0.8.0.sol +0 -43
- package/tests/format/BreakingChangesV0.8.0/__snapshots__/jsfmt.spec.js.snap +0 -815
- package/tests/format/BreakingChangesV0.8.0/jsfmt.spec.js +0 -26
- package/tests/format/Comments/Comments.sol +0 -104
- package/tests/format/Comments/__snapshots__/jsfmt.spec.js.snap +0 -244
- package/tests/format/Comments/jsfmt.spec.js +0 -1
- package/tests/format/Conditional/Conditional.sol +0 -26
- package/tests/format/Conditional/__snapshots__/jsfmt.spec.js.snap +0 -80
- package/tests/format/Conditional/jsfmt.spec.js +0 -1
- package/tests/format/Constructors/Constructors.sol +0 -8
- package/tests/format/Constructors/__snapshots__/jsfmt.spec.js.snap +0 -54
- package/tests/format/Constructors/jsfmt.spec.js +0 -1
- package/tests/format/ContractDefinitions/ContractDefinitions.sol +0 -2
- package/tests/format/ContractDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -22
- package/tests/format/ContractDefinitions/jsfmt.spec.js +0 -1
- package/tests/format/CustomErrors/CustomErrors.sol +0 -20
- package/tests/format/CustomErrors/__snapshots__/jsfmt.spec.js.snap +0 -50
- package/tests/format/CustomErrors/jsfmt.spec.js +0 -1
- package/tests/format/EnumDefinitions/EnumDefinitions.sol +0 -4
- package/tests/format/EnumDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -72
- package/tests/format/EnumDefinitions/jsfmt.spec.js +0 -2
- package/tests/format/Etc/Etc.sol +0 -48
- package/tests/format/Etc/__snapshots__/jsfmt.spec.js.snap +0 -134
- package/tests/format/Etc/jsfmt.spec.js +0 -1
- package/tests/format/ExplicitVariableTypes/ExplicitVariableTypes.sol +0 -36
- package/tests/format/ExplicitVariableTypes/__snapshots__/jsfmt.spec.js.snap +0 -258
- package/tests/format/ExplicitVariableTypes/jsfmt.spec.js +0 -9
- package/tests/format/ForStatements/ForStatements.sol +0 -43
- package/tests/format/ForStatements/__snapshots__/jsfmt.spec.js.snap +0 -108
- package/tests/format/ForStatements/jsfmt.spec.js +0 -1
- package/tests/format/FunctionCalls/FunctionCalls.sol +0 -40
- package/tests/format/FunctionCalls/__snapshots__/jsfmt.spec.js.snap +0 -310
- package/tests/format/FunctionCalls/jsfmt.spec.js +0 -2
- package/tests/format/FunctionDefinitions/FunctionDefinitions.sol +0 -169
- package/tests/format/FunctionDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -875
- package/tests/format/FunctionDefinitions/jsfmt.spec.js +0 -1
- package/tests/format/HexLiteral/HexLiteral.sol +0 -7
- package/tests/format/HexLiteral/__snapshots__/jsfmt.spec.js.snap +0 -57
- package/tests/format/HexLiteral/jsfmt.spec.js +0 -8
- package/tests/format/IfStatements/IfStatements.sol +0 -112
- package/tests/format/IfStatements/__snapshots__/jsfmt.spec.js.snap +0 -534
- package/tests/format/IfStatements/jsfmt.spec.js +0 -1
- package/tests/format/Immutable/Immutable.sol +0 -20
- package/tests/format/Immutable/__snapshots__/jsfmt.spec.js.snap +0 -53
- package/tests/format/Immutable/jsfmt.spec.js +0 -1
- package/tests/format/ImportDirective/ImportDirectives.sol +0 -5
- package/tests/format/ImportDirective/__snapshots__/jsfmt.spec.js.snap +0 -46
- package/tests/format/ImportDirective/jsfmt.spec.js +0 -2
- package/tests/format/Inbox/Inbox.sol +0 -33
- package/tests/format/Inbox/__snapshots__/jsfmt.spec.js.snap +0 -79
- package/tests/format/Inbox/jsfmt.spec.js +0 -1
- package/tests/format/IndexOf/IndexOf.sol +0 -67
- package/tests/format/IndexOf/__snapshots__/jsfmt.spec.js.snap +0 -144
- package/tests/format/IndexOf/jsfmt.spec.js +0 -1
- package/tests/format/IndexRangeAccess/IndexRangeAccess.sol +0 -9
- package/tests/format/IndexRangeAccess/__snapshots__/jsfmt.spec.js.snap +0 -31
- package/tests/format/IndexRangeAccess/jsfmt.spec.js +0 -1
- package/tests/format/InheritanceSpecifier/InheritanceSpecifier.sol +0 -2
- package/tests/format/InheritanceSpecifier/__snapshots__/jsfmt.spec.js.snap +0 -24
- package/tests/format/InheritanceSpecifier/jsfmt.spec.js +0 -1
- package/tests/format/Issues/Issue205.sol +0 -12
- package/tests/format/Issues/Issue289.sol +0 -6
- package/tests/format/Issues/Issue355.sol +0 -12
- package/tests/format/Issues/Issue385.sol +0 -13
- package/tests/format/Issues/Issue564.sol +0 -9
- package/tests/format/Issues/__snapshots__/jsfmt.spec.js.snap +0 -174
- package/tests/format/Issues/jsfmt.spec.js +0 -1
- package/tests/format/MemberAccess/MemberAccess.sol +0 -102
- package/tests/format/MemberAccess/__snapshots__/jsfmt.spec.js.snap +0 -243
- package/tests/format/MemberAccess/jsfmt.spec.js +0 -1
- package/tests/format/ModifierDefinitions/ModifierDefinitions.sol +0 -6
- package/tests/format/ModifierDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -29
- package/tests/format/ModifierDefinitions/jsfmt.spec.js +0 -1
- package/tests/format/ModifierInvocations/ModifierInvocations.sol +0 -17
- package/tests/format/ModifierInvocations/__snapshots__/jsfmt.spec.js.snap +0 -51
- package/tests/format/ModifierInvocations/jsfmt.spec.js +0 -1
- package/tests/format/MultipartStrings/MultipartStrings.sol +0 -10
- package/tests/format/MultipartStrings/__snapshots__/jsfmt.spec.js.snap +0 -39
- package/tests/format/MultipartStrings/jsfmt.spec.js +0 -1
- package/tests/format/NameValueExpression/NameValueExpression.sol +0 -6
- package/tests/format/NameValueExpression/__snapshots__/jsfmt.spec.js.snap +0 -68
- package/tests/format/NameValueExpression/jsfmt.spec.js +0 -2
- package/tests/format/Ownable/Ownable.sol +0 -75
- package/tests/format/Ownable/__snapshots__/jsfmt.spec.js.snap +0 -163
- package/tests/format/Ownable/jsfmt.spec.js +0 -1
- package/tests/format/Parentheses/AddNoParentheses.sol +0 -92
- package/tests/format/Parentheses/BitAndNoParentheses.sol +0 -92
- package/tests/format/Parentheses/BitOrNoParentheses.sol +0 -92
- package/tests/format/Parentheses/BitXorNoParentheses.sol +0 -92
- package/tests/format/Parentheses/DivNoParentheses.sol +0 -92
- package/tests/format/Parentheses/ExpNoParentheses.sol +0 -92
- package/tests/format/Parentheses/LogicNoParentheses.sol +0 -20
- package/tests/format/Parentheses/ModNoParentheses.sol +0 -92
- package/tests/format/Parentheses/MulNoParentheses.sol +0 -92
- package/tests/format/Parentheses/ShiftLNoParentheses.sol +0 -92
- package/tests/format/Parentheses/ShiftRNoParentheses.sol +0 -92
- package/tests/format/Parentheses/SubNoParentheses.sol +0 -92
- package/tests/format/Parentheses/__snapshots__/jsfmt.spec.js.snap +0 -2237
- package/tests/format/Parentheses/jsfmt.spec.js +0 -1
- package/tests/format/Pragma/Pragma.sol +0 -8
- package/tests/format/Pragma/__snapshots__/jsfmt.spec.js.snap +0 -29
- package/tests/format/Pragma/jsfmt.spec.js +0 -1
- package/tests/format/PrettierIgnore/PrettierIgnore.sol +0 -39
- package/tests/format/PrettierIgnore/__snapshots__/jsfmt.spec.js.snap +0 -87
- package/tests/format/PrettierIgnore/jsfmt.spec.js +0 -1
- package/tests/format/Proxy/Proxy.sol +0 -52
- package/tests/format/Proxy/__snapshots__/jsfmt.spec.js.snap +0 -127
- package/tests/format/Proxy/jsfmt.spec.js +0 -1
- package/tests/format/RespectDefaultOptions/__snapshots__/jsfmt.spec.js.snap +0 -19
- package/tests/format/RespectDefaultOptions/jsfmt.spec.js +0 -5
- package/tests/format/RespectDefaultOptions/respect-default-options.js +0 -3
- package/tests/format/SampleCrowdsale/SampleCrowdsale.sol +0 -48
- package/tests/format/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap +0 -113
- package/tests/format/SampleCrowdsale/jsfmt.spec.js +0 -1
- package/tests/format/SimpleAuction/SimpleAuction.sol +0 -123
- package/tests/format/SimpleAuction/__snapshots__/jsfmt.spec.js.snap +0 -250
- package/tests/format/SimpleAuction/jsfmt.spec.js +0 -1
- package/tests/format/SimpleStorage/SimpleStorage.sol +0 -14
- package/tests/format/SimpleStorage/__snapshots__/jsfmt.spec.js.snap +0 -41
- package/tests/format/SimpleStorage/jsfmt.spec.js +0 -1
- package/tests/format/SplittableCommodity/SplittableCommodity.sol +0 -57
- package/tests/format/SplittableCommodity/__snapshots__/jsfmt.spec.js.snap +0 -135
- package/tests/format/SplittableCommodity/jsfmt.spec.js +0 -1
- package/tests/format/StateVariableDeclarations/StateVariableDeclarations.sol +0 -3
- package/tests/format/StateVariableDeclarations/__snapshots__/jsfmt.spec.js.snap +0 -20
- package/tests/format/StateVariableDeclarations/jsfmt.spec.js +0 -1
- package/tests/format/StringLiteral/StringLiteral.sol +0 -11
- package/tests/format/StringLiteral/__snapshots__/jsfmt.spec.js.snap +0 -36
- package/tests/format/StringLiteral/jsfmt.spec.js +0 -1
- package/tests/format/StyleGuide/BlankLines.sol +0 -19
- package/tests/format/StyleGuide/ControlStructures.sol +0 -57
- package/tests/format/StyleGuide/FunctionDeclaration.sol +0 -135
- package/tests/format/StyleGuide/Mappings.sol +0 -9
- package/tests/format/StyleGuide/MaximumLineLength.sol +0 -67
- package/tests/format/StyleGuide/OtherRecommendations.sol +0 -29
- package/tests/format/StyleGuide/VariableDeclarations.sol +0 -6
- package/tests/format/StyleGuide/WhitespaceInExpressions.sol +0 -13
- package/tests/format/StyleGuide/__snapshots__/jsfmt.spec.js.snap +0 -772
- package/tests/format/StyleGuide/jsfmt.spec.js +0 -1
- package/tests/format/TryCatch/TryCatch.sol +0 -103
- package/tests/format/TryCatch/__snapshots__/jsfmt.spec.js.snap +0 -241
- package/tests/format/TryCatch/jsfmt.spec.js +0 -1
- package/tests/format/Tupples/Tupples.sol +0 -25
- package/tests/format/Tupples/__snapshots__/jsfmt.spec.js.snap +0 -74
- package/tests/format/Tupples/jsfmt.spec.js +0 -1
- package/tests/format/TypeDefinition/TypeDefinition.sol +0 -12
- package/tests/format/TypeDefinition/__snapshots__/jsfmt.spec.js.snap +0 -74
- package/tests/format/TypeDefinition/jsfmt.spec.js +0 -1
- package/tests/format/WhileStatements/WhileStatements.sol +0 -37
- package/tests/format/WhileStatements/__snapshots__/jsfmt.spec.js.snap +0 -110
- package/tests/format/WhileStatements/jsfmt.spec.js +0 -1
- package/tests/format/WrongCompiler/WrongCompiler.sol +0 -3
- package/tests/format/WrongCompiler/__snapshots__/jsfmt.spec.js.snap +0 -55
- package/tests/format/WrongCompiler/jsfmt.spec.js +0 -10
- package/tests/format/quotes/Quotes.sol +0 -24
- package/tests/format/quotes/__snapshots__/jsfmt.spec.js.snap +0 -135
- package/tests/format/quotes/jsfmt.spec.js +0 -2
- package/tests/format/strings/__snapshots__/jsfmt.spec.js.snap +0 -1579
- package/tests/format/strings/jsfmt.spec.js +0 -1
- package/tests/format/strings/strings.sol +0 -717
- package/tests/unit/binary-operator-printers/__snapshots__/index.test.js.snap +0 -13
- package/tests/unit/binary-operator-printers/index.test.js +0 -5
- package/tests/unit/comments/printer.test.js +0 -9
- package/tests/unit/prettier-version.test.js +0 -26
- package/tests/unit/printer.test.js +0 -9
|
@@ -1 +0,0 @@
|
|
|
1
|
-
run_spec(__dirname, ['solidity-parse']);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
pragma solidity ^0.5.2;
|
|
2
|
-
|
|
3
|
-
contract Arrays {
|
|
4
|
-
bytes32[] public permissions = [bytes32("addPartner"), bytes32("removePartner"), bytes32("addGroup"), bytes32("removeGroup"), bytes32("addUserToGroup"), bytes32("removeUserFromGroup"), bytes32("addSolution"), bytes32("removeSolution"), bytes32("addLibrary"), bytes32("removeLibrary"), bytes32("addPermissionToGroup"), bytes32("removePermissionFromGroup")];
|
|
5
|
-
|
|
6
|
-
function a() {
|
|
7
|
-
Outcome.OutcomeItem[] memory outcomeFrom = abi.decode(fromPart.outcome, (Outcome.OutcomeItem[]));
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
contract ArraySlices {
|
|
12
|
-
function f(bytes calldata x) public {
|
|
13
|
-
bytes memory a1 = abi.decode(x[:], (bytes));
|
|
14
|
-
bytes4 a2 = abi.decode(x[:4], (bytes4));
|
|
15
|
-
address a3 = abi.decode(x[4:], (address));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Arrays.sol format 1`] = `
|
|
4
|
-
====================================options=====================================
|
|
5
|
-
parsers: ["solidity-parse"]
|
|
6
|
-
printWidth: 80
|
|
7
|
-
| printWidth
|
|
8
|
-
=====================================input======================================
|
|
9
|
-
pragma solidity ^0.5.2;
|
|
10
|
-
|
|
11
|
-
contract Arrays {
|
|
12
|
-
bytes32[] public permissions = [bytes32("addPartner"), bytes32("removePartner"), bytes32("addGroup"), bytes32("removeGroup"), bytes32("addUserToGroup"), bytes32("removeUserFromGroup"), bytes32("addSolution"), bytes32("removeSolution"), bytes32("addLibrary"), bytes32("removeLibrary"), bytes32("addPermissionToGroup"), bytes32("removePermissionFromGroup")];
|
|
13
|
-
|
|
14
|
-
function a() {
|
|
15
|
-
Outcome.OutcomeItem[] memory outcomeFrom = abi.decode(fromPart.outcome, (Outcome.OutcomeItem[]));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
contract ArraySlices {
|
|
20
|
-
function f(bytes calldata x) public {
|
|
21
|
-
bytes memory a1 = abi.decode(x[:], (bytes));
|
|
22
|
-
bytes4 a2 = abi.decode(x[:4], (bytes4));
|
|
23
|
-
address a3 = abi.decode(x[4:], (address));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
=====================================output=====================================
|
|
28
|
-
pragma solidity ^0.5.2;
|
|
29
|
-
|
|
30
|
-
contract Arrays {
|
|
31
|
-
bytes32[] public permissions = [
|
|
32
|
-
bytes32("addPartner"),
|
|
33
|
-
bytes32("removePartner"),
|
|
34
|
-
bytes32("addGroup"),
|
|
35
|
-
bytes32("removeGroup"),
|
|
36
|
-
bytes32("addUserToGroup"),
|
|
37
|
-
bytes32("removeUserFromGroup"),
|
|
38
|
-
bytes32("addSolution"),
|
|
39
|
-
bytes32("removeSolution"),
|
|
40
|
-
bytes32("addLibrary"),
|
|
41
|
-
bytes32("removeLibrary"),
|
|
42
|
-
bytes32("addPermissionToGroup"),
|
|
43
|
-
bytes32("removePermissionFromGroup")
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
function a() {
|
|
47
|
-
Outcome.OutcomeItem[] memory outcomeFrom = abi.decode(
|
|
48
|
-
fromPart.outcome,
|
|
49
|
-
(Outcome.OutcomeItem[])
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
contract ArraySlices {
|
|
55
|
-
function f(bytes calldata x) public {
|
|
56
|
-
bytes memory a1 = abi.decode(x[:], (bytes));
|
|
57
|
-
bytes4 a2 = abi.decode(x[:4], (bytes4));
|
|
58
|
-
address a3 = abi.decode(x[4:], (address));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
================================================================================
|
|
63
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
run_spec(__dirname, ['solidity-parse']);
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
contract Assembly {
|
|
2
|
-
function ifAssembly() {
|
|
3
|
-
assembly {
|
|
4
|
-
if
|
|
5
|
-
returndatasize {
|
|
6
|
-
success := 0
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function caseAssembly() {
|
|
12
|
-
assembly {
|
|
13
|
-
switch value
|
|
14
|
-
case 0 {
|
|
15
|
-
mstore(0, 0x0000000000000000000000000000000000000000000000000000000000000000)
|
|
16
|
-
}
|
|
17
|
-
case 1 {
|
|
18
|
-
mstore(0, 0x1111111111111111111111111111111111111111111111111111111111111111)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function forAssembly() {
|
|
24
|
-
assembly {
|
|
25
|
-
for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function callWithComments() {
|
|
30
|
-
assembly {
|
|
31
|
-
f(
|
|
32
|
-
1, // one
|
|
33
|
-
2, // two
|
|
34
|
-
3 // three
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function assemblyFunctionNoParameters() {
|
|
40
|
-
assembly {
|
|
41
|
-
function getAnswer ()
|
|
42
|
-
-> answer {
|
|
43
|
-
answer:= 42
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function assemblyFunctionOneParameter() {
|
|
49
|
-
assembly {
|
|
50
|
-
function inc (x)
|
|
51
|
-
-> result {
|
|
52
|
-
result := add(x,
|
|
53
|
-
1)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function assemblyFunctionThreeParameters() {
|
|
59
|
-
assembly {
|
|
60
|
-
function sum (a, b, c)
|
|
61
|
-
-> result {
|
|
62
|
-
result := add(a,
|
|
63
|
-
add(b, c))
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function assemblyFunctionLongParameters() {
|
|
69
|
-
assembly {
|
|
70
|
-
function sum (thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines)
|
|
71
|
-
-> result {
|
|
72
|
-
result := 0
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function assemblyFunctionLongReturnParameters() {
|
|
78
|
-
assembly {
|
|
79
|
-
function sum (a, b, c, d, e)
|
|
80
|
-
-> thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines {
|
|
81
|
-
thisIs := 0
|
|
82
|
-
aFunctionWithVery := 0
|
|
83
|
-
veryLongParameterNames := 0
|
|
84
|
-
andItAlsoHasALotOfParameters := 0
|
|
85
|
-
soItShouldBeSplitInMultipleLines := 0
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
function assemblyFunctionLongParametersAndReturnParameters() {
|
|
92
|
-
assembly {
|
|
93
|
-
function sum (a,veryLong, listof, parameters, thatShould,splitForSure)
|
|
94
|
-
-> thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines {
|
|
95
|
-
thisIs := 0
|
|
96
|
-
aFunctionWithVery := 0
|
|
97
|
-
veryLongParameterNames := 0
|
|
98
|
-
andItAlsoHasALotOfParameters := 0
|
|
99
|
-
soItShouldBeSplitInMultipleLines := 0
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function assemblyNoParameterCalls() {
|
|
105
|
-
assembly {
|
|
106
|
-
call(gas(), to, value, inputData, inputDataSize, 0, 0)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function assemblyLabels() {
|
|
111
|
-
assembly {
|
|
112
|
-
let n := calldataload(4)
|
|
113
|
-
let a := 1
|
|
114
|
-
let b := a
|
|
115
|
-
loop:
|
|
116
|
-
jumpi(loopend, eq(n, 0))
|
|
117
|
-
a add swap1
|
|
118
|
-
n := sub(n, 1)
|
|
119
|
-
jump(loop)
|
|
120
|
-
|
|
121
|
-
loopend:
|
|
122
|
-
mstore(0, a)
|
|
123
|
-
return(0, 0x20)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
assembly{
|
|
127
|
-
let x := 8
|
|
128
|
-
jump(two)
|
|
129
|
-
one:
|
|
130
|
-
// Here the stack height is 2 (because we pushed x and 7),
|
|
131
|
-
// but the assembler thinks it is 1 because it reads
|
|
132
|
-
// from top to bottom.
|
|
133
|
-
// Accessing the stack variable x here will lead to errors.
|
|
134
|
-
x := 9
|
|
135
|
-
jump(three)
|
|
136
|
-
two:
|
|
137
|
-
7 // push something onto the stack
|
|
138
|
-
jump(one)
|
|
139
|
-
three:
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function assemblyFunctionNoReturn () {
|
|
144
|
-
|
|
145
|
-
assembly {
|
|
146
|
-
|
|
147
|
-
function $somefn(somearg) {
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function letWithoutValue ( ) {
|
|
153
|
-
|
|
154
|
-
assembly { let result }
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function memberAccess ( ) {
|
|
158
|
-
|
|
159
|
-
assembly {
|
|
160
|
-
ds.slot := position
|
|
161
|
-
offset := x.offset
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function commentsInAssemblyBlock () {
|
|
166
|
-
|
|
167
|
-
assembly {
|
|
168
|
-
/* foo bar baz */
|
|
169
|
-
/* foobbbbbb */
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function withBreak() {
|
|
174
|
-
assembly {
|
|
175
|
-
for {} 1 {} {
|
|
176
|
-
break
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Assembly.sol format 1`] = `
|
|
4
|
-
====================================options=====================================
|
|
5
|
-
parsers: ["solidity-parse"]
|
|
6
|
-
printWidth: 80
|
|
7
|
-
| printWidth
|
|
8
|
-
=====================================input======================================
|
|
9
|
-
contract Assembly {
|
|
10
|
-
function ifAssembly() {
|
|
11
|
-
assembly {
|
|
12
|
-
if
|
|
13
|
-
returndatasize {
|
|
14
|
-
success := 0
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function caseAssembly() {
|
|
20
|
-
assembly {
|
|
21
|
-
switch value
|
|
22
|
-
case 0 {
|
|
23
|
-
mstore(0, 0x0000000000000000000000000000000000000000000000000000000000000000)
|
|
24
|
-
}
|
|
25
|
-
case 1 {
|
|
26
|
-
mstore(0, 0x1111111111111111111111111111111111111111111111111111111111111111)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function forAssembly() {
|
|
32
|
-
assembly {
|
|
33
|
-
for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function callWithComments() {
|
|
38
|
-
assembly {
|
|
39
|
-
f(
|
|
40
|
-
1, // one
|
|
41
|
-
2, // two
|
|
42
|
-
3 // three
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function assemblyFunctionNoParameters() {
|
|
48
|
-
assembly {
|
|
49
|
-
function getAnswer ()
|
|
50
|
-
-> answer {
|
|
51
|
-
answer:= 42
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function assemblyFunctionOneParameter() {
|
|
57
|
-
assembly {
|
|
58
|
-
function inc (x)
|
|
59
|
-
-> result {
|
|
60
|
-
result := add(x,
|
|
61
|
-
1)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function assemblyFunctionThreeParameters() {
|
|
67
|
-
assembly {
|
|
68
|
-
function sum (a, b, c)
|
|
69
|
-
-> result {
|
|
70
|
-
result := add(a,
|
|
71
|
-
add(b, c))
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function assemblyFunctionLongParameters() {
|
|
77
|
-
assembly {
|
|
78
|
-
function sum (thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines)
|
|
79
|
-
-> result {
|
|
80
|
-
result := 0
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function assemblyFunctionLongReturnParameters() {
|
|
86
|
-
assembly {
|
|
87
|
-
function sum (a, b, c, d, e)
|
|
88
|
-
-> thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines {
|
|
89
|
-
thisIs := 0
|
|
90
|
-
aFunctionWithVery := 0
|
|
91
|
-
veryLongParameterNames := 0
|
|
92
|
-
andItAlsoHasALotOfParameters := 0
|
|
93
|
-
soItShouldBeSplitInMultipleLines := 0
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
function assemblyFunctionLongParametersAndReturnParameters() {
|
|
100
|
-
assembly {
|
|
101
|
-
function sum (a,veryLong, listof, parameters, thatShould,splitForSure)
|
|
102
|
-
-> thisIs, aFunctionWithVery, veryLongParameterNames, andItAlsoHasALotOfParameters, soItShouldBeSplitInMultipleLines {
|
|
103
|
-
thisIs := 0
|
|
104
|
-
aFunctionWithVery := 0
|
|
105
|
-
veryLongParameterNames := 0
|
|
106
|
-
andItAlsoHasALotOfParameters := 0
|
|
107
|
-
soItShouldBeSplitInMultipleLines := 0
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function assemblyNoParameterCalls() {
|
|
113
|
-
assembly {
|
|
114
|
-
call(gas(), to, value, inputData, inputDataSize, 0, 0)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function assemblyLabels() {
|
|
119
|
-
assembly {
|
|
120
|
-
let n := calldataload(4)
|
|
121
|
-
let a := 1
|
|
122
|
-
let b := a
|
|
123
|
-
loop:
|
|
124
|
-
jumpi(loopend, eq(n, 0))
|
|
125
|
-
a add swap1
|
|
126
|
-
n := sub(n, 1)
|
|
127
|
-
jump(loop)
|
|
128
|
-
|
|
129
|
-
loopend:
|
|
130
|
-
mstore(0, a)
|
|
131
|
-
return(0, 0x20)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
assembly{
|
|
135
|
-
let x := 8
|
|
136
|
-
jump(two)
|
|
137
|
-
one:
|
|
138
|
-
// Here the stack height is 2 (because we pushed x and 7),
|
|
139
|
-
// but the assembler thinks it is 1 because it reads
|
|
140
|
-
// from top to bottom.
|
|
141
|
-
// Accessing the stack variable x here will lead to errors.
|
|
142
|
-
x := 9
|
|
143
|
-
jump(three)
|
|
144
|
-
two:
|
|
145
|
-
7 // push something onto the stack
|
|
146
|
-
jump(one)
|
|
147
|
-
three:
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function assemblyFunctionNoReturn () {
|
|
152
|
-
|
|
153
|
-
assembly {
|
|
154
|
-
|
|
155
|
-
function $somefn(somearg) {
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function letWithoutValue ( ) {
|
|
161
|
-
|
|
162
|
-
assembly { let result }
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function memberAccess ( ) {
|
|
166
|
-
|
|
167
|
-
assembly {
|
|
168
|
-
ds.slot := position
|
|
169
|
-
offset := x.offset
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function commentsInAssemblyBlock () {
|
|
174
|
-
|
|
175
|
-
assembly {
|
|
176
|
-
/* foo bar baz */
|
|
177
|
-
/* foobbbbbb */
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function withBreak() {
|
|
182
|
-
assembly {
|
|
183
|
-
for {} 1 {} {
|
|
184
|
-
break
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
=====================================output=====================================
|
|
191
|
-
contract Assembly {
|
|
192
|
-
function ifAssembly() {
|
|
193
|
-
assembly {
|
|
194
|
-
if returndatasize {
|
|
195
|
-
success := 0
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function caseAssembly() {
|
|
201
|
-
assembly {
|
|
202
|
-
switch value
|
|
203
|
-
case 0 {
|
|
204
|
-
mstore(
|
|
205
|
-
0,
|
|
206
|
-
0x0000000000000000000000000000000000000000000000000000000000000000
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
case 1 {
|
|
210
|
-
mstore(
|
|
211
|
-
0,
|
|
212
|
-
0x1111111111111111111111111111111111111111111111111111111111111111
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function forAssembly() {
|
|
219
|
-
assembly {
|
|
220
|
-
for {
|
|
221
|
-
let i := 0
|
|
222
|
-
} lt(i, x) {
|
|
223
|
-
i := add(i, 1)
|
|
224
|
-
} {
|
|
225
|
-
y := mul(2, y)
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function callWithComments() {
|
|
231
|
-
assembly {
|
|
232
|
-
f(
|
|
233
|
-
1, // one
|
|
234
|
-
2, // two
|
|
235
|
-
3 // three
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function assemblyFunctionNoParameters() {
|
|
241
|
-
assembly {
|
|
242
|
-
function getAnswer() -> answer {
|
|
243
|
-
answer := 42
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function assemblyFunctionOneParameter() {
|
|
249
|
-
assembly {
|
|
250
|
-
function inc(x) -> result {
|
|
251
|
-
result := add(x, 1)
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function assemblyFunctionThreeParameters() {
|
|
257
|
-
assembly {
|
|
258
|
-
function sum(a, b, c) -> result {
|
|
259
|
-
result := add(a, add(b, c))
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function assemblyFunctionLongParameters() {
|
|
265
|
-
assembly {
|
|
266
|
-
function sum(
|
|
267
|
-
thisIs,
|
|
268
|
-
aFunctionWithVery,
|
|
269
|
-
veryLongParameterNames,
|
|
270
|
-
andItAlsoHasALotOfParameters,
|
|
271
|
-
soItShouldBeSplitInMultipleLines
|
|
272
|
-
) -> result {
|
|
273
|
-
result := 0
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function assemblyFunctionLongReturnParameters() {
|
|
279
|
-
assembly {
|
|
280
|
-
function sum(a, b, c, d, e)
|
|
281
|
-
->
|
|
282
|
-
thisIs,
|
|
283
|
-
aFunctionWithVery,
|
|
284
|
-
veryLongParameterNames,
|
|
285
|
-
andItAlsoHasALotOfParameters,
|
|
286
|
-
soItShouldBeSplitInMultipleLines
|
|
287
|
-
{
|
|
288
|
-
thisIs := 0
|
|
289
|
-
aFunctionWithVery := 0
|
|
290
|
-
veryLongParameterNames := 0
|
|
291
|
-
andItAlsoHasALotOfParameters := 0
|
|
292
|
-
soItShouldBeSplitInMultipleLines := 0
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function assemblyFunctionLongParametersAndReturnParameters() {
|
|
298
|
-
assembly {
|
|
299
|
-
function sum(
|
|
300
|
-
a,
|
|
301
|
-
veryLong,
|
|
302
|
-
listof,
|
|
303
|
-
parameters,
|
|
304
|
-
thatShould,
|
|
305
|
-
splitForSure
|
|
306
|
-
)
|
|
307
|
-
->
|
|
308
|
-
thisIs,
|
|
309
|
-
aFunctionWithVery,
|
|
310
|
-
veryLongParameterNames,
|
|
311
|
-
andItAlsoHasALotOfParameters,
|
|
312
|
-
soItShouldBeSplitInMultipleLines
|
|
313
|
-
{
|
|
314
|
-
thisIs := 0
|
|
315
|
-
aFunctionWithVery := 0
|
|
316
|
-
veryLongParameterNames := 0
|
|
317
|
-
andItAlsoHasALotOfParameters := 0
|
|
318
|
-
soItShouldBeSplitInMultipleLines := 0
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function assemblyNoParameterCalls() {
|
|
324
|
-
assembly {
|
|
325
|
-
call(gas(), to, value, inputData, inputDataSize, 0, 0)
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function assemblyLabels() {
|
|
330
|
-
assembly {
|
|
331
|
-
let n := calldataload(4)
|
|
332
|
-
let a := 1
|
|
333
|
-
let b := a
|
|
334
|
-
loop:
|
|
335
|
-
jumpi(loopend, eq(n, 0))
|
|
336
|
-
a
|
|
337
|
-
add
|
|
338
|
-
swap1
|
|
339
|
-
n := sub(n, 1)
|
|
340
|
-
jump(loop)
|
|
341
|
-
|
|
342
|
-
loopend:
|
|
343
|
-
mstore(0, a)
|
|
344
|
-
return(0, 0x20)
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
assembly {
|
|
348
|
-
let x := 8
|
|
349
|
-
jump(two)
|
|
350
|
-
one:
|
|
351
|
-
// Here the stack height is 2 (because we pushed x and 7),
|
|
352
|
-
// but the assembler thinks it is 1 because it reads
|
|
353
|
-
// from top to bottom.
|
|
354
|
-
// Accessing the stack variable x here will lead to errors.
|
|
355
|
-
x := 9
|
|
356
|
-
jump(three)
|
|
357
|
-
two:
|
|
358
|
-
7 // push something onto the stack
|
|
359
|
-
jump(one)
|
|
360
|
-
three:
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function assemblyFunctionNoReturn() {
|
|
365
|
-
assembly {
|
|
366
|
-
function $somefn(somearg) {
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
function letWithoutValue() {
|
|
373
|
-
assembly {
|
|
374
|
-
let result
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function memberAccess() {
|
|
379
|
-
assembly {
|
|
380
|
-
ds.slot := position
|
|
381
|
-
offset := x.offset
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function commentsInAssemblyBlock() {
|
|
386
|
-
assembly {
|
|
387
|
-
/* foo bar baz */
|
|
388
|
-
/* foobbbbbb */
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function withBreak() {
|
|
393
|
-
assembly {
|
|
394
|
-
for {
|
|
395
|
-
|
|
396
|
-
} 1 {
|
|
397
|
-
|
|
398
|
-
} {
|
|
399
|
-
break
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
================================================================================
|
|
406
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
run_spec(__dirname, ['solidity-parse']);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
This is a very simple demonstration of a while loops. Same as JS/c.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
contract BasicIterator {
|
|
6
|
-
|
|
7
|
-
address creator; // reserve one "address"-type spot
|
|
8
|
-
uint8[10] integers; // reserve a chunk of storage for 10 8-bit unsigned integers in an array
|
|
9
|
-
|
|
10
|
-
function BasicIterator()
|
|
11
|
-
{
|
|
12
|
-
creator = msg.sender; // set the creator address
|
|
13
|
-
uint8 x = 0; // initialize an 8-bit, unsigned integer to zero
|
|
14
|
-
while(x < integers.length) // the variable integers was initialized to length 10
|
|
15
|
-
{
|
|
16
|
-
integers[x] = x; // set integers to [0,1,2,3,4,5,6,7,8,9] over ten iterations
|
|
17
|
-
x++;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getSum() constant returns (uint) // "constant" just means this function returns something to the caller
|
|
22
|
-
{ // which is immediately followed by what type gets returned, in this case a full uint256
|
|
23
|
-
uint8 sum = 0;
|
|
24
|
-
uint8 x = 0;
|
|
25
|
-
while(x < integers.length)
|
|
26
|
-
{
|
|
27
|
-
sum = sum + integers[x];
|
|
28
|
-
x++;
|
|
29
|
-
}
|
|
30
|
-
return sum;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**********
|
|
34
|
-
Standard kill() function to recover funds
|
|
35
|
-
**********/
|
|
36
|
-
|
|
37
|
-
function kill()
|
|
38
|
-
{
|
|
39
|
-
if (msg.sender == creator)
|
|
40
|
-
{
|
|
41
|
-
suicide(creator); // kills this contract and sends remaining funds back to creator
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|