Changes in src/CodeGen/FixMain.cc [a16764a6:bf2438c]
- File:
-
- 1 edited
-
src/CodeGen/FixMain.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixMain.cc
ra16764a6 rbf2438c 23 23 24 24 #include "Common/SemanticError.h" // for SemanticError 25 #include "CodeGen/GenType.h" // for GenType26 25 #include "SynTree/Declaration.h" // for FunctionDecl, operator<< 27 26 #include "SynTree/Type.h" // for FunctionType … … 31 30 std::unique_ptr<FunctionDecl> FixMain::main_signature = nullptr; 32 31 33 template<typename container>34 std::string genTypeAt(const container& p, size_t idx) {35 return genType((*std::next(p.begin(), idx))->get_type(), "");36 }37 38 32 void FixMain::registerMain(FunctionDecl* functionDecl) 39 33 { 40 34 if(main_signature) { 41 SemanticError(functionDecl, "Multiple definition of main routine\n");35 throw SemanticError("Multiple definition of main routine\n", functionDecl); 42 36 } 43 37 main_signature.reset( functionDecl->clone() ); … … 49 43 50 44 os << main_signature->get_scopedMangleName() << "("; 51 const auto& params = main_signature->get_functionType()->get_parameters(); 52 switch(params.size()) { 53 case 3: os << "(" << genTypeAt(params, 0) << ")argc, (" << genTypeAt(params, 1) << ")argv, (" << genTypeAt(params, 2) << ")envp"; break; 54 case 2: os << "(" << genTypeAt(params, 0) << ")argc, (" << genTypeAt(params, 1) << ")argv"; break; 45 switch(main_signature->get_functionType()->get_parameters().size()) { 46 case 3: os << "argc, argv, envp"; break; 47 case 2: os << "argc, argv"; break; 55 48 case 0: break; 56 49 default : assert(false);
Note:
See TracChangeset
for help on using the changeset viewer.