| 828 | } |
| 829 | |
| 830 | Expression * ast_NameName ( yyscan_t scanner, string * ena, string * eni, const LineInfo & enaAt, const LineInfo & eniAt ) { |
| 831 | Enumeration * pEnum = nullptr; |
| 832 | Expression * resConst = nullptr; |
| 833 | auto enums = yyextra->g_Program->findEnum(*ena); |
| 834 | auto aliases = yyextra->g_Program->findAlias(*ena); |
| 835 | if ( enums.size()+aliases.size() > 1 ) { |
| 836 | string candidates; |
| 837 | if ( enums.size() ) candidates += yyextra->g_Program->describeCandidates(enums); |
| 838 | if ( aliases.size() ) candidates += yyextra->g_Program->describeCandidates(aliases); |
| 839 | das_yyerror(scanner,"too many options for the " + *ena + "\n" + candidates, enaAt, |
| 840 | CompilationError::ambiguous_enumeration); |
| 841 | } else if ( enums.size()==0 && aliases.size()==0 ) { |
| 842 | das_yyerror(scanner,"enumeration or bitfield not found " + *ena, enaAt, |
| 843 | CompilationError::lookup_enumeration); |
| 844 | } else if ( enums.size()==1 ) { |
| 845 | pEnum = enums.back(); |
| 846 | } else if ( aliases.size()==1 ) { |
| 847 | auto alias = aliases.back(); |
| 848 | if ( alias->isEnum() ) { |
| 849 | pEnum = alias->enumType; |
| 850 | } else if ( alias->isBitfield() ) { |
| 851 | int bit = alias->findArgumentIndex(*eni); |
| 852 | if ( bit!=-1 ) { |
| 853 | auto td = new TypeDecl(*alias); |
| 854 | td->ref = false; |
| 855 | auto bitConst = new ExprConstBitfield(eniAt, 1ull << uint64_t(bit)); |
| 856 | bitConst->baseType = alias->baseType; |
| 857 | bitConst->bitfieldType = new TypeDecl(*alias); |
| 858 | resConst = bitConst; |
| 859 | } else { |
| 860 | das_yyerror(scanner,"enumeration or bitfield not found " + *ena, enaAt, |
| 861 | CompilationError::lookup_bitfield); |
| 862 | } |
| 863 | } else { |
| 864 | das_yyerror(scanner,"expecting enumeration or bitfield " + *ena, enaAt, |
| 865 | CompilationError::invalid_type); |
| 866 | } |
| 867 | } |
| 868 | if ( pEnum ) { |
| 869 | auto td = new TypeDecl(pEnum); |
| 870 | resConst = new ExprConstEnumeration(eniAt, *eni, td); |
| 871 | } |
| 872 | delete ena; |
| 873 | delete eni; |
| 874 | if ( resConst ) { |
| 875 | return resConst; |
| 876 | } else { |
| 877 | return new ExprConstInt(0); // dummy |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | |
| 882 | Expression * ast_makeBlock ( yyscan_t scanner, int bal, AnnotationList * annL, vector<CaptureEntry> * clist, |
no test coverage detected