#ifndef __X10_ARRAY_REMOTEARRAY_H
#define __X10_ARRAY_REMOTEARRAY_H

#include <x10rt.h>


#define X10_LANG_OBJECT_H_NODEPS
#include <x10/lang/Object.h>
#undef X10_LANG_OBJECT_H_NODEPS
#define X10_UTIL_REMOTEINDEXEDMEMORYCHUNK_H_NODEPS
#include <x10/util/RemoteIndexedMemoryChunk.h>
#undef X10_UTIL_REMOTEINDEXEDMEMORYCHUNK_H_NODEPS
#define X10_LANG_INT_H_NODEPS
#include <x10/lang/Int.h>
#undef X10_LANG_INT_H_NODEPS
#define X10_LANG_GLOBALREF_H_NODEPS
#include <x10/lang/GlobalRef.h>
#undef X10_LANG_GLOBALREF_H_NODEPS
namespace x10 { namespace array { 
class Region;
} } 
namespace x10 { namespace lang { 
class Int;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class GlobalRef;
} } 
namespace x10 { namespace array { 
template<class TPMGL(T)> class Array;
} } 
namespace x10 { namespace util { 
template<class TPMGL(T)> class RemoteIndexedMemoryChunk;
} } 
namespace x10 { namespace lang { 
class Place;
} } 
namespace x10 { namespace compiler { 
class Native;
} } 
namespace x10 { namespace lang { 
class Runtime;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(U)> class Fun_0_0;
} } 
namespace x10 { namespace array { 
class Point;
} } 
namespace x10 { namespace lang { 
class Boolean;
} } 
namespace x10 { namespace compiler { 
class CompilerFlags;
} } 
namespace x10 { namespace lang { 
class FailedDynamicCheckException;
} } 
namespace x10 { namespace lang { 
class Any;
} } 
namespace x10 { namespace array { 

template<class TPMGL(T)> class RemoteArray;
template <> class RemoteArray<void>;
template<class TPMGL(T)> class RemoteArray : public x10::lang::Object   {
    public:
    RTT_H_DECLS_CLASS
    
    x10aux::ref<x10::array::Region> FMGL(region);
    
    x10_int FMGL(size);
    
    x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > FMGL(array);
    
    x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > FMGL(rawData);
    
    x10_int rank();
    x10::lang::Place home();
    void _constructor(x10aux::ref<x10::array::Array<TPMGL(T)> > a);
    
    static x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > _make(x10aux::ref<x10::array::Array<TPMGL(T)> > a);
    
    void _constructor(x10aux::ref<x10::array::Region> reg, x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > raw);
    
    static x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > _make(x10aux::ref<x10::array::Region> reg,
                                                                 x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > raw);
    
    virtual TPMGL(T) __apply(x10_int i);
    virtual TPMGL(T) __apply(x10aux::ref<x10::array::Point> p);
    virtual TPMGL(T) __set(x10_int i, TPMGL(T) v);
    virtual TPMGL(T) __set(x10aux::ref<x10::array::Point> p, TPMGL(T) v);
    virtual x10aux::ref<x10::array::Array<TPMGL(T)> > __apply();
    virtual x10_boolean equals(x10aux::ref<x10::lang::Any> other);
    virtual x10_int hashCode();
    virtual x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > x10__array__RemoteArray____x10__array__RemoteArray__this(
      );
    
    // Serialization
    public: static const x10aux::serialization_id_t _serialization_id;
    
    public: x10aux::serialization_id_t _get_serialization_id() {
         return _serialization_id;
    }
    
    public: virtual void _serialize_body(x10aux::serialization_buffer& buf);
    
    public: static x10aux::ref<x10::lang::Reference> _deserializer(x10aux::deserialization_buffer& buf);
    
    public: void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};
template <> class RemoteArray<void> : public x10::lang::Object
{
    public:
    static x10aux::RuntimeType rtt;
    static const x10aux::RuntimeType* getRTT() { return & rtt; }
    
};

} } 
#endif // X10_ARRAY_REMOTEARRAY_H

namespace x10 { namespace array { 
template<class TPMGL(T)> class RemoteArray;
} } 

#ifndef X10_ARRAY_REMOTEARRAY_H_NODEPS
#define X10_ARRAY_REMOTEARRAY_H_NODEPS
#include <x10/lang/Object.h>
#include <x10/array/Region.h>
#include <x10/lang/Int.h>
#include <x10/lang/GlobalRef.h>
#include <x10/array/Array.h>
#include <x10/util/RemoteIndexedMemoryChunk.h>
#include <x10/lang/Place.h>
#include <x10/compiler/Native.h>
#include <x10/lang/Runtime.h>
#include <x10/lang/Fun_0_0.h>
#include <x10/array/Point.h>
#include <x10/lang/Boolean.h>
#include <x10/compiler/CompilerFlags.h>
#include <x10/lang/FailedDynamicCheckException.h>
#include <x10/lang/Any.h>
#ifndef X10_ARRAY_REMOTEARRAY_H_GENERICS
#define X10_ARRAY_REMOTEARRAY_H_GENERICS
#endif // X10_ARRAY_REMOTEARRAY_H_GENERICS
#ifndef X10_ARRAY_REMOTEARRAY_H_IMPLEMENTATION
#define X10_ARRAY_REMOTEARRAY_H_IMPLEMENTATION
#include <x10/array/RemoteArray.h>

#ifndef X10_ARRAY_REMOTEARRAY__CLOSURE__1_CLOSURE
#define X10_ARRAY_REMOTEARRAY__CLOSURE__1_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/Fun_0_0.h>
template<class TPMGL(T)> class x10_array_RemoteArray__closure__1 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::Fun_0_0<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > >::template itable <x10_array_RemoteArray__closure__1<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > __apply() {
        
        //#line 91 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
        return x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > >::_make(x10::array::Array<TPMGL(T)>::_make(reg,
                                                                                                                          x10::util::IndexedMemoryChunk<TPMGL(T) >((raw)->raw(), (raw)->raw(), (raw)->length())));
        
    }
    
    // captured environment
    x10aux::ref<x10::array::Region> reg;
    x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > raw;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->reg);
        buf.write(this->raw);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_array_RemoteArray__closure__1<TPMGL(T) >* storage = x10aux::alloc<x10_array_RemoteArray__closure__1<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_array_RemoteArray__closure__1<TPMGL(T) > >(storage));
        x10aux::ref<x10::array::Region> that_reg = buf.read<x10aux::ref<x10::array::Region> >();
        x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > that_raw = buf.read<x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > >();
        x10aux::ref<x10_array_RemoteArray__closure__1<TPMGL(T) > > this_ = new (storage) x10_array_RemoteArray__closure__1<TPMGL(T) >(that_reg, that_raw);
        return this_;
    }
    
    x10_array_RemoteArray__closure__1(x10aux::ref<x10::array::Region> reg, x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > raw) : reg(reg), raw(raw) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::Fun_0_0<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > > >(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::Fun_0_0<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > > >(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10:91";
    }

};

template<class TPMGL(T)> typename x10::lang::Fun_0_0<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > >::template itable <x10_array_RemoteArray__closure__1<TPMGL(T) > >x10_array_RemoteArray__closure__1<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_array_RemoteArray__closure__1<TPMGL(T) >::__apply, &x10_array_RemoteArray__closure__1<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_array_RemoteArray__closure__1<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::Fun_0_0<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > > >, &x10_array_RemoteArray__closure__1<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_array_RemoteArray__closure__1<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_array_RemoteArray__closure__1<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_NOT_ASYNC);

#endif // X10_ARRAY_REMOTEARRAY__CLOSURE__1_CLOSURE

//#line 37 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.PropertyDecl_c

//#line 41 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.PropertyDecl_c

//#line 45 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.PropertyDecl_c

//#line 52 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10FieldDecl_c
/**
     * Caches a remote reference to the backing storage for the remote array
     * to enable DMA operations to be initiated remotely.  
     */

//#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10_int x10::array::RemoteArray<TPMGL(T)>::rank(
  ) {
    
    //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return x10aux::nullCheck(((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->
                               FMGL(region))->FMGL(rank);
    
}

//#line 62 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10::lang::Place x10::array::RemoteArray<TPMGL(T)>::home(
  ) {
    
    //#line 62 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return x10::lang::Place::place((((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->
                                      FMGL(array))->location);
    
}

//#line 68 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::array::RemoteArray<TPMGL(T)>::_constructor(
                           x10aux::ref<x10::array::Array<TPMGL(T)> > a) {
    
    //#line 68 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::lang::Object::_constructor();
    
    //#line 69 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.AssignPropertyCall_c
    FMGL(region) = a->FMGL(region);
    FMGL(size) = a->FMGL(size);
    FMGL(array) = x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > >::_make(a);
    
    //#line 70 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->
      FMGL(rawData) = x10::util::RemoteIndexedMemoryChunk<TPMGL(T) >((a->x10::array::Array<TPMGL(T)>::raw())->raw(), (a->x10::array::Array<TPMGL(T)>::raw())->length());
}
template<class TPMGL(T)> x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > x10::array::RemoteArray<TPMGL(T)>::_make(
                           x10aux::ref<x10::array::Array<TPMGL(T)> > a)
{
    x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::array::RemoteArray<TPMGL(T)> >(), 0, sizeof(x10::array::RemoteArray<TPMGL(T)>))) x10::array::RemoteArray<TPMGL(T)>();
    this_->_constructor(a);
    return this_;
}



//#line 85 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::array::RemoteArray<TPMGL(T)>::_constructor(
                           x10aux::ref<x10::array::Region> reg,
                           x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > raw) {
    
    //#line 85 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::lang::Object::_constructor();
    
    //#line 86 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10LocalDecl_c
    x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > arr;
    
    //#line 87 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10If_c
    if ((raw)->home->x10::lang::Place::isCUDA()) {} else {
        
        //#line 91 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": Eval of x10.ast.X10LocalAssign_c
        arr = x10::lang::Runtime::template evalAt<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > >(
                (raw)->home, x10aux::ref<x10::lang::Fun_0_0<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > > >(x10aux::ref<x10_array_RemoteArray__closure__1<TPMGL(T) > >(new (x10aux::alloc<x10::lang::Fun_0_0<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > > >(sizeof(x10_array_RemoteArray__closure__1<TPMGL(T)>)))x10_array_RemoteArray__closure__1<TPMGL(T)>(reg, raw))));
    }
    
    //#line 93 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.AssignPropertyCall_c
    FMGL(region) = reg;
    FMGL(size) = reg->size();
    FMGL(array) = arr;
    
    //#line 94 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->
      FMGL(rawData) = raw;
}
template<class TPMGL(T)> x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > x10::array::RemoteArray<TPMGL(T)>::_make(
                           x10aux::ref<x10::array::Region> reg,
                           x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > raw)
{
    x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::array::RemoteArray<TPMGL(T)> >(), 0, sizeof(x10::array::RemoteArray<TPMGL(T)>))) x10::array::RemoteArray<TPMGL(T)>();
    this_->_constructor(reg, raw);
    return this_;
}



//#line 108 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::array::RemoteArray<TPMGL(T)>::__apply(
  x10_int i) {
    
    //#line 109 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return x10aux::nullCheck(((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->x10::array::RemoteArray<TPMGL(T)>::__apply())->x10::array::Array<TPMGL(T)>::__apply(
             i);
    
}

//#line 121 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::array::RemoteArray<TPMGL(T)>::__apply(
  x10aux::ref<x10::array::Point> p) {
    
    //#line 121 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return x10aux::nullCheck(((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->x10::array::RemoteArray<TPMGL(T)>::__apply())->x10::array::Array<TPMGL(T)>::__apply(
             p);
    
}

//#line 136 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::array::RemoteArray<TPMGL(T)>::__set(
  x10_int i, TPMGL(T) v) {
    
    //#line 137 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return x10aux::nullCheck(((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->x10::array::RemoteArray<TPMGL(T)>::__apply())->x10::array::Array<TPMGL(T)>::__set(
             i, v);
    
}

//#line 151 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::array::RemoteArray<TPMGL(T)>::__set(
  x10aux::ref<x10::array::Point> p, TPMGL(T) v) {
    
    //#line 152 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return x10aux::nullCheck(((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->x10::array::RemoteArray<TPMGL(T)>::__apply())->x10::array::Array<TPMGL(T)>::__set(
             p, v);
    
}

//#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::array::Array<TPMGL(T)> >
  x10::array::RemoteArray<TPMGL(T)>::__apply() {
    
    //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return (__extension__ ({
        
        //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10LocalDecl_c
        x10aux::ref<x10::array::Array<TPMGL(T)> > __desugarer__var__46__40790 =
          (((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->
             FMGL(array))->__apply();
        
        //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10LocalDecl_c
        x10aux::ref<x10::array::Array<TPMGL(T)> > ret40791;
        
        //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10If_c
        if (!((x10aux::struct_equals(x10aux::nullCheck(__desugarer__var__46__40790)->
                                       FMGL(rank), x10aux::nullCheck(x10aux::nullCheck(((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this))->
                                                                       FMGL(region))->
                                                     FMGL(rank)))))
        {
            
            //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10If_c
            if (true) {
                
                //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": polyglot.ast.Throw_c
                x10aux::throwException(x10aux::nullCheck(x10::lang::FailedDynamicCheckException::_make(x10aux::string_utils::lit("x10.array.Array[T]{self.rank==this(:x10.array.RemoteArray).region.rank}"))));
            }
            
        }
        
        //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": Eval of x10.ast.X10LocalAssign_c
        ret40791 = __desugarer__var__46__40790;
        ret40791;
    }))
    ;
    
}

//#line 161 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10_boolean x10::array::RemoteArray<TPMGL(T)>::equals(
  x10aux::ref<x10::lang::Any> other) {
    
    //#line 162 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10If_c
    if (!(x10aux::instanceof<x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > >(other)))
    {
        
        //#line 162 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
        return false;
        
    }
    
    //#line 163 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > oRA =
      x10aux::class_cast<x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > >(other);
    
    //#line 164 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return (x10aux::nullCheck(oRA)->FMGL(array))->equals(x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Any> >(((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->
                                                                                                                      FMGL(array)));
    
}

//#line 167 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10_int x10::array::RemoteArray<TPMGL(T)>::hashCode(
  ) {
    
    //#line 167 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return (((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this)->
              FMGL(array))->hashCode();
    
}

//#line 33 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >
  x10::array::RemoteArray<TPMGL(T)>::x10__array__RemoteArray____x10__array__RemoteArray__this(
  ) {
    
    //#line 33 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/array/RemoteArray.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::array::RemoteArray<TPMGL(T)> >)this);
    
}
template<class TPMGL(T)> const x10aux::serialization_id_t x10::array::RemoteArray<TPMGL(T)>::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10::array::RemoteArray<TPMGL(T)>::_deserializer, x10aux::CLOSURE_KIND_NOT_ASYNC);

template<class TPMGL(T)> void x10::array::RemoteArray<TPMGL(T)>::_serialize_body(x10aux::serialization_buffer& buf) {
    x10::lang::Object::_serialize_body(buf);
    buf.write(this->FMGL(rawData));
    buf.write(this->FMGL(region));
    buf.write(this->FMGL(size));
    buf.write(this->FMGL(array));
    
}

template<class TPMGL(T)> x10aux::ref<x10::lang::Reference> x10::array::RemoteArray<TPMGL(T)>::_deserializer(x10aux::deserialization_buffer& buf) {
    x10aux::ref<x10::array::RemoteArray<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::array::RemoteArray<TPMGL(T)> >(), 0, sizeof(x10::array::RemoteArray<TPMGL(T)>))) x10::array::RemoteArray<TPMGL(T)>();
    buf.record_reference(this_);
    this_->_deserialize_body(buf);
    return this_;
}

template<class TPMGL(T)> void x10::array::RemoteArray<TPMGL(T)>::_deserialize_body(x10aux::deserialization_buffer& buf) {
    x10::lang::Object::_deserialize_body(buf);
    FMGL(rawData) = buf.read<x10::util::RemoteIndexedMemoryChunk<TPMGL(T) > >();
    FMGL(region) = buf.read<x10aux::ref<x10::array::Region> >();
    FMGL(size) = buf.read<x10_int>();
    FMGL(array) = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::array::Array<TPMGL(T)> > > >();
}

template<class TPMGL(T)> x10aux::RuntimeType x10::array::RemoteArray<TPMGL(T)>::rtt;
template<class TPMGL(T)> void x10::array::RemoteArray<TPMGL(T)>::_initRTT() {
    const x10aux::RuntimeType *canonical = x10aux::getRTT<x10::array::RemoteArray<void> >();
    if (rtt.initStageOne(canonical)) return;
    const x10aux::RuntimeType* parents[1] = { x10aux::getRTT<x10::lang::Object>()};
    const x10aux::RuntimeType* params[1] = { x10aux::getRTT<TPMGL(T)>()};
    x10aux::RuntimeType::Variance variances[1] = { x10aux::RuntimeType::invariant};
    const char *baseName = "x10.array.RemoteArray";
    rtt.initStageTwo(baseName, x10aux::RuntimeType::class_kind, 1, parents, 1, params, variances);
}
#endif // X10_ARRAY_REMOTEARRAY_H_IMPLEMENTATION
#endif // __X10_ARRAY_REMOTEARRAY_H_NODEPS
