Changes in src/CodeGen/FixNames.cc [bf2438c:fa4805f]
- File:
-
- 1 edited
-
src/CodeGen/FixNames.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixNames.cc
rbf2438c rfa4805f 14 14 // 15 15 16 #include <memory> 17 16 18 #include "FixNames.h" 17 18 #include <memory> // for unique_ptr 19 #include <string> // for string, operator!=, operator== 20 21 #include "Common/SemanticError.h" // for SemanticError 22 #include "FixMain.h" // for FixMain 23 #include "Parser/LinkageSpec.h" // for Cforall, isMangled 24 #include "SymTab/Mangler.h" // for Mangler 25 #include "SynTree/Constant.h" // for Constant 26 #include "SynTree/Declaration.h" // for FunctionDecl, ObjectDecl, Declarat... 27 #include "SynTree/Expression.h" // for ConstantExpr 28 #include "SynTree/Label.h" // for Label, noLabels 29 #include "SynTree/Statement.h" // for ReturnStmt, CompoundStmt 30 #include "SynTree/Type.h" // for Type, BasicType, Type::Qualifiers 31 #include "SynTree/Visitor.h" // for Visitor, acceptAll 19 #include "SynTree/Declaration.h" 20 #include "SynTree/Expression.h" 21 #include "SynTree/Visitor.h" 22 #include "SymTab/Mangler.h" 23 #include "OperatorTable.h" 24 #include "FixMain.h" 32 25 33 26 namespace CodeGen { … … 49 42 main_type = new FunctionType( Type::Qualifiers(), true ), nullptr ) 50 43 }; 51 main_type->get_returnVals().push_back( 44 main_type->get_returnVals().push_back( 52 45 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 53 46 ); … … 59 52 std::string mangle_main_args() { 60 53 FunctionType* main_type; 61 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, 54 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, 62 55 main_type = new FunctionType( Type::Qualifiers(), false ), nullptr ) 63 56 }; 64 main_type->get_returnVals().push_back( 57 main_type->get_returnVals().push_back( 65 58 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 66 59 ); 67 60 68 mainDecl->get_functionType()->get_parameters().push_back( 61 mainDecl->get_functionType()->get_parameters().push_back( 69 62 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) 70 63 ); 71 64 72 mainDecl->get_functionType()->get_parameters().push_back( 73 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, 74 new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 65 mainDecl->get_functionType()->get_parameters().push_back( 66 new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, 67 new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), 75 68 nullptr ) 76 69 ); … … 82 75 83 76 bool is_main(const std::string& name) { 84 static std::string mains[] = { 85 mangle_main(), 77 static std::string mains[] = { 78 mangle_main(), 86 79 mangle_main_args() 87 80 }; … … 119 112 int nargs = functionDecl->get_functionType()->get_parameters().size(); 120 113 if( !(nargs == 0 || nargs == 2 || nargs == 3) ) { 121 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 114 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 122 115 } 123 116 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );
Note:
See TracChangeset
for help on using the changeset viewer.