Changeset 59c8dff for src/Validate
- Timestamp:
- Jan 19, 2024, 2:42:58 AM (4 months ago)
- Branches:
- master
- Children:
- f988834
- Parents:
- 8b4faf6
- Location:
- src/Validate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/Autogen.cpp
r8b4faf6 r59c8dff 186 186 // could possibly use a new linkage type. For now we just make the 187 187 // basic ones intrinsic to code-gen them as C assignments. 188 const auto & real_type = decl->base; 189 const auto & basic = real_type.as<ast::BasicType>(); 190 if(!real_type || (basic && basic->isInteger())) proto_linkage = ast::Linkage::Intrinsic; 188 // const auto & real_type = decl->base; 189 // const auto & basic = real_type.as<ast::BasicType>(); 190 191 // if(!real_type || (basic && basic->isInteger())) proto_linkage = ast::Linkage::Intrinsic; 192 193 // Turns other enumeration type into Intrinstic as well to temporarily fix the recursive 194 // construction bug 195 proto_linkage = ast::Linkage::Intrinsic; 191 196 } 192 197 … … 742 747 } 743 748 ); 749 // auto fname = ast::getFunctionName( callExpr ); 750 // if (fname == "posE" ) { 751 // std::cerr << "Found posE autogen" << std::endl; 752 // } 744 753 functionDecl->stmts = new ast::CompoundStmt( location, 745 754 { new ast::ExprStmt( location, callExpr ) } … … 792 801 } 793 802 803 struct PseudoFuncGenerateRoutine final : 804 public ast::WithDeclsToAdd<>, 805 public ast::WithShortCircuiting { 806 void previsit( const ast::EnumDecl * enumDecl ); 807 }; 808 809 void PseudoFuncGenerateRoutine::previsit( const ast::EnumDecl * enumDecl ) { 810 const CodeLocation& location = enumDecl->location; 811 if ( enumDecl->members.size() == 0 || !enumDecl->base || enumDecl->name == "" ) return; 812 813 std::vector<ast::ptr<ast::Init>> inits; 814 std::vector<ast::ptr<ast::Init>> labels; 815 for ( const ast::Decl * mem: enumDecl->members ) { 816 auto memAsObjectDecl = dynamic_cast< const ast::ObjectDecl * >( mem ); 817 inits.emplace_back( memAsObjectDecl->init ); 818 labels.emplace_back( new ast::SingleInit( 819 location, ast::ConstantExpr::from_string(location, mem->name) ) ); 820 } 821 auto init = new ast::ListInit( location, std::move( inits ) ); 822 auto label_strings = new ast::ListInit( location, std::move(labels) ); 823 auto values = new ast::ObjectDecl( 824 location, 825 "__enum_values_"+enumDecl->name, 826 new ast::ArrayType( 827 // new ast::PointerType( new ast::BasicType{ ast::BasicType::Char} ), 828 enumDecl->base, 829 ast::ConstantExpr::from_int( location, enumDecl->members.size() ), 830 ast::LengthFlag::FixedLen, ast::DimensionFlag::DynamicDim 831 ) 832 ,init 833 , 834 ast::Storage::Static, 835 ast::Linkage::AutoGen 836 ); 837 auto label_arr = new ast::ObjectDecl( 838 location, 839 "__enum_labels_"+enumDecl->name, 840 new ast::ArrayType( 841 new ast::PointerType( new ast::BasicType{ ast::BasicType::Char} ), 842 ast::ConstantExpr::from_int( location, enumDecl->members.size() ), 843 ast::LengthFlag::FixedLen, ast::DimensionFlag::DynamicDim 844 ), 845 label_strings, 846 ast::Storage::Static, 847 ast::Linkage::AutoGen 848 ); 849 850 declsToAddAfter.push_back( values ); 851 declsToAddAfter.push_back( label_arr ); 852 } 853 794 854 } // namespace 795 855 796 856 void autogenerateRoutines( ast::TranslationUnit & translationUnit ) { 797 857 ast::Pass<AutogenerateRoutines>::run( translationUnit ); 858 // ast::Pass<PseudoFuncGenerateRoutine>::run( translationUnit ); 798 859 } 799 860 -
src/Validate/module.mk
r8b4faf6 r59c8dff 52 52 Validate/ReturnCheck.hpp \ 53 53 Validate/VerifyCtorDtorAssign.cpp \ 54 Validate/VerifyCtorDtorAssign.hpp 54 Validate/VerifyCtorDtorAssign.hpp \ 55 Validate/ReplacePseudoFunc.cpp \ 56 Validate/ReplacePseudoFunc.hpp 55 57 56 58 SRCDEMANGLE += $(SRC_VALIDATE)
Note: See TracChangeset
for help on using the changeset viewer.