From 0debb30a4dcaf085ed0ac41da4a24a6659eee1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 24 Feb 2023 19:47:00 +0100 Subject: [PATCH] User-defined literal suffixes: AST --- libsolidity/ast/AST.h | 12 ++++++++++-- libsolidity/ast/ASTJsonExporter.cpp | 3 ++- libsolidity/ast/ASTJsonImporter.cpp | 3 ++- test/libsolidity/ASTJSON/address_payable.json | 2 ++ .../ASTJSON/address_payable_parseOnly.json | 2 ++ .../ast_internal_function_different_ids_export.json | 8 ++++++++ .../ASTJSON/ast_internal_function_id_export.json | 9 +++++++++ .../ASTJSON/event_aggregated_contract.json | 3 +++ .../ASTJSON/event_emited_in_base_contract.json | 1 + .../ASTJSON/fail_after_parsing_parseOnly.json | 1 + test/libsolidity/ASTJSON/indirect_event.json | 3 +++ .../ASTJSON/indirect_event_parseOnly.json | 3 +++ test/libsolidity/ASTJSON/non_utf8.json | 2 ++ test/libsolidity/ASTJSON/non_utf8_parseOnly.json | 2 ++ test/libsolidity/ASTJSON/used_errors.json | 2 ++ test/libsolidity/ASTJSON/used_errors_parseOnly.json | 2 ++ 16 files changed, 54 insertions(+), 4 deletions(-) diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 2608fb8bb..584fa1775 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -2171,9 +2171,15 @@ public: ASTPointer _expression, std::vector> _arguments, std::vector> _names, - std::vector _nameLocations + std::vector _nameLocations, + bool _isSuffixCall = false ): - Expression(_id, _location), m_expression(std::move(_expression)), m_arguments(std::move(_arguments)), m_names(std::move(_names)), m_nameLocations(std::move(_nameLocations)) + Expression(_id, _location), + m_expression(std::move(_expression)), + m_arguments(std::move(_arguments)), + m_names(std::move(_names)), + m_nameLocations(std::move(_nameLocations)), + m_isSuffixCall(_isSuffixCall) { solAssert(m_nameLocations.size() == m_names.size()); } @@ -2191,6 +2197,7 @@ public: /// If this is not a named call, this is empty. std::vector> const& names() const { return m_names; } std::vector const& nameLocations() const { return m_nameLocations; } + bool isSuffixCall() const { return m_isSuffixCall; } FunctionCallAnnotation& annotation() const override; @@ -2199,6 +2206,7 @@ private: std::vector> m_arguments; std::vector> m_names; std::vector m_nameLocations; + bool m_isSuffixCall{}; }; /** diff --git a/libsolidity/ast/ASTJsonExporter.cpp b/libsolidity/ast/ASTJsonExporter.cpp index c91506545..b3abf93f9 100644 --- a/libsolidity/ast/ASTJsonExporter.cpp +++ b/libsolidity/ast/ASTJsonExporter.cpp @@ -893,7 +893,8 @@ bool ASTJsonExporter::visit(FunctionCall const& _node) make_pair("names", std::move(names)), make_pair("nameLocations", sourceLocationsToJson(_node.nameLocations())), make_pair("arguments", toJson(_node.arguments())), - make_pair("tryCall", _node.annotation().tryCall) + make_pair("tryCall", _node.annotation().tryCall), + make_pair("isSuffixCall", _node.isSuffixCall()) }; if (_node.annotation().kind.set()) diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 9329f02cc..82f2bb256 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -970,7 +970,8 @@ ASTPointer ASTJsonImporter::createFunctionCall(Json::Value const& names, sourceLocations ? *sourceLocations : - vector(names.size()) + vector(names.size()), + memberAsBool(_node, "isSuffixCall") ); } diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index eab7e22a8..bf364c09a 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -322,6 +322,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], @@ -448,6 +449,7 @@ "isConstant": false, "isLValue": false, "isPure": true, + "isSuffixCall": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/address_payable_parseOnly.json b/test/libsolidity/ASTJSON/address_payable_parseOnly.json index 28ced57e7..395f0bd11 100644 --- a/test/libsolidity/ASTJSON/address_payable_parseOnly.json +++ b/test/libsolidity/ASTJSON/address_payable_parseOnly.json @@ -214,6 +214,7 @@ } }, "id": 26, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", @@ -286,6 +287,7 @@ } }, "id": 34, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", diff --git a/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json b/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json index cb8ef7724..fbd40379a 100644 --- a/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json +++ b/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json @@ -321,6 +321,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -379,6 +380,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -455,6 +457,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -598,6 +601,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -656,6 +660,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -840,6 +845,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -898,6 +904,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -974,6 +981,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/ast_internal_function_id_export.json b/test/libsolidity/ASTJSON/ast_internal_function_id_export.json index 724413bfa..04ec8338d 100644 --- a/test/libsolidity/ASTJSON/ast_internal_function_id_export.json +++ b/test/libsolidity/ASTJSON/ast_internal_function_id_export.json @@ -471,6 +471,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -529,6 +530,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -1083,6 +1085,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -1141,6 +1144,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -1199,6 +1203,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -1275,6 +1280,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -1351,6 +1357,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -1482,6 +1489,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -1522,6 +1530,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/event_aggregated_contract.json b/test/libsolidity/ASTJSON/event_aggregated_contract.json index b1b8f76dd..7896f0ac2 100644 --- a/test/libsolidity/ASTJSON/event_aggregated_contract.json +++ b/test/libsolidity/ASTJSON/event_aggregated_contract.json @@ -79,6 +79,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -277,6 +278,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -342,6 +344,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/event_emited_in_base_contract.json b/test/libsolidity/ASTJSON/event_emited_in_base_contract.json index a7dbac9dd..92cfea578 100644 --- a/test/libsolidity/ASTJSON/event_emited_in_base_contract.json +++ b/test/libsolidity/ASTJSON/event_emited_in_base_contract.json @@ -185,6 +185,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json index 68487d21e..9697992f0 100644 --- a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json +++ b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json @@ -150,6 +150,7 @@ "typeDescriptions": {} }, "id": 18, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", diff --git a/test/libsolidity/ASTJSON/indirect_event.json b/test/libsolidity/ASTJSON/indirect_event.json index 0f836e172..6aaca7da9 100644 --- a/test/libsolidity/ASTJSON/indirect_event.json +++ b/test/libsolidity/ASTJSON/indirect_event.json @@ -80,6 +80,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -218,6 +219,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -258,6 +260,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/indirect_event_parseOnly.json b/test/libsolidity/ASTJSON/indirect_event_parseOnly.json index e2d4cd123..984e47a8b 100644 --- a/test/libsolidity/ASTJSON/indirect_event_parseOnly.json +++ b/test/libsolidity/ASTJSON/indirect_event_parseOnly.json @@ -53,6 +53,7 @@ "typeDescriptions": {} }, "id": 6, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", @@ -155,6 +156,7 @@ "typeDescriptions": {} }, "id": 18, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", @@ -180,6 +182,7 @@ "typeDescriptions": {} }, "id": 21, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 2931e66f3..e0c2715d9 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -133,6 +133,7 @@ "isConstant": false, "isLValue": false, "isPure": true, + "isSuffixCall": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], @@ -181,6 +182,7 @@ "isConstant": false, "isLValue": false, "isPure": true, + "isSuffixCall": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json index ddf5de637..c93770e45 100644 --- a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json +++ b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json @@ -85,6 +85,7 @@ } }, "id": 10, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", @@ -109,6 +110,7 @@ } }, "id": 11, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", diff --git a/test/libsolidity/ASTJSON/used_errors.json b/test/libsolidity/ASTJSON/used_errors.json index 6a7b8fba0..56b951a87 100644 --- a/test/libsolidity/ASTJSON/used_errors.json +++ b/test/libsolidity/ASTJSON/used_errors.json @@ -65,6 +65,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], @@ -175,6 +176,7 @@ "isConstant": false, "isLValue": false, "isPure": false, + "isSuffixCall": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], diff --git a/test/libsolidity/ASTJSON/used_errors_parseOnly.json b/test/libsolidity/ASTJSON/used_errors_parseOnly.json index 109d91d82..3912a454a 100644 --- a/test/libsolidity/ASTJSON/used_errors_parseOnly.json +++ b/test/libsolidity/ASTJSON/used_errors_parseOnly.json @@ -40,6 +40,7 @@ "typeDescriptions": {} }, "id": 6, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", @@ -127,6 +128,7 @@ "typeDescriptions": {} }, "id": 15, + "isSuffixCall": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall",