diff --git a/opast.cc b/opast.cc index 1e07155..19f9ae8 100644 --- a/opast.cc +++ b/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( @@ -64,7 +56,6 @@ T_RootNode::T_RootNode( ) noexcept } ) { } - T_RootNode::T_AddFunctionResult T_RootNode::addFunction( 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_String const& name , - T_RootNode& parent ) noexcept - : A_FuncNode( name , &parent ) -{ } - T_Optional< T_SRDLocation > T_FuncNode::addArgument( T_SRDToken const& token ) noexcept { @@ -126,21 +102,6 @@ T_Optional< T_SRDLocation > T_FuncNode::addArgument( /*= 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_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( diff --git a/opast.hh b/opast.hh index 1755b07..a95c96f 100644 --- a/opast.hh +++ b/opast.hh @@ -115,7 +115,8 @@ class T_InstrListNode : public A_Node T_Array< T_OwnPtr< A_InstructionNode > > instructions_; public: - T_InstrListNode( A_Node& parent ) noexcept; + T_InstrListNode( A_Node& parent ) noexcept + : A_Node( ILIST , &parent ) { } template< typename IType , @@ -233,7 +234,9 @@ class T_SpecialFuncNode : public A_FuncNode public: T_SpecialFuncNode( bool isInit , - T_RootNode& parent ) noexcept; + T_RootNode& parent ) noexcept + : A_FuncNode( isInit , &parent ) + { } }; // Normal functions @@ -245,7 +248,9 @@ class T_FuncNode : public A_FuncNode public: 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 // of the initial argument. @@ -398,9 +403,18 @@ class T_PipelineInstrNode : public A_InstructionNode public: T_PipelineInstrNode( 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( - 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, // 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: T_ProfileInstrNode( 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 { return text_; } @@ -452,7 +470,13 @@ class T_ProgramInstrNode : public A_InstructionNode T_ProgramInstrNode( T_InstrListNode& parent , 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 @@ -465,7 +489,11 @@ class T_SetInstrNode : public A_InstructionNode public: 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 { return id_; } @@ -494,7 +522,11 @@ class T_TextureInstrNode : public A_InstructionNode T_TextureInstrNode( T_InstrListNode& parent , 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 { width_ = std::move( width ); } @@ -523,12 +555,24 @@ class T_ConstantExprNode : public A_ExpressionNode public: 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 , - int64_t value ) noexcept; + int64_t value ) noexcept + : A_ExpressionNode( EXPR_CONST , parent ) , wasFloat_( false ) , + vFloat_( value ) , vInt_( value ) + { } + 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 { return wasFloat_; } @@ -546,9 +590,14 @@ class T_IdentifierExprNode : public A_ExpressionNode public: 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_String const& id ) noexcept; + T_String const& id ) noexcept + : A_ExpressionNode( EXPR_ID , parent ) , id_( id ) + { } T_String const& id( ) const noexcept { return id_; }