Repository navigation
Expand file tree
/
Copy pathTypeDefinition.hpp
More file actions
85 lines (71 loc) · 1.81 KB
/
Copy pathTypeDefinition.hpp
File metadata and controls
85 lines (71 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @file TypeDefinition.hpp
* @author huangjian
* @date 2022-02-21
* @version 1.0
* @copyright huangjian
**/
#ifndef TYPEDEFINITION_HPP
#define TYPEDEFINITION_HPP
#include "Type.hpp"
#include "CodeContainer.hpp"
#include <vector>
/**
* @brief The TypeDefinition class 类型定义
*/
class TypeDefinition : public Type
{
public:
TypeDefinition(const String &name,
TypeRef declare);
public:
/**
* @brief declare 返回一个纯类型,无命名
* @return
*/
TypeRef declare() const;
/**
* @brief name 获取类型名称
* @return
*/
String name() const;
private:
String m_name;
};
class BlockTypeDefinition : public TypeDefinition {
public:
enum Position {
Position_Start = 0x01,
Position_End = 0x02
};
static bool hasPosition(int pos, Position check);
/**
* @brief indexToPosition
* @param idx
* @param count
* @return
*/
static int indexToPosition(int idx, int count);
public:
typedef ::CodeContainer CodesContainer;
public:
BlockTypeDefinition(const String &name,
TypeRef declare,
const CodesContainer &codeContainer);
virtual ~BlockTypeDefinition() override;
public:
const CodesContainer &codeContainer() const;
public:
virtual int typeWrite(Dequque &leftSide, Dequque &rightSide) override;
virtual Kind kind() const override { return Code::CodeBlock; }
protected:
void addCode(CodeRef code);
/**
* @brief writeCode
* @param code
*/
void writeCode(CodeRef code, int position, Dequque &larea, Dequque &rarea);
private:
CodesContainer m_codeContainer;
};
#endif // TYPEDEFINITION_HPP