User-defined literal suffixes: AST

This commit is contained in:
Kamil Śliwak 2023-02-24 19:47:00 +01:00
parent 9af3439ff7
commit 2986772f3f
10 changed files with 27 additions and 4 deletions

View File

@ -2156,9 +2156,15 @@ public:
ASTPointer<Expression> _expression, ASTPointer<Expression> _expression,
std::vector<ASTPointer<Expression>> _arguments, std::vector<ASTPointer<Expression>> _arguments,
std::vector<ASTPointer<ASTString>> _names, std::vector<ASTPointer<ASTString>> _names,
std::vector<SourceLocation> _nameLocations std::vector<SourceLocation> _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()); solAssert(m_nameLocations.size() == m_names.size());
} }
@ -2176,6 +2182,7 @@ public:
/// If this is not a named call, this is empty. /// If this is not a named call, this is empty.
std::vector<ASTPointer<ASTString>> const& names() const { return m_names; } std::vector<ASTPointer<ASTString>> const& names() const { return m_names; }
std::vector<SourceLocation> const& nameLocations() const { return m_nameLocations; } std::vector<SourceLocation> const& nameLocations() const { return m_nameLocations; }
bool isSuffixCall() const { return m_isSuffixCall; }
FunctionCallAnnotation& annotation() const override; FunctionCallAnnotation& annotation() const override;
@ -2184,6 +2191,7 @@ private:
std::vector<ASTPointer<Expression>> m_arguments; std::vector<ASTPointer<Expression>> m_arguments;
std::vector<ASTPointer<ASTString>> m_names; std::vector<ASTPointer<ASTString>> m_names;
std::vector<SourceLocation> m_nameLocations; std::vector<SourceLocation> m_nameLocations;
bool m_isSuffixCall;
}; };
/** /**

View File

@ -878,7 +878,8 @@ bool ASTJsonExporter::visit(FunctionCall const& _node)
make_pair("names", std::move(names)), make_pair("names", std::move(names)),
make_pair("nameLocations", sourceLocationsToJson(_node.nameLocations())), make_pair("nameLocations", sourceLocationsToJson(_node.nameLocations())),
make_pair("arguments", toJson(_node.arguments())), 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()) if (_node.annotation().kind.set())

View File

@ -965,7 +965,8 @@ ASTPointer<FunctionCall> ASTJsonImporter::createFunctionCall(Json::Value const&
names, names,
sourceLocations ? sourceLocations ?
*sourceLocations : *sourceLocations :
vector<SourceLocation>(names.size()) vector<SourceLocation>(names.size()),
memberAsBool(_node, "isSuffixCall")
); );
} }

View File

@ -322,6 +322,7 @@
"isConstant": false, "isConstant": false,
"isLValue": false, "isLValue": false,
"isPure": false, "isPure": false,
"isSuffixCall": false,
"kind": "typeConversion", "kind": "typeConversion",
"lValueRequested": false, "lValueRequested": false,
"nameLocations": [], "nameLocations": [],
@ -448,6 +449,7 @@
"isConstant": false, "isConstant": false,
"isLValue": false, "isLValue": false,
"isPure": true, "isPure": true,
"isSuffixCall": false,
"kind": "typeConversion", "kind": "typeConversion",
"lValueRequested": false, "lValueRequested": false,
"nameLocations": [], "nameLocations": [],

View File

@ -214,6 +214,7 @@
} }
}, },
"id": 26, "id": 26,
"isSuffixCall": false,
"nameLocations": [], "nameLocations": [],
"names": [], "names": [],
"nodeType": "FunctionCall", "nodeType": "FunctionCall",
@ -286,6 +287,7 @@
} }
}, },
"id": 34, "id": 34,
"isSuffixCall": false,
"nameLocations": [], "nameLocations": [],
"names": [], "names": [],
"nodeType": "FunctionCall", "nodeType": "FunctionCall",

View File

@ -150,6 +150,7 @@
"typeDescriptions": {} "typeDescriptions": {}
}, },
"id": 18, "id": 18,
"isSuffixCall": false,
"nameLocations": [], "nameLocations": [],
"names": [], "names": [],
"nodeType": "FunctionCall", "nodeType": "FunctionCall",

View File

@ -133,6 +133,7 @@
"isConstant": false, "isConstant": false,
"isLValue": false, "isLValue": false,
"isPure": true, "isPure": true,
"isSuffixCall": false,
"kind": "typeConversion", "kind": "typeConversion",
"lValueRequested": false, "lValueRequested": false,
"nameLocations": [], "nameLocations": [],
@ -181,6 +182,7 @@
"isConstant": false, "isConstant": false,
"isLValue": false, "isLValue": false,
"isPure": true, "isPure": true,
"isSuffixCall": false,
"kind": "typeConversion", "kind": "typeConversion",
"lValueRequested": false, "lValueRequested": false,
"nameLocations": [], "nameLocations": [],

View File

@ -85,6 +85,7 @@
} }
}, },
"id": 10, "id": 10,
"isSuffixCall": false,
"nameLocations": [], "nameLocations": [],
"names": [], "names": [],
"nodeType": "FunctionCall", "nodeType": "FunctionCall",
@ -109,6 +110,7 @@
} }
}, },
"id": 11, "id": 11,
"isSuffixCall": false,
"nameLocations": [], "nameLocations": [],
"names": [], "names": [],
"nodeType": "FunctionCall", "nodeType": "FunctionCall",

View File

@ -65,6 +65,7 @@
"isConstant": false, "isConstant": false,
"isLValue": false, "isLValue": false,
"isPure": false, "isPure": false,
"isSuffixCall": false,
"kind": "functionCall", "kind": "functionCall",
"lValueRequested": false, "lValueRequested": false,
"nameLocations": [], "nameLocations": [],
@ -175,6 +176,7 @@
"isConstant": false, "isConstant": false,
"isLValue": false, "isLValue": false,
"isPure": false, "isPure": false,
"isSuffixCall": false,
"kind": "functionCall", "kind": "functionCall",
"lValueRequested": false, "lValueRequested": false,
"nameLocations": [], "nameLocations": [],

View File

@ -40,6 +40,7 @@
"typeDescriptions": {} "typeDescriptions": {}
}, },
"id": 6, "id": 6,
"isSuffixCall": false,
"nameLocations": [], "nameLocations": [],
"names": [], "names": [],
"nodeType": "FunctionCall", "nodeType": "FunctionCall",
@ -127,6 +128,7 @@
"typeDescriptions": {} "typeDescriptions": {}
}, },
"id": 15, "id": 15,
"isSuffixCall": false,
"nameLocations": [], "nameLocations": [],
"names": [], "names": [],
"nodeType": "FunctionCall", "nodeType": "FunctionCall",