mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Update grammar * Update expression handling for uninit * update existing tests * Add new tests * Remove fullpath from escriptgrammar generation comment * fix tests * Update eScript guide * Declare escript version 0x11 * Add core-changes * Add `true` and `false` to grammar * true/false implementation * Fix existing tests * Add new tests * Update core changes * add docs * Fix BooleanValue::describe_to * bool optimizations * optimize uninit * remove unused var assignments * Update grammar for case labels for uninit, booleans * Fix case label handling for uninit, true, false * Tests * Fix compiler version display v1.1700000017881393 -> v1.17 * optimize boolean binary operations * fix unary boolean optimizer * add boolean, uninit optimizer test * Use new fmt lib apis * Fix compiler warning * really fix warning lol * Add Executor[Module]::getParam for bools, FindSubstance test
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#include "BinaryOperatorOptimizer.h"
|
|
|
|
#include "bscript/compiler/ast/BinaryOperator.h"
|
|
|
|
#include "BinaryOperatorWithBooleanOptimizer.h"
|
|
#include "BinaryOperatorWithFloatOptimizer.h"
|
|
#include "BinaryOperatorWithIntegerOptimizer.h"
|
|
#include "BinaryOperatorWithStringOptimizer.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
BinaryOperatorOptimizer::BinaryOperatorOptimizer( BinaryOperator& op, Report& report )
|
|
: op( op ), report( report )
|
|
{
|
|
}
|
|
|
|
std::unique_ptr<Expression> BinaryOperatorOptimizer::optimize()
|
|
{
|
|
op.lhs().accept( *this );
|
|
return std::move( optimized_result );
|
|
}
|
|
|
|
void BinaryOperatorOptimizer::visit_children( Node& )
|
|
{
|
|
}
|
|
|
|
void BinaryOperatorOptimizer::visit_boolean_value( BooleanValue& lhs )
|
|
{
|
|
BinaryOperatorWithBooleanOptimizer optimizer( lhs, op, report );
|
|
op.rhs().accept( optimizer );
|
|
optimized_result = std::move( optimizer.optimized_result );
|
|
}
|
|
|
|
void BinaryOperatorOptimizer::visit_float_value( FloatValue& lhs )
|
|
{
|
|
BinaryOperatorWithFloatOptimizer optimizer( lhs, op, report );
|
|
op.rhs().accept( optimizer );
|
|
optimized_result = std::move( optimizer.optimized_result );
|
|
}
|
|
|
|
void BinaryOperatorOptimizer::visit_integer_value( IntegerValue& lhs )
|
|
{
|
|
BinaryOperatorWithIntegerOptimizer optimizer( lhs, op, report );
|
|
op.rhs().accept( optimizer );
|
|
optimized_result = std::move( optimizer.optimized_result );
|
|
}
|
|
|
|
void BinaryOperatorOptimizer::visit_string_value( StringValue& lhs )
|
|
{
|
|
BinaryOperatorWithStringOptimizer optimizer( lhs, op );
|
|
op.rhs().accept( optimizer );
|
|
optimized_result = std::move( optimizer.optimized_result );
|
|
}
|
|
|
|
} // namespace Pol::Bscript::Compiler
|