Skip to content

Commit fd4dc3d

Browse files
remove checkTokenType()
1 parent b93b93b commit fd4dc3d

File tree

3 files changed

+22
-38
lines changed

3 files changed

+22
-38
lines changed

libs/libvtrutil/src/vtr_token.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Tokens::Tokens(std::string_view inString) {
4545
if (cur_token_type != e_token_type::NULL_TOKEN) {
4646
// Finalize the current token
4747
t_token& current_token = tokens_.back();
48-
current_token.data = std::string(inString.substr(prev_in_string_index,
49-
in_string_index - prev_in_string_index));
48+
current_token.data = inString.substr(prev_in_string_index,
49+
in_string_index - prev_in_string_index);
5050
}
5151
if (new_token_type != e_token_type::NULL_TOKEN) {
5252
// Start a new token
@@ -63,8 +63,8 @@ Tokens::Tokens(std::string_view inString) {
6363
// Finalize the last token if it exists
6464
if (cur_token_type != e_token_type::NULL_TOKEN && !tokens_.empty()) {
6565
t_token& current_token = tokens_.back();
66-
current_token.data = std::string(inString.substr(prev_in_string_index,
67-
in_string_index - prev_in_string_index));
66+
current_token.data = inString.substr(prev_in_string_index,
67+
in_string_index - prev_in_string_index);
6868
}
6969
}
7070

@@ -102,14 +102,6 @@ enum e_token_type GetTokenTypeFromChar(const enum e_token_type cur_token_type,
102102
}
103103
}
104104

105-
///@brief Returns true if the token's type equals to token_type
106-
bool checkTokenType(const t_token& token, enum e_token_type token_type) {
107-
if (token.type != token_type) {
108-
return false;
109-
}
110-
return true;
111-
}
112-
113105
///@brief Returns a 2D array representing the atof result of all the input string entries seperated by whitespace
114106
void my_atof_2D(float** matrix, const int max_i, const int max_j, const char* instring) {
115107
int i, j;

libs/libvtrutil/src/vtr_token.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class Tokens {
4343
std::vector<t_token> tokens_;
4444
};
4545

46-
bool checkTokenType(const t_token& token, enum e_token_type token_type);
47-
4846
void my_atof_2D(float** matrix, const int max_i, const int max_j, const char* instring);
4947

5048
bool check_my_atof_2D(const int max_i, const int max_j, const char* instring, int* num_entries);

vpr/src/pack/pb_type_graph.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,29 +1304,27 @@ static bool realloc_and_load_pb_graph_pin_ptrs_at_var(const int line_num,
13041304
(*token_index)++;
13051305
if (tokens[*token_index].type == e_token_type::OPEN_SQUARE_BRACKET) {
13061306
(*token_index)++;
1307-
if (!checkTokenType(tokens[*token_index], e_token_type::INT)) {
1307+
if (tokens[*token_index].type != e_token_type::INT) {
13081308
return false; //clb[abc
13091309
}
13101310
pb_msb = vtr::atoi(tokens[*token_index].data);
13111311
VTR_ASSERT_MSG(pb_msb >= 0, "Pin most-significant-bit must be non-negative");
13121312
(*token_index)++;
1313-
if (!checkTokenType(tokens[*token_index], e_token_type::COLON)) {
1314-
if (!checkTokenType(tokens[*token_index],
1315-
e_token_type::CLOSE_SQUARE_BRACKET)) {
1313+
if (tokens[*token_index].type != e_token_type::COLON) {
1314+
if (tokens[*token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
13161315
return false; //clb[9abc
13171316
}
13181317
pb_lsb = pb_msb;
13191318
(*token_index)++;
13201319
} else {
13211320
(*token_index)++;
1322-
if (!checkTokenType(tokens[*token_index], e_token_type::INT)) {
1321+
if (tokens[*token_index].type != e_token_type::INT) {
13231322
return false; //clb[9:abc
13241323
}
13251324
pb_lsb = vtr::atoi(tokens[*token_index].data);
13261325
VTR_ASSERT_MSG(pb_lsb >= 0, "Pin most-significant-bit must be non-negative");
13271326
(*token_index)++;
1328-
if (!checkTokenType(tokens[*token_index],
1329-
e_token_type::CLOSE_SQUARE_BRACKET)) {
1327+
if (tokens[*token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
13301328
return false; //clb[9:0abc
13311329
}
13321330
(*token_index)++;
@@ -1359,29 +1357,27 @@ static bool realloc_and_load_pb_graph_pin_ptrs_at_var(const int line_num,
13591357

13601358
if (tokens[*token_index].type == e_token_type::OPEN_SQUARE_BRACKET) {
13611359
(*token_index)++;
1362-
if (!checkTokenType(tokens[*token_index], e_token_type::INT)) {
1360+
if (tokens[*token_index].type != e_token_type::INT) {
13631361
return false;
13641362
}
13651363
pb_msb = vtr::atoi(tokens[*token_index].data);
13661364
VTR_ASSERT_MSG(pb_msb >= 0, "Pin most-significant-bit must be non-negative");
13671365
(*token_index)++;
1368-
if (!checkTokenType(tokens[*token_index], e_token_type::COLON)) {
1369-
if (!checkTokenType(tokens[*token_index],
1370-
e_token_type::CLOSE_SQUARE_BRACKET)) {
1366+
if (tokens[*token_index].type != e_token_type::COLON) {
1367+
if (tokens[*token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
13711368
return false;
13721369
}
13731370
pb_lsb = pb_msb;
13741371
(*token_index)++;
13751372
} else {
13761373
(*token_index)++;
1377-
if (!checkTokenType(tokens[*token_index], e_token_type::INT)) {
1374+
if (tokens[*token_index].type != e_token_type::INT) {
13781375
return false;
13791376
}
13801377
pb_lsb = vtr::atoi(tokens[*token_index].data);
13811378
VTR_ASSERT_MSG(pb_lsb >= 0, "Pin most-significant-bit must be non-negative");
13821379
(*token_index)++;
1383-
if (!checkTokenType(tokens[*token_index],
1384-
e_token_type::CLOSE_SQUARE_BRACKET)) {
1380+
if (tokens[*token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
13851381
return false;
13861382
}
13871383
(*token_index)++;
@@ -1413,13 +1409,13 @@ static bool realloc_and_load_pb_graph_pin_ptrs_at_var(const int line_num,
14131409

14141410
found = false;
14151411

1416-
if (!checkTokenType(tokens[*token_index], e_token_type::DOT)) {
1412+
if (tokens[*token_index].type != e_token_type::DOT) {
14171413
return false; //clb[9:0]123
14181414
}
14191415
(*token_index)++;
14201416

1421-
bool is_string = !checkTokenType(tokens[*token_index], e_token_type::STRING);
1422-
bool is_int = !checkTokenType(tokens[*token_index], e_token_type::INT);
1417+
bool is_string = tokens[*token_index].type == e_token_type::STRING;
1418+
bool is_int = tokens[*token_index].type == e_token_type::INT;
14231419

14241420
if (!is_string && !is_int)
14251421
return false;
@@ -1435,29 +1431,27 @@ static bool realloc_and_load_pb_graph_pin_ptrs_at_var(const int line_num,
14351431

14361432
if (tokens[*token_index].type == e_token_type::OPEN_SQUARE_BRACKET) {
14371433
(*token_index)++;
1438-
if (!checkTokenType(tokens[*token_index], e_token_type::INT)) {
1434+
if (tokens[*token_index].type != e_token_type::INT) {
14391435
return false;
14401436
}
14411437
pin_msb = vtr::atoi(tokens[*token_index].data);
14421438
VTR_ASSERT_MSG(pin_msb >= 0, "Pin most-significant-bit must be non-negative");
14431439
(*token_index)++;
1444-
if (!checkTokenType(tokens[*token_index], e_token_type::COLON)) {
1445-
if (!checkTokenType(tokens[*token_index],
1446-
e_token_type::CLOSE_SQUARE_BRACKET)) {
1440+
if (tokens[*token_index].type != e_token_type::COLON) {
1441+
if (tokens[*token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
14471442
return false;
14481443
}
14491444
pin_lsb = pin_msb;
14501445
(*token_index)++;
14511446
} else {
14521447
(*token_index)++;
1453-
if (!checkTokenType(tokens[*token_index], e_token_type::INT)) {
1448+
if (tokens[*token_index].type != e_token_type::INT) {
14541449
return false;
14551450
}
14561451
pin_lsb = vtr::atoi(tokens[*token_index].data);
14571452
VTR_ASSERT_MSG(pin_lsb >= 0, "Pin most-significant-bit must be non-negative");
14581453
(*token_index)++;
1459-
if (!checkTokenType(tokens[*token_index],
1460-
e_token_type::CLOSE_SQUARE_BRACKET)) {
1454+
if (tokens[*token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
14611455
return false;
14621456
}
14631457
(*token_index)++;

0 commit comments

Comments
 (0)