Changes in src/Validate/Autogen.cpp [59c8dff:b262cb3]
- File:
-
- 1 edited
-
src/Validate/Autogen.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/Autogen.cpp
r59c8dff rb262cb3 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 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; 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; 196 191 } 197 192 … … 445 440 446 441 auto * paramType = ast::deepCopy( member->get_type() ); 447 paramType->attributes.clear(); 442 erase_if( paramType->attributes, []( ast::Attribute const * attr ){ 443 return !attr->isValidOnFuncParam(); 444 } ); 448 445 ast::ObjectDecl * param = new ast::ObjectDecl( 449 446 getLocation(), member->name, paramType ); … … 747 744 } 748 745 ); 749 // auto fname = ast::getFunctionName( callExpr );750 // if (fname == "posE" ) {751 // std::cerr << "Found posE autogen" << std::endl;752 // }753 746 functionDecl->stmts = new ast::CompoundStmt( location, 754 747 { new ast::ExprStmt( location, callExpr ) } … … 801 794 } 802 795 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::DynamicDim831 )832 ,init833 ,834 ast::Storage::Static,835 ast::Linkage::AutoGen836 );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::DynamicDim844 ),845 label_strings,846 ast::Storage::Static,847 ast::Linkage::AutoGen848 );849 850 declsToAddAfter.push_back( values );851 declsToAddAfter.push_back( label_arr );852 }853 854 796 } // namespace 855 797 856 798 void autogenerateRoutines( ast::TranslationUnit & translationUnit ) { 857 799 ast::Pass<AutogenerateRoutines>::run( translationUnit ); 858 // ast::Pass<PseudoFuncGenerateRoutine>::run( translationUnit );859 800 } 860 801
Note:
See TracChangeset
for help on using the changeset viewer.