mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
34 lines
811 B
C++
34 lines
811 B
C++
#include "BinaryOperatorWithStringOptimizer.h"
|
|
|
|
#include "bscript/compiler/ast/BinaryOperator.h"
|
|
#include "bscript/compiler/ast/StringValue.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
BinaryOperatorWithStringOptimizer::BinaryOperatorWithStringOptimizer( StringValue& lhs,
|
|
BinaryOperator& op )
|
|
: lhs( lhs ), op( op )
|
|
{
|
|
}
|
|
|
|
void BinaryOperatorWithStringOptimizer::visit_children( Node& ) {}
|
|
|
|
void BinaryOperatorWithStringOptimizer::visit_string_value( StringValue& rhs )
|
|
{
|
|
std::string value;
|
|
switch ( op.token_id )
|
|
{
|
|
case TOK_ADD:
|
|
{
|
|
value = lhs.value + rhs.value;
|
|
break;
|
|
}
|
|
|
|
default:
|
|
return;
|
|
}
|
|
|
|
optimized_result = std::make_unique<StringValue>( op.source_location, value );
|
|
}
|
|
|
|
} // namespace Pol::Bscript::Compiler
|