acpa/include/element.h
2023-08-29 19:52:40 +08:00

58 lines
1.0 KiB
C++

#ifndef ACPA_ELEMENT_H
#define ACPA_ELEMENT_H
#include <map>
#include <vector>
#include <string>
#include <memory>
using std::map;
using std::vector;
using std::string;
using std::weak_ptr;
using std::shared_ptr;
struct Struct;
struct ValType;
struct TemplateType;
struct StructType;
struct FunctionType;
struct Struct {
weak_ptr<Struct> fa;
vector<shared_ptr<TemplateType>> c1;
vector<shared_ptr<ValType>> c2;
map<string, shared_ptr<ValType>> vars;
map<string, shared_ptr<Struct>> structs;
};
struct ValType {
virtual const int type() = 0;
};
struct TemplateType : ValType {
const int type() override {
return 0;
}
};
struct StructType : ValType {
const int type() override {
return 1;
}
shared_ptr<Struct> str;
map<shared_ptr<TemplateType>, shared_ptr<ValType>> mp;
};
struct FunctionType : ValType {
const int type() override {
return 2;
}
vector<shared_ptr<TemplateType>> c1;
vector<shared_ptr<ValType>> c2;
shared_ptr<ValType> c3;
};
bool sameType(shared_ptr<ValType>, shared_ptr<ValType>);
#endif