From 673b73c42d4ae4f35fe62f3b7527b6129127a553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Mon, 13 Nov 2017 18:21:06 +0100 Subject: [PATCH] Compiler - Also gather constants from OP_INPUT --- opcomp.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/opcomp.cc b/opcomp.cc index 4367691..9b3b828 100644 --- a/opcomp.cc +++ b/opcomp.cc @@ -156,11 +156,19 @@ void T_CompilerImpl_::gatherConstants( ) noexcept { constants.clear( ); astVisitor.visit( input->root , [&]( A_Node& node , const bool exit ) { - if ( exit && node.type( ) == A_Node::EXPR_CONST ) { - T_OpValue value; - value.f = dynamic_cast< T_ConstantExprNode& >( node ).floatValue( ); - constants.add( value.u ); + if ( exit ) { + return true; } + + T_OpValue value; + if ( node.type( ) == A_Node::EXPR_CONST ) { + value.f = dynamic_cast< T_ConstantExprNode& >( node ).floatValue( ); + } else if ( node.type( ) == A_Node::OP_INPUT ) { + value.f = dynamic_cast< T_InputInstrNode& >( node ).defValue( ); + } else { + return true; + } + constants.add( value.u ); return true; } );