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

Function findMatchingVariable

src/builtin/module_builtin_ast.cpp:199–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197 }
198
199 void findMatchingVariable ( Program * program, Function * func, const char * _name, bool seePrivate,
200 const TBlock<void,TTemporary<TArray<Variable *>>> & block, Context * context, LineInfoArg * arg ) {
201 if ( !program ) context->throw_error_at(arg, "expecting program");
202 if ( !_name ) context->throw_error_at(arg, "expecting name");
203 string moduleName, varName;
204 splitTypeName(_name, moduleName, varName);
205 vector<Variable *> result;
206 auto inWhichModule = getCurrentSearchModule(program, func, moduleName.c_str());
207 program->library.foreach([&](Module * mod) -> bool {
208 if ( auto var = mod->findVariable(varName) ) {
209 if ( inWhichModule->isVisibleDirectly(var->module) ) {
210 if ( seePrivate || canAccessGlobalVariable(var,inWhichModule,program->thisModule.get()) ) {
211 result.push_back(var);
212 }
213 }
214 }
215 return true;
216 },moduleName);
217 Array arr;
218 array_mark_locked(arr, (char *)result.data(), (int32_t)result.size());
219 das_invoke<void>::invoke<Array&>(context,arg,block,arr);
220 }
221
222 // end lookup
223

Callers

nothing calls this directly

Calls 12

splitTypeNameFunction · 0.85
getCurrentSearchModuleFunction · 0.85
canAccessGlobalVariableFunction · 0.85
array_mark_lockedFunction · 0.85
throw_error_atMethod · 0.80
c_strMethod · 0.45
foreachMethod · 0.45
findVariableMethod · 0.45
getMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected