PandA-2024.02
aadl_information.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2015-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
41 #include "aadl_information.hpp"
43 
45 #include "exceptions.hpp"
46 #include <boost/algorithm/string/replace.hpp>
47 
49  : endianess(NATIVE_ENDIANESS), direction(INOUT), num_registers(0), bambu_address(0), pointer(false)
50 {
51 }
52 
54 AadlInformation::AadlParameter::Endianess(const std::string& endianess_string)
55 {
56  if(endianess_string == "UPER")
57  {
58  return BIG_ENDIANESS;
59  }
60  if(endianess_string == "LOWER")
61  {
62  return LITTLE_ENDIANESS;
63  }
64  if(endianess_string == "NATIVE")
65  {
66  return NATIVE_ENDIANESS;
67  }
68  THROW_UNREACHABLE(endianess_string);
69  return BIG_ENDIANESS;
70 }
71 
73 AadlInformation::AadlParameter::GetDirection(const std::string& direction_string)
74 {
75  if(direction_string == "IN")
76  {
77  return IN;
78  }
79  if(direction_string == "OUT")
80  {
81  return OUT;
82  }
83  if(direction_string == "IN OUT")
84  {
85  return INOUT;
86  }
87  THROW_UNREACHABLE(direction_string);
88  return IN;
89 }
90 
91 std::string AadlInformation::Normalize(const std::string& name) const
92 {
93  return boost::replace_all_copy(name, "-", "_");
94 }
95 
96 void AadlInformation::AddAsnType(const std::string& name, const AsnTypeRef& asn_type)
97 {
98  asn_types[Normalize(name)] = asn_type;
99 }
100 
102 {
103  const auto normalized = Normalize(name);
104  THROW_ASSERT(asn_types.find(normalized) != asn_types.end(), name);
105  return asn_types.find(normalized)->second;
106 }
The information collected from aadl file.
AsnTypeRef CGetAsnType(const std::string &name) const
Get an asn_type.
std::string name
The name of the parameter;.
std::string asn_type
The type of the parameter.
exceptions managed by PandA
static Direction GetDirection(const std::string &direction_string)
Return the direction.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Definition: exceptions.hpp:292
enum { IN, OUT, INOUT } Direction
std::string Normalize(const std::string &name) const
Normalize asn_type name.
enum { BIG_ENDIANESS, LITTLE_ENDIANESS, NATIVE_ENDIANESS } EndianessType
void AddAsnType(const std::string &name, const AsnTypeRef &asn_type)
Add an asn_type.
CustomMap< std::string, AsnTypeRef > asn_types
The asn types.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
static EndianessType Endianess(const std::string &endianess_string)
Return the endianess.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

Generated on Mon Feb 12 2024 13:02:54 for PandA-2024.02 by doxygen 1.8.13