hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
builtinModule.cpp
Go to the documentation of this file.
1#include "builtinModule.hpp"
3#include "compiler/ir/IR.h"
4#include "share/def.hpp"
5#include <utility>
6
7namespace yoi {
15
23
31
39
43
51
59
67
75
77 module->interfaceTable.put_create(L"NullInterface", managedPtr(getNullInterfaceInstanceDefinition()));
78 }
79
84 sharedValueType.put(L"string", managedPtr(getStrObject()));
87 sharedValueType.put(L"unsigned", managedPtr(getUnsignedObject()));
89
90 sharedValueType.put(L"foreignInt32Type", managedPtr(getForeignInt32Object()));
91 sharedValueType.put(L"foreignFloatType", managedPtr(getForeignFloatObject()));
93
94
95 for (auto &sharedValue : sharedValueType) {
96 if (sharedValue.second->isForeignBasicType() || sharedValue.second->type == IRValueType::valueType::none)
97 continue;
98 auto nullInterface = std::make_pair(HOSHI_COMPILER_CTX_GLOB_ID_CONST, 0);
99 auto nullImplName = L"interfaceImpl#" + std::to_wstring(HOSHI_COMPILER_CTX_GLOB_ID_CONST) + L"#0#" + sharedValue.second->to_string();
100 module->interfaceTable[0]->implementations.emplace_back(
101 sharedValue.second->type, sharedValue.second->typeAffiliateModule, sharedValue.second->typeIndex);
103 nullImplName,
104 {sharedValue.second->type, sharedValue.second->typeAffiliateModule, sharedValue.second->typeIndex},
106 {},
107 {}});
108 module->interfaceImplementationTable.put_create(nullImplName, nullImpl);
109 }
110
111 // make NullInterface object shared
112 sharedValueType.put(L"NullInterface", managedPtr(IRValueType{
115 0,
117 }));
118 }
119
123
124 BuiltinModuleBuilder::BuiltinModuleBuilder(std::shared_ptr<IRModule> module) : module(std::move(module)) {}
125
127 module->modulePath = L"builtin";
128 module->identifier = HOSHI_COMPILER_CTX_GLOB_ID_CONST;
129
132 }
133
141
149} // namespace yoi
#define HOSHI_COMPILER_CTX_GLOB_ID_CONST
yoi::IRValueType getDeciObject()
static yoi::IRInterfaceInstanceDefinition getNullInterfaceInstanceDefinition()
yoi::IRValueType getCharObject()
yoi::IRValueType getStrObject()
yoi::IRValueType getForeignFloatObject()
yoi::IRValueType getPointerDefinition()
yoi::IRValueType getIntObject()
yoi::IRValueType getBoolObject()
yoi::IRValueType getNoneObject()
yoi::IRValueType getForeignInt32Object()
yoi::IRValueType getUnsignedObject()
yoi::indexTable< yoi::wstr, std::shared_ptr< IRValueType > > sharedValueType
yoi::IRValueType getShortObject()
std::shared_ptr< T > managedPtr(const T &v)
Definition def.hpp:324
std::vector< t > vec
Definition def.hpp:53
uint64_t indexT
Definition def.hpp:51