76 lines
3.1 KiB
C++
76 lines
3.1 KiB
C++
#ifndef ACPA_ELEMENT_H
|
|
#define ACPA_ELEMENT_H
|
|
|
|
#include <map>
|
|
#include <set>
|
|
#include <utility>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
using std::map;
|
|
using std::set;
|
|
using std::pair;
|
|
using std::shared_ptr;
|
|
using std::string;
|
|
using std::vector;
|
|
using std::weak_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 {
|
|
enum Type {
|
|
TEMPLATE,
|
|
STRUCT,
|
|
FUNCTION
|
|
};
|
|
virtual ValType::Type type() const = 0;
|
|
virtual shared_ptr<ValType> struct_replace(shared_ptr<StructType>, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) = 0;
|
|
virtual shared_ptr<ValType> function_replace(const map<shared_ptr<TemplateType>, shared_ptr<ValType>>&, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) = 0;
|
|
virtual bool sameType(shared_ptr<ValType>, set<pair<shared_ptr<TemplateType>, shared_ptr<TemplateType>>>&) = 0;
|
|
virtual ~ValType() = default;
|
|
};
|
|
|
|
struct TemplateType : ValType, std::enable_shared_from_this<TemplateType> {
|
|
ValType::Type type() const override;
|
|
shared_ptr<ValType> struct_replace(shared_ptr<StructType>, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) override;
|
|
shared_ptr<ValType> function_replace(const map<shared_ptr<TemplateType>, shared_ptr<ValType>>&, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) override;
|
|
bool sameType(shared_ptr<ValType>, set<pair<shared_ptr<TemplateType>, shared_ptr<TemplateType>>>&) override;
|
|
};
|
|
|
|
struct StructType : ValType, std::enable_shared_from_this<StructType> {
|
|
ValType::Type type() const override;
|
|
shared_ptr<ValType> struct_replace(shared_ptr<StructType>, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) override;
|
|
shared_ptr<ValType> function_replace(const map<shared_ptr<TemplateType>, shared_ptr<ValType>>&, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) override;
|
|
bool sameType(shared_ptr<ValType>, set<pair<shared_ptr<TemplateType>, shared_ptr<TemplateType>>>&) override;
|
|
shared_ptr<Struct> str;
|
|
map<shared_ptr<TemplateType>, shared_ptr<ValType>> mp;
|
|
};
|
|
|
|
struct FunctionType : ValType, std::enable_shared_from_this<FunctionType> {
|
|
ValType::Type type() const override;
|
|
shared_ptr<ValType> struct_replace(shared_ptr<StructType>, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) override;
|
|
shared_ptr<ValType> function_replace(const map<shared_ptr<TemplateType>, shared_ptr<ValType>>&, map<shared_ptr<TemplateType>, shared_ptr<TemplateType>>&) override;
|
|
bool sameType(shared_ptr<ValType>, set<pair<shared_ptr<TemplateType>, shared_ptr<TemplateType>>>&) override;
|
|
vector<shared_ptr<TemplateType>> c1;
|
|
vector<shared_ptr<ValType>> c2;
|
|
shared_ptr<ValType> c3;
|
|
};
|
|
|
|
shared_ptr<ValType> struct_replace(shared_ptr<ValType>, shared_ptr<StructType>);
|
|
shared_ptr<ValType> function_replace(shared_ptr<ValType>, const map<shared_ptr<TemplateType>, shared_ptr<ValType>>&);
|
|
bool sameType(shared_ptr<ValType>, shared_ptr<ValType>);
|
|
|
|
#endif |