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

Function runFunctionAnnotations

src/parser/parser_impl.cpp:166–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164 }
165
166 void runFunctionAnnotations ( yyscan_t scanner, DasParserState * extra, Function * func, AnnotationList * annL, const LineInfo & at, bool genericMode ) {
167 if ( annL ) {
168 for ( auto itA = annL->begin(); itA!=annL->end(); ) {
169 auto pA = *itA;
170 if ( pA->annotation ) {
171 if ( pA->annotation->rtti_isFunctionAnnotation() ) {
172 auto ann = static_cast<FunctionAnnotation*>(pA->annotation);
173 if ( genericMode && !ann->isAppliedToGeneric() ) {
174 itA ++;
175 continue;
176 }
177 string err;
178 if ( !ann->apply(func, *yyextra->g_Program->thisModuleGroup, pA->arguments, err) ) {
179 das_yyerror(scanner,"macro [" +pA->annotation->name + "] failed to apply to a function " + func->name + "\n" + err, at,
180 CompilationError::runtime_annotation);
181 } else if ( ann->name=="type_function" && ann->module->name=="$" ) {
182 // this is awkward. we need this so that [type_function] can be used in the same module
183 auto mod = func->module ? func->module : extra->g_Program->thisModule.get();
184 string keyword = mod->name.empty() ? func->name : mod->name + "::" + func->name;
185 extra->das_keywords[func->name] = DasKeyword{false,true,keyword};
186 }
187 itA ++;
188 } else {
189 das_yyerror(scanner, pA->getMangledName() + " is not a function macro, functions are only allowed function macros",
190 at, CompilationError::invalid_annotation);
191 itA = annL->erase(itA);
192 }
193 } else {
194 itA = annL->erase(itA);
195 }
196 }
197 swap ( func->annotations, *annL );
198 for ( const auto & pA : *annL ) {
199 func->annotations.push_back(pA);
200 }
201 delete annL;
202 }
203 }
204
205 Expression * ast_arrayComprehension ( yyscan_t scanner, const LineInfo & loc, vector<VariableNameAndPosition> * iters,
206 Expression * srcs, Expression * subexpr, Expression * where, const LineInfo & forend, bool genSyntax, bool tableSyntax ) {

Callers 4

yyparseFunction · 0.85
yyparseFunction · 0.85
ast_structVarDefFunction · 0.85
yyparseFunction · 0.85

Calls 11

isAppliedToGenericMethod · 0.80
das_yyerrorFunction · 0.70
swapFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
applyMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45
getMangledNameMethod · 0.45
eraseMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected