ROSE 0.11.145.147
Declaration.h
1#ifndef ROSE_BinaryAnalysis_CallingConvention_Declaration_H
2#define ROSE_BinaryAnalysis_CallingConvention_Declaration_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/CallingConvention/BasicTypes.h>
6
7#include <Rose/BinaryAnalysis/ConcreteLocation.h>
8
9#include <Sawyer/Result.h>
10#include <Sawyer/SharedObject.h>
11
12#include <string>
13#include <vector>
14
15class SgAsmType;
16
17namespace Rose {
18namespace BinaryAnalysis {
19namespace CallingConvention {
20
31public:
34
35private:
36 std::string name_; // optional declaration name
37 std::string comment_; // optional declaration comment
38 std::string sourceCode_; // string from which this declaration was parsed
39 DefinitionPtr callingConvention_; // required calling convention definition
40 SgAsmType *returnType_ = nullptr; // type of the function return value
41 std::vector<std::pair<SgAsmType*, std::string>> arguments_; // types (and names) of the arguments
42 std::vector<std::vector<ConcreteLocation>> argumentLocations_; // computed argument locations based on calling convention
43 std::vector<ConcreteLocation> returnLocations_; // location of return value(s)
44
45public:
47protected:
48 explicit Declaration(const DefinitionPtr&);
49public:
75 static Ptr instance(const DefinitionPtr&, const std::string&);
76
77public:
83 const std::string& name() const;
84 void name(const std::string&);
92 const std::string& comment() const;
93 void comment(const std::string&);
97 const std::string& toString() const;
98
103
109
113 size_t nArguments() const;
114
120 SgAsmType* argumentType(size_t index) const;
121
127 const std::string& argumentName(size_t index) const;
128
130 const std::vector<std::pair<SgAsmType*, std::string>>& arguments() const;
131
132public:
144 Sawyer::Result<std::vector<ConcreteLocation>, std::string> argumentLocation(const std::string &argName) const;
158
159private:
160 // Compute locations for all arguments or throw an exception
161 void computeArgumentLocations();
162 void computeReturnLocations();
163};
164
165} // namespace
166} // namespace
167} // namespace
168
169#endif
170#endif
Sawyer::Result< std::vector< ConcreteLocation >, std::string > argumentLocation(size_t index) const
Return the concrete location(s) for a function argument, or an error string.
const std::vector< std::pair< SgAsmType *, std::string > > & arguments() const
Property: The type and name for each argument.
Sawyer::Result< std::vector< ConcreteLocation >, std::string > returnLocation() const
Return concrete location for the function return value, if any, or an error string.
SgAsmType * returnType() const
Property: Return type.
size_t nArguments() const
Property: Number of arguments.
const std::string & name() const
Property: Name.
static Ptr instance(const DefinitionPtr &, const std::string &)
Create a function declaration by parsing a C-like declaration.
const std::string & comment() const
Property: Comment.
void comment(const std::string &)
Property: Comment.
const std::string & argumentName(size_t index) const
Property: Optional argument name.
void name(const std::string &)
Property: Name.
SgAsmType * argumentType(size_t index) const
Property: Argument type.
DefinitionPtr callingConvention() const
Property: Calling convention.
Sawyer::Result< std::vector< ConcreteLocation >, std::string > argumentLocation(const std::string &argName) const
Return the concrete location(s) for a function argument, or an error string.
const std::string & toString() const
Source code from which declaration was parsed.
Result containing a value or an error.
Definition Result.h:315
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
Base class for binary types.
Sawyer::SharedPointer< Declaration > DeclarationPtr
Shared-ownership pointer to Declaration.
The ROSE library.