loom
64 строки · 1.8 Кб
1/*
2MIT License
3
4Copyright (c) 2021 МГТУ им. Н.Э. Баумана, кафедра ИУ-6, Михаил Фетисов,
5
6https://bmstu.codes/lsx/simodo/loom
7*/
8
9#include "simodo/interpret/SemanticModuleFactory_interface.h"
10#include "SystemVerilogAnalyzer.h"
11#include "SystemVerilogPreview.h"
12
13#include <memory>
14#include <cassert>
15
16#ifdef CROSS_WIN
17// MinGW related workaround
18#define BOOST_DLL_FORCE_ALIAS_INSTANTIATION
19#endif
20
21#include <boost/dll/alias.hpp>
22
23using namespace simodo;
24
25namespace sv
26{
27class SystemVerilogInterpret : public interpret::SemanticModuleFactory_interface
28{
29interpret::ModuleManagement_interface & _mm;
30
31public:
32SystemVerilogInterpret(interpret::ModuleManagement_interface & module_management)
33: _mm(module_management)
34{
35}
36
37virtual version_t version() const override { return lib_version(); }
38
39virtual interpret::SemanticModule_interface *
40create(interpret::Interpret_interface & ) const override
41{
42switch(_mm.interpret_type())
43{
44case interpret::InterpretType::Analyzer:
45return new SystemVerilogAnalyzer(_mm, _mm.semantic_data());
46case interpret::InterpretType::Preview:
47return new SystemVerilogPreview(_mm);
48default:
49return nullptr;
50}
51}
52
53// Self factory method
54static std::shared_ptr<SemanticModuleFactory_interface> self_create(interpret::ModuleManagement_interface & module_management) {
55return std::make_shared<SystemVerilogInterpret>(module_management);
56}
57};
58
59}
60
61BOOST_DLL_ALIAS(
62sv::SystemVerilogInterpret::self_create, // <-- this function is exported with...
63create_simodo_interpret // <-- ...this alias name
64)
65
66