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

Function generateLocalFunction

src/ast/ast_generate.cpp:659–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657 }
658
659 FunctionPtr generateLocalFunction ( const string & lambdaName, ExprBlock * block ) {
660 auto lfn = lambdaName + "`function";
661 auto pFunc = new Function();
662 pFunc->generated = true;
663 pFunc->at = pFunc->atDecl = block->at;
664 pFunc->name = lfn;
665 pFunc->body = block->clone();
666 pFunc->privateFunction = true;
667 auto wb = static_cast<ExprBlock*>(pFunc->body);
668 wb->blockFlags = 0;
669 wb->arguments.clear();
670 wb->returnType = nullptr;
671 pFunc->result = new TypeDecl(*block->type);
672 for ( auto & arg : block->arguments ) {
673 auto cA = arg->clone();
674 cA->marked_used = true;
675 pFunc->arguments.push_back(cA);
676 }
677 verifyGenerated(pFunc->body);
678 return pFunc;
679 }
680
681 bool isCaptureAsRef ( const VariablePtr & var ) {
682 return var->capture_as_ref;

Callers 1

Calls 4

verifyGeneratedFunction · 0.85
cloneMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected