blob: b95288e95ce87cfb4ec4c2cb05eb3d40f5f7ebb0 [file] [log] [blame]
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +01001//
2// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "Decoder.hpp"
7
George Gekov23c26272021-08-16 11:32:10 +01008namespace asr
9{
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010010
George Gekov23c26272021-08-16 11:32:10 +010011Decoder::Decoder(std::map<int, std::string>& labels) :
12 m_labels(labels) {}
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010013
George Gekov23c26272021-08-16 11:32:10 +010014std::string Decoder::FilterCharacters(std::vector<char>& unfiltered)
15{
16 std::string filtered;
17
18 for (int i = 0; i < unfiltered.size(); ++i)
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010019 {
George Gekov23c26272021-08-16 11:32:10 +010020 if (unfiltered.at(i) == '$')
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010021 {
George Gekov23c26272021-08-16 11:32:10 +010022 continue;
23 }
24 else if (i + 1 < unfiltered.size() && unfiltered.at(i) == unfiltered.at(i + 1))
25 {
26 continue;
27 }
28 else
29 {
30 filtered += unfiltered.at(i);
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010031 }
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010032 }
George Gekov23c26272021-08-16 11:32:10 +010033 return filtered;
34}
35} // namespace asr
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010036