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

View File

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

View File

@ -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": [],

View File

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

View File

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

View File

@ -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": [],

View File

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

View File

@ -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": [],

View File

@ -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",