From: <dgr...@us...> - 2010-01-27 17:01:44
|
Revision: 12750 http://x10.svn.sourceforge.net/x10/?rev=12750&view=rev Author: dgrove-oss Date: 2010-01-27 17:01:38 +0000 (Wed, 27 Jan 2010) Log Message: ----------- Intorduce an explicit C++ level class to stand for the NullType instead of using x10::lang::Reference. This enables us to get an RTT object for the NullType while still maintaining the useful implementation invariant that there is no RTT for x10::lang::Reference because it does not exist at the X10 level. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-cpp/x10/lang/Reference.cc trunk/x10.runtime/src-cpp/x10/lang/Reference.h trunk/x10.runtime/src-cpp/x10aux/ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-01-27 17:01:38 UTC (rev 12750) @@ -301,7 +301,7 @@ name = ((ParameterType)type).name().toString(); return mangled_parameter_type_name(name); // parameter types shouldn't be refs } else if (type.isNull()) { - return "x10aux::NullType"; // typedef to something sensible + return "x10aux::ref<x10::lang::NullType>"; // typedef to something sensible } else assert false : type; // unhandled type. assert (name != null); Modified: trunk/x10.runtime/src-cpp/x10/lang/Reference.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.cc 2010-01-27 17:01:38 UTC (rev 12750) @@ -40,4 +40,10 @@ } } +x10aux::RuntimeType x10::lang::NullType::rtt; + +void x10::lang::NullType::_initRTT() { + rtt.init(&rtt, "null", 0, NULL, 0, NULL, NULL); +} + // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10/lang/Reference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Reference.h 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.runtime/src-cpp/x10/lang/Reference.h 2010-01-27 17:01:38 UTC (rev 12750) @@ -116,6 +116,20 @@ " (expecting id " << id << ") from buf: "<<&buf); return x10aux::DeserializationDispatcher::create<T>(buf); } + + /** + * This is a class that exists only at the C++ implementation level, + * not at the X10 language level. It's only real purpose is to + * provide a C++ level type for x10aux::NullType and therefore permit + * a unique RTT object to be associated with the X10 value null. + * + * This is an abstract class because no instance of it will ever be + * created (we use NULL as the value for X10's null). + */ + class NullType : public Reference { + public: + RTT_H_DECLS_CLASS; + }; } } Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-01-27 16:36:04 UTC (rev 12749) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-01-27 17:01:38 UTC (rev 12750) @@ -9,7 +9,7 @@ #include <x10aux/RTT.h> #include <x10aux/network.h> -namespace x10 { namespace lang { class Reference; } } +namespace x10 { namespace lang { class NullType; } } namespace x10aux { @@ -181,9 +181,8 @@ return obj; } - // will be initialised to null - typedef ref<x10::lang::Reference> NullType; - static NullType null; + // will be initialised to NULL + static ref<x10::lang::NullType> null; template<class F, class T> bool operator!=(F f, T t) { return !(f == t); } // comparison of a primitive with a ref This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |