MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / getFunctionHash

Function getFunctionHash

src/simulate/simulate_fn_hash.cpp:118–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 }
117
118 uint64_t getFunctionHash ( Function * fun, SimNode * node, Context * context ) {
119 debug_hash("\n%s\n", fun->getMangledName().c_str());
120 SimFnHashVisitor hashV(context);
121 // append return type and result type
122 uint64_t resT = fun->result->getSemanticHash();
123 hashV.write(&resT, sizeof(uint64_t));
124 debug_hash("\nresult <%s> = %" PRIx64 "\n", fun->result->getMangledName().c_str(), resT);
125 for ( auto & arg : fun->arguments ) {
126 uint64_t argT = arg->type->getSemanticHash();
127 hashV.write(&argT, sizeof(argT));
128 debug_hash("arg %s <%s> = %" PRIx64 "\n", arg->type->getMangledName().c_str(), arg->name.c_str(), argT);
129 }
130
131 // append code
132 node->visit(hashV);
133 if ( fun->aotHashDeppendsOnArguments ) {
134 for ( auto & arg : fun->arguments ) {
135 hashV.write(arg->name.c_str());
136 if ( arg->init ) {
137 TextWriter tw;
138 tw << *(arg->init);
139 hashV.write(tw.str().c_str());
140 }
141 }
142 }
143 uint64_t res = hashV.getHash();
144 debug_hash("\n%s = %" PRIx64 "\n", fun->getMangledName().c_str(), res);
145 return res;
146 }
147
148 struct DependencyCollector {
149 void collect ( const Function * fun ) {

Callers 3

simulateMethod · 0.85
linkCppAotMethod · 0.85
getFunctionHashByIdFunction · 0.85

Calls 7

getSemanticHashMethod · 0.80
c_strMethod · 0.45
getMangledNameMethod · 0.45
writeMethod · 0.45
visitMethod · 0.45
strMethod · 0.45
getHashMethod · 0.45

Tested by

no test coverage detected