Gyoji Compiler
|
All aspects of the Gyoji language belong in this namespace. More...
Namespaces | |
namespace | analysis |
Analysis pass performs checks to ensure semantic consistency. | |
namespace | context |
The context namespace deals with objects that should last the entire scope of compilation. | |
namespace | frontend |
This is the front-end to the Gyoji parser. | |
namespace | mir |
Middle intermediate representation (MIR) of a translation unit. | |
Typedefs | |
template<class T > | |
using | owned = std::unique_ptr< T > |
All aspects of the Gyoji language belong in this namespace.
The Gyoji namespace contains the main components of the compiler.
using Gyoji::owned = typedef std::unique_ptr<T> |
This is a convenience definition for a unique pointer. Pointers defined with this type are owned by the class in which they are declared, so their life-span should be at least as long as the structure they contain.
The owning class may safely return references to the owned type as long as the caller agrees not to let the reference live longer than the object that gave it up.
For example, this is the typical pattern of usage for an owned pointer.
class Foo { }; class Bar { public: const Foo & get() const { return *foo; }; private: Gyoji::owned<Foo> foo; };
Given this setup, this is an acceptable use:
void some_function() { Bar b; const Foo & foo = b.get(); }
However, the following is an unacceptable use because the reference lives beyond the scope of the owning pointer. Note that the J language is designed so that this usage will be disallowed by the compiler, but since the bootstrap is written in C++, this is still possible even if it is unsafe.
const Foo & some_function() { Bar b; return b.get(); }