Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    ra16764a6 rbd06384  
    214214        void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) {
    215215                FunctionDecl * decl = functionDecl->clone();
    216                 delete decl->statements;
    217216                decl->statements = nullptr;
    218217                declsToAdd.push_back( decl );
     
    333332                } catch ( SemanticErrorException err ) {
    334333                        // okay if decl does not resolve - that means the function should not be generated
    335                         delete dcl;
    336334                }
    337335        }
     
    373371                        // do not carry over field's attributes to parameter type
    374372                        Type * paramType = field->get_type()->clone();
    375                         deleteAll( paramType->attributes );
    376373                        paramType->attributes.clear();
    377374                        // add a parameter corresponding to this field
     
    383380                        resolve( ctor );
    384381                }
    385                 delete memCtorType;
    386382        }
    387383
     
    511507                        // do not carry over field's attributes to parameter type
    512508                        Type * paramType = field->get_type()->clone();
    513                         deleteAll( paramType->attributes );
    514509                        paramType->attributes.clear();
    515510                        // add a parameter corresponding to this field
     
    524519                        break;
    525520                }
    526                 delete memCtorType;
    527521        }
    528522
     
    594588                // must visit children (enum constants) to add them to the indexer
    595589                if ( enumDecl->has_body() ) {
    596                         EnumInstType enumInst( Type::Qualifiers(), enumDecl->get_name() );
    597                         enumInst.set_baseEnum( enumDecl );
    598                         EnumFuncGenerator gen( &enumInst, data, functionNesting, indexer );
     590                        auto enumInst = new EnumInstType{ Type::Qualifiers(), enumDecl->get_name() };
     591                        enumInst->set_baseEnum( enumDecl );
     592                        EnumFuncGenerator gen( enumInst, data, functionNesting, indexer );
    599593                        generateFunctions( gen, declsToAddAfter );
    600594                }
     
    604598                visit_children = false;
    605599                if ( structDecl->has_body() ) {
    606                         StructInstType structInst( Type::Qualifiers(), structDecl->name );
    607                         structInst.set_baseStruct( structDecl );
     600                        auto structInst = new StructInstType{ Type::Qualifiers(), structDecl->name };
     601                        structInst->set_baseStruct( structDecl );
    608602                        for ( TypeDecl * typeDecl : structDecl->parameters ) {
    609                                 structInst.parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
    610                         }
    611                         StructFuncGenerator gen( structDecl, &structInst, data, functionNesting, indexer );
     603                                structInst->parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
     604                        }
     605                        StructFuncGenerator gen( structDecl, structInst, data, functionNesting, indexer );
    612606                        generateFunctions( gen, declsToAddAfter );
    613607                } // if
     
    617611                visit_children = false;
    618612                if ( unionDecl->has_body()  ) {
    619                         UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() );
    620                         unionInst.set_baseUnion( unionDecl );
     613                        auto unionInst = new UnionInstType{ Type::Qualifiers(), unionDecl->get_name() };
     614                        unionInst->set_baseUnion( unionDecl );
    621615                        for ( TypeDecl * typeDecl : unionDecl->get_parameters() ) {
    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 );
     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 );
    625619                        generateFunctions( gen, declsToAddAfter );
    626620                } // if
     
    631625                if ( ! typeDecl->base ) return;
    632626
    633                 TypeInstType refType( Type::Qualifiers(), typeDecl->name, typeDecl );
    634                 TypeFuncGenerator gen( typeDecl, &refType, data, functionNesting, indexer );
     627                auto refType = new TypeInstType{ Type::Qualifiers(), typeDecl->name, typeDecl };
     628                TypeFuncGenerator gen( typeDecl, refType, data, functionNesting, indexer );
    635629                generateFunctions( gen, declsToAddAfter );
    636630
Note: See TracChangeset for help on using the changeset viewer.