Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/FixNames.cc

    rbf2438c rfa4805f  
    1414//
    1515
     16#include <memory>
     17
    1618#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"
    3225
    3326namespace CodeGen {
     
    4942                                                                                                                                   main_type = new FunctionType( Type::Qualifiers(), true ), nullptr )
    5043                                };
    51                 main_type->get_returnVals().push_back(
     44                main_type->get_returnVals().push_back( 
    5245                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
    5346                );
     
    5952        std::string mangle_main_args() {
    6053                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, 
    6255                                                                                                                                   main_type = new FunctionType( Type::Qualifiers(), false ), nullptr )
    6356                                };
    64                 main_type->get_returnVals().push_back(
     57                main_type->get_returnVals().push_back( 
    6558                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
    6659                );
    6760
    68                 mainDecl->get_functionType()->get_parameters().push_back(
     61                mainDecl->get_functionType()->get_parameters().push_back( 
    6962                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
    7063                );
    7164
    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 ) ) ), 
    7568                        nullptr )
    7669                );
     
    8275
    8376        bool is_main(const std::string& name) {
    84                 static std::string mains[] = {
    85                         mangle_main(),
     77                static std::string mains[] = { 
     78                        mangle_main(), 
    8679                        mangle_main_args()
    8780                };
     
    119112                        int nargs = functionDecl->get_functionType()->get_parameters().size();
    120113                        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); 
    122115                        }
    123116                        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.