Skip to content

Commit cc95e67

Browse files
committed
feat(esc): improve data type naming
1 parent e270e04 commit cc95e67

18 files changed

+185
-100
lines changed

compiler/carpntr/build/program_code.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ struct yy__configuration_Config;
5858
#define yy__os_Arguments struct yk__arguments*
5959
#define yy__os_get_args yk__get_args
6060
#define yy__os_ProcessResult struct yk__process_result*
61-
struct yktuple0;
62-
typedef int32_t (*ykfncptr0)(void*);
63-
typedef void (*ykfncptr1)(void*);
61+
struct yt_tuple_fn_in_any_ptr_out_any_ptr;
62+
typedef int32_t (*yt_fn_in_any_ptr_out_int)(void*);
63+
typedef void (*yt_fn_in_any_ptr_out)(void*);
6464
struct yy__raylib_support_CObject* yy__raylib_support_fill_arguments(yk__sds, struct yy__raylib_support_CObject*, bool);
6565
struct yy__raylib_support_CObject* yy__raylib_support_fill_web_arguments(yk__sds, struct yy__raylib_support_CObject*);
6666
struct yy__raylib_support_CObject* yy__raylib_support_co(yk__sds, yk__sds, yk__sds, bool, bool);
@@ -84,11 +84,11 @@ void yy__condition_destroy(yy__condition_Condition*);
8484
int32_t yy__condition_signal(yy__condition_Condition*);
8585
int32_t yy__condition_broadcast(yy__condition_Condition*);
8686
int32_t yy__condition_wait(yy__condition_Condition*, yy__mutex_Mutex*);
87-
int32_t yy__thread_create_with_data(yy__thread_Thread*, ykfncptr0, void*);
87+
int32_t yy__thread_create_with_data(yy__thread_Thread*, yt_fn_in_any_ptr_out_int, void*);
8888
void yy__thread_exit(int32_t);
8989
int32_t yy__thread_join(yy__thread_Thread);
9090
struct yy__pool_ThreadPool* yy__pool_create(uint8_t, uint32_t);
91-
int32_t yy__pool_add(struct yy__pool_ThreadPool*, ykfncptr1, void*);
91+
int32_t yy__pool_add(struct yy__pool_ThreadPool*, yt_fn_in_any_ptr_out, void*);
9292
int32_t yy__pool_destroy(struct yy__pool_ThreadPool*, bool);
9393
int32_t yy__pool_internal_del_pool(struct yy__pool_ThreadPool*);
9494
int32_t yy__pool_internal_tpool_work(void*);
@@ -210,7 +210,7 @@ struct yy__pool_ThreadPool {
210210
yy__mutex_Mutex yy__pool_lock;
211211
yy__condition_Condition yy__pool_notify;
212212
yy__thread_Thread* yy__pool_threads;
213-
struct yktuple0* yy__pool_queue;
213+
struct yt_tuple_fn_in_any_ptr_out_any_ptr* yy__pool_queue;
214214
int32_t yy__pool_thread_count;
215215
int32_t yy__pool_queue_size;
216216
int32_t yy__pool_head;
@@ -273,7 +273,7 @@ struct yy__configuration_Config {
273273
struct yy__configuration_Compilation* yy__configuration_compilation;
274274
yk__sds* yy__configuration_errors;
275275
};
276-
struct yktuple0 { ykfncptr1 e1; void* e2; };
276+
struct yt_tuple_fn_in_any_ptr_out_any_ptr { yt_fn_in_any_ptr_out e1; void* e2; };
277277
// --functions--
278278
struct yy__raylib_support_CObject* yy__raylib_support_fill_arguments(yk__sds yy__raylib_support_src_path, struct yy__raylib_support_CObject* yy__raylib_support_c, bool yy__raylib_support_dll)
279279
{
@@ -732,7 +732,7 @@ void yy__condition_destroy(yy__condition_Condition* nn__cnd) { cnd_destroy(nn__c
732732
int32_t yy__condition_signal(yy__condition_Condition* nn__cnd) { return cnd_signal(nn__cnd); }
733733
int32_t yy__condition_broadcast(yy__condition_Condition* nn__cnd) { return cnd_broadcast(nn__cnd); }
734734
int32_t yy__condition_wait(yy__condition_Condition* nn__cnd, yy__mutex_Mutex* nn__mtx) { return cnd_wait(nn__cnd, nn__mtx); }
735-
int32_t yy__thread_create_with_data(yy__thread_Thread* nn__thr, ykfncptr0 nn__func, void* nn__data) { return thrd_create(nn__thr, nn__func, nn__data); }
735+
int32_t yy__thread_create_with_data(yy__thread_Thread* nn__thr, yt_fn_in_any_ptr_out_int nn__func, void* nn__data) { return thrd_create(nn__thr, nn__func, nn__data); }
736736
void yy__thread_exit(int32_t nn__res) { thrd_exit(nn__res); }
737737
int32_t yy__thread_join(yy__thread_Thread nn__thr)
738738
{
@@ -790,7 +790,7 @@ struct yy__pool_ThreadPool* yy__pool_create(uint8_t yy__pool_thread_count, uint3
790790
struct yy__pool_ThreadPool* t__4 = yy__pool_tpool;
791791
return t__4;
792792
}
793-
int32_t yy__pool_add(struct yy__pool_ThreadPool* yy__pool_tpool, ykfncptr1 yy__pool_func, void* yy__pool_arg)
793+
int32_t yy__pool_add(struct yy__pool_ThreadPool* yy__pool_tpool, yt_fn_in_any_ptr_out yy__pool_func, void* yy__pool_arg)
794794
{
795795
int32_t yy__pool_err = yy__pool_SUCCESS;
796796
int32_t yy__pool_next = INT32_C(0);
@@ -906,7 +906,7 @@ int32_t yy__pool_internal_del_pool(struct yy__pool_ThreadPool* yy__pool_tpool)
906906
int32_t yy__pool_internal_tpool_work(void* yy__pool_tpool_obj)
907907
{
908908
struct yy__pool_ThreadPool* yy__pool_tpool = ((struct yy__pool_ThreadPool*)yy__pool_tpool_obj);
909-
struct yktuple0 yy__pool_task;
909+
struct yt_tuple_fn_in_any_ptr_out_any_ptr yy__pool_task;
910910
while (true)
911911
{
912912
yy__mutex_lock((&(yy__pool_tpool->yy__pool_lock)));
@@ -927,7 +927,7 @@ int32_t yy__pool_internal_tpool_work(void* yy__pool_tpool_obj)
927927
yy__pool_tpool->yy__pool_head = (((yy__pool_tpool->yy__pool_head + INT32_C(1))) % yy__pool_tpool->yy__pool_queue_size);
928928
yy__pool_tpool->yy__pool_count -= INT32_C(1);
929929
yy__mutex_unlock((&(yy__pool_tpool->yy__pool_lock)));
930-
ykfncptr1 yy__pool_fnc = yy__pool_task.e1;
930+
yt_fn_in_any_ptr_out yy__pool_fnc = yy__pool_task.e1;
931931
yy__pool_fnc(yy__pool_task.e2);
932932
}
933933
yy__pool_tpool->yy__pool_started -= INT32_C(1);

compiler/carpntr/main.yaka.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ struct yy__configuration_Config;
4848
#define yy__os_Arguments struct yk__arguments*
4949
#define yy__os_get_args yk__get_args
5050
#define yy__os_ProcessResult struct yk__process_result*
51-
struct yktuple0;
52-
typedef int32_t (*ykfncptr0)(void*);
53-
typedef void (*ykfncptr1)(void*);
51+
struct yt_tuple_fn_in_any_ptr_out_any_ptr;
52+
typedef int32_t (*yt_fn_in_any_ptr_out_int)(void*);
53+
typedef void (*yt_fn_in_any_ptr_out)(void*);
5454
struct yy__raylib_support_CObject* yy__raylib_support_fill_arguments(yk__sds, struct yy__raylib_support_CObject*, bool);
5555
struct yy__raylib_support_CObject* yy__raylib_support_fill_web_arguments(yk__sds, struct yy__raylib_support_CObject*);
5656
struct yy__raylib_support_CObject* yy__raylib_support_co(yk__sds, yk__sds, yk__sds, bool, bool);
@@ -74,11 +74,11 @@ void yy__condition_destroy(yy__condition_Condition*);
7474
int32_t yy__condition_signal(yy__condition_Condition*);
7575
int32_t yy__condition_broadcast(yy__condition_Condition*);
7676
int32_t yy__condition_wait(yy__condition_Condition*, yy__mutex_Mutex*);
77-
int32_t yy__thread_create_with_data(yy__thread_Thread*, ykfncptr0, void*);
77+
int32_t yy__thread_create_with_data(yy__thread_Thread*, yt_fn_in_any_ptr_out_int, void*);
7878
void yy__thread_exit(int32_t);
7979
int32_t yy__thread_join(yy__thread_Thread);
8080
struct yy__pool_ThreadPool* yy__pool_create(uint8_t, uint32_t);
81-
int32_t yy__pool_add(struct yy__pool_ThreadPool*, ykfncptr1, void*);
81+
int32_t yy__pool_add(struct yy__pool_ThreadPool*, yt_fn_in_any_ptr_out, void*);
8282
int32_t yy__pool_destroy(struct yy__pool_ThreadPool*, bool);
8383
int32_t yy__pool_internal_del_pool(struct yy__pool_ThreadPool*);
8484
int32_t yy__pool_internal_tpool_work(void*);
@@ -200,7 +200,7 @@ struct yy__pool_ThreadPool {
200200
yy__mutex_Mutex yy__pool_lock;
201201
yy__condition_Condition yy__pool_notify;
202202
yy__thread_Thread* yy__pool_threads;
203-
struct yktuple0* yy__pool_queue;
203+
struct yt_tuple_fn_in_any_ptr_out_any_ptr* yy__pool_queue;
204204
int32_t yy__pool_thread_count;
205205
int32_t yy__pool_queue_size;
206206
int32_t yy__pool_head;
@@ -263,7 +263,7 @@ struct yy__configuration_Config {
263263
struct yy__configuration_Compilation* yy__configuration_compilation;
264264
yk__sds* yy__configuration_errors;
265265
};
266-
struct yktuple0 { ykfncptr1 e1; void* e2; };
266+
struct yt_tuple_fn_in_any_ptr_out_any_ptr { yt_fn_in_any_ptr_out e1; void* e2; };
267267
// --functions--
268268
struct yy__raylib_support_CObject* yy__raylib_support_fill_arguments(yk__sds yy__raylib_support_src_path, struct yy__raylib_support_CObject* yy__raylib_support_c, bool yy__raylib_support_dll)
269269
{
@@ -722,7 +722,7 @@ void yy__condition_destroy(yy__condition_Condition* nn__cnd) { cnd_destroy(nn__c
722722
int32_t yy__condition_signal(yy__condition_Condition* nn__cnd) { return cnd_signal(nn__cnd); }
723723
int32_t yy__condition_broadcast(yy__condition_Condition* nn__cnd) { return cnd_broadcast(nn__cnd); }
724724
int32_t yy__condition_wait(yy__condition_Condition* nn__cnd, yy__mutex_Mutex* nn__mtx) { return cnd_wait(nn__cnd, nn__mtx); }
725-
int32_t yy__thread_create_with_data(yy__thread_Thread* nn__thr, ykfncptr0 nn__func, void* nn__data) { return thrd_create(nn__thr, nn__func, nn__data); }
725+
int32_t yy__thread_create_with_data(yy__thread_Thread* nn__thr, yt_fn_in_any_ptr_out_int nn__func, void* nn__data) { return thrd_create(nn__thr, nn__func, nn__data); }
726726
void yy__thread_exit(int32_t nn__res) { thrd_exit(nn__res); }
727727
int32_t yy__thread_join(yy__thread_Thread nn__thr)
728728
{
@@ -780,7 +780,7 @@ struct yy__pool_ThreadPool* yy__pool_create(uint8_t yy__pool_thread_count, uint3
780780
struct yy__pool_ThreadPool* t__4 = yy__pool_tpool;
781781
return t__4;
782782
}
783-
int32_t yy__pool_add(struct yy__pool_ThreadPool* yy__pool_tpool, ykfncptr1 yy__pool_func, void* yy__pool_arg)
783+
int32_t yy__pool_add(struct yy__pool_ThreadPool* yy__pool_tpool, yt_fn_in_any_ptr_out yy__pool_func, void* yy__pool_arg)
784784
{
785785
int32_t yy__pool_err = yy__pool_SUCCESS;
786786
int32_t yy__pool_next = INT32_C(0);
@@ -896,7 +896,7 @@ int32_t yy__pool_internal_del_pool(struct yy__pool_ThreadPool* yy__pool_tpool)
896896
int32_t yy__pool_internal_tpool_work(void* yy__pool_tpool_obj)
897897
{
898898
struct yy__pool_ThreadPool* yy__pool_tpool = ((struct yy__pool_ThreadPool*)yy__pool_tpool_obj);
899-
struct yktuple0 yy__pool_task;
899+
struct yt_tuple_fn_in_any_ptr_out_any_ptr yy__pool_task;
900900
while (true)
901901
{
902902
yy__mutex_lock((&(yy__pool_tpool->yy__pool_lock)));
@@ -917,7 +917,7 @@ int32_t yy__pool_internal_tpool_work(void* yy__pool_tpool_obj)
917917
yy__pool_tpool->yy__pool_head = (((yy__pool_tpool->yy__pool_head + INT32_C(1))) % yy__pool_tpool->yy__pool_queue_size);
918918
yy__pool_tpool->yy__pool_count -= INT32_C(1);
919919
yy__mutex_unlock((&(yy__pool_tpool->yy__pool_lock)));
920-
ykfncptr1 yy__pool_fnc = yy__pool_task.e1;
920+
yt_fn_in_any_ptr_out yy__pool_fnc = yy__pool_task.e1;
921921
yy__pool_fnc(yy__pool_task.e2);
922922
}
923923
yy__pool_tpool->yy__pool_started -= INT32_C(1);

compiler/src/compiler/entry_struct_func_compiler.cpp

+105-25
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,26 @@
4040
#include "entry_struct_func_compiler.h"
4141
#include <iomanip>
4242
#include <iostream>
43+
const std::vector<std::pair<std::string, std::string>> REPLACEMENTS = {
44+
{"function", "fn"},
45+
{"m_entry", "pair"},
46+
{"_s_pair_", "_pair_str_"},
47+
{"fixed_arr", "arr"}};
4348
using namespace yaksha;
4449
entry_struct_func_compiler::entry_struct_func_compiler(ykdt_pool *pool)
4550
: pool_(pool), counter_(0), autogen_structs_list_(), autogen_structs_(),
4651
autogen_func_typedefs_(), autogen_func_typedef_list_(),
4752
counter_functions_(0), code_(), code_fnc_(), counter_tuples_(0),
4853
autogen_tuple_list_(), autogen_tuples_(), code_tuples_(),
49-
counter_bin_data_(0), autogen_bin_data_(), bin_data_(), counter_fxa_(0) {}
54+
counter_bin_data_(0), autogen_bin_data_(), bin_data_(), counter_fxa_(0),
55+
forward_decls_(), name_improvements_() {}
5056
std::string entry_struct_func_compiler::compile(ykdatatype *entry_dt,
5157
datatype_compiler *dtc) {
5258
std::string repr = entry_dt->as_string();
5359
if (autogen_structs_.find(repr) != autogen_structs_.end()) {
54-
return "struct ykentry" + std::to_string(autogen_structs_[repr]);
60+
return "struct " +
61+
improve_name(repr,
62+
"ykentry" + std::to_string(autogen_structs_[repr]));
5563
}
5664
entry_data d{};
5765
d.incremented_id_ = counter_++;
@@ -66,24 +74,22 @@ std::string entry_struct_func_compiler::compile(ykdatatype *entry_dt,
6674
return "<><>";
6775
}
6876
std::stringstream code{};
69-
code << "struct ykentry" << d.incremented_id_ << " { "
77+
std::string name =
78+
improve_name(repr, "ykentry" + std::to_string(d.incremented_id_));
79+
code << "struct " << name << " { "
7080
<< dtc->convert_dt(d.key_dt_, datatype_location::STRUCT, "", "")
7181
<< " key; "
7282
<< dtc->convert_dt(d.val_dt_, datatype_location::STRUCT, "", "")
7383
<< " value; };\n";
7484
code_ << code.str();
7585
autogen_structs_list_.emplace_back(d);
7686
autogen_structs_[repr] = d.incremented_id_;
77-
return "struct ykentry" + std::to_string(d.incremented_id_);
87+
forward_decls_ << "struct " << name << ";\n";
88+
return "struct " + improve_name(repr, name);
7889
}
7990
void entry_struct_func_compiler::compile_forward_declarations(
8091
std::stringstream &target) {
81-
for (auto &e : autogen_structs_list_) {
82-
target << "struct ykentry" << e.incremented_id_ << ";\n";
83-
}
84-
for (auto &e : autogen_tuple_list_) {
85-
target << "struct yktuple" << e.incremented_id_ << ";\n";
86-
}
92+
target << forward_decls_.str();
8793
}
8894
void entry_struct_func_compiler::compile_structures(std::stringstream &target) {
8995
target << code_.str();
@@ -97,7 +103,8 @@ entry_struct_func_compiler::compile_function_dt(ykdatatype *function_dt,
97103
datatype_compiler *dtc) {
98104
std::string fdt_str = function_dt->as_string();
99105
if (autogen_func_typedefs_.find(fdt_str) != autogen_func_typedefs_.end()) {
100-
return "ykfncptr" + std::to_string(autogen_func_typedefs_[fdt_str]);
106+
return improve_name(
107+
fdt_str, "ykfncptr" + std::to_string(autogen_func_typedefs_[fdt_str]));
101108
}
102109
// Check assumption that must not happen
103110
if (!function_dt->is_function() || function_dt->args_.size() != 2 ||
@@ -122,7 +129,9 @@ entry_struct_func_compiler::compile_function_dt(ykdatatype *function_dt,
122129
code << "<><>";
123130
}
124131
unsigned int current_num = counter_functions_++;
125-
code << "(*ykfncptr" << current_num << ")(";
132+
std::string name =
133+
improve_name(fdt_str, "ykfncptr" + std::to_string(current_num));
134+
code << "(*" << name << ")(";
126135
if (input->args_.empty()) {
127136
code << "void";
128137
} else {
@@ -142,7 +151,7 @@ entry_struct_func_compiler::compile_function_dt(ykdatatype *function_dt,
142151
func_data d{input, output, current_num};
143152
autogen_func_typedef_list_.emplace_back(d);
144153
autogen_func_typedefs_[fdt_str] = current_num;
145-
return "ykfncptr" + std::to_string(current_num);
154+
return name;
146155
}
147156
void entry_struct_func_compiler::compile_function_defs(
148157
std::stringstream &target) {
@@ -155,13 +164,17 @@ std::string entry_struct_func_compiler::compile_tuple(ykdatatype *tuple_dt,
155164
datatype_compiler *dtc) {
156165
std::string repr = tuple_dt->as_string();
157166
if (autogen_tuples_.find(repr) != autogen_tuples_.end()) {
158-
return "struct yktuple" + std::to_string(autogen_tuples_[repr]);
167+
std::string name =
168+
improve_name(repr, "yktuple" + std::to_string(autogen_tuples_[repr]));
169+
return "struct " + name;
159170
}
160171
tuple_data d{};
161172
d.incremented_id_ = counter_tuples_++;
162173
d.tuple_dt_ = tuple_dt;
163174
std::stringstream code{};
164-
code << "struct yktuple" << d.incremented_id_ << " {";
175+
std::string name =
176+
improve_name(repr, "yktuple" + std::to_string(d.incremented_id_));
177+
code << "struct " << name << " {";
165178
size_t i = 1;
166179
for (ykdatatype *dt_arg : d.tuple_dt_->args_) {
167180
code << " " << dtc->convert_dt(dt_arg, datatype_location::STRUCT, "", "")
@@ -172,7 +185,8 @@ std::string entry_struct_func_compiler::compile_tuple(ykdatatype *tuple_dt,
172185
code_ << code.str();
173186
autogen_tuple_list_.emplace_back(d);
174187
autogen_tuples_[repr] = d.incremented_id_;
175-
return "struct yktuple" + std::to_string(d.incremented_id_);
188+
forward_decls_ << "struct " << name << ";\n";
189+
return "struct " + name;
176190
}
177191
bool entry_struct_func_compiler::has_bin_data() {
178192
return !autogen_bin_data_.empty();
@@ -212,14 +226,17 @@ void entry_struct_func_compiler::compile_binary_data_to(
212226
}
213227
std::string
214228
entry_struct_func_compiler::compile_fixed_array(ykdatatype *fixed_array_dt,
215-
datatype_compiler *dtc) {
229+
datatype_compiler *dtc) {
216230
std::string fxa_str = fixed_array_dt->as_string();
217231
if (autogen_fxa_.find(fxa_str) != autogen_fxa_.end()) {
218-
return "ykfxa" + std::to_string(autogen_fxa_[fxa_str]);
232+
return improve_name(fxa_str,
233+
"ykfxa" + std::to_string(autogen_fxa_[fxa_str]));
219234
}
220235
// Check assumption that must not happen
221-
if (!fixed_array_dt->is_fixed_size_array() || fixed_array_dt->args_.size() != 2 ||
222-
fixed_array_dt->args_[0]->is_sm_entry() || fixed_array_dt->args_[1]->is_m_entry()) {
236+
if (!fixed_array_dt->is_fixed_size_array() ||
237+
fixed_array_dt->args_.size() != 2 ||
238+
fixed_array_dt->args_[0]->is_sm_entry() ||
239+
fixed_array_dt->args_[1]->is_m_entry()) {
223240
// Must not happen
224241
return "<><>";
225242
}
@@ -229,22 +246,85 @@ entry_struct_func_compiler::compile_fixed_array(ykdatatype *fixed_array_dt,
229246
ykdatatype *target_datatype = fixed_array_dt->args_[0];
230247
ykdatatype *size_specifier = fixed_array_dt->args_[1];
231248
code << "typedef ";
232-
code << dtc->convert_dt(target_datatype, datatype_location::STRUCT, "", "")
233-
<< " ";
249+
code << dtc->convert_dt(target_datatype, datatype_location::STRUCT, "", "")
250+
<< " ";
234251
unsigned int current_num = counter_fxa_++;
235-
code << "ykfxa" << current_num << "[";
252+
std::string name =
253+
improve_name(fxa_str, "ykfxa" + std::to_string(current_num));
254+
code << name << "[";
236255
code << size_specifier->token_->token_;
237256
code << "];\n";
238257
// write the finalized code here
239258
code_fxa_ << code.str();
240259
tuple_data d{fixed_array_dt, current_num};
241260
autogen_fxa_list_.emplace_back(d);
242261
autogen_fxa_[fxa_str] = current_num;
243-
return "ykfxa" + std::to_string(current_num);
262+
return name;
244263
}
245264
void entry_struct_func_compiler::compiled_fixed_array_to(
246265
std::stringstream &target) {
247266
target << code_fxa_.str();
248267
}
249-
bool entry_struct_func_compiler::has_fixed_arrays() { return !autogen_fxa_.empty(); }
268+
bool entry_struct_func_compiler::has_fixed_arrays() {
269+
return !autogen_fxa_.empty();
270+
}
271+
std::string sanitize_name(const std::string &input) {
272+
auto is_valid_char = [](char c) { return std::isalnum(c) || c == '_'; };
273+
std::string result;
274+
for (size_t i = 0; i < input.length(); ++i) {
275+
char c = input[i];
276+
if (is_valid_char(c)) {
277+
if (std::isupper(c)) {
278+
result += "_";
279+
result += static_cast<char>(std::tolower(c));
280+
} else {
281+
result += c;
282+
}
283+
} else {
284+
result += '_';
285+
}
286+
}
287+
// Remove double underscores
288+
std::size_t dunder = result.find("__");
289+
while (dunder != std::string::npos) {
290+
result.erase(dunder, 1);
291+
dunder = result.find("__");
292+
}
293+
// Remove leading and trailing underscores
294+
result.erase(result.begin(),
295+
std::find_if(result.begin(), result.end(),
296+
[](unsigned char ch) { return ch != '_'; }));
297+
result.erase(std::find_if(result.rbegin(), result.rend(),
298+
[](unsigned char ch) { return ch != '_'; })
299+
.base(),
300+
result.end());
301+
result = "yt_" + result;
302+
// Replace
303+
for (const auto &replacement : REPLACEMENTS) {
304+
size_t pos;
305+
while ((pos = result.find(replacement.first)) != std::string::npos) {
306+
result.replace(pos, replacement.first.length(), replacement.second);
307+
}
308+
}
309+
return result;
310+
}
311+
std::string entry_struct_func_compiler::improve_name(
312+
const std::string &yaksha_datatype_string,
313+
const std::string &numbered_name) {
314+
if (name_improvements_.find(yaksha_datatype_string) !=
315+
name_improvements_.end()) {
316+
return name_improvements_[yaksha_datatype_string];
317+
}
318+
std::string improved = sanitize_name(yaksha_datatype_string);
319+
// too large use numbered name
320+
if (improved.size() > 60 || improved.empty()) { improved = numbered_name; }
321+
// conflict, so use numbered name
322+
if (reverse_name_improvements_.find(improved) !=
323+
reverse_name_improvements_.end()) {
324+
improved = numbered_name;
325+
}
326+
name_improvements_[yaksha_datatype_string] = improved;
327+
reverse_name_improvements_[improved] = yaksha_datatype_string;
328+
return improved;
329+
}
250330
entry_struct_func_compiler::~entry_struct_func_compiler() = default;

0 commit comments

Comments
 (0)