#ifndef __X10_LANG_PLACE_H
#define __X10_LANG_PLACE_H

#include <x10rt.h>


#define X10_LANG_ANY_H_NODEPS
#include <x10/lang/Any.h>
#undef X10_LANG_ANY_H_NODEPS
#define X10_LANG_ANY_H_NODEPS
#include <x10/lang/Any.h>
#undef X10_LANG_ANY_H_NODEPS
#define X10_LANG_INT_H_NODEPS
#include <x10/lang/Int.h>
#undef X10_LANG_INT_H_NODEPS
namespace x10 { namespace lang { 
class Int;
} } 
namespace x10 { namespace compiler { 
class Native;
} } 
namespace x10 { namespace lang { 
class Boolean;
} } 
namespace x10 { namespace lang { 
class BadPlaceException;
} } 
namespace x10 { namespace array { 
template<class TPMGL(T)> class Array;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(Z1), class TPMGL(U)> class Fun_0_1;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class Sequence;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class Iterable;
} } 
namespace x10 { namespace compiler { 
class CompilerFlags;
} } 
namespace x10 { namespace lang { 
class IllegalArgumentException;
} } 
namespace x10 { namespace lang { 
class String;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class GlobalRef;
} } 
namespace x10 { namespace lang { 
class Object;
} } 
namespace x10 { namespace compiler { 
class NonEscaping;
} } 
namespace x10 { namespace lang { 

class Any; class String; // Forward reference are required in Place to prevent circularity
class Place   {
    public:
    RTT_H_DECLS_STRUCT
    
    x10::lang::Place* operator->() { return this; }
    
    x10_int FMGL(id);
    
    static x10aux::itable_entry _itables[2];
    
    x10aux::itable_entry* _getITables() { return _itables; }
    
    static x10::lang::Any::itable<x10::lang::Place > _itable_0;
    
    static x10aux::itable_entry _iboxitables[2];
    
    x10aux::itable_entry* _getIBoxITables() { return _iboxitables; }
    
    static x10::lang::Place _alloc(){x10::lang::Place t; return t; }
    
    x10_int id() {
        
        //#line 27 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (*this)->FMGL(id);
        
    }
    static x10_int FMGL(ALL_PLACES);
    
    static x10_int FMGL(ALL_PLACES__get)();
    static x10_int FMGL(MAX_PLACES);
    
    static x10_int FMGL(MAX_PLACES__get)();
    static x10_int FMGL(NUM_ACCELS);
    
    static void FMGL(NUM_ACCELS__do_init)();
    static void FMGL(NUM_ACCELS__init)();
    static volatile x10aux::status FMGL(NUM_ACCELS__status);
    static x10_int FMGL(NUM_ACCELS__get)();
    static x10aux::ref<x10::lang::Reference> FMGL(NUM_ACCELS__deserialize)(x10aux::deserialization_buffer &buf);
    static const x10aux::serialization_id_t FMGL(NUM_ACCELS__id);
    
    static x10_int numChildren(x10_int id) {
        
        //#line 50 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return ((x10_int)0);
        
    }
    static x10_boolean isHost(x10_int id) {
        
        //#line 56 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return true;
        
    }
    static x10_boolean isSPE(x10_int id) {
        
        //#line 62 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return false;
        
    }
    static x10_boolean isCUDA(x10_int id) {
        
        //#line 68 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return false;
        
    }
    static x10_int parent(x10_int id) {
        
        //#line 76 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return id;
        
    }
    static x10_int child(x10_int p, x10_int i);
    static x10_int childIndex(x10_int id);
    static x10aux::ref<x10::array::Array<x10aux::ref<x10::array::Array<x10::lang::Place> > > >
      FMGL(childrenArray);
    
    static void FMGL(childrenArray__do_init)();
    static void FMGL(childrenArray__init)();
    static volatile x10aux::status FMGL(childrenArray__status);
    static x10aux::ref<x10::array::Array<x10aux::ref<x10::array::Array<x10::lang::Place> > > >
      FMGL(childrenArray__get)();
    static x10aux::ref<x10::lang::Reference> FMGL(childrenArray__deserialize)(x10aux::deserialization_buffer &buf);
    static const x10aux::serialization_id_t FMGL(childrenArray__id);
    
    static x10aux::ref<x10::array::Array<x10::lang::Place> >
      FMGL(places);
    
    static void FMGL(places__do_init)();
    static void FMGL(places__init)();
    static volatile x10aux::status FMGL(places__status);
    static x10aux::ref<x10::array::Array<x10::lang::Place> >
      FMGL(places__get)();
    static x10aux::ref<x10::lang::Reference> FMGL(places__deserialize)(x10aux::deserialization_buffer &buf);
    static const x10aux::serialization_id_t FMGL(places__id);
    
    static x10aux::ref<x10::lang::Sequence<x10::lang::Place> >
      places();
    static x10aux::ref<x10::lang::Iterable<x10aux::ref<x10::array::Array<x10::lang::Place> > > >
      FMGL(children);
    
    static void FMGL(children__do_init)();
    static void FMGL(children__init)();
    static volatile x10aux::status FMGL(children__status);
    static x10aux::ref<x10::lang::Iterable<x10aux::ref<x10::array::Array<x10::lang::Place> > > >
      FMGL(children__get)();
    static x10aux::ref<x10::lang::Reference> FMGL(children__deserialize)(x10aux::deserialization_buffer &buf);
    static const x10aux::serialization_id_t FMGL(children__id);
    
    static x10::lang::Place FMGL(FIRST_PLACE);
    
    static void FMGL(FIRST_PLACE__do_init)();
    static void FMGL(FIRST_PLACE__init)();
    static volatile x10aux::status FMGL(FIRST_PLACE__status);
    static x10::lang::Place FMGL(FIRST_PLACE__get)();
    static x10aux::ref<x10::lang::Reference> FMGL(FIRST_PLACE__deserialize)(x10aux::deserialization_buffer &buf);
    static const x10aux::serialization_id_t FMGL(FIRST_PLACE__id);
    
    void _constructor(x10_int id);
    
    static x10::lang::Place _make(x10_int id);
    
    static x10::lang::Place place(x10_int id) {
        
        //#line 127 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10::lang::Place::_make(id);
        
    }
    x10::lang::Place next() {
        
        //#line 132 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (*this)->x10::lang::Place::next(((x10_int)1));
        
    }
    x10::lang::Place prev() {
        
        //#line 137 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (*this)->x10::lang::Place::next(((x10_int)-1));
        
    }
    x10::lang::Place prev(x10_int i) {
        
        //#line 142 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (*this)->x10::lang::Place::next(((x10_int) -(i)));
        
    }
    x10::lang::Place next(x10_int i) {
        
        //#line 149 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10If_c
        if (x10aux::is_host((*this)->FMGL(id))) {
            
            //#line 150 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10LocalDecl_c
            x10_int k = ((x10_int) ((((x10_int) ((((x10_int) (((*this)->
                                                                 FMGL(id)) + (((x10_int) ((i) % x10aux::zeroCheck(x10aux::num_hosts))))))) + (x10aux::num_hosts)))) % x10aux::zeroCheck(x10aux::num_hosts)));
            
            //#line 151 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
            return x10::lang::Place::place(k);
            
        }
        
        //#line 154 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (*this);
        
    }
    static x10_int numPlaces() {
        
        //#line 160 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10aux::num_places;
        
    }
    x10_boolean isFirst() {
        
        //#line 165 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (x10aux::struct_equals((*this)->FMGL(id), ((x10_int)0)));
        
    }
    x10_boolean isLast() {
        
        //#line 166 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (x10aux::struct_equals((*this)->FMGL(id), ((x10_int) ((x10aux::num_hosts) - (((x10_int)1))))));
        
    }
    x10_boolean isHost() {
        
        //#line 169 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10aux::is_host((*this)->FMGL(id));
        
    }
    x10_boolean isSPE() {
        
        //#line 172 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10aux::is_spe((*this)->FMGL(id));
        
    }
    x10_boolean isCUDA() {
        
        //#line 175 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10aux::is_cuda((*this)->FMGL(id));
        
    }
    x10_int numChildren() {
        
        //#line 179 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10aux::num_children((*this)->FMGL(id));
        
    }
    x10::lang::Place child(x10_int i) {
        
        //#line 183 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10::lang::Place::_make(x10aux::child((*this)->
                                                       FMGL(id),i));
        
    }
    x10aux::ref<x10::array::Array<x10::lang::Place> > children(
      );
    x10::lang::Place parent() {
        
        //#line 189 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return x10::lang::Place::_make(x10aux::parent((*this)->
                                                        FMGL(id)));
        
    }
    x10_int childIndex();
    x10aux::ref<x10::lang::String> toString();
    x10_boolean equals(x10::lang::Place p) {
        
        //#line 202 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (x10aux::struct_equals(p->FMGL(id), (*this)->
                                                     FMGL(id)));
        
    }
    x10_boolean equals(x10aux::ref<x10::lang::Any> p);
    x10_int hashCode() {
        
        //#line 204 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (*this)->FMGL(id);
        
    }
    x10aux::ref<x10::lang::String> typeName();
    x10_boolean _struct_equals(x10aux::ref<x10::lang::Any> other);
    x10_boolean _struct_equals(x10::lang::Place other) {
        
        //#line 26 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (x10aux::struct_equals((*this)->FMGL(id), other->
                                                           FMGL(id)));
        
    }
    x10::lang::Place x10__lang__Place____x10__lang__Place__this(
      ) {
        
        //#line 26 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Place.x10": x10.ast.X10Return_c
        return (*this);
        
    }
    
    static void _serialize(x10::lang::Place this_, x10aux::serialization_buffer& buf);
    
    static x10::lang::Place _deserialize(x10aux::deserialization_buffer& buf) {
        x10::lang::Place this_;
        this_->_deserialize_body(buf);
        return this_;
    }
    
    void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};

} } 
#endif // X10_LANG_PLACE_H

namespace x10 { namespace lang { 
class Place;
} } 

#ifndef X10_LANG_PLACE_H_NODEPS
#define X10_LANG_PLACE_H_NODEPS
#include <x10/lang/Any.h>
#include <x10/lang/Int.h>
#include <x10/compiler/Native.h>
#include <x10/lang/Boolean.h>
#include <x10/lang/BadPlaceException.h>
#include <x10/array/Array.h>
#include <x10/lang/Fun_0_1.h>
#include <x10/lang/Sequence.h>
#include <x10/lang/Iterable.h>
#include <x10/compiler/CompilerFlags.h>
#include <x10/lang/IllegalArgumentException.h>
#include <x10/lang/String.h>
#include <x10/lang/GlobalRef.h>
#include <x10/lang/Object.h>
#include <x10/compiler/NonEscaping.h>
#ifndef X10_LANG_PLACE_H_GENERICS
#define X10_LANG_PLACE_H_GENERICS
inline x10_int x10::lang::Place::FMGL(ALL_PLACES__get)() {
    return x10::lang::Place::FMGL(ALL_PLACES);
}

inline x10_int x10::lang::Place::FMGL(MAX_PLACES__get)() {
    return x10::lang::Place::FMGL(MAX_PLACES);
}

inline x10_int x10::lang::Place::FMGL(NUM_ACCELS__get)() {
    if (FMGL(NUM_ACCELS__status) != x10aux::INITIALIZED) {
        FMGL(NUM_ACCELS__init)();
    }
    return x10::lang::Place::FMGL(NUM_ACCELS);
}

inline x10aux::ref<x10::array::Array<x10aux::ref<x10::array::Array<x10::lang::Place> > > >
  x10::lang::Place::FMGL(childrenArray__get)() {
    if (FMGL(childrenArray__status) != x10aux::INITIALIZED) {
        FMGL(childrenArray__init)();
    }
    return x10::lang::Place::FMGL(childrenArray);
}

inline x10aux::ref<x10::array::Array<x10::lang::Place> > x10::lang::Place::FMGL(places__get)() {
    if (FMGL(places__status) != x10aux::INITIALIZED) {
        FMGL(places__init)();
    }
    return x10::lang::Place::FMGL(places);
}

inline x10aux::ref<x10::lang::Iterable<x10aux::ref<x10::array::Array<x10::lang::Place> > > >
  x10::lang::Place::FMGL(children__get)() {
    if (FMGL(children__status) != x10aux::INITIALIZED) {
        FMGL(children__init)();
    }
    return x10::lang::Place::FMGL(children);
}

inline x10::lang::Place x10::lang::Place::FMGL(FIRST_PLACE__get)() {
    if (FMGL(FIRST_PLACE__status) != x10aux::INITIALIZED) {
        FMGL(FIRST_PLACE__init)();
    }
    return x10::lang::Place::FMGL(FIRST_PLACE);
}

#endif // X10_LANG_PLACE_H_GENERICS
#endif // __X10_LANG_PLACE_H_NODEPS
