| 113 | } |
| 114 | |
| 115 | void varDeclToTypeDecl ( yyscan_t scanner, TypeDecl * pType, vector<VariableDeclaration*> * list, bool needNames ) { |
| 116 | bool anyNames = false; |
| 117 | for ( auto pDecl : *list ) { |
| 118 | if ( pDecl->pTypeDecl ) { |
| 119 | int count = pDecl->pNameList ? int(pDecl->pNameList->size()) : 1; |
| 120 | for ( int ai=0; ai!=count; ++ai ) { |
| 121 | auto pVarType = new TypeDecl(*pDecl->pTypeDecl); |
| 122 | if ( pDecl->pInit ) { |
| 123 | das_yyerror(scanner,"can't have default values in a type declaration", |
| 124 | (*pDecl->pNameList)[ai].at,CompilationError::cant_type); |
| 125 | } |
| 126 | pType->argTypes.push_back(pVarType); |
| 127 | if ( needNames && pDecl->pNameList && !(*pDecl->pNameList)[ai].name.empty() ) { |
| 128 | if ( !(*pDecl->pNameList)[ai].aka.empty() ) { |
| 129 | das_yyerror(scanner,"type declaration can't have an aka", (*pDecl->pNameList)[ai].at, |
| 130 | CompilationError::invalid_type_aka); |
| 131 | } |
| 132 | anyNames = true; |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | if ( anyNames ) { |
| 138 | for ( auto pDecl : *list ) { |
| 139 | if ( pDecl->pTypeDecl ) { |
| 140 | if ( pDecl->pNameList ) { |
| 141 | for ( const auto & name : *pDecl->pNameList ) { |
| 142 | pType->argNames.push_back(name.name); |
| 143 | } |
| 144 | } else { |
| 145 | pType->argNames.push_back(string()); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | Annotation * findAnnotation ( yyscan_t scanner, const string & name, const LineInfo & at ) { |
| 153 | auto ann = yyextra->g_Program->findAnnotation(name); |