| 1059 | } |
| 1060 | |
| 1061 | Function * ast_functionDeclarationHeader ( yyscan_t scanner, string * name, vector<VariableDeclaration*> * list, |
| 1062 | TypeDecl * result, const LineInfo & nameAt ) { |
| 1063 | auto pFunction = new Function(); |
| 1064 | pFunction->at = nameAt; |
| 1065 | pFunction->name = *name; |
| 1066 | pFunction->result = result; |
| 1067 | if ( list ) { |
| 1068 | for ( auto pDecl : *list ) { |
| 1069 | if ( pDecl->pTypeDecl ) { |
| 1070 | for ( const auto & name_at : *pDecl->pNameList ) { |
| 1071 | if ( !pFunction->findArgument(name_at.name) ) { |
| 1072 | VariablePtr pVar = new Variable(); |
| 1073 | pVar->name = name_at.name; |
| 1074 | pVar->aka = name_at.aka; |
| 1075 | pVar->at = name_at.at; |
| 1076 | if ( pDecl->pNameList->size()>1 ) { |
| 1077 | pVar->type = new TypeDecl(*pDecl->pTypeDecl); |
| 1078 | } else { |
| 1079 | pVar->type = pDecl->pTypeDecl; pDecl->pTypeDecl = nullptr; |
| 1080 | } |
| 1081 | if ( pDecl->pInit ) { |
| 1082 | if ( pDecl->pNameList->size()>1 ) { |
| 1083 | pVar->init = pDecl->pInit->clone(); |
| 1084 | } else { |
| 1085 | pVar->init = pDecl->pInit; pDecl->pInit = nullptr; |
| 1086 | } |
| 1087 | pVar->init_via_move = pDecl->init_via_move; |
| 1088 | pVar->init_via_clone = pDecl->init_via_clone; |
| 1089 | } |
| 1090 | if ( pDecl->annotation ) { |
| 1091 | pVar->annotation = *pDecl->annotation; |
| 1092 | } |
| 1093 | pFunction->arguments.push_back(pVar); |
| 1094 | } else { |
| 1095 | das_yyerror(scanner,"function argument is already declared " + name_at.name,name_at.at, |
| 1096 | CompilationError::already_declared_function_argument); |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | deleteVariableDeclarationList(list); |
| 1102 | } |
| 1103 | delete name; |
| 1104 | return pFunction; |
| 1105 | } |
| 1106 | |
| 1107 | void das_collect_all_keywords ( Module * mod, yyscan_t scanner ) { |
| 1108 | das_collect_keywords(mod,scanner); |
no test coverage detected