Parser - Moved some constructors to the header
This commit is contained in:
parent
397f1c5c75
commit
b4f448c21f
2 changed files with 63 additions and 147 deletions
133
opast.cc
133
opast.cc
|
@ -29,14 +29,6 @@ T_RootNode& A_Node::root( ) const noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*= T_InstrListNode ==========================================================*/
|
|
||||||
|
|
||||||
T_InstrListNode::T_InstrListNode(
|
|
||||||
A_Node& parent ) noexcept
|
|
||||||
: A_Node( ILIST , &parent )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*= A_FuncNode ===============================================================*/
|
/*= A_FuncNode ===============================================================*/
|
||||||
|
|
||||||
A_FuncNode::A_FuncNode(
|
A_FuncNode::A_FuncNode(
|
||||||
|
@ -64,7 +56,6 @@ T_RootNode::T_RootNode( ) noexcept
|
||||||
} )
|
} )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
T_RootNode::T_AddFunctionResult T_RootNode::addFunction(
|
T_RootNode::T_AddFunctionResult T_RootNode::addFunction(
|
||||||
T_OwnPtr< A_FuncNode >& function ) noexcept
|
T_OwnPtr< A_FuncNode >& function ) noexcept
|
||||||
{
|
{
|
||||||
|
@ -91,23 +82,8 @@ T_RootNode::T_AddFunctionResult T_RootNode::addFunction(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*= T_SpecialFuncNode ========================================================*/
|
|
||||||
|
|
||||||
T_SpecialFuncNode::T_SpecialFuncNode(
|
|
||||||
bool isInit ,
|
|
||||||
T_RootNode& parent ) noexcept
|
|
||||||
: A_FuncNode( isInit , &parent )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*= T_FuncNode ===============================================================*/
|
/*= T_FuncNode ===============================================================*/
|
||||||
|
|
||||||
T_FuncNode::T_FuncNode(
|
|
||||||
T_String const& name ,
|
|
||||||
T_RootNode& parent ) noexcept
|
|
||||||
: A_FuncNode( name , &parent )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
T_Optional< T_SRDLocation > T_FuncNode::addArgument(
|
T_Optional< T_SRDLocation > T_FuncNode::addArgument(
|
||||||
T_SRDToken const& token ) noexcept
|
T_SRDToken const& token ) noexcept
|
||||||
{
|
{
|
||||||
|
@ -126,21 +102,6 @@ T_Optional< T_SRDLocation > T_FuncNode::addArgument(
|
||||||
|
|
||||||
/*= T_PipelineInstrNode ======================================================*/
|
/*= T_PipelineInstrNode ======================================================*/
|
||||||
|
|
||||||
T_PipelineInstrNode::T_PipelineInstrNode(
|
|
||||||
T_InstrListNode& parent ,
|
|
||||||
T_SRDToken const& idToken ) noexcept
|
|
||||||
: A_InstructionNode( OP_PIPELINE , parent , E_InstrRestriction::FRAME ) ,
|
|
||||||
id_( idToken.stringValue( ) ) ,
|
|
||||||
idLocation_( idToken.location( ) )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
T_PipelineInstrNode::T_PipelineInstrNode(
|
|
||||||
T_InstrListNode& parent ) noexcept
|
|
||||||
: A_InstructionNode( OP_PIPELINE , parent , E_InstrRestriction::FRAME ) ,
|
|
||||||
id_( "*invalid*" ) ,
|
|
||||||
idLocation_{ }
|
|
||||||
{ }
|
|
||||||
|
|
||||||
T_Optional< T_SRDLocation > T_PipelineInstrNode::addProgram(
|
T_Optional< T_SRDLocation > T_PipelineInstrNode::addProgram(
|
||||||
T_SRDToken const& pidToken ) noexcept
|
T_SRDToken const& pidToken ) noexcept
|
||||||
{
|
{
|
||||||
|
@ -155,100 +116,6 @@ T_Optional< T_SRDLocation > T_PipelineInstrNode::addProgram(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*= T_ProfileInstrNode =======================================================*/
|
|
||||||
|
|
||||||
T_ProfileInstrNode::T_ProfileInstrNode(
|
|
||||||
T_InstrListNode& parent ,
|
|
||||||
T_String const& text ) noexcept
|
|
||||||
: A_InstructionNode( OP_PROFILE , parent , E_InstrRestriction::INIT ) ,
|
|
||||||
text_( text ) ,
|
|
||||||
instructions_( *this )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*= T_ProgramInstrNode =======================================================*/
|
|
||||||
|
|
||||||
T_ProgramInstrNode::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_SetInstrNode ===========================================================*/
|
|
||||||
|
|
||||||
T_SetInstrNode::T_SetInstrNode(
|
|
||||||
T_InstrListNode& parent ,
|
|
||||||
T_SRDToken const& idToken ) noexcept
|
|
||||||
: A_InstructionNode( OP_PROGRAM , parent ) ,
|
|
||||||
id_( idToken.stringValue( ) ) ,
|
|
||||||
idLocation_( idToken.location( ) )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*= T_TextureInstrNode =======================================================*/
|
|
||||||
|
|
||||||
T_TextureInstrNode::T_TextureInstrNode(
|
|
||||||
T_InstrListNode& parent ,
|
|
||||||
T_SRDToken const& idToken ,
|
|
||||||
const E_TexType type ) noexcept
|
|
||||||
: A_InstructionNode( OP_PROGRAM , parent , E_InstrRestriction::FRAME ) ,
|
|
||||||
id_( idToken.stringValue( ) ) ,
|
|
||||||
idLocation_( idToken.location( ) ) ,
|
|
||||||
type_( type )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*= T_ConstantExprNode =======================================================*/
|
|
||||||
|
|
||||||
T_ConstantExprNode::T_ConstantExprNode(
|
|
||||||
A_Node& parent ,
|
|
||||||
T_SRDToken const& token ) noexcept
|
|
||||||
: A_ExpressionNode( EXPR_CONST , parent ) ,
|
|
||||||
wasFloat_( token.type( ) == E_SRDTokenType::FLOAT ) ,
|
|
||||||
vFloat_( token.floatValue( ) ) ,
|
|
||||||
vInt_( token.longValue( ) )
|
|
||||||
{
|
|
||||||
location( ) = token.location( );
|
|
||||||
}
|
|
||||||
|
|
||||||
T_ConstantExprNode::T_ConstantExprNode(
|
|
||||||
A_Node& parent ,
|
|
||||||
double value ) noexcept
|
|
||||||
: A_ExpressionNode( EXPR_CONST , parent ) , wasFloat_( true ) ,
|
|
||||||
vFloat_( value ) , vInt_( (int64_t) value )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
T_ConstantExprNode::T_ConstantExprNode(
|
|
||||||
A_Node& parent ,
|
|
||||||
int64_t value ) noexcept
|
|
||||||
: A_ExpressionNode( EXPR_CONST , parent ) , wasFloat_( false ) ,
|
|
||||||
vFloat_( value ) , vInt_( value )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*= T_IdentifierExprNode =====================================================*/
|
|
||||||
|
|
||||||
T_IdentifierExprNode::T_IdentifierExprNode(
|
|
||||||
A_Node& parent ,
|
|
||||||
T_SRDToken const& token ) noexcept
|
|
||||||
: T_IdentifierExprNode( parent , token.stringValue( ) )
|
|
||||||
{
|
|
||||||
location( ) = token.location( );
|
|
||||||
}
|
|
||||||
|
|
||||||
T_IdentifierExprNode::T_IdentifierExprNode(
|
|
||||||
A_Node& parent ,
|
|
||||||
T_String const& id ) noexcept
|
|
||||||
: A_ExpressionNode( EXPR_ID , parent ) , id_( id )
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*= T_UnaryOperatorNode ======================================================*/
|
/*= T_UnaryOperatorNode ======================================================*/
|
||||||
|
|
||||||
T_UnaryOperatorNode::T_UnaryOperatorNode(
|
T_UnaryOperatorNode::T_UnaryOperatorNode(
|
||||||
|
|
77
opast.hh
77
opast.hh
|
@ -115,7 +115,8 @@ class T_InstrListNode : public A_Node
|
||||||
T_Array< T_OwnPtr< A_InstructionNode > > instructions_;
|
T_Array< T_OwnPtr< A_InstructionNode > > instructions_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_InstrListNode( A_Node& parent ) noexcept;
|
T_InstrListNode( A_Node& parent ) noexcept
|
||||||
|
: A_Node( ILIST , &parent ) { }
|
||||||
|
|
||||||
template<
|
template<
|
||||||
typename IType ,
|
typename IType ,
|
||||||
|
@ -233,7 +234,9 @@ class T_SpecialFuncNode : public A_FuncNode
|
||||||
public:
|
public:
|
||||||
T_SpecialFuncNode(
|
T_SpecialFuncNode(
|
||||||
bool isInit ,
|
bool isInit ,
|
||||||
T_RootNode& parent ) noexcept;
|
T_RootNode& parent ) noexcept
|
||||||
|
: A_FuncNode( isInit , &parent )
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Normal functions
|
// Normal functions
|
||||||
|
@ -245,7 +248,9 @@ class T_FuncNode : public A_FuncNode
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_FuncNode( T_String const& name ,
|
T_FuncNode( T_String const& name ,
|
||||||
T_RootNode& parent ) noexcept;
|
T_RootNode& parent ) noexcept
|
||||||
|
: A_FuncNode( name , &parent )
|
||||||
|
{ }
|
||||||
|
|
||||||
// Add an argument. If the argument is a duplicate, return the location
|
// Add an argument. If the argument is a duplicate, return the location
|
||||||
// of the initial argument.
|
// of the initial argument.
|
||||||
|
@ -398,9 +403,18 @@ class T_PipelineInstrNode : public A_InstructionNode
|
||||||
public:
|
public:
|
||||||
T_PipelineInstrNode(
|
T_PipelineInstrNode(
|
||||||
T_InstrListNode& parent ,
|
T_InstrListNode& parent ,
|
||||||
T_SRDToken const& idToken ) noexcept;
|
T_SRDToken const& idToken ) noexcept
|
||||||
|
: A_InstructionNode( OP_PIPELINE , parent , E_InstrRestriction::FRAME ) ,
|
||||||
|
id_( idToken.stringValue( ) ) ,
|
||||||
|
idLocation_( idToken.location( ) )
|
||||||
|
{ }
|
||||||
|
|
||||||
explicit T_PipelineInstrNode(
|
explicit T_PipelineInstrNode(
|
||||||
T_InstrListNode& parent ) noexcept;
|
T_InstrListNode& parent ) noexcept
|
||||||
|
: A_InstructionNode( OP_PIPELINE , parent , E_InstrRestriction::FRAME ) ,
|
||||||
|
id_( "*invalid*" ) ,
|
||||||
|
idLocation_{ }
|
||||||
|
{ }
|
||||||
|
|
||||||
// Add a program identifier. The token is assumed to be a valid word,
|
// 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
|
// and the list of programs is assumed not to be full. If the identifer
|
||||||
|
@ -428,7 +442,11 @@ class T_ProfileInstrNode : public A_InstructionNode
|
||||||
public:
|
public:
|
||||||
T_ProfileInstrNode(
|
T_ProfileInstrNode(
|
||||||
T_InstrListNode& parent ,
|
T_InstrListNode& parent ,
|
||||||
T_String const& text ) noexcept;
|
T_String const& text ) noexcept
|
||||||
|
: A_InstructionNode( OP_PROFILE , parent , E_InstrRestriction::INIT ) ,
|
||||||
|
text_( text ) ,
|
||||||
|
instructions_( *this )
|
||||||
|
{ }
|
||||||
|
|
||||||
T_String const& text( ) const
|
T_String const& text( ) const
|
||||||
{ return text_; }
|
{ return text_; }
|
||||||
|
@ -452,7 +470,13 @@ class T_ProgramInstrNode : public A_InstructionNode
|
||||||
T_ProgramInstrNode(
|
T_ProgramInstrNode(
|
||||||
T_InstrListNode& parent ,
|
T_InstrListNode& parent ,
|
||||||
T_SRDToken const& idToken ,
|
T_SRDToken const& idToken ,
|
||||||
T_SRDToken const& pathToken ) noexcept;
|
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( ) )
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setting a global variable
|
// Setting a global variable
|
||||||
|
@ -465,7 +489,11 @@ class T_SetInstrNode : public A_InstructionNode
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_SetInstrNode( T_InstrListNode& parent ,
|
T_SetInstrNode( T_InstrListNode& parent ,
|
||||||
T_SRDToken const& idToken ) noexcept;
|
T_SRDToken const& idToken ) noexcept
|
||||||
|
: A_InstructionNode( OP_PROGRAM , parent ) ,
|
||||||
|
id_( idToken.stringValue( ) ) ,
|
||||||
|
idLocation_( idToken.location( ) )
|
||||||
|
{ }
|
||||||
|
|
||||||
T_String const& identifier( ) const noexcept
|
T_String const& identifier( ) const noexcept
|
||||||
{ return id_; }
|
{ return id_; }
|
||||||
|
@ -494,7 +522,11 @@ class T_TextureInstrNode : public A_InstructionNode
|
||||||
T_TextureInstrNode(
|
T_TextureInstrNode(
|
||||||
T_InstrListNode& parent ,
|
T_InstrListNode& parent ,
|
||||||
T_SRDToken const& id ,
|
T_SRDToken const& id ,
|
||||||
E_TexType type ) noexcept;
|
E_TexType type ) noexcept
|
||||||
|
: A_InstructionNode( OP_PROGRAM , parent , E_InstrRestriction::FRAME ) ,
|
||||||
|
id_( id.stringValue( ) ) , idLocation_( id.location( ) ) ,
|
||||||
|
type_( type )
|
||||||
|
{ }
|
||||||
|
|
||||||
void setWidth( P_ExpressionNode width ) noexcept
|
void setWidth( P_ExpressionNode width ) noexcept
|
||||||
{ width_ = std::move( width ); }
|
{ width_ = std::move( width ); }
|
||||||
|
@ -523,12 +555,24 @@ class T_ConstantExprNode : public A_ExpressionNode
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_ConstantExprNode( A_Node& parent ,
|
T_ConstantExprNode( A_Node& parent ,
|
||||||
T_SRDToken const& token ) noexcept;
|
T_SRDToken const& token ) noexcept
|
||||||
|
: A_ExpressionNode( EXPR_CONST , parent ) ,
|
||||||
|
wasFloat_( token.type( ) == E_SRDTokenType::FLOAT ) ,
|
||||||
|
vFloat_( token.floatValue( ) ) ,
|
||||||
|
vInt_( token.longValue( ) )
|
||||||
|
{ location( ) = token.location( ); }
|
||||||
|
|
||||||
T_ConstantExprNode( A_Node& parent ,
|
T_ConstantExprNode( A_Node& parent ,
|
||||||
int64_t value ) noexcept;
|
int64_t value ) noexcept
|
||||||
|
: A_ExpressionNode( EXPR_CONST , parent ) , wasFloat_( false ) ,
|
||||||
|
vFloat_( value ) , vInt_( value )
|
||||||
|
{ }
|
||||||
|
|
||||||
T_ConstantExprNode( A_Node& parent ,
|
T_ConstantExprNode( A_Node& parent ,
|
||||||
double value ) noexcept;
|
double value ) noexcept
|
||||||
|
: A_ExpressionNode( EXPR_CONST , parent ) , wasFloat_( true ) ,
|
||||||
|
vFloat_( value ) , vInt_( (int64_t) value )
|
||||||
|
{ }
|
||||||
|
|
||||||
bool wasFloat( ) const noexcept
|
bool wasFloat( ) const noexcept
|
||||||
{ return wasFloat_; }
|
{ return wasFloat_; }
|
||||||
|
@ -546,9 +590,14 @@ class T_IdentifierExprNode : public A_ExpressionNode
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_IdentifierExprNode( A_Node& parent ,
|
T_IdentifierExprNode( A_Node& parent ,
|
||||||
T_SRDToken const& token ) noexcept;
|
T_SRDToken const& token ) noexcept
|
||||||
|
: T_IdentifierExprNode( parent , token.stringValue( ) )
|
||||||
|
{ location( ) = token.location( ); }
|
||||||
|
|
||||||
T_IdentifierExprNode( A_Node& parent ,
|
T_IdentifierExprNode( A_Node& parent ,
|
||||||
T_String const& id ) noexcept;
|
T_String const& id ) noexcept
|
||||||
|
: A_ExpressionNode( EXPR_ID , parent ) , id_( id )
|
||||||
|
{ }
|
||||||
|
|
||||||
T_String const& id( ) const noexcept
|
T_String const& id( ) const noexcept
|
||||||
{ return id_; }
|
{ return id_; }
|
||||||
|
|
Loading…
Reference in a new issue