NewLang Project
Yet another programm language
|
#include <term.h>
Public Member Functions | |
NameLookupStack (GlobalObjects &glob, StorageTerm::ModuleMapType &modules) | |
void | clear () |
virtual | ~NameLookupStack () |
void | PushScope (TermPtr ns, bool is_function=false) |
void | PopScope () |
void | SetLookupNamespace (TermPtr ns) |
bool | AddName (const TermPtr var, const char *alt_name=nullptr) |
TermPtr | FindInternalName (std::string_view int_name) |
TermPtr | LookupName (std::string name) |
TermPtr | LookupNameVars (const std::string_view name) |
TermPtr | LookupNameNamespace (const std::string_view ns, const std::string_view name) |
std::string | MakeInternalName (const TermPtr &term, bool is_static) |
std::string | MakeInternalName (const std::string_view name, bool is_static) |
void | ExpandNamespace (std::string &name) |
std::string | GetNamespace () |
std::string | GetFuntionName () |
std::string | MakeNamespace (int skip, bool is_global) |
bool | CheckInterrupt (std::string_view name) |
std::string | GetOffer () |
bool | LookupBlock_ (TermPtr &term) |
std::string | GetOfferBlock () |
std::string | Dump () |
Static Public Member Functions | |
static std::string | EnumerateString (const StringArray &names) |
Public Attributes | |
GlobalObjects & | m_glob |
Buildin in Runtime. | |
StorageTerm::ModuleMapType & | m_modules |
Use as a pre-declaration of (an "external") object. | |
size_t | m_block_num |
Нумератор безымянных блоков кода | |
Класс для разрешния имен при работе анализатора. Формирует текущую область видимости при анализе кода, реализует алгоритм разрешения имен, проверяет наличие (корректность) имен объектов включая глобальные.
На выходе работы анализатора имеет объект - модуль со списком имен:
При выполнении JIT создает из текущих загруженных модулей единый объект контекст для каждого потока свой. Состав модулей определяется компиляции программы и не изменяется при выполнении. Динамическая загрузка модуля происходит в конкретном контексте (потоке) и не влияет на глобальный контекст?
В TermPtr не должно быть никаких данных, чтобы их (код) можно было шарить между потоками.
NameLookupStack::NameLookupStack | ( | GlobalObjects & | glob, |
StorageTerm::ModuleMapType & | modules ) |
|
inlinevirtual |
void NameLookupStack::clear | ( | ) |
Definition at line 169 of file term.cpp.
References newlang::Term::Create(), m_modules, and newlang::NAME.
Referenced by NameLookupStack().
|
inlinestatic |
void NameLookupStack::PushScope | ( | TermPtr | ns, |
bool | is_function = false ) |
Definition at line 181 of file term.cpp.
References newlang::Term::CreateName(), newlang::ScopeVars::function_name, m_block_num, and newlang::ScopeVars::scope_name.
Referenced by newlang::ScopePush::ScopePush().
|
inline |
Definition at line 264 of file term.h.
References ASSERT.
Referenced by newlang::ScopePush::~ScopePush().
void NameLookupStack::SetLookupNamespace | ( | TermPtr | ns | ) |
Definition at line 200 of file term.cpp.
References LOG_LEVEL_INFO, and NL_MESSAGE.
Referenced by newlang::AstAnalysis::CreateOp_().
bool NameLookupStack::AddName | ( | const TermPtr | var, |
const char * | alt_name = nullptr ) |
Добавялет в текущую область имен новый объект с указанным внутренним именем (int_name). или альтернативным именем (alt_name), которое должно быть нормализованным Имя сразу добавляется в текщее хранилище (на постоянной основе), и в стек простарнства имен для поиска по простому имени. У одной и той же перменной может быть несколько внутренних имен (например, синонимы у аругментов функций), потому термин (его внутреннее имя) не модифицируеься.
int_name | |
var |
Definition at line 426 of file term.cpp.
References ASSERT, newlang::Term::CheckTermEq(), newlang::isGlobalScope(), newlang::isStaticName(), LOG_LEVEL_INFO, LOG_RUNTIME, m_glob, m_modules, newlang::StorageTerm::MODULE_MAIN, NL_MESSAGE, and newlang::GlobalObjects::RegisterObject().
Referenced by newlang::AstAnalysis::CreateOp_().
TermPtr NameLookupStack::FindInternalName | ( | std::string_view | int_name | ) |
Выполняет поиск объекта по <внутреннему имени (int_name)> Расширение имен согласно name lookup ны выполняется!
int_name | Внутреннему имя объекта для поиска |
local_only | Искать только в локальном хранилище (для чистых функций) |
Definition at line 475 of file term.cpp.
References newlang::GlobalObjects::FindObject(), m_glob, m_modules, newlang::StorageTerm::MODULE_MAIN, and newlang::VariablePair::term.
Referenced by LookupName(), and LookupNameVars().
TermPtr NameLookupStack::LookupName | ( | std::string | name | ) |
Производит поиск <простого имени в соответствии с name lookup>
name | Простое имя для поиска |
local_only | Искать только в локальном хранилище (для чистых функций) |
Definition at line 541 of file term.cpp.
References FindInternalName(), newlang::isInternalName(), newlang::isTrivialName(), LookupNameNamespace(), LookupNameVars(), MakeNamespace(), and newlang::NormalizeName().
Referenced by newlang::AstAnalysis::LookupName().
TermPtr NameLookupStack::LookupNameVars | ( | const std::string_view | name | ) |
Definition at line 494 of file term.cpp.
References FindInternalName(), m_modules, and newlang::StorageTerm::MODULE_MAIN.
Referenced by LookupName(), and LookupNameNamespace().
TermPtr NameLookupStack::LookupNameNamespace | ( | const std::string_view | ns, |
const std::string_view | name ) |
std::string NameLookupStack::MakeInternalName | ( | const TermPtr & | term, |
bool | is_static ) |
Definition at line 309 of file term.cpp.
References ASSERT, and MakeInternalName().
Referenced by newlang::AstAnalysis::CreateOp_(), and MakeInternalName().
std::string NameLookupStack::MakeInternalName | ( | const std::string_view | name, |
bool | is_static ) |
Definition at line 318 of file term.cpp.
References ASSERT, GetFuntionName(), GetNamespace(), newlang::isStaticName(), newlang::isTrivialName(), and result.
void NameLookupStack::ExpandNamespace | ( | std::string & | name | ) |
Definition at line 223 of file term.cpp.
References GetFuntionName(), and GetNamespace().
Referenced by LookupBlock_().
std::string NameLookupStack::GetNamespace | ( | ) |
Definition at line 289 of file term.cpp.
References ASSERT, and result.
Referenced by ExpandNamespace(), and MakeInternalName().
std::string NameLookupStack::GetFuntionName | ( | ) |
Definition at line 277 of file term.cpp.
References ASSERT, and LOG_RUNTIME.
Referenced by ExpandNamespace(), and MakeInternalName().
std::string NameLookupStack::MakeNamespace | ( | int | skip, |
bool | is_global ) |
bool NameLookupStack::CheckInterrupt | ( | std::string_view | name | ) |
Definition at line 234 of file term.cpp.
References LOG_RUNTIME.
bool NameLookupStack::LookupBlock_ | ( | TermPtr & | term | ) |
Definition at line 647 of file term.cpp.
References ASSERT, Dump(), ExpandNamespace(), LOG_LEVEL_INFO, and NL_MESSAGE.
Referenced by newlang::AstAnalysis::RecursiveAnalyzer().
std::string NameLookupStack::GetOfferBlock | ( | ) |
std::string NameLookupStack::Dump | ( | ) |
Definition at line 691 of file term.cpp.
References result.
Referenced by LookupBlock_(), and newlang::AstAnalysis::RecursiveAnalyzer().
GlobalObjects& newlang::NameLookupStack::m_glob |
Buildin in Runtime.
Definition at line 236 of file term.h.
Referenced by AddName(), and FindInternalName().
StorageTerm::ModuleMapType& newlang::NameLookupStack::m_modules |
Use as a pre-declaration of (an "external") object.
Definition at line 237 of file term.h.
Referenced by AddName(), clear(), FindInternalName(), and LookupNameVars().
size_t newlang::NameLookupStack::m_block_num |