00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00039 #ifndef __NUSMV_CORE_NODE_ANONYMIZERS_NODE_ANONYMIZER_BASE_PRIVATE_H__
00040 #define __NUSMV_CORE_NODE_ANONYMIZERS_NODE_ANONYMIZER_BASE_PRIVATE_H__
00041
00042
00043 #include "nusmv/core/node/anonymizers/NodeAnonymizerBase.h"
00044 #include "nusmv/core/utils/EnvObject.h"
00045 #include "nusmv/core/utils/EnvObject_private.h"
00046 #include "nusmv/core/utils/defs.h"
00047 #include "nusmv/core/utils/BiMap.h"
00048 #include "nusmv/core/utils/LRUCache.h"
00049 #include "nusmv/core/node/node.h"
00050
00051
00052 #ifdef NODE_ANONYMIZER_BASE_DEBUG
00053 # include "nusmv/core/utils/Logger.h"
00054 # include "nusmv/core/node/printers/MasterPrinter.h"
00055 #endif
00056
00057 #ifdef NODE_ANONYMIZER_BASE_DEBUG
00058 FILE* nab_debug_stream;
00059 Logger_ptr nab_debug_logger;
00060 #endif
00061
00062 #ifdef NODE_ANONYMIZER_BASE_DEBUG
00063 # define NAB_DEBUG_PRINT(format, ...) \
00064 { \
00065 NuSMVEnv_ptr const env = EnvObject_get_environment(ENV_OBJECT(self)); \
00066 const MasterPrinter_ptr sexpprint = \
00067 MASTER_PRINTER(NuSMVEnv_get_value(env, ENV_SEXP_PRINTER)); \
00068 Logger_ptr logger = nab_debug_logger; \
00069 \
00070 if (NULL == logger) { \
00071 nab_debug_stream = fopen("nab_debug.txt", "w"); \
00072 nab_debug_logger = Logger_create(nab_debug_stream); \
00073 logger = nab_debug_logger; \
00074 } \
00075 Logger_log(logger, "%s", "\n"); \
00076 Logger_nlog(logger, sexpprint, format, __VA_ARGS__); \
00077 Logger_log(logger, "%s", "\n"); \
00078 }
00079 #else
00080 # define NAB_DEBUG_PRINT(format, message, ...)
00081 #endif
00082
00110 typedef struct NodeAnonymizerBase_TAG
00111 {
00112
00113 INHERITS_FROM(EnvObject);
00114
00115
00116
00117
00118 BiMap_ptr map;
00119 LRUCache_ptr orig2anon;
00120 LRUCache_ptr anon2orig;
00121 size_t memoization_threshold;
00122 unsigned long long counter;
00123 const char* default_prefix;
00124
00125
00126
00127
00128 node_ptr (*translate)(NodeAnonymizerBase_ptr self,
00129 node_ptr id,
00130 const char* prefix);
00131 const char* (*build_anonymous)(NodeAnonymizerBase_ptr self,
00132 node_ptr id,
00133 const char* prefix);
00134 boolean (*is_leaf)(NodeAnonymizerBase_ptr self, node_ptr node);
00135 boolean (*is_id)(NodeAnonymizerBase_ptr self, node_ptr node);
00136
00137 } NodeAnonymizerBase;
00138
00139
00140
00141
00142
00143
00153 void node_anonymizer_base_init(NodeAnonymizerBase_ptr self,
00154 NuSMVEnv_ptr env,
00155 const char* default_prefix,
00156 size_t memoization_threshold);
00157
00166 void node_anonymizer_base_deinit(NodeAnonymizerBase_ptr self);
00167
00179 node_ptr node_anonymizer_base_translate(NodeAnonymizerBase_ptr self,
00180 node_ptr id,
00181 const char* prefix);
00182
00190 const char* node_anonymizer_base_choose_prefix(NodeAnonymizerBase_ptr self,
00191 const char* prefix);
00192
00199 node_ptr node_anonymizer_base_map_expr(NodeAnonymizerBase_ptr self,
00200 node_ptr expr);
00201
00208 node_ptr node_anonymizer_base_map_back(NodeAnonymizerBase_ptr self,
00209 node_ptr expr);
00210
00219 int node_anonymizer_read_map_from_bimap(NodeAnonymizerBase_ptr self,
00220 BiMap_ptr map);
00221
00231 const char* node_anonymizer_base_build_anonymous(NodeAnonymizerBase_ptr self,
00232 node_ptr id,
00233 const char* prefix);
00234
00242 node_ptr node_anonymizer_base_search_mapping(NodeAnonymizerBase_ptr self,
00243 node_ptr id);
00244
00251 void node_anonymizer_base_insert_mapping(NodeAnonymizerBase_ptr self,
00252 node_ptr id,
00253 node_ptr anonymous);
00254
00255
00256
00263 node_ptr node_anonymizer_base_search_expr_cache(NodeAnonymizerBase_ptr self,
00264 node_ptr expr);
00265
00272 void node_anonymizer_base_insert_expr_cache(NodeAnonymizerBase_ptr self,
00273 node_ptr expr,
00274 node_ptr anonymous_expr);
00275
00282 node_ptr
00283 node_anonymizer_base_search_anon2orig(NodeAnonymizerBase_ptr self,
00284 node_ptr expr);
00285
00292 void node_anonymizer_base_insert_anon2orig(NodeAnonymizerBase_ptr self,
00293 node_ptr anonymous_expr,
00294 node_ptr expr);
00295
00296
00297
00298
00305 boolean node_anonymizer_base_is_leaf(NodeAnonymizerBase_ptr self,
00306 node_ptr id);
00307
00314 boolean node_anonymizer_base_is_id(NodeAnonymizerBase_ptr self,
00315 node_ptr id);
00316
00323 boolean node_anonymizer_base_is_id_original(NodeAnonymizerBase_ptr self,
00324 node_ptr id);
00325
00332 boolean node_anonymizer_base_is_id_anonymous(NodeAnonymizerBase_ptr self,
00333 node_ptr id);
00334
00335
00336
00337 #endif