Skip to content

Commit 998cc63

Browse files
smowtonpeterschrammel
authored andcommitted
Add parameter-indexing utility
This creates a map from parameter names to their indices.
1 parent d895844 commit 998cc63

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/util/parameter_indices.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
#include "parameter_indices.h"
3+
4+
std::map<irep_idt,std::size_t> get_parameter_indices(const code_typet& fn_type)
5+
{
6+
std::map<irep_idt,std::size_t> parameter_indices;
7+
for (std::size_t i = 0UL; i != fn_type.parameters().size(); ++i)
8+
parameter_indices.insert({fn_type.parameters().at(i).get_identifier(),i});
9+
return parameter_indices;
10+
}

src/util/parameter_indices.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef PARAMETER_INDICES_H
2+
#define PARAMETER_INDICES_H
3+
4+
#include <unordered_map>
5+
#include "std_types.h"
6+
7+
std::map<irep_idt,std::size_t> get_parameter_indices(const code_typet& fn_type);
8+
9+
#endif

0 commit comments

Comments
 (0)