Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rbd06384 ra16764a6  
    214214        void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) {
    215215                FunctionDecl * decl = functionDecl->clone();
     216                delete decl->statements;
    216217                decl->statements = nullptr;
    217218                declsToAdd.push_back( decl );
     
    332333                } catch ( SemanticErrorException err ) {
    333334                        // okay if decl does not resolve - that means the function should not be generated
     335                        delete dcl;
    334336                }
    335337        }
     
    371373                        // do not carry over field's attributes to parameter type
    372374                        Type * paramType = field->get_type()->clone();
     375                        deleteAll( paramType->attributes );
    373376                        paramType->attributes.clear();
    374377                        // add a parameter corresponding to this field
     
    380383                        resolve( ctor );
    381384                }
     385                delete memCtorType;
    382386        }
    383387
     
    507511                        // do not carry over field's attributes to parameter type
    508512                        Type * paramType = field->get_type()->clone();
     513                        deleteAll( paramType->attributes );
    509514                        paramType->attributes.clear();
    510515                        // add a parameter corresponding to this field
     
    519524                        break;
    520525                }
     526                delete memCtorType;
    521527        }
    522528
     
    588594                // must visit children (enum constants) to add them to the indexer
    589595                if ( enumDecl->has_body() ) {
    590                         auto enumInst = new EnumInstType{ Type::Qualifiers(), enumDecl->get_name() };
    591                         enumInst->set_baseEnum( enumDecl );
    592                         EnumFuncGenerator gen( enumInst, data, functionNesting, indexer );
     596                        EnumInstType enumInst( Type::Qualifiers(), enumDecl->get_name() );
     597                        enumInst.set_baseEnum( enumDecl );
     598                        EnumFuncGenerator gen( &enumInst, data, functionNesting, indexer );
    593599                        generateFunctions( gen, declsToAddAfter );
    594600                }
     
    598604                visit_children = false;
    599605                if ( structDecl->has_body() ) {
    600                         auto structInst = new StructInstType{ Type::Qualifiers(), structDecl->name };
    601                         structInst->set_baseStruct( structDecl );
     606                        StructInstType structInst( Type::Qualifiers(), structDecl->name );
     607                        structInst.set_baseStruct( structDecl );
    602608                        for ( TypeDecl * typeDecl : structDecl->parameters ) {
    603                                 structInst->parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
    604                         }
    605                         StructFuncGenerator gen( structDecl, structInst, data, functionNesting, indexer );
     609                                structInst.parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
     610                        }
     611                        StructFuncGenerator gen( structDecl, &structInst, data, functionNesting, indexer );
    606612                        generateFunctions( gen, declsToAddAfter );
    607613                } // if
     
    611617                visit_children = false;
    612618                if ( unionDecl->has_body()  ) {
    613                         auto unionInst = new UnionInstType{ Type::Qualifiers(), unionDecl->get_name() };
    614                         unionInst->set_baseUnion( unionDecl );
     619                        UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() );
     620                        unionInst.set_baseUnion( unionDecl );
    615621                        for ( TypeDecl * typeDecl : unionDecl->get_parameters() ) {
    616                                 unionInst->get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) );
    617                         }
    618                         UnionFuncGenerator gen( unionDecl, unionInst, data, functionNesting, indexer );
     622                                unionInst.get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) );
     623                        }
     624                        UnionFuncGenerator gen( unionDecl, &unionInst, data, functionNesting, indexer );
    619625                        generateFunctions( gen, declsToAddAfter );
    620626                } // if
     
    625631                if ( ! typeDecl->base ) return;
    626632
    627                 auto refType = new TypeInstType{ Type::Qualifiers(), typeDecl->name, typeDecl };
    628                 TypeFuncGenerator gen( typeDecl, refType, data, functionNesting, indexer );
     633                TypeInstType refType( Type::Qualifiers(), typeDecl->name, typeDecl );
     634                TypeFuncGenerator gen( typeDecl, &refType, data, functionNesting, indexer );
    629635                generateFunctions( gen, declsToAddAfter );
    630636
Note: See TracChangeset for help on using the changeset viewer.