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

Method validateAotCpp

src/ast/ast_handle.cpp:248–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246 }
247
248 void Program::validateAotCpp ( TextWriter & logs, Context & ) {
249 library.foreach([&](Module * mod) -> bool {
250 if ( mod->builtIn ) {
251 logs << "// validating " << mod->name << "\n";
252 for ( auto & [key, tp] : mod->handleTypes ) {
253 if ( tp->rtti_isBasicStructureAnnotation() ) {
254 auto bs = static_cast<BasicStructureAnnotation*>(tp);
255 if ( !bs->validationNeverFails ) {
256 auto cppt = new TypeDecl(Type::tHandle);
257 cppt->annotation = bs;
258 auto cppn = describeCppType(cppt);
259 logs << "//\t" << cppn << " aka " << tp->name << "\n";
260 for ( const auto & flp : bs->fields ) {
261 const auto & fld = flp.second;
262 if ( fld.offset != -1u ) {
263 if ( fld.cppName.find('(')==string::npos ) { // sometimes we bind ref member function as if field
264 logs << "\t\tstatic_assert(offsetof(" << cppn << ","
265 << fld.cppName << ")==" << fld.offset << ",\"mismatching offset\");\n";
266 }
267 }
268 }
269 }
270 }
271 }
272 mod->enumerations.foreach([&](auto tp){
273 auto cppt = new TypeDecl(tp);
274 auto cppn = describeCppType(cppt);
275 auto baset = tp->makeBaseType();
276 logs << "//\t" << cppn << " aka " << tp->name << "\n";
277 logs << "\t\tstatic_assert( is_same < underlying_type< " << cppn << " >::type, "
278 << describeCppType(baset) << ">::value,\"mismatching underlying type, expecting "
279 << das_to_string(tp->baseType) << "\");\n";
280 });
281 }
282 return true;
283 },"*");
284 }
285
286 void reportTrait ( const TypeDeclPtr & type, const string & prefix, set<Structure *> & visited, const callable<void(const TypeDeclPtr &, const string &)> & report ) {
287 report(type, prefix);

Callers

nothing calls this directly

Calls 5

describeCppTypeFunction · 0.85
das_to_stringFunction · 0.85
makeBaseTypeMethod · 0.80
foreachMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected