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

Method preVisitMakeLocal

src/ast/ast_derive_alias.cpp:347–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345 // make local
346 template <typename TT>
347 void preVisitMakeLocal ( ExprMakeLocal * expr, TT && collectAliasSources ) {
348 auto it = cmresDest.find(expr);
349 if ( it!=cmresDest.end() ) {
350 // left
351 auto resOut = it->second;
352 ExpressionSources resSrc;
353 if ( collectSources(program, resOut, resSrc, false, true) ) {
354 if ( checkAliasing ) {
355 program->error("[[" + string(expr->__rtti) + " ]] always aliases",
356 "some form of ... *ptr ... = [[" + string(expr->__rtti) + " ...]] where we don't know where pointer came from", "",
357 expr->at, CompilationError::invalid_expression);
358 } else {
359 expr->alwaysAlias = true;
360 }
361 return;
362 }
363 // check if there are any globals
364 bool anyGlobals = false;
365 for ( auto v : resSrc ) {
366 if ( v->global ) {
367 anyGlobals = true;
368 break;
369 }
370 }
371 // right
372 ExpressionSources argSrc;
373 if ( collectAliasSources(argSrc,anyGlobals) ) {
374 if ( checkAliasing ) {
375 program->error("[[" + string(expr->__rtti) + " ]] always aliases",
376 "some form of ... = [[" + string(expr->__rtti) + " ... *ptr ... ]] where we don't know where pointer came from", "",
377 expr->at, CompilationError::invalid_expression);
378 } else {
379 expr->alwaysAlias = true;
380 }
381 } else if ( auto aliasVar = intersectSources ( resSrc, argSrc ) ) {
382 if ( checkAliasing ) {
383 program->error("[[" + string(expr->__rtti) + " ]] aliases",
384 "some form of ... " + aliasVar->name + " ... = [[" + string(expr->__rtti) + " ... " + aliasVar->name + " ... ]]", "",
385 expr->at, CompilationError::invalid_expression);
386 } else {
387 expr->alwaysAlias = true;
388 }
389 }
390 }
391 }
392 virtual void preVisit ( ExprMakeArray * expr ) override {
393 Visitor::preVisit(expr);
394 preVisitMakeLocal(expr,[&](ExpressionSources & argSrc, bool anyGlobals) -> bool {

Callers

nothing calls this directly

Calls 6

collectSourcesFunction · 0.85
stringClass · 0.85
intersectSourcesFunction · 0.85
findMethod · 0.45
endMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected