Plasma Engine  2.0
Loading...
Searching...
No Matches
ExpressionCompiler.h
1#pragma once
2
3#include <Foundation/CodeUtils/Expression/ExpressionAST.h>
4#include <Foundation/Types/Delegate.h>
5
7
8class PL_FOUNDATION_DLL plExpressionCompiler
9{
10public:
13
14 plResult Compile(plExpressionAST& ref_ast, plExpressionByteCode& out_byteCode, plStringView sDebugAstOutputPath = plStringView());
15
16private:
17 plResult TransformAndOptimizeAST(plExpressionAST& ast, plStringView sDebugAstOutputPath);
18 plResult BuildNodeInstructions(const plExpressionAST& ast);
19 plResult UpdateRegisterLifetime(const plExpressionAST& ast);
20 plResult AssignRegisters();
21 plResult GenerateByteCode(const plExpressionAST& ast, plExpressionByteCode& out_byteCode);
22 plResult GenerateConstantByteCode(const plExpressionAST::Constant* pConstant);
23
25 plResult TransformASTPreOrder(plExpressionAST& ast, TransformFunc func);
26 plResult TransformASTPostOrder(plExpressionAST& ast, TransformFunc func);
27 plResult TransformNode(plExpressionAST::Node*& pNode, TransformFunc& func);
28 plResult TransformOutputNode(plExpressionAST::Output*& pOutputNode, TransformFunc& func);
29
30 void DumpAST(const plExpressionAST& ast, plStringView sOutputPath, plStringView sSuffix);
31
36
40
41 plDynamicArray<plUInt32> m_ByteCode;
42
43 struct LiveInterval
44 {
45 PL_DECLARE_POD_TYPE();
46
47 plUInt32 m_uiStart;
48 plUInt32 m_uiEnd;
49 const plExpressionAST::Node* m_pNode;
50 };
51
52 plDynamicArray<LiveInterval> m_LiveIntervals;
53};
Definition DynamicArray.h:81
Definition ExpressionAST.h:9
Definition ExpressionByteCode.h:10
Definition ExpressionCompiler.h:9
Definition HashTable.h:333
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A generic delegate class which supports static functions and member functions.
Definition Delegate.h:76
Definition ExpressionAST.h:223
Definition ExpressionAST.h:195
Definition ExpressionAST.h:240
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54