Changeset fb114fa1


Ignore:
Timestamp:
Sep 27, 2016, 11:22:48 AM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
4b1fd2c
Parents:
3b5e3aa
Message:

more refactoring of parser code

Location:
src
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.h

    r3b5e3aa rfb114fa1  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 14:38:53 2015
    13 // Update Count     : 4
     12// Last Modified On : Sat Sep 24 15:13:42 2016
     13// Update Count     : 5
    1414//
    1515
     
    4646}
    4747
    48 
    4948#endif // SEMANTICERROR_H
    5049
  • src/Common/module.mk

    r3b5e3aa rfb114fa1  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Thu Aug 18 13:29:04 2016
    14 ## Update Count     : 2
     13## Last Modified On : Tue Sep 27 11:06:38 2016
     14## Update Count     : 4
    1515###############################################################################
    1616
    1717SRC += Common/SemanticError.cc \
    1818       Common/UniqueName.cc \
     19       Common/DebugMalloc.cc \
    1920       Common/Assert.cc
  • src/Makefile.am

    r3b5e3aa rfb114fa1  
    1111## Created On       : Sun May 31 08:51:46 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sat Aug 20 11:13:12 2016
    14 ## Update Count     : 71
     13## Last Modified On : Sat Sep 24 15:03:52 2016
     14## Update Count     : 73
    1515###############################################################################
    1616
     
    4040cfa_cpplib_PROGRAMS = driver/cfa-cpp
    4141driver_cfa_cpp_SOURCES = ${SRC}
    42 driver_cfa_cpp_LDADD = ${LEXLIB}                        # yywrap
     42driver_cfa_cpp_LDADD = ${LEXLIB} -ldl                   # yywrap
    4343driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -rdynamic -I${abs_top_srcdir}/src/include
    4444
  • src/Makefile.in

    r3b5e3aa rfb114fa1  
    9898        Common/driver_cfa_cpp-SemanticError.$(OBJEXT) \
    9999        Common/driver_cfa_cpp-UniqueName.$(OBJEXT) \
     100        Common/driver_cfa_cpp-Interpose.$(OBJEXT) \
    100101        Common/driver_cfa_cpp-Assert.$(OBJEXT) \
    101102        ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) \
     
    359360        CodeGen/CodeGenerator.cc CodeGen/GenType.cc \
    360361        CodeGen/FixNames.cc CodeGen/OperatorTable.cc \
    361         Common/SemanticError.cc Common/UniqueName.cc Common/Assert.cc \
     362        Common/SemanticError.cc Common/UniqueName.cc \
     363        Common/Interpose.cc Common/Assert.cc \
    362364        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    363365        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
     
    414416cfa_cpplibdir = ${libdir}
    415417driver_cfa_cpp_SOURCES = ${SRC}
    416 driver_cfa_cpp_LDADD = ${LEXLIB}                        # yywrap
     418driver_cfa_cpp_LDADD = ${LEXLIB} -ldl                   # yywrap
    417419driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -rdynamic -I${abs_top_srcdir}/src/include
    418420all: $(BUILT_SOURCES)
     
    514516        Common/$(DEPDIR)/$(am__dirstamp)
    515517Common/driver_cfa_cpp-UniqueName.$(OBJEXT): Common/$(am__dirstamp) \
     518        Common/$(DEPDIR)/$(am__dirstamp)
     519Common/driver_cfa_cpp-Interpose.$(OBJEXT): Common/$(am__dirstamp) \
    516520        Common/$(DEPDIR)/$(am__dirstamp)
    517521Common/driver_cfa_cpp-Assert.$(OBJEXT): Common/$(am__dirstamp) \
     
    789793        -rm -f CodeGen/driver_cfa_cpp-OperatorTable.$(OBJEXT)
    790794        -rm -f Common/driver_cfa_cpp-Assert.$(OBJEXT)
     795        -rm -f Common/driver_cfa_cpp-Interpose.$(OBJEXT)
    791796        -rm -f Common/driver_cfa_cpp-SemanticError.$(OBJEXT)
    792797        -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT)
     
    895900@AMDEP_TRUE@@am__include@ @am__quote@CodeGen/$(DEPDIR)/driver_cfa_cpp-OperatorTable.Po@am__quote@
    896901@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Assert.Po@am__quote@
     902@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Interpose.Po@am__quote@
    897903@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@
    898904@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@
     
    11321138@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-UniqueName.obj `if test -f 'Common/UniqueName.cc'; then $(CYGPATH_W) 'Common/UniqueName.cc'; else $(CYGPATH_W) '$(srcdir)/Common/UniqueName.cc'; fi`
    11331139
     1140Common/driver_cfa_cpp-Interpose.o: Common/Interpose.cc
     1141@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-Interpose.o -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-Interpose.Tpo -c -o Common/driver_cfa_cpp-Interpose.o `test -f 'Common/Interpose.cc' || echo '$(srcdir)/'`Common/Interpose.cc
     1142@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-Interpose.Tpo Common/$(DEPDIR)/driver_cfa_cpp-Interpose.Po
     1143@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Common/Interpose.cc' object='Common/driver_cfa_cpp-Interpose.o' libtool=no @AMDEPBACKSLASH@
     1144@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1145@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-Interpose.o `test -f 'Common/Interpose.cc' || echo '$(srcdir)/'`Common/Interpose.cc
     1146
     1147Common/driver_cfa_cpp-Interpose.obj: Common/Interpose.cc
     1148@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-Interpose.obj -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-Interpose.Tpo -c -o Common/driver_cfa_cpp-Interpose.obj `if test -f 'Common/Interpose.cc'; then $(CYGPATH_W) 'Common/Interpose.cc'; else $(CYGPATH_W) '$(srcdir)/Common/Interpose.cc'; fi`
     1149@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-Interpose.Tpo Common/$(DEPDIR)/driver_cfa_cpp-Interpose.Po
     1150@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Common/Interpose.cc' object='Common/driver_cfa_cpp-Interpose.obj' libtool=no @AMDEPBACKSLASH@
     1151@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1152@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-Interpose.obj `if test -f 'Common/Interpose.cc'; then $(CYGPATH_W) 'Common/Interpose.cc'; else $(CYGPATH_W) '$(srcdir)/Common/Interpose.cc'; fi`
     1153
    11341154Common/driver_cfa_cpp-Assert.o: Common/Assert.cc
    11351155@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-Assert.o -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-Assert.Tpo -c -o Common/driver_cfa_cpp-Assert.o `test -f 'Common/Assert.cc' || echo '$(srcdir)/'`Common/Assert.cc
  • src/Parser/DeclarationNode.cc

    r3b5e3aa rfb114fa1  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 11:12:52 2016
    13 // Update Count     : 627
     12// Last Modified On : Mon Sep 26 22:18:40 2016
     13// Update Count     : 640
    1414//
    1515
     
    9292
    9393        newnode->variable.name = variable.name ? new string( *variable.name ) : nullptr;
     94        newnode->variable.tyClass = variable.tyClass;
    9495        newnode->variable.assertions = maybeClone( variable.assertions );
    95         newnode->variable.tyClass = variable.tyClass;
    9696
    9797        newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr;
     
    148148}
    149149
    150 DeclarationNode * DeclarationNode::newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) {
     150DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) {
    151151        DeclarationNode * newnode = new DeclarationNode;
    152152        newnode->name = name;
    153 
    154153        newnode->type = new TypeData( TypeData::Function );
    155154        newnode->type->function.params = param;
     
    222221} // DeclarationNode::newLength
    223222
    224 DeclarationNode * DeclarationNode::newFromTypedef( std::string * name ) {
     223DeclarationNode * DeclarationNode::newFromTypedef( string * name ) {
    225224        DeclarationNode * newnode = new DeclarationNode;
    226225        newnode->type = new TypeData( TypeData::SymbolicInst );
    227         newnode->type->symbolic.name = name ? new string( *name ) : nullptr;
     226        newnode->type->symbolic.name = name;
    228227        newnode->type->symbolic.isTypedef = true;
    229228        newnode->type->symbolic.params = nullptr;
     
    231230} // DeclarationNode::newFromTypedef
    232231
    233 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     232DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
    234233        DeclarationNode * newnode = new DeclarationNode;
    235234        newnode->type = new TypeData( TypeData::Aggregate );
    236235        newnode->type->aggregate.kind = kind;
    237236        if ( name ) {
    238                 newnode->type->aggregate.name = new string( *name );
     237                newnode->type->aggregate.name = name;
    239238        } else {                                                                                        // anonymous aggregate ?
    240239                newnode->type->aggregate.name = new string( anonymous.newName() );
     
    246245} // DeclarationNode::newAggregate
    247246
    248 DeclarationNode * DeclarationNode::newEnum( std::string * name, DeclarationNode * constants ) {
    249         DeclarationNode * newnode = new DeclarationNode;
    250         newnode->name = name;
     247DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants ) {
     248        DeclarationNode * newnode = new DeclarationNode;
    251249        newnode->type = new TypeData( TypeData::Enum );
    252250        if ( name ) {
    253                 newnode->type->enumeration.name = new string( *name );
     251                newnode->type->enumeration.name = name;
    254252        } else {                                                                                        // anonymous aggregate ?
    255253                newnode->type->enumeration.name = new string( anonymous.newName() );
     
    259257} // DeclarationNode::newEnum
    260258
    261 DeclarationNode * DeclarationNode::newEnumConstant( std::string * name, ExpressionNode * constant ) {
     259DeclarationNode * DeclarationNode::newEnumConstant( string * name, ExpressionNode * constant ) {
    262260        DeclarationNode * newnode = new DeclarationNode;
    263261        newnode->name = name;
     
    267265} // DeclarationNode::newEnumConstant
    268266
    269 DeclarationNode * DeclarationNode::newName( std::string * name ) {
     267DeclarationNode * DeclarationNode::newName( string * name ) {
    270268        DeclarationNode * newnode = new DeclarationNode;
    271269        newnode->name = name;
     
    273271} // DeclarationNode::newName
    274272
    275 DeclarationNode * DeclarationNode::newFromTypeGen( std::string * name, ExpressionNode * params ) {
     273DeclarationNode * DeclarationNode::newFromTypeGen( string * name, ExpressionNode * params ) {
    276274        DeclarationNode * newnode = new DeclarationNode;
    277275        newnode->type = new TypeData( TypeData::SymbolicInst );
    278         newnode->type->symbolic.name = name ? new string( *name ) : nullptr;
     276        newnode->type->symbolic.name = name;
    279277        newnode->type->symbolic.isTypedef = false;
    280278        newnode->type->symbolic.actuals = params;
     
    282280} // DeclarationNode::newFromTypeGen
    283281
    284 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, std::string * name ) {
    285         DeclarationNode * newnode = new DeclarationNode;
    286         newnode->name = name;
    287 //      newnode->type = new TypeData( TypeData::Variable );
     282DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, string * name ) {
     283        DeclarationNode * newnode = new DeclarationNode;
    288284        newnode->type = nullptr;
    289285        newnode->variable.tyClass = tc;
    290         newnode->variable.name = newnode->name ? new string( *newnode->name ) : nullptr;
     286        newnode->variable.name = name;
    291287        return newnode;
    292288} // DeclarationNode::newTypeParam
    293289
    294 DeclarationNode * DeclarationNode::newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts ) {
     290DeclarationNode * DeclarationNode::newTrait( const string * name, DeclarationNode * params, DeclarationNode * asserts ) {
    295291        DeclarationNode * newnode = new DeclarationNode;
    296292        newnode->type = new TypeData( TypeData::Aggregate );
     
    302298} // DeclarationNode::newTrait
    303299
    304 DeclarationNode * DeclarationNode::newTraitUse( const std::string * name, ExpressionNode * params ) {
     300DeclarationNode * DeclarationNode::newTraitUse( const string * name, ExpressionNode * params ) {
    305301        DeclarationNode * newnode = new DeclarationNode;
    306302        newnode->type = new TypeData( TypeData::AggregateInst );
     
    312308} // DeclarationNode::newTraitUse
    313309
    314 DeclarationNode * DeclarationNode::newTypeDecl( std::string * name, DeclarationNode * typeParams ) {
    315         DeclarationNode * newnode = new DeclarationNode;
    316         newnode->name = name;
     310DeclarationNode * DeclarationNode::newTypeDecl( string * name, DeclarationNode * typeParams ) {
     311        DeclarationNode * newnode = new DeclarationNode;
    317312        newnode->type = new TypeData( TypeData::Symbolic );
    318313        newnode->type->symbolic.isTypedef = false;
    319314        newnode->type->symbolic.params = typeParams;
    320         newnode->type->symbolic.name = newnode->name;
     315        newnode->type->symbolic.name = name;
    321316        return newnode;
    322317} // DeclarationNode::newTypeDecl
     
    377372} // DeclarationNode::newBuiltinType
    378373
    379 DeclarationNode * DeclarationNode::newAttr( std::string * name, ExpressionNode * expr ) {
    380         DeclarationNode * newnode = new DeclarationNode;
    381 //      newnode->type = new TypeData( TypeData::Attr );
     374DeclarationNode * DeclarationNode::newAttr( string * name, ExpressionNode * expr ) {
     375        DeclarationNode * newnode = new DeclarationNode;
    382376        newnode->type = nullptr;
    383377        newnode->attr.name = name;
     
    386380}
    387381
    388 DeclarationNode * DeclarationNode::newAttr( std::string * name, DeclarationNode * type ) {
    389         DeclarationNode * newnode = new DeclarationNode;
    390 //      newnode->type = new TypeData( TypeData::Attr );
     382DeclarationNode * DeclarationNode::newAttr( string * name, DeclarationNode * type ) {
     383        DeclarationNode * newnode = new DeclarationNode;
    391384        newnode->type = nullptr;
    392385        newnode->attr.name = name;
     
    520513                                        dst->basictype = src->basictype;
    521514                                } else if ( src->basictype != DeclarationNode::NoBasicType )
    522                                         throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src );
     515                                        throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src );
    523516
    524517                                if ( dst->complextype == DeclarationNode::NoComplexType ) {
    525518                                        dst->complextype = src->complextype;
    526519                                } else if ( src->complextype != DeclarationNode::NoComplexType )
    527                                         throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src );
     520                                        throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src );
    528521
    529522                                if ( dst->signedness == DeclarationNode::NoSignedness ) {
    530523                                        dst->signedness = src->signedness;
    531524                                } else if ( src->signedness != DeclarationNode::NoSignedness )
    532                                         throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src );
     525                                        throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src );
    533526
    534527                                if ( dst->length == DeclarationNode::NoLength ) {
     
    537530                                        dst->length = DeclarationNode::LongLong;
    538531                                } else if ( src->length != DeclarationNode::NoLength )
    539                                         throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src );
     532                                        throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src );
    540533                        } // if
    541534                        break;
     
    643636}
    644637
    645 DeclarationNode * DeclarationNode::addName( std::string * newname ) {
     638DeclarationNode * DeclarationNode::addName( string * newname ) {
    646639        assert( ! name );
    647640        name = newname;
Note: See TracChangeset for help on using the changeset viewer.