#ifndef __X10_COMPILER_WS_COLLECTINGFINISH_H
#define __X10_COMPILER_WS_COLLECTINGFINISH_H

#include <x10rt.h>


#define X10_COMPILER_WS_FINISHFRAME_H_NODEPS
#include <x10/compiler/ws/FinishFrame.h>
#undef X10_COMPILER_WS_FINISHFRAME_H_NODEPS
#define X10_UTIL_INDEXEDMEMORYCHUNK_H_NODEPS
#include <x10/util/IndexedMemoryChunk.h>
#undef X10_UTIL_INDEXEDMEMORYCHUNK_H_NODEPS
namespace x10 { namespace lang { 
template<class TPMGL(T)> class Reducible;
} } 
namespace x10 { namespace compiler { 
class Uninitialized;
} } 
namespace x10 { namespace util { 
template<class TPMGL(T)> class IndexedMemoryChunk;
} } 
namespace x10 { namespace compiler { 
class Ifdef;
} } 
namespace x10 { namespace compiler { namespace ws { 
class Frame;
} } } 
namespace x10 { namespace lang { 
class Int;
} } 
namespace x10 { namespace lang { 
class Runtime;
} } 
namespace x10 { namespace util { 
template<class TPMGL(T)> class Stack;
} } 
namespace x10 { namespace lang { 
class Throwable;
} } 
namespace x10 { namespace util { namespace concurrent { 
class Lock;
} } } 
namespace x10 { namespace lang { 
class Boolean;
} } 
namespace x10 { namespace util { 
template<class TPMGL(T)> class ArrayList;
} } 
namespace x10 { namespace compiler { 
class Finalization;
} } 
namespace x10 { namespace compiler { 
class Abort;
} } 
namespace x10 { namespace compiler { 
class CompilerFlags;
} } 
namespace x10 { namespace compiler { namespace ws { 
class Worker;
} } } 
namespace x10 { namespace compiler { namespace ws { 

template<class TPMGL(T)> class CollectingFinish;
template <> class CollectingFinish<void>;
template<class TPMGL(T)> class CollectingFinish : public x10::compiler::ws::FinishFrame
  {
    public:
    RTT_H_DECLS_CLASS
    
    x10aux::ref<x10::lang::Reducible<TPMGL(T)> > FMGL(reducer);
    
    x10::util::IndexedMemoryChunk<TPMGL(T) > FMGL(resultRail);
    
    TPMGL(T) FMGL(result);
    
    void _constructor(x10aux::ref<x10::compiler::ws::Frame> up, x10aux::ref<x10::lang::Reducible<TPMGL(T)> > rd);
    
    void _constructor(x10_int x, x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> > o);
    
    virtual x10aux::ref<x10::compiler::ws::Frame> realloc();
    virtual void accept(TPMGL(T) t, x10aux::ref<x10::compiler::ws::Worker> worker);
    virtual TPMGL(T) fastResult(x10aux::ref<x10::compiler::ws::Worker> worker);
    virtual TPMGL(T) result();
    virtual x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >
      x10__compiler__ws__CollectingFinish____x10__compiler__ws__CollectingFinish__this(
      );
    
    // Serialization
    public: virtual void _serialize_body(x10aux::serialization_buffer& buf);
    
    public: void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};
template <> class CollectingFinish<void> : public x10::compiler::ws::FinishFrame
{
    public:
    static x10aux::RuntimeType rtt;
    static const x10aux::RuntimeType* getRTT() { return & rtt; }
    
};

} } } 
#endif // X10_COMPILER_WS_COLLECTINGFINISH_H

namespace x10 { namespace compiler { namespace ws { 
template<class TPMGL(T)> class CollectingFinish;
} } } 

#ifndef X10_COMPILER_WS_COLLECTINGFINISH_H_NODEPS
#define X10_COMPILER_WS_COLLECTINGFINISH_H_NODEPS
#include <x10/compiler/ws/FinishFrame.h>
#include <x10/lang/Reducible.h>
#include <x10/compiler/Uninitialized.h>
#include <x10/util/IndexedMemoryChunk.h>
#include <x10/compiler/Ifdef.h>
#include <x10/compiler/ws/Frame.h>
#include <x10/lang/Int.h>
#include <x10/lang/Runtime.h>
#include <x10/util/Stack.h>
#include <x10/lang/Throwable.h>
#include <x10/util/concurrent/Lock.h>
#include <x10/lang/Boolean.h>
#include <x10/util/ArrayList.h>
#include <x10/compiler/Finalization.h>
#include <x10/compiler/Abort.h>
#include <x10/compiler/CompilerFlags.h>
#include <x10/compiler/ws/Worker.h>
#ifndef X10_COMPILER_WS_COLLECTINGFINISH_H_GENERICS
#define X10_COMPILER_WS_COLLECTINGFINISH_H_GENERICS
#endif // X10_COMPILER_WS_COLLECTINGFINISH_H_GENERICS
#ifndef X10_COMPILER_WS_COLLECTINGFINISH_H_IMPLEMENTATION
#define X10_COMPILER_WS_COLLECTINGFINISH_H_IMPLEMENTATION
#include <x10/compiler/ws/CollectingFinish.h>


//#line 16 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10FieldDecl_c

//#line 17 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10FieldDecl_c

//#line 18 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10FieldDecl_c

//#line 20 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::compiler::ws::CollectingFinish<TPMGL(T)>::_constructor(
                           x10aux::ref<x10::compiler::ws::Frame> up,
                           x10aux::ref<x10::lang::Reducible<TPMGL(T)> > rd) {
    
    //#line 21 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::compiler::ws::FinishFrame::_constructor(up);
    
    //#line 20 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.AssignPropertyCall_c
    
    //#line 22 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
      FMGL(reducer) = rd;
    {
        
        //#line 23 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
        ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
          FMGL(result) = x10::lang::Reducible<TPMGL(T)>::zero(x10aux::nullCheck(rd));
    }
}


//#line 33 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::compiler::ws::CollectingFinish<TPMGL(T)>::_constructor(
                           x10_int x, x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> > o) {
    
    //#line 35 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::compiler::ws::FinishFrame::_constructor(
      x, x10aux::class_cast_unchecked<x10aux::ref<x10::compiler::ws::FinishFrame> >(o));
    
    //#line 33 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.AssignPropertyCall_c
    
    //#line 37 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
      FMGL(reducer) = x10aux::nullCheck(o)->FMGL(reducer);
    
    //#line 38 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
    x10_int size = x10::lang::Runtime::FMGL(NTHREADS);
    
    //#line 39 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
      FMGL(resultRail) = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(size, 8, false, false);
    
    //#line 40 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": polyglot.ast.For_c
    {
        x10_int i;
        for (
             //#line 40 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
             i = ((x10_int)0); ((i) < (size)); 
                                               //#line 40 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10LocalAssign_c
                                               i = ((x10_int) ((i) + (((x10_int)1)))))
        {
            
            //#line 41 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
            (((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
               FMGL(resultRail))->__set(i, x10::lang::Reducible<TPMGL(T)>::zero(x10aux::nullCheck(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                                                                                    FMGL(reducer))));
        }
    }
    
}


//#line 45 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::compiler::ws::Frame>
  x10::compiler::ws::CollectingFinish<TPMGL(T)>::realloc(
  ) {
    
    //#line 47 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
    if ((!x10aux::struct_equals(X10_NULL, ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                            FMGL(redirect))))
    {
        
        //#line 47 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10Return_c
        return x10aux::class_cast_unchecked<x10aux::ref<x10::compiler::ws::Frame> >(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                                                                      FMGL(redirect));
        
    }
    
    //#line 48 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::compiler::ws::FinishFrame> tmp = x10aux::class_cast_unchecked<x10aux::ref<x10::compiler::ws::FinishFrame> >(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->remap());
    
    //#line 49 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
    x10aux::nullCheck(tmp)->FMGL(redirect) = tmp;
    
    //#line 50 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
    if ((!x10aux::struct_equals(X10_NULL, ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                            FMGL(stack))))
    {
        
        //#line 51 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
        x10aux::nullCheck(tmp)->FMGL(stack) = x10::util::Stack<x10aux::ref<x10::lang::Throwable> >::_make();
        
        //#line 52 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
        x10::lang::Runtime::FMGL(atomicMonitor)->lock();
        
        //#line 53 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10While_c
        while (!(x10aux::nullCheck(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                     FMGL(stack))->isEmpty()))
        {
            
            //#line 53 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
            x10aux::nullCheck(x10aux::nullCheck(tmp)->FMGL(stack))->push(
              x10aux::nullCheck(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                  FMGL(stack))->pop());
        }
        
        //#line 54 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
        ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
          FMGL(stack) = X10_NULL;
        
        //#line 55 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
        x10::lang::Runtime::FMGL(atomicMonitor)->unlock();
    }
    {
        
        //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
        x10aux::ref<x10::lang::Throwable> throwable41493 =
          X10_NULL;
        
        //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": polyglot.ast.Try_c
        try {
            {
                
                //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
                x10::lang::Runtime::enterAtomic();
                {
                    
                    //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
                    ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                      FMGL(redirect) = tmp;
                }
            }
            
            //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
            x10::compiler::Finalization::plausibleThrow();
        }
        catch (x10aux::__ref& __ref__670) {
            x10aux::ref<x10::lang::Throwable>& __exc__ref__670 = (x10aux::ref<x10::lang::Throwable>&)__ref__670;
            if (true) {
                x10aux::ref<x10::lang::Throwable> formal41494 =
                  static_cast<x10aux::ref<x10::lang::Throwable> >(__exc__ref__670);
                {
                    
                    //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10LocalAssign_c
                    throwable41493 = formal41494;
                }
            } else
            throw;
        }
        
        //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
        if ((!x10aux::struct_equals(X10_NULL, throwable41493)))
        {
            
            //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
            if (x10aux::instanceof<x10aux::ref<x10::compiler::Abort> >(throwable41493))
            {
                
                //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": polyglot.ast.Throw_c
                x10aux::throwException(x10aux::nullCheck(throwable41493));
            }
            
        }
        
        //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
        if (true) {
            
            //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
            x10::lang::Runtime::exitAtomic();
        }
        
        //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
        if ((!x10aux::struct_equals(X10_NULL, throwable41493)))
        {
            
            //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
            if (!(x10aux::instanceof<x10aux::ref<x10::compiler::Finalization> >(throwable41493)))
            {
                
                //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": polyglot.ast.Throw_c
                x10aux::throwException(x10aux::nullCheck(throwable41493));
            }
            
        }
        
    }
    
    //#line 59 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
    x10aux::nullCheck(static_cast<x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> > >(tmp))->
      FMGL(result) = ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                       FMGL(result);
    
    //#line 60 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10Return_c
    return x10aux::class_cast_unchecked<x10aux::ref<x10::compiler::ws::Frame> >(tmp);
    
}

//#line 63 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::compiler::ws::CollectingFinish<TPMGL(T)>::accept(
  TPMGL(T) t, x10aux::ref<x10::compiler::ws::Worker> worker) {
    {
        
        //#line 65 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10If_c
        if ((x10aux::struct_equals(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                     FMGL(redirect), X10_NULL)))
        {
            
            //#line 66 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
            ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
              FMGL(result) = x10::lang::Reducible<TPMGL(T)>::__apply(x10aux::nullCheck(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                                                                         FMGL(reducer)), 
                               ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                 FMGL(result), t);
        } else {
            
            //#line 69 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
            x10_int id = x10aux::nullCheck(worker)->FMGL(id);
            
            //#line 70 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
            x10::util::IndexedMemoryChunk<TPMGL(T) > rr =
              x10aux::nullCheck(static_cast<x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> > >(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                                                                                            FMGL(redirect)))->
                FMGL(resultRail);
            
            //#line 71 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
            (rr)->__set(id, x10::lang::Reducible<TPMGL(T)>::__apply(x10aux::nullCheck(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                                                                        FMGL(reducer)), 
                              (rr)->__apply(id), t));
        }
        
    }
}

//#line 81 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::compiler::ws::CollectingFinish<TPMGL(T)>::fastResult(
  x10aux::ref<x10::compiler::ws::Worker> worker) {
    {
        
        //#line 83 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10Return_c
        return ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                 FMGL(result);
        
    }
}

//#line 93 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::compiler::ws::CollectingFinish<TPMGL(T)>::result(
  ) {
    {
        
        //#line 96 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
        x10_int size = x10::lang::Runtime::FMGL(NTHREADS);
        
        //#line 97 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": polyglot.ast.For_c
        {
            x10_int i;
            for (
                 //#line 97 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10LocalDecl_c
                 i = ((x10_int)0); ((i) < (size)); 
                                                   //#line 97 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10LocalAssign_c
                                                   i = ((x10_int) ((i) + (((x10_int)1)))))
            {
                
                //#line 98 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10FieldAssign_c
                ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                  FMGL(result) = x10::lang::Reducible<TPMGL(T)>::__apply(x10aux::nullCheck(((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                                                                             FMGL(reducer)), 
                                   ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                     FMGL(result), (((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                                                      FMGL(resultRail))->__apply(i));
            }
        }
        
        //#line 100 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": Eval of x10.ast.X10Call_c
        (((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
           FMGL(resultRail))->deallocate();
        
        //#line 101 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10Return_c
        return ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this)->
                 FMGL(result);
        
    }
}

//#line 15 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >
  x10::compiler::ws::CollectingFinish<TPMGL(T)>::x10__compiler__ws__CollectingFinish____x10__compiler__ws__CollectingFinish__this(
  ) {
    
    //#line 15 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/compiler/ws/CollectingFinish.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::compiler::ws::CollectingFinish<TPMGL(T)> >)this);
    
}
template<class TPMGL(T)> void x10::compiler::ws::CollectingFinish<TPMGL(T)>::_serialize_body(x10aux::serialization_buffer& buf) {
    x10::compiler::ws::FinishFrame::_serialize_body(buf);
    buf.write(this->FMGL(reducer));
    buf.write(this->FMGL(resultRail));
    buf.write(this->FMGL(result));
    
}

template<class TPMGL(T)> void x10::compiler::ws::CollectingFinish<TPMGL(T)>::_deserialize_body(x10aux::deserialization_buffer& buf) {
    x10::compiler::ws::FinishFrame::_deserialize_body(buf);
    FMGL(reducer) = buf.read<x10aux::ref<x10::lang::Reducible<TPMGL(T)> > >();
    FMGL(resultRail) = buf.read<x10::util::IndexedMemoryChunk<TPMGL(T) > >();
    FMGL(result) = buf.read<TPMGL(T)>();
}

template<class TPMGL(T)> x10aux::RuntimeType x10::compiler::ws::CollectingFinish<TPMGL(T)>::rtt;
template<class TPMGL(T)> void x10::compiler::ws::CollectingFinish<TPMGL(T)>::_initRTT() {
    const x10aux::RuntimeType *canonical = x10aux::getRTT<x10::compiler::ws::CollectingFinish<void> >();
    if (rtt.initStageOne(canonical)) return;
    const x10aux::RuntimeType* parents[1] = { x10aux::getRTT<x10::compiler::ws::FinishFrame>()};
    const x10aux::RuntimeType* params[1] = { x10aux::getRTT<TPMGL(T)>()};
    x10aux::RuntimeType::Variance variances[1] = { x10aux::RuntimeType::invariant};
    const char *baseName = "x10.compiler.ws.CollectingFinish";
    rtt.initStageTwo(baseName, x10aux::RuntimeType::class_kind, 1, parents, 1, params, variances);
}
#endif // X10_COMPILER_WS_COLLECTINGFINISH_H_IMPLEMENTATION
#endif // __X10_COMPILER_WS_COLLECTINGFINISH_H_NODEPS
