Merge pull request #12043 from ethereum/exportCanonicalName

Export canonicalName
This commit is contained in:
chriseth 2021-09-29 10:11:30 +02:00 committed by GitHub
commit ed7884e341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 76 additions and 4 deletions

View File

@ -8,6 +8,7 @@ Compiler Features:
Bugfixes:
* AST: Export ``canonicalName`` for ``UserDefinedValueTypeDefinition`` and ``ContractDefinition``.

View File

@ -275,6 +275,7 @@ bool ASTJsonConverter::visit(ContractDefinition const& _node)
make_pair("nodes", toJson(_node.subNodes())),
make_pair("scope", idOrNull(_node.scope()))
};
addIfSet(attributes, "canonicalName", _node.annotation().canonicalName);
if (_node.annotation().unimplementedDeclarations.has_value())
attributes.emplace_back("fullyImplemented", _node.annotation().unimplementedDeclarations->empty());
@ -361,6 +362,7 @@ bool ASTJsonConverter::visit(UserDefinedValueTypeDefinition const& _node)
make_pair("nameLocation", sourceLocationToString(_node.nameLocation())),
make_pair("underlyingType", toJson(*_node.underlyingType()))
};
addIfSet(attributes, "canonicalName", _node.annotation().canonicalName);
setJsonNode(_node, "UserDefinedValueTypeDefinition", std::move(attributes));

View File

@ -30,6 +30,7 @@ JSON AST (compact format):
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -1 +1 @@
{"contracts":{"combined_json_with_base_path/c.sol:C":{}},"sourceList":["combined_json_with_base_path/c.sol","combined_json_with_base_path/input.sol"],"sources":{"combined_json_with_base_path/c.sol":{"AST":{"absolutePath":"combined_json_with_base_path/c.sol","exportedSymbols":{"C":[5]},"id":6,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":4,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":5,"linearizedBaseContracts":[5],"name":"C","nameLocation":"69:1:0","nodeType":"ContractDefinition","nodes":[],"scope":6,"src":"60:13:0","usedErrors":[]}],"src":"36:38:0"}},"combined_json_with_base_path/input.sol":{"AST":{"absolutePath":"combined_json_with_base_path/input.sol","exportedSymbols":{"C":[5]},"id":3,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:1"},{"absolutePath":"combined_json_with_base_path/c.sol","file":"./c.sol","id":2,"nameLocation":"-1:-1:-1","nodeType":"ImportDirective","scope":3,"sourceUnit":6,"src":"60:17:1","symbolAliases":[],"unitAlias":""}],"src":"36:42:1"}}},"version": "<VERSION REMOVED>"}
{"contracts":{"combined_json_with_base_path/c.sol:C":{}},"sourceList":["combined_json_with_base_path/c.sol","combined_json_with_base_path/input.sol"],"sources":{"combined_json_with_base_path/c.sol":{"AST":{"absolutePath":"combined_json_with_base_path/c.sol","exportedSymbols":{"C":[5]},"id":6,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":4,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"canonicalName":"C","contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":5,"linearizedBaseContracts":[5],"name":"C","nameLocation":"69:1:0","nodeType":"ContractDefinition","nodes":[],"scope":6,"src":"60:13:0","usedErrors":[]}],"src":"36:38:0"}},"combined_json_with_base_path/input.sol":{"AST":{"absolutePath":"combined_json_with_base_path/input.sol","exportedSymbols":{"C":[5]},"id":3,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:1"},{"absolutePath":"combined_json_with_base_path/c.sol","file":"./c.sol","id":2,"nameLocation":"-1:-1:-1","nodeType":"ImportDirective","scope":3,"sourceUnit":6,"src":"60:17:1","symbolAliases":[],"unitAlias":""}],"src":"36:42:1"}}},"version": "<VERSION REMOVED>"}

View File

@ -31,6 +31,7 @@ JSON AST (compact format):
{
"abstract": false,
"baseContracts": [],
"canonicalName": "Error1",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -10,4 +10,4 @@
2 | pragma solidity >=0.0; contract Errort6 { using foo for ; /* missing type name */ }
| ^
","message":"Recovered in ContractDefinition at '}'.","severity":"warning","sourceLocation":{"end":120,"file":"A","start":119},"type":"Warning"}],"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"Errort6":[3]},"id":4,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":3,"linearizedBaseContracts":[3],"name":"Errort6","nameLocation":"68:7:0","nodeType":"ContractDefinition","nodes":[],"scope":4,"src":"59:35:0","usedErrors":[]}],"src":"36:84:0"},"id":0}}}
","message":"Recovered in ContractDefinition at '}'.","severity":"warning","sourceLocation":{"end":120,"file":"A","start":119},"type":"Warning"}],"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"Errort6":[3]},"id":4,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"canonicalName":"Errort6","contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":3,"linearizedBaseContracts":[3],"name":"Errort6","nameLocation":"68:7:0","nodeType":"ContractDefinition","nodes":[],"scope":4,"src":"59:35:0","usedErrors":[]}],"src":"36:84:0"},"id":0}}}

View File

@ -1 +1 @@
{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nameLocation":"68:1:0","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"97:2:0","statements":[]},"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nameLocation":"81:1:0","nodeType":"FunctionDefinition","parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"82:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"97:0:0"},"scope":6,"src":"72:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"59:42:0","usedErrors":[]}],"src":"36:65:0"},"id":0}}}
{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"canonicalName":"C","contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nameLocation":"68:1:0","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"97:2:0","statements":[]},"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nameLocation":"81:1:0","nodeType":"FunctionDefinition","parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"82:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"97:0:0"},"scope":6,"src":"72:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"59:42:0","usedErrors":[]}],"src":"36:65:0"},"id":0}}}

View File

@ -14,6 +14,7 @@
{
"abstract": true,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"id": 8,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"id": 6,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -18,6 +18,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "A",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -121,6 +122,7 @@
"src": "50:1:1"
}
],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -30,6 +30,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "A",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -64,6 +65,7 @@
"src": "29:1:1"
}
],
"canonicalName": "B",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -99,6 +101,7 @@
"src": "49:1:1"
}
],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -135,6 +138,7 @@
"src": "69:1:1"
}
],
"canonicalName": "D",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -172,6 +176,7 @@
"src": "89:1:1"
}
],
"canonicalName": "E",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -15,6 +15,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"documentation":
@ -57,6 +58,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"documentation":
@ -99,6 +101,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -18,6 +18,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C1",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -52,6 +53,7 @@
"src": "30:2:1"
}
],
"canonicalName": "C2",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -15,6 +15,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "c",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "c",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -22,6 +22,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "A",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -94,6 +95,7 @@
"src": "72:1:1"
}
],
"canonicalName": "B",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": false,
@ -207,6 +209,7 @@
"src": "167:1:1"
}
],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "c",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "c",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -22,6 +22,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "A",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -79,6 +80,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "B",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -164,6 +166,7 @@
"src": "117:1:1"
}
],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -112,6 +112,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -24,6 +24,7 @@
"nodes":
[
{
"canonicalName": "MyAddress",
"id": 2,
"name": "MyAddress",
"nameLocation": "5:9:1",
@ -44,6 +45,7 @@
}
},
{
"canonicalName": "MyUInt",
"id": 4,
"name": "MyUInt",
"nameLocation": "32:6:1",
@ -202,6 +204,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
@ -216,6 +219,7 @@
"nodes":
[
{
"canonicalName": "C.MyAddress",
"id": 18,
"name": "MyAddress",
"nameLocation": "118:9:1",
@ -236,6 +240,7 @@
}
},
{
"canonicalName": "C.MyUInt",
"id": 20,
"name": "MyUInt",
"nameLocation": "149:6:1",

View File

@ -18,6 +18,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "L",
"contractDependencies": [],
"contractKind": "library",
"fullyImplemented": true,
@ -37,6 +38,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "C",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -14,6 +14,7 @@
{
"abstract": false,
"baseContracts": [],
"canonicalName": "Sample",
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,

View File

@ -485,7 +485,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
BOOST_CHECK_EQUAL(
util::jsonCompactPrint(result["sources"]["fileA"]["ast"]),
"{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]},\"id\":2,\"nodeType\":\"SourceUnit\",\"nodes\":[{\"abstract\":false,"
"\"baseContracts\":[],\"contractDependencies\":[],\"contractKind\":\"contract\",\"fullyImplemented\":true,\"id\":1,"
"\"baseContracts\":[],\"canonicalName\":\"A\",\"contractDependencies\":[],\"contractKind\":\"contract\",\"fullyImplemented\":true,\"id\":1,"
"\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nameLocation\":\"9:1:0\",\"nodeType\":\"ContractDefinition\",\"nodes\":[],\"scope\":2,"
"\"src\":\"0:14:0\",\"usedErrors\":[]}],\"src\":\"0:14:0\"}"
);