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.
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#ifndef POLSERVER_INSTRUCTIONGENERATOR_H
|
|
#define POLSERVER_INSTRUCTIONGENERATOR_H
|
|
|
|
#include "compiler/ast/NodeVisitor.h"
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
class InstructionEmitter;
|
|
|
|
class InstructionGenerator : public NodeVisitor
|
|
{
|
|
public:
|
|
explicit InstructionGenerator( InstructionEmitter& );
|
|
|
|
void visit_float_value( FloatValue& ) override;
|
|
void visit_function_call( FunctionCall& ) override;
|
|
void visit_identifier( Identifier& ) override;
|
|
void visit_integer_value( IntegerValue& ) override;
|
|
void visit_string_value( StringValue& ) override;
|
|
void visit_unary_operator( UnaryOperator& ) override;
|
|
void visit_value_consumer( ValueConsumer& ) override;
|
|
void visit_var_statement( VarStatement& ) override;
|
|
|
|
private:
|
|
// There are two of these because sometimes when calling a method
|
|
// on InstructionEmitter, the variable name reads better as a noun,
|
|
// and sometimes it reads better as a verb.
|
|
InstructionEmitter& emitter;
|
|
InstructionEmitter& emit;
|
|
};
|
|
|
|
} // namespace Pol::Bscript::Compiler
|
|
|
|
|
|
#endif // POLSERVER_INSTRUCTIONGENERATOR_H
|