| 966 | } |
| 967 | |
| 968 | Expression * ast_Let ( yyscan_t scanner, bool kwd_let, bool inScope, VariableDeclaration * decl, const LineInfo & kwd_letAt, const LineInfo & declAt ) { |
| 969 | auto pLet = new ExprLet(); |
| 970 | pLet->at = kwd_letAt; |
| 971 | pLet->atInit = declAt; |
| 972 | pLet->inScope = inScope; |
| 973 | pLet->isTupleExpansion = decl->isTupleExpansion; |
| 974 | if ( decl->pTypeDecl ) { |
| 975 | for ( const auto & name_at : *decl->pNameList ) { |
| 976 | if ( !pLet->find(name_at.name) ) { |
| 977 | VariablePtr pVar = new Variable(); |
| 978 | pVar->name = name_at.name; |
| 979 | pVar->aka = name_at.aka; |
| 980 | pVar->at = name_at.at; |
| 981 | if ( decl->pNameList->size()>1 ) { |
| 982 | pVar->type = new TypeDecl(*decl->pTypeDecl); |
| 983 | } else { |
| 984 | pVar->type = decl->pTypeDecl; decl->pTypeDecl = nullptr; |
| 985 | } |
| 986 | if ( decl->pInit ) { |
| 987 | if ( decl->pNameList->size()>1 ) { |
| 988 | pVar->init = decl->pInit->clone(); |
| 989 | } else { |
| 990 | pVar->init = decl->pInit; decl->pInit = nullptr; |
| 991 | } |
| 992 | pVar->init_via_move = decl->init_via_move; |
| 993 | pVar->init_via_clone = decl->init_via_clone; |
| 994 | } |
| 995 | if ( kwd_let ) { |
| 996 | pVar->type->constant = true; |
| 997 | } else { |
| 998 | pVar->type->removeConstant = true; |
| 999 | } |
| 1000 | pLet->variables.push_back(pVar); |
| 1001 | } else { |
| 1002 | das_yyerror(scanner,"local variable is already declared " + name_at.name,name_at.at, |
| 1003 | CompilationError::already_declared_local); |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | if ( auto pTagExpr = decl->pNameList->front().tag ) { |
| 1008 | auto pTag = new ExprTag(declAt, pTagExpr, pLet, "i"); |
| 1009 | delete decl; |
| 1010 | return pTag; |
| 1011 | } else { |
| 1012 | delete decl; |
| 1013 | return pLet; |
| 1014 | } |
| 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(); |