Changeset 5b7a60c8


Ignore:
Timestamp:
Aug 18, 2016, 5:00:32 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
12756de
Parents:
99cad3aa (diff), 7ecbb7e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Location:
src
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r99cad3aa r5b7a60c8  
    4949}
    5050
     51template< typename T, typename U >
     52static inline T * maybeMoveBuild( const U *orig ) {
     53        T* ret = maybeBuild<T>(orig);
     54        delete orig;
     55        return ret;
     56}
     57
     58
    5159template< typename Input_iterator >
    5260void printEnums( Input_iterator begin, Input_iterator end, const char * const *name_array, std::ostream &os ) {
  • src/Parser/ExpressionNode.cc

    r99cad3aa r5b7a60c8  
    167167
    168168NameExpr * build_varref( const string *name, bool labelp ) {
    169         return new NameExpr( *name, nullptr );
     169        NameExpr *expr = new NameExpr( *name, nullptr );
     170        delete name;
     171        return expr;
    170172}
    171173
     
    184186        if ( dynamic_cast< VoidType * >( targetType ) ) {
    185187                delete targetType;
    186                 return new CastExpr( maybeBuild< Expression >(expr_node) );
     188                return new CastExpr( maybeMoveBuild< Expression >(expr_node) );
    187189        } else {
    188                 return new CastExpr( maybeBuild< Expression >(expr_node), targetType );
     190                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );
    189191        } // if
    190192}
    191193
    192194Expression *build_fieldSel( ExpressionNode *expr_node, NameExpr *member ) {
    193         UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeBuild< Expression >(expr_node) );
     195        UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeMoveBuild< Expression >(expr_node) );
    194196        delete member;
    195197        return ret;
     
    198200Expression *build_pfieldSel( ExpressionNode *expr_node, NameExpr *member ) {
    199201        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    200         deref->get_args().push_back( maybeBuild< Expression >(expr_node) );
     202        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
    201203        UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref );
    202204        delete member;
     
    205207
    206208Expression *build_addressOf( ExpressionNode *expr_node ) {
    207                 return new AddressExpr( maybeBuild< Expression >(expr_node) );
     209                return new AddressExpr( maybeMoveBuild< Expression >(expr_node) );
    208210}
    209211Expression *build_sizeOfexpr( ExpressionNode *expr_node ) {
    210         return new SizeofExpr( maybeBuild< Expression >(expr_node) );
     212        return new SizeofExpr( maybeMoveBuild< Expression >(expr_node) );
    211213}
    212214Expression *build_sizeOftype( DeclarationNode *decl_node ) {
     
    214216}
    215217Expression *build_alignOfexpr( ExpressionNode *expr_node ) {
    216         return new AlignofExpr( maybeBuild< Expression >(expr_node) );
     218        return new AlignofExpr( maybeMoveBuild< Expression >(expr_node) );
    217219}
    218220Expression *build_alignOftype( DeclarationNode *decl_node ) {
     
    224226
    225227Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ) {
    226         return new LogicalExpr( notZeroExpr( maybeBuild< Expression >(expr_node1) ), notZeroExpr( maybeBuild< Expression >(expr_node2) ), kind );
     228        return new LogicalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );
    227229}
    228230
    229231Expression *build_unary_val( OperKinds op, ExpressionNode *expr_node ) {
    230232        std::list< Expression * > args;
    231         args.push_back( maybeBuild< Expression >(expr_node) );
     233        args.push_back( maybeMoveBuild< Expression >(expr_node) );
    232234        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    233235}
    234236Expression *build_unary_ptr( OperKinds op, ExpressionNode *expr_node ) {
    235237        std::list< Expression * > args;
    236         args.push_back( new AddressExpr( maybeBuild< Expression >(expr_node) ) );
     238        args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node) ) );
    237239        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    238240}
    239241Expression *build_binary_val( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
    240242        std::list< Expression * > args;
    241         args.push_back( maybeBuild< Expression >(expr_node1) );
    242         args.push_back( maybeBuild< Expression >(expr_node2) );
     243        args.push_back( maybeMoveBuild< Expression >(expr_node1) );
     244        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
    243245        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    244246}
    245247Expression *build_binary_ptr( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
    246248        std::list< Expression * > args;
    247         args.push_back( new AddressExpr( maybeBuild< Expression >(expr_node1) ) );
    248         args.push_back( maybeBuild< Expression >(expr_node2) );
     249        args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node1) ) );
     250        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
    249251        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    250252}
    251253
    252254Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ) {
    253         return new ConditionalExpr( notZeroExpr( maybeBuild< Expression >(expr_node1) ), maybeBuild< Expression >(expr_node2), maybeBuild< Expression >(expr_node3) );
     255        return new ConditionalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );
    254256}
    255257
    256258Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
    257         return new CommaExpr( maybeBuild< Expression >(expr_node1), maybeBuild< Expression >(expr_node2) );
     259        return new CommaExpr( maybeMoveBuild< Expression >(expr_node1), maybeMoveBuild< Expression >(expr_node2) );
    258260}
    259261
    260262Expression *build_attrexpr( NameExpr *var, ExpressionNode * expr_node ) {
    261         return new AttrExpr( var, maybeBuild< Expression >(expr_node) );
     263        return new AttrExpr( var, maybeMoveBuild< Expression >(expr_node) );
    262264}
    263265Expression *build_attrtype( NameExpr *var, DeclarationNode * decl_node ) {
     
    267269Expression *build_tuple( ExpressionNode * expr_node ) {
    268270        TupleExpr *ret = new TupleExpr();
    269         buildList( expr_node, ret->get_exprs() );
     271        buildMoveList( expr_node, ret->get_exprs() );
    270272        return ret;
    271273}
     
    273275Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
    274276        std::list< Expression * > args;
    275 
    276         buildList( expr_node, args );
    277         return new UntypedExpr( maybeBuild< Expression >(function), args, nullptr );
     277        buildMoveList( expr_node, args );
     278        return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr );
    278279}
    279280
    280281Expression *build_range( ExpressionNode * low, ExpressionNode *high ) {
    281         Expression *low_cexpr = maybeBuild< Expression >( low );
    282         Expression *high_cexpr = maybeBuild< Expression >( high );
    283         return new RangeExpr( low_cexpr, high_cexpr );
     282        return new RangeExpr( maybeMoveBuild< Expression >( low ), maybeMoveBuild< Expression >( high ) );
    284283}
    285284
    286285Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {
    287         return new AsmExpr( maybeBuild< Expression >( inout ), constraint, maybeBuild< Expression >(operand) );
     286        return new AsmExpr( maybeMoveBuild< Expression >( inout ), constraint, maybeMoveBuild< Expression >(operand) );
    288287}
    289288
    290289Expression *build_valexpr( StatementNode *s ) {
    291         return new UntypedValofExpr( maybeBuild< Statement >(s), nullptr );
     290        return new UntypedValofExpr( maybeMoveBuild< Statement >(s), nullptr );
    292291}
    293292Expression *build_typevalue( DeclarationNode *decl ) {
     
    298297        Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type
    299298        if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
    300                 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeBuild< Initializer >(kids) );
     299                return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeMoveBuild< Initializer >(kids) );
    301300        // these types do not have associated type information
    302301        } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl )  ) {
    303                 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeBuild< Initializer >(kids) );
     302                return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
    304303        } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl )  ) {
    305                 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeBuild< Initializer >(kids) );
     304                return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
    306305        } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl )  ) {
    307                 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeBuild< Initializer >(kids) );
     306                return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
    308307        } else {
    309308                assert( false );
  • src/Parser/ParseNode.h

    r99cad3aa r5b7a60c8  
    387387void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList );
    388388
     389template< typename SynTreeType, typename NodeType >
     390void buildMoveList( const NodeType *firstNode, std::list< SynTreeType * > &outputList ) {
     391        buildList(firstNode, outputList);
     392        delete firstNode;
     393}
     394
     395
    389396#endif // PARSENODE_H
    390397
  • src/Parser/StatementNode.cc

    r99cad3aa r5b7a60c8  
    6262        StatementNode *node = dynamic_cast< StatementNode * >(prev);
    6363        std::list< Statement * > stmts;
    64         buildList( stmt, stmts );
     64        buildMoveList( stmt, stmts );
    6565        // splice any new Statements to end of current Statements
    6666        CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt);
     
    7070
    7171Statement *build_expr( ExpressionNode *ctl ) {
    72         Expression *e = maybeBuild< Expression >( ctl );
     72        Expression *e = maybeMoveBuild< Expression >( ctl );
    7373
    7474        if ( e )
     
    8181        Statement *thenb, *elseb = 0;
    8282        std::list< Statement * > branches;
    83         buildList< Statement, StatementNode >( then_stmt, branches );
     83        buildMoveList< Statement, StatementNode >( then_stmt, branches );
    8484        assert( branches.size() == 1 );
    8585        thenb = branches.front();
     
    8787        if ( else_stmt ) {
    8888                std::list< Statement * > branches;
    89                 buildList< Statement, StatementNode >( else_stmt, branches );
     89                buildMoveList< Statement, StatementNode >( else_stmt, branches );
    9090                assert( branches.size() == 1 );
    9191                elseb = branches.front();
    9292        } // if
    93         return new IfStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), thenb, elseb );
     93        return new IfStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), thenb, elseb );
    9494}
    9595
    9696Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {
    9797        std::list< Statement * > branches;
    98         buildList< Statement, StatementNode >( stmt, branches );
     98        buildMoveList< Statement, StatementNode >( stmt, branches );
    9999        assert( branches.size() >= 0 );                                         // size == 0 for switch (...) {}, i.e., no declaration or statements
    100         return new SwitchStmt( noLabels, maybeBuild< Expression >(ctl), branches );
     100        return new SwitchStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
    101101}
    102102Statement *build_case( ExpressionNode *ctl ) {
    103103        std::list< Statement * > branches;
    104         return new CaseStmt( noLabels, maybeBuild< Expression >(ctl), branches );
     104        return new CaseStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
    105105}
    106106Statement *build_default() {
     
    111111Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) {
    112112        std::list< Statement * > branches;
    113         buildList< Statement, StatementNode >( stmt, branches );
     113        buildMoveList< Statement, StatementNode >( stmt, branches );
    114114        assert( branches.size() == 1 );
    115         return new WhileStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), branches.front(), kind );
     115        return new WhileStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind );
    116116}
    117117
    118118Statement *build_for( ForCtl *forctl, StatementNode *stmt ) {
    119119        std::list< Statement * > branches;
    120         buildList< Statement, StatementNode >( stmt, branches );
     120        buildMoveList< Statement, StatementNode >( stmt, branches );
    121121        assert( branches.size() == 1 );
    122122
    123123        std::list< Statement * > init;
    124124        if ( forctl->init != 0 ) {
    125                 buildList( forctl->init, init );
     125                buildMoveList( forctl->init, init );
    126126        } // if
    127127
    128128        Expression *cond = 0;
    129129        if ( forctl->condition != 0 )
    130                 cond = notZeroExpr( maybeBuild< Expression >(forctl->condition) );
     130                cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
    131131
    132132        Expression *incr = 0;
    133133        if ( forctl->change != 0 )
    134                 incr = maybeBuild< Expression >(forctl->change);
     134                incr = maybeMoveBuild< Expression >(forctl->change);
    135135
    136136        delete forctl;
     
    142142}
    143143Statement *build_computedgoto( ExpressionNode *ctl ) {
    144         return new BranchStmt( noLabels, maybeBuild< Expression >(ctl), BranchStmt::Goto );
     144        return new BranchStmt( noLabels, maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );
    145145}
    146146
    147147Statement *build_return( ExpressionNode *ctl ) {
    148148        std::list< Expression * > exps;
    149         buildList( ctl, exps );
     149        buildMoveList( ctl, exps );
    150150        return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr );
    151151}
    152152Statement *build_throw( ExpressionNode *ctl ) {
    153153        std::list< Expression * > exps;
    154         buildList( ctl, exps );
     154        buildMoveList( ctl, exps );
    155155        return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr, true );
    156156}
     
    158158Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
    159159        std::list< Statement * > branches;
    160         buildList< Statement, StatementNode >( catch_stmt, branches );
    161         CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeBuild< Statement >(try_stmt));
     160        buildMoveList< Statement, StatementNode >( catch_stmt, branches );
     161        CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    162162        assert( tryBlock );
    163         FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeBuild< Statement >(finally_stmt) );
     163        FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
    164164        return new TryStmt( noLabels, tryBlock, branches, finallyBlock );
    165165}
    166166Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) {
    167167        std::list< Statement * > branches;
    168         buildList< Statement, StatementNode >( stmt, branches );
     168        buildMoveList< Statement, StatementNode >( stmt, branches );
    169169        assert( branches.size() == 1 );
    170         return new CatchStmt( noLabels, maybeBuild< Declaration >(decl), branches.front(), catchAny );
     170        return new CatchStmt( noLabels, maybeMoveBuild< Declaration >(decl), branches.front(), catchAny );
    171171}
    172172Statement *build_finally( StatementNode *stmt ) {
    173173        std::list< Statement * > branches;
    174         buildList< Statement, StatementNode >( stmt, branches );
     174        buildMoveList< Statement, StatementNode >( stmt, branches );
    175175        assert( branches.size() == 1 );
    176176        return new FinallyStmt( noLabels, dynamic_cast< CompoundStmt * >( branches.front() ) );
     
    179179Statement *build_compound( StatementNode *first ) {
    180180        CompoundStmt *cs = new CompoundStmt( noLabels );
    181         buildList( first, cs->get_kids() );
     181        buildMoveList( first, cs->get_kids() );
    182182        return cs;
    183183}
     
    187187        std::list< ConstantExpr * > clob;
    188188
    189         buildList( output, out );
    190         buildList( input, in );
    191         buildList( clobber, clob );
     189        buildMoveList( output, out );
     190        buildMoveList( input, in );
     191        buildMoveList( clobber, clob );
    192192        return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );
    193193}
  • src/examples/gc_no_raii/premake4.lua

    r99cad3aa r5b7a60c8  
    66        "src/",
    77        "../",
     8        "containers/"
    89}
    910
     
    4849                linkoptions (linkOptionList)
    4950                includedirs (includeDirList)
    50                 files { "src/**.c" }
     51                files { "src/**.c", "containers/**.c" }
    5152
    5253        configuration "debug"
  • src/examples/gc_no_raii/src/gc.h

    r99cad3aa r5b7a60c8  
    44#include "internal/collector.h"
    55
    6 forall(otype T)
    7 static inline gcpointer(T) gcmalloc()
    8 {
    9     gcpointer(T) ptr = { gc_allocate(sizeof(T)) };
    10     ptr{};
    11     gc_conditional_collect();
    12     return ptr;
    13 }
     6// forall(otype T)
     7// static inline gcpointer(T) gcmalloc()
     8// {
     9//     gcpointer(T) ptr = { gc_allocate(sizeof(T)) };
     10//     ptr{};
     11//     gc_conditional_collect();
     12//     return ptr;
     13// }
    1414
    1515forall(otype T)
    1616static inline void gcmalloc(gcpointer(T)* ptr)
    1717{
    18         ptr{ gc_allocate(sizeof(T)) };
    19       (*ptr){};
     18        ptr { gc_allocate(sizeof(T)) };
     19        get(ptr) {};
    2020      gc_conditional_collect();
    2121}
  • src/examples/gc_no_raii/src/gcpointers.c

    r99cad3aa r5b7a60c8  
    4242}
    4343
    44 void gcpointer_ctor(gcpointer_t* this)
     44void ?{}(gcpointer_t* this)
    4545{
    4646        this->ptr = (intptr_t)NULL;
     
    4848}
    4949
    50 void gcpointer_ctor(gcpointer_t* this, void* address)
     50void ?{}(gcpointer_t* this, void* address)
    5151{
    5252        this->ptr = (intptr_t)address;
     
    5656}
    5757
    58 void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other)
     58void ?{}(gcpointer_t* this, gcpointer_t other)
    5959{
    60         this->ptr = other->ptr;
     60        this->ptr = other.ptr;
    6161        this->next = NULL;
    6262
     
    6464}
    6565
    66 void gcpointer_dtor(gcpointer_t* this)
     66void ^?{}(gcpointer_t* this)
    6767{
    6868        unregister_ptr(this);
     
    9898        return this->ptr == (intptr_t)NULL;
    9999}
     100
     101forall(otype T) void ?{}(gcpointer(T)* this) {
     102        (&this->internal) {};
     103}
     104
     105forall(otype T) void ?{}(gcpointer(T)* this, void* address) {
     106        (&this->internal) { address };
     107}
     108
     109forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other) {
     110        (&this->internal) { other->internal };
     111}
     112
     113forall(otype T) void ^?{}(gcpointer(T)* this) {
     114        ^?{}(&this->internal);
     115}
     116
     117// forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs);
     118//
     119// forall(otype T) T *?(gcpointer(T) this);
     120
     121forall(otype T) T* get(gcpointer(T)* this) {
     122        return (T*)this->internal.ptr;
     123}
     124//
     125// //Logical operators
     126// forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs);
     127// forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs);
  • src/examples/gc_no_raii/src/gcpointers.h

    r99cad3aa r5b7a60c8  
    3030forall(otype T) void ?{}(gcpointer(T)* this);
    3131forall(otype T) void ?{}(gcpointer(T)* this, void* address);
    32 forall(otype T) void ctor(gcpointer(T)* this, void* address);
    3332forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other);
    3433forall(otype T) void ^?{}(gcpointer(T)* this);
     
    3736
    3837forall(otype T) T *?(gcpointer(T) this);
     38forall(otype T) T* get(gcpointer(T)* this);
    3939
    4040//Logical operators
  • src/examples/gc_no_raii/src/internal/collector.c

    r99cad3aa r5b7a60c8  
    88}
    99#endif
     10
     11#include <fstream>
    1012
    1113#include "state.h"
     
    3638void* gc_allocate(size_t target_size)
    3739{
     40        sout | "Allocating " | target_size | " bytes" | endl;
     41
    3842        size_t size = gc_compute_size(target_size + sizeof(gc_object_header));
     43
     44        sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl;
     45        sout | "Actual allocation size: " | size | " bytes" | endl;
    3946
    4047        check(size < POOL_SIZE_BYTES);
  • src/examples/gc_no_raii/src/internal/state.h

    r99cad3aa r5b7a60c8  
    99}
    1010#endif
     11#include <fstream>
    1112#include <vector>
    1213
     
    3738static inline bool gc_needs_collect(gc_state* state)
    3839{
     40        sout | "Used Space: " | state->used_space | " bytes" | endl;
    3941        return state->used_space * 2 > state->total_space;
    4042}
  • src/examples/gc_no_raii/test/gctest.c

    r99cad3aa r5b7a60c8  
    22
    33#include "gc.h"
     4#include "internal/collector.h"
    45
    56#warning default test
     
    89        sout | "Bonjour au monde!\n";
    910
    10         for(int i = 0; i < 1000000; i++) {
    11                 gcpointer(int) anInt;
    12                 gcmalloc(&anInt);
     11        gcpointer(int) theInt;
     12        gcmalloc(&theInt);
     13
     14        for(int i = 0; i < 10; i++) {
     15                int a;
     16                {
     17                        gcpointer(int) anInt;
     18                        gcmalloc(&anInt);
     19                }
     20                int p;
    1321        }
     22
     23        gc_collect(gc_get_state());
     24        gc_conditional_collect();
    1425}
Note: See TracChangeset for help on using the changeset viewer.