| 1015 | } |
| 1016 | |
| 1017 | Expression * ast_LetList ( yyscan_t scanner, bool kwd_let, bool inScope, vector<VariableDeclaration *> & decl, const LineInfo & kwd_letAt, const LineInfo & declAt ) { |
| 1018 | auto pLet = new ExprLet(); |
| 1019 | pLet->at = kwd_letAt; |
| 1020 | pLet->atInit = declAt; |
| 1021 | pLet->inScope = inScope; |
| 1022 | for ( auto pDecl : decl ) { |
| 1023 | if ( pDecl->pTypeDecl ) { |
| 1024 | for ( const auto & name_at : *pDecl->pNameList ) { |
| 1025 | if ( !pLet->find(name_at.name) ) { |
| 1026 | VariablePtr pVar = new Variable(); |
| 1027 | pVar->name = name_at.name; |
| 1028 | pVar->aka = name_at.aka; |
| 1029 | pVar->at = name_at.at; |
| 1030 | if ( pDecl->pNameList->size()>1 ) { |
| 1031 | pVar->type = new TypeDecl(*pDecl->pTypeDecl); |
| 1032 | } else { |
| 1033 | pVar->type = pDecl->pTypeDecl; pDecl->pTypeDecl = nullptr; |
| 1034 | } |
| 1035 | if ( pDecl->pInit ) { |
| 1036 | if ( pDecl->pNameList->size()>1 ) { |
| 1037 | pVar->init = pDecl->pInit->clone(); |
| 1038 | } else { |
| 1039 | pVar->init = pDecl->pInit; pDecl->pInit = nullptr; |
| 1040 | } |
| 1041 | pVar->init_via_move = pDecl->init_via_move; |
| 1042 | pVar->init_via_clone = pDecl->init_via_clone; |
| 1043 | } |
| 1044 | if ( kwd_let ) { |
| 1045 | pVar->type->constant = true; |
| 1046 | } else { |
| 1047 | pVar->type->removeConstant = true; |
| 1048 | } |
| 1049 | pLet->variables.push_back(pVar); |
| 1050 | } else { |
| 1051 | das_yyerror(scanner,"local variable is already declared " + name_at.name,name_at.at, |
| 1052 | CompilationError::already_declared_local); |
| 1053 | } |
| 1054 | } |
| 1055 | } |
| 1056 | } |
| 1057 | deleteVariableDeclarationList(&decl); |
| 1058 | return pLet; |
| 1059 | } |
| 1060 | |
| 1061 | Function * ast_functionDeclarationHeader ( yyscan_t scanner, string * name, vector<VariableDeclaration*> * list, |
| 1062 | TypeDecl * result, const LineInfo & nameAt ) { |
no test coverage detected