Parser - Clean-up in AST node definitions

This commit is contained in:
Emmanuel BENOîT 2017-11-10 23:09:36 +01:00
parent 7abf50ae61
commit d944ff80f3
3 changed files with 362 additions and 314 deletions

View file

@ -258,6 +258,46 @@ A_Node* opast::ASTVisitorBrowser(
}
/*= E_DataType ===============================================================*/
T_StringBuilder& opast::operator<<(
T_StringBuilder& sb ,
const E_DataType dt )
{
switch ( dt ) {
case E_DataType::UNKNOWN:
sb << "unknown";
return sb;
case E_DataType::BUILTIN:
sb << "built-in variable";
return sb;
case E_DataType::VARIABLE:
sb << "variable";
return sb;
case E_DataType::FRAMEBUFFER:
sb << "framebuffer";
return sb;
case E_DataType::INPUT:
sb << "input";
return sb;
case E_DataType::PIPELINE:
sb << "pipeline";
return sb;
case E_DataType::PROGRAM:
sb << "program";
return sb;
case E_DataType::SAMPLER:
sb << "sampler";
return sb;
case E_DataType::TEXTURE:
sb << "texture";
return sb;
}
sb << "*unknown data type*";
return sb;
}
/*= A_FuncNode ===============================================================*/
A_FuncNode::A_FuncNode(

628
opast.hh
View file

@ -7,6 +7,9 @@ namespace opast {
using namespace ebcl;
/*= BASE CLASS FOR AST NODES ===================================================*/
class T_RootNode;
class A_Node
@ -91,7 +94,22 @@ extern A_Node* ASTVisitorBrowser(
A_Node& node ,
const uint32_t child ) noexcept;
/*============================================================================*/
// Data types
enum class E_DataType {
UNKNOWN ,
BUILTIN ,
VARIABLE ,
FRAMEBUFFER ,
INPUT ,
PIPELINE ,
PROGRAM ,
SAMPLER ,
TEXTURE ,
};
M_LSHIFT_OP( T_StringBuilder , E_DataType );
/*= BASE STRUCTURES FOR INSTRUCTIONS =========================================*/
// Some instructions are restricted to either the initialisation code or the
// frame code.
@ -124,7 +142,6 @@ class A_InstructionNode : public A_Node
{ return restriction_; }
};
// Nodes that store lists of instructions
class T_InstrListNode : public A_Node
{
@ -157,7 +174,21 @@ template<
return (IType&) *instructions_.last( );
}
/*----------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
// Base class for expressions
class A_ExpressionNode : public A_Node
{
protected:
A_ExpressionNode( E_Type type ,
A_Node& parent ) noexcept
: A_Node( type , &parent )
{ }
};
using P_ExpressionNode = T_OwnPtr< A_ExpressionNode >;
/*= FUNCTIONS AND ROOT NODES =================================================*/
// Function-like nodes
class A_FuncNode : public A_Node
@ -188,6 +219,8 @@ class A_FuncNode : public A_Node
};
using P_InstrListNode = T_OwnPtr< T_InstrListNode >;
/*----------------------------------------------------------------------------*/
// Root node, keeps track of the whole tree and related data (function table,
// assets...)
class T_RootNode : public A_Node
@ -278,20 +311,8 @@ class T_FuncNode : public A_FuncNode
{ return argNames_.size( ); }
};
/*----------------------------------------------------------------------------*/
// Base class for expressions
class A_ExpressionNode : public A_Node
{
protected:
A_ExpressionNode( E_Type type ,
A_Node& parent ) noexcept
: A_Node( type , &parent )
{ }
};
using P_ExpressionNode = T_OwnPtr< A_ExpressionNode >;
/*============================================================================*/
/*= GENERAL / FLOW CONTROL INSTRUCTIONS ========================================*/
// Function call
class T_CallInstrNode : public A_InstructionNode
@ -327,28 +348,6 @@ class T_CallInstrNode : public A_InstructionNode
{ return *arguments_[ index ]; }
};
// Clear instruction
class T_ClearInstrNode : public A_InstructionNode
{
private:
T_StaticArray< P_ExpressionNode , 4 > components_;
public:
T_ClearInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_CLEAR , parent ,
E_InstrRestriction::INIT )
{ }
void addComponent( P_ExpressionNode expr ) noexcept
{ if ( expr ) { components_.add( std::move( expr ) ); } }
uint32_t components( ) const noexcept
{ return components_.size( ); }
A_ExpressionNode& component( const uint32_t index ) const noexcept
{ return *components_[ index ]; }
};
// Conditional instruction
class T_CondInstrNode : public A_InstructionNode
{
@ -395,8 +394,98 @@ class T_CondInstrNode : public A_InstructionNode
{ return *defaultCase_; }
};
// Local variable declarations
class T_LocalsInstrNode : public A_InstructionNode
{
private:
T_AutoArray< T_String , 8 > vars_;
T_AutoArray< T_SRDLocation , 8 > varLocs_;
public:
T_LocalsInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_LOCALS , parent )
{ }
bool addVariable( T_SRDToken const& token ) noexcept;
uint32_t variables( ) const noexcept
{ return vars_.size( ); }
T_String const& varName(
const uint32_t index ) const noexcept
{ return vars_[ index ]; }
T_SRDLocation const& varLocation(
const uint32_t index ) const noexcept
{ return varLocs_[ index ]; }
};
// Setting a global variable
class T_SetInstrNode : public A_InstructionNode
{
private:
T_String id_;
T_SRDLocation idLocation_;
P_ExpressionNode expression_;
public:
T_SetInstrNode( T_InstrListNode& parent ,
T_SRDToken const& idToken ) noexcept
: A_InstructionNode( OP_SET , parent ) ,
id_( idToken.stringValue( ) ) ,
idLocation_( idToken.location( ) )
{ }
T_String const& id( ) const noexcept
{ return id_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return idLocation_; }
void setExpression( P_ExpressionNode expression ) noexcept
{ expression_ = std::move( expression ); }
bool hasExpression( ) const noexcept
{ return bool( expression_ ); }
A_ExpressionNode& expression( ) const noexcept
{ return *expression_; }
};
/*= RESOURCE DEFINITION INSTRUCTIONS =========================================*/
// Base class
class A_ResourceDefInstrNode : public A_InstructionNode
{
private:
T_String id_;
T_SRDLocation idLocation_;
E_DataType dataType_;
protected:
A_ResourceDefInstrNode(
const E_Type type ,
T_InstrListNode& parent ,
T_SRDToken const& identifier ,
const E_DataType dataType ) noexcept
: A_InstructionNode( type , parent , E_InstrRestriction::FRAME ) ,
id_( identifier.stringValue( ) ) ,
idLocation_( identifier.location( ) ) ,
dataType_( dataType )
{ }
public:
T_String const& id( ) const noexcept
{ return id_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return idLocation_; }
E_DataType dataType( ) const noexcept
{ return dataType_; }
};
/*------------------------------------------------------------------------------*/
// Framebuffer definition instruction
class T_FramebufferInstrNode : public A_InstructionNode
class T_FramebufferInstrNode : public A_ResourceDefInstrNode
{
private:
struct T_Attachment_
@ -406,9 +495,6 @@ class T_FramebufferInstrNode : public A_InstructionNode
T_SRDLocation location;
};
T_String idFramebuffer_;
T_SRDLocation locFramebuffer_;
T_AutoArray< T_Attachment_ , 8 > colorAttachments_;
T_Optional< T_Attachment_ > depthAttachment_;
@ -417,20 +503,12 @@ class T_FramebufferInstrNode : public A_InstructionNode
public:
T_FramebufferInstrNode( T_InstrListNode& parent ,
T_SRDToken const& identifier ) noexcept
: A_InstructionNode( OP_FRAMEBUFFER , parent , E_InstrRestriction::FRAME ) ,
idFramebuffer_( identifier.stringValue( ) ) ,
locFramebuffer_( identifier.location( ) )
: A_ResourceDefInstrNode( OP_FRAMEBUFFER , parent ,
identifier , E_DataType::FRAMEBUFFER )
{ }
// ---------------------------------------------------------------------
T_String const& id( ) const noexcept
{ return idFramebuffer_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return locFramebuffer_; }
// ---------------------------------------------------------------------
bool addColorAttachment( T_SRDToken const& id ,
P_ExpressionNode lod = {} ) noexcept;
@ -465,85 +543,205 @@ class T_FramebufferInstrNode : public A_InstructionNode
{ return depthAttachment_->location; }
};
// Fullscreen quad instruction
class T_FullscreenInstrNode : public A_InstructionNode
{
public:
T_FullscreenInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_FULLSCREEN , parent , E_InstrRestriction::INIT )
{ }
};
// Input declaration
class T_InputInstrNode : public A_InstructionNode
class T_InputInstrNode : public A_ResourceDefInstrNode
{
private:
T_String name_;
T_SRDLocation nameLocation_;
float defValue_;
T_SRDLocation dvLocation_;
public:
T_InputInstrNode( T_InstrListNode& parent ,
T_SRDToken const& tName ) noexcept
: A_InstructionNode( OP_INPUT , parent , E_InstrRestriction::FRAME ) ,
name_( tName.stringValue( ) ) , nameLocation_( tName.location( ) )
: A_ResourceDefInstrNode( OP_INPUT , parent ,
tName , E_DataType::INPUT )
{}
T_InputInstrNode( T_InstrListNode& parent ,
T_SRDToken const& tName ,
T_SRDToken const& tDefault ) noexcept
: A_InstructionNode( OP_INPUT , parent , E_InstrRestriction::FRAME ) ,
name_( tName.stringValue( ) ) , nameLocation_( tName.location( ) ) ,
: A_ResourceDefInstrNode( OP_INPUT , parent ,
tName , E_DataType::INPUT ) ,
defValue_( tDefault.floatValue( ) ) , dvLocation_( tDefault.location( ) )
{}
T_String const& name( ) const noexcept
{ return name_; }
T_SRDLocation const& nameLocation( ) const noexcept
{ return nameLocation_; }
float defValue( ) const noexcept
{ return defValue_; }
T_SRDLocation const& defValueLocation( ) const noexcept
{ return dvLocation_; }
};
// Local variable declarations
class T_LocalsInstrNode : public A_InstructionNode
// Pipeline declaration instruction
class T_PipelineInstrNode : public A_ResourceDefInstrNode
{
private:
T_AutoArray< T_String , 8 > vars_;
T_AutoArray< T_SRDLocation , 8 > varLocs_;
T_StaticArray< T_String , 6 > pids_;
T_StaticArray< T_SRDLocation , 6 > pidLocations_;
public:
T_LocalsInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_LOCALS , parent )
T_PipelineInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& idToken ) noexcept
: A_ResourceDefInstrNode( OP_PIPELINE , parent ,
idToken , E_DataType::PIPELINE )
{ }
bool addVariable( T_SRDToken const& token ) noexcept;
// Add a program identifier. The token is assumed to be a valid word,
// and the list of programs is assumed not to be full. If the identifer
// is already in the pipeline's list, the location of the first
// occurrence will be returned.
T_Optional< T_SRDLocation > addProgram(
T_SRDToken const& pidToken ) noexcept;
uint32_t variables( ) const noexcept
{ return vars_.size( ); }
uint32_t size( ) const noexcept
{ return pids_.size( ); }
T_String const& varName(
const uint32_t index ) const noexcept
{ return vars_[ index ]; }
T_SRDLocation const& varLocation(
const uint32_t index ) const noexcept
{ return varLocs_[ index ]; }
T_String const& program( const uint32_t index ) const noexcept
{ return pids_[ index ]; }
T_SRDLocation const& pLocation( const uint32_t index ) const noexcept
{ return pidLocations_[ index ]; }
};
// Main output selection
class T_MainOutputInstrNode : public A_InstructionNode
// Program loader instruction
class T_ProgramInstrNode : public A_ResourceDefInstrNode
{
private:
T_String path_;
T_SRDLocation pathLocation_;
public:
T_MainOutputInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_MAINOUT , parent , E_InstrRestriction::INIT )
T_ProgramInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& idToken ,
T_SRDToken const& pathToken ) noexcept
: A_ResourceDefInstrNode( OP_PROGRAM , parent ,
idToken , E_DataType::PROGRAM ) ,
path_( pathToken.stringValue( ) ) ,
pathLocation_( pathToken.location( ) )
{ }
T_String const& path( ) const noexcept
{ return path_; }
T_SRDLocation const& pathLocation( ) const noexcept
{ return pathLocation_; }
};
// Sampler definition
class T_SamplerInstrNode : public A_ResourceDefInstrNode
{
private:
struct T_Sampling_
{
T_SRDLocation location;
E_TexSampling mode;
};
struct T_Mipmaps_
{
T_SRDLocation location;
T_Optional< E_TexSampling > mode;
};
struct T_Wrapping_
{
T_SRDLocation location;
E_TexWrap mode;
};
struct T_LOD_
{
T_SRDLocation location;
P_ExpressionNode min;
P_ExpressionNode max;
};
T_Optional< T_Sampling_ > sampling_;
T_Optional< T_Mipmaps_ > mipmaps_;
T_Optional< T_Wrapping_ > wrapping_;
T_Optional< T_LOD_ > lod_;
public:
T_SamplerInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& id ) noexcept
: A_ResourceDefInstrNode( OP_SAMPLER , parent ,
id , E_DataType::SAMPLER )
{ }
// Attempt to set sampling mode, mipmap mode, wrapping mode or
// LOD minimal/maximal, returning the location of the previous
// definition if there was one.
T_Optional< T_SRDLocation > setSampling(
E_TexSampling mode ,
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setMipmapSampling(
E_TexSampling mode ,
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setNoMipmap(
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setWrapping(
E_TexWrap mode ,
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setLOD(
T_SRDLocation const& location ,
P_ExpressionNode min ,
P_ExpressionNode max ) noexcept;
// Get either the defined values or the defaults
E_TexSampling sampling( ) const noexcept
{ return sampling_ ? sampling_->mode : E_TexSampling::NEAREST; }
T_Optional< E_TexSampling > mipmap( ) const noexcept
{ return mipmaps_ ? mipmaps_->mode : T_Optional< E_TexSampling >{}; }
E_TexWrap wrapping( ) const noexcept
{ return wrapping_ ? wrapping_->mode : E_TexWrap::REPEAT; }
A_ExpressionNode* minLod( ) const noexcept
{ return lod_ ? lod_->min.get( ) : nullptr; }
A_ExpressionNode* maxLod( ) const noexcept
{ return lod_ ? lod_->max.get( ) : nullptr; }
};
// Texture definition
class T_TextureInstrNode : public A_ResourceDefInstrNode
{
private:
E_TexType type_;
P_ExpressionNode width_;
P_ExpressionNode height_;
P_ExpressionNode lods_;
public:
T_TextureInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& id ,
E_TexType type ) noexcept
: A_ResourceDefInstrNode( OP_TEXTURE , parent ,
id , E_DataType::TEXTURE ) ,
type_( type )
{ }
void setWidth( P_ExpressionNode width ) noexcept
{ width_ = std::move( width ); }
bool hasWidth( ) const noexcept
{ return bool( width_ ); }
A_ExpressionNode& width( ) const noexcept
{ return *width_; }
void setHeight( P_ExpressionNode height ) noexcept
{ height_ = std::move( height ); }
bool hasHeight( ) const noexcept
{ return bool( height_ ); }
A_ExpressionNode& height( ) const noexcept
{ return *height_; }
void setLODs( P_ExpressionNode lods ) noexcept
{ lods_ = std::move( lods ); }
A_ExpressionNode* lods( ) const noexcept
{ return lods_.get( ); }
};
/*= TOOL CONTROL INSTRUCTIONS ==================================================*/
// Output debugging
class T_OutputDebugInstrNode : public A_InstructionNode
{
@ -579,52 +777,6 @@ class T_OutputDebugInstrNode : public A_InstructionNode
{ return locDescription_; }
};
// Pipeline declaration instruction
class T_PipelineInstrNode : public A_InstructionNode
{
private:
T_String id_;
T_SRDLocation idLocation_;
T_StaticArray< T_String , 6 > pids_;
T_StaticArray< T_SRDLocation , 6 > pidLocations_;
public:
T_PipelineInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& idToken ) noexcept
: A_InstructionNode( OP_PIPELINE , parent , E_InstrRestriction::FRAME ) ,
id_( idToken.stringValue( ) ) ,
idLocation_( idToken.location( ) )
{ }
explicit T_PipelineInstrNode(
T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_PIPELINE , parent , E_InstrRestriction::FRAME ) ,
id_( "*invalid*" ) ,
idLocation_{ }
{ }
T_String const& id( ) const noexcept
{ return id_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return idLocation_; }
// Add a program identifier. The token is assumed to be a valid word,
// and the list of programs is assumed not to be full. If the identifer
// is already in the pipeline's list, the location of the first
// occurrence will be returned.
T_Optional< T_SRDLocation > addProgram(
T_SRDToken const& pidToken ) noexcept;
uint32_t size( ) const noexcept
{ return pids_.size( ); }
T_String const& program( const uint32_t index ) const noexcept
{ return pids_[ index ]; }
T_SRDLocation const& pLocation( const uint32_t index ) const noexcept
{ return pidLocations_[ index ]; }
};
// Profiling instruction
class T_ProfileInstrNode : public A_InstructionNode
{
@ -650,189 +802,47 @@ class T_ProfileInstrNode : public A_InstructionNode
{ return instructions_; }
};
// Program loader instruction
class T_ProgramInstrNode : public A_InstructionNode
/*= RENDERING INSTRUCTIONS =====================================================*/
// Clear instruction
class T_ClearInstrNode : public A_InstructionNode
{
private:
T_String id_;
T_SRDLocation idLocation_;
T_String path_;
T_SRDLocation pathLocation_;
T_StaticArray< P_ExpressionNode , 4 > components_;
public:
T_ProgramInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& idToken ,
T_SRDToken const& pathToken ) noexcept
: A_InstructionNode( OP_PROGRAM , parent , E_InstrRestriction::FRAME ) ,
id_( idToken.stringValue( ) ) ,
idLocation_( idToken.location( ) ) ,
path_( pathToken.stringValue( ) ) ,
pathLocation_( pathToken.location( ) )
T_ClearInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_CLEAR , parent ,
E_InstrRestriction::INIT )
{ }
T_String const& id( ) const noexcept
{ return id_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return idLocation_; }
void addComponent( P_ExpressionNode expr ) noexcept
{ if ( expr ) { components_.add( std::move( expr ) ); } }
uint32_t components( ) const noexcept
{ return components_.size( ); }
A_ExpressionNode& component( const uint32_t index ) const noexcept
{ return *components_[ index ]; }
};
// Sampler definition
class T_SamplerInstrNode : public A_InstructionNode
// Fullscreen quad instruction
class T_FullscreenInstrNode : public A_InstructionNode
{
private:
struct T_Sampling_
{
T_SRDLocation location;
E_TexSampling mode;
};
struct T_Mipmaps_
{
T_SRDLocation location;
T_Optional< E_TexSampling > mode;
};
struct T_Wrapping_
{
T_SRDLocation location;
E_TexWrap mode;
};
struct T_LOD_
{
T_SRDLocation location;
P_ExpressionNode min;
P_ExpressionNode max;
};
T_String id_;
T_SRDLocation idLocation_;
T_Optional< T_Sampling_ > sampling_;
T_Optional< T_Mipmaps_ > mipmaps_;
T_Optional< T_Wrapping_ > wrapping_;
T_Optional< T_LOD_ > lod_;
public:
T_SamplerInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& id ) noexcept
: A_InstructionNode( OP_SAMPLER , parent ) ,
id_( id.stringValue( ) ) ,
idLocation_( id.location( ) )
T_FullscreenInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_FULLSCREEN , parent , E_InstrRestriction::INIT )
{ }
T_String const& id( ) const noexcept
{ return id_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return idLocation_; }
// Attempt to set sampling mode, mipmap mode, wrapping mode or
// LOD minimal/maximal, returning the location of the previous
// definition if there was one.
T_Optional< T_SRDLocation > setSampling(
E_TexSampling mode ,
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setMipmapSampling(
E_TexSampling mode ,
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setNoMipmap(
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setWrapping(
E_TexWrap mode ,
T_SRDLocation const& location ) noexcept;
T_Optional< T_SRDLocation > setLOD(
T_SRDLocation const& location ,
P_ExpressionNode min ,
P_ExpressionNode max ) noexcept;
// Get either the defined values or the defaults
E_TexSampling sampling( ) const noexcept
{ return sampling_ ? sampling_->mode : E_TexSampling::NEAREST; }
T_Optional< E_TexSampling > mipmap( ) const noexcept
{ return mipmaps_ ? mipmaps_->mode : T_Optional< E_TexSampling >{}; }
E_TexWrap wrapping( ) const noexcept
{ return wrapping_ ? wrapping_->mode : E_TexWrap::REPEAT; }
A_ExpressionNode* minLod( ) const noexcept
{ return lod_ ? lod_->min.get( ) : nullptr; }
A_ExpressionNode* maxLod( ) const noexcept
{ return lod_ ? lod_->max.get( ) : nullptr; }
};
// Setting a global variable
class T_SetInstrNode : public A_InstructionNode
// Main output selection
class T_MainOutputInstrNode : public A_InstructionNode
{
private:
T_String id_;
T_SRDLocation idLocation_;
P_ExpressionNode expression_;
public:
T_SetInstrNode( T_InstrListNode& parent ,
T_SRDToken const& idToken ) noexcept
: A_InstructionNode( OP_SET , parent ) ,
id_( idToken.stringValue( ) ) ,
idLocation_( idToken.location( ) )
T_MainOutputInstrNode( T_InstrListNode& parent ) noexcept
: A_InstructionNode( OP_MAINOUT , parent , E_InstrRestriction::INIT )
{ }
T_String const& id( ) const noexcept
{ return id_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return idLocation_; }
void setExpression( P_ExpressionNode expression ) noexcept
{ expression_ = std::move( expression ); }
bool hasExpression( ) const noexcept
{ return bool( expression_ ); }
A_ExpressionNode& expression( ) const noexcept
{ return *expression_; }
};
// Texture definition
class T_TextureInstrNode : public A_InstructionNode
{
private:
T_String id_;
T_SRDLocation idLocation_;
E_TexType type_;
P_ExpressionNode width_;
P_ExpressionNode height_;
P_ExpressionNode lods_;
public:
T_TextureInstrNode(
T_InstrListNode& parent ,
T_SRDToken const& id ,
E_TexType type ) noexcept
: A_InstructionNode( OP_TEXTURE , parent , E_InstrRestriction::FRAME ) ,
id_( id.stringValue( ) ) , idLocation_( id.location( ) ) ,
type_( type )
{ }
T_String const& id( ) const noexcept
{ return id_; }
T_SRDLocation const& idLocation( ) const noexcept
{ return idLocation_; }
void setWidth( P_ExpressionNode width ) noexcept
{ width_ = std::move( width ); }
bool hasWidth( ) const noexcept
{ return bool( width_ ); }
A_ExpressionNode& width( ) const noexcept
{ return *width_; }
void setHeight( P_ExpressionNode height ) noexcept
{ height_ = std::move( height ); }
bool hasHeight( ) const noexcept
{ return bool( height_ ); }
A_ExpressionNode& height( ) const noexcept
{ return *height_; }
void setLODs( P_ExpressionNode lods ) noexcept
{ lods_ = std::move( lods ); }
A_ExpressionNode* lods( ) const noexcept
{ return lods_.get( ); }
};
// Uniform setting instruction
@ -975,7 +985,8 @@ class T_ViewportInstrNode : public A_InstructionNode
{ return *parameters_[ int( p ) ]; }
};
/*============================================================================*/
/*= EXPRESSIONS ==============================================================*/
// A constant value
class T_ConstantExprNode : public A_ExpressionNode
@ -1138,7 +1149,8 @@ class T_BinaryOperatorNode : public A_ExpressionNode
{ return *right_; }
};
/*============================================================================*/
/*= PARSER ===================================================================*/
class T_Parser : public A_PrivateImplementation
{

View file

@ -795,14 +795,10 @@ M_INSTR_( Pipeline )
const bool validId( input[ 1 ].type( ) == E_SRDTokenType::WORD );
if ( !validId ) {
errors.addNew( "pipeline identifier expected" , input[ 1 ].location( ) );
return;
}
T_PipelineInstrNode& pipeline{ ([&instructions,&input,validId]( ) -> T_PipelineInstrNode& {
if ( validId ) {
return instructions.add< T_PipelineInstrNode >( input[ 0 ] );
}
return instructions.add< T_PipelineInstrNode >( );
})() };
auto& pipeline{ instructions.add< T_PipelineInstrNode >( input[ 0 ] ) };
pipeline.location( ) = input[ 0 ].location( );
const auto nMax{ std::min( input.size( ) , 8u ) };