mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
Adds: - UnaryOperator: AST node for unary operators -, ++, --, and so forth - UnaryOperatorOptimizer: optimizes a unary operator with its operand - now integer and float negation, and integer inversion - later x[y]++ to a single instruction Also: - automatically include basic.em, which includes some parameter defaults like -1. This allows the compiler to generate output for a hello, world script with the exact same .ecl output as the legacy compiler.
31 lines
565 B
C++
31 lines
565 B
C++
#ifndef POLSERVER_OPTIMIZER_H
|
|
#define POLSERVER_OPTIMIZER_H
|
|
|
|
#include "compiler/ast/NodeVisitor.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
class Report;
|
|
class CompilerWorkspace;
|
|
|
|
class Optimizer : public NodeVisitor
|
|
{
|
|
public:
|
|
explicit Optimizer( Report& );
|
|
|
|
void optimize( CompilerWorkspace& );
|
|
void visit_children( Node& ) override;
|
|
|
|
void visit_unary_operator( UnaryOperator& ) override;
|
|
|
|
std::unique_ptr<Node> optimized_replacement;
|
|
|
|
private:
|
|
Report& report;
|
|
};
|
|
|
|
} // namespace Pol::Bscript::Compiler
|
|
|
|
#endif // POLSERVER_OPTIMIZER_H
|