NewLang Project
Yet another programm language
|
#include <runtime.h>
Public Types | |
typedef ffi_status | ffi_prep_cif_type(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes) |
typedef ffi_status | ffi_prep_cif_var_type(ffi_cif *cif, ffi_abi abi, unsigned int nfixedargs, unsigned int ntotalargs, ffi_type *rtype, ffi_type **atypes) |
typedef void | ffi_call_type(ffi_cif *cif, void(*fn) (void), void *rvalue, void **avalue) |
![]() | |
typedef std::pair< std::string, VariablePair > | PairType |
Public Member Functions | |
void | GlobalNameBuildinRegister () |
bool | RegisterSystemFunc (const char *source) |
virtual void | Clear () |
bool | RegisterBuildinFunc (std::string proto, void *func) |
ObjPtr | CreateFunction (TermPtr proto, TermPtr block) |
ObjPtr | CreateFunction (TermPtr proto, void *addr) |
RunTime (const StringArray &args={}) | |
virtual | ~RunTime () |
void | InitInternal (const StringArray args) |
bool | LoadModuleFromFile (const char *name_str, bool init) |
ObjPtr | OpLoadModule (TermPtr term) |
ObjPtr | ObjFromModule (ModulePtr module, TermPtr term) |
bool | UnLoadModule (const char *name_str, bool deinit) |
ObjPtr | ExecModule (const char *module, const char *output, bool cached, Context *ctx) |
bool | RegisterBuildinType (ObjType type, std::vector< std::string > parents) |
ObjPtr | GetTypeFromString (const std::string_view type, bool *has_error=nullptr) |
std::vector< std::wstring > | SelectPredict (std::wstring wstart, size_t overage_count=0) |
std::vector< std::wstring > | SelectPredict (std::string start, size_t overage_count=0) |
void | CreateArgs_ (ObjPtr &args, const TermPtr &term, Context *runner=nullptr) |
ObjPtr | CreateDict (const TermPtr &term, Context *runner=nullptr) |
ObjPtr | CreateTensor (const TermPtr &term, Context *runner=nullptr) |
int | RunMain () |
bool | CompileCppSource (const std::string_view source, std::string &out, std::vector< std::string > opts={}) |
TermPtr | ParseBuildin (const std::string_view src) |
RunTime (const RunTime &)=delete | |
const RunTime & | operator= (const RunTime &)=delete |
![]() | |
bool | RegisterObject (bool only_new, const std::string_view name, TermPtr term, Variable var) |
VariablePair * | FindObject (const std::string_view name) |
size_t | size () |
bool | AppendModule (ModulePtr module) |
std::string | Dump (const std::string_view filter="", const char delim=';') |
Static Public Member Functions | |
static ObjPtr | CreateNative (const char *proto, const char *module=nullptr, bool lazzy=false, const char *mangle_name=nullptr) |
static ObjPtr | CreateNative (TermPtr proto, const char *module=nullptr, bool lazzy=false, const char *mangle_name=nullptr) |
static ObjPtr | CreateNative (TermPtr proto, void *addr) |
static std::string | Escape (const std::string_view str) |
static RuntimePtr | Init (StringArray args) |
static RuntimePtr | Init (int argc=0, const char **argv=nullptr, const char **penv=nullptr) |
static std::string | NativeNameMangling (const Term *term, RunTime *rt) |
static std::string | NativeNameMangling (std::string_view name) |
static bool | ModuleSave (const FileModule &data, const std::string_view filename, const std::string_view module_name="") |
static bool | ModuleRead (FileModule &data, const std::string_view filename, const std::string_view modulename="") |
static std::string | GetLastErrorMessage () |
static ObjType | BaseTypeFromString (RunTime *rt, const std::string_view text, bool *has_error=nullptr) |
static bool | pred_compare (const std::string &find, const std::string &str) |
static bool | ExpandFileName (std::string &filename) |
static void * | GetNativeAddress (void *handle, const std::string_view name) |
static StringArray | MakeMainArgs (int argc, const char **argv, const char **penv) |
static ObjPtr | MakeObjArgs (int argc, const char **argv) |
static std::vector< std::string > | SplitChar (std::string_view str, const std::string_view delimiter) |
static std::vector< std::string > | SplitString (const std::string_view str, const std::string_view delim) |
Public Attributes | |
TermPtr | m_main |
StringArray | m_module_loader |
std::string | m_work_dir |
std::string | m_exec_dir |
std::string | m_cache_dir |
std::string | m_temp_dir |
std::string | m_user_dir |
std::vector< std::string > | m_search_dir |
bool | m_assert_enable |
bool | m_load_dsl |
bool | m_embed_source |
bool | m_import_module |
bool | m_import_native |
bool | m_eval_enable |
bool | m_load_runtime |
bool | m_link_rt |
bool | m_link_jit |
int | m_typedef_limit |
DiagPtr | m_diag |
TermPtr | m_main_ast |
![]() | |
ModulePtr | m_curr_module |
std::map< std::string, ModulePtr > | m_modules |
Static Public Attributes | |
static std::string | ffi_file |
static void * | m_ffi_handle = nullptr |
static ffi_type * | m_ffi_type_void = nullptr |
static ffi_type * | m_ffi_type_uint8 = nullptr |
static ffi_type * | m_ffi_type_sint8 = nullptr |
static ffi_type * | m_ffi_type_uint16 = nullptr |
static ffi_type * | m_ffi_type_sint16 = nullptr |
static ffi_type * | m_ffi_type_uint32 = nullptr |
static ffi_type * | m_ffi_type_sint32 = nullptr |
static ffi_type * | m_ffi_type_uint64 = nullptr |
static ffi_type * | m_ffi_type_sint64 = nullptr |
static ffi_type * | m_ffi_type_float = nullptr |
static ffi_type * | m_ffi_type_double = nullptr |
static ffi_type * | m_ffi_type_pointer = nullptr |
static ffi_prep_cif_type * | m_ffi_prep_cif = nullptr |
static ffi_prep_cif_var_type * | m_ffi_prep_cif_var = nullptr |
static ffi_call_type * | m_ffi_call = nullptr |
static ObjType | m_wide_char_type |
static ffi_type * | m_wide_char_type_ffi = nullptr |
static ObjType | m_integer_type |
Protected Member Functions | |
bool | ParseArgs (StringArray args) |
typedef ffi_status newlang::RunTime::ffi_prep_cif_type(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes) |
typedef ffi_status newlang::RunTime::ffi_prep_cif_var_type(ffi_cif *cif, ffi_abi abi, unsigned int nfixedargs, unsigned int ntotalargs, ffi_type *rtype, ffi_type **atypes) |
typedef void newlang::RunTime::ffi_call_type(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue) |
RunTime::RunTime | ( | const StringArray & | args = {} | ) |
Definition at line 2293 of file runtime.cpp.
References ffi_file, GetNativeAddress(), InitInternal(), newlang::Int16, newlang::Int32, newlang::Int64, LOG_RUNTIME, m_assert_enable, m_cache_dir, m_embed_source, m_eval_enable, m_ffi_call, m_ffi_handle, m_ffi_prep_cif, m_ffi_prep_cif_var, m_ffi_type_double, m_ffi_type_float, m_ffi_type_pointer, m_ffi_type_sint16, m_ffi_type_sint32, m_ffi_type_sint64, m_ffi_type_sint8, m_ffi_type_uint16, m_ffi_type_uint32, m_ffi_type_uint64, m_ffi_type_uint8, m_ffi_type_void, m_import_module, m_import_native, m_integer_type, m_link_jit, m_link_rt, m_load_dsl, m_load_runtime, m_temp_dir, m_typedef_limit, m_user_dir, m_wide_char_type, m_wide_char_type_ffi, m_work_dir, STATIC_ASSERT, and newlang::utf8_decode().
|
virtual |
Definition at line 2285 of file runtime.cpp.
References m_ffi_handle.
|
delete |
void RunTime::GlobalNameBuildinRegister | ( | ) |
Definition at line 1336 of file runtime.cpp.
References newlang::Any, newlang::Arithmetic, newlang::BLOCK, newlang::BLOCK_TRY, newlang::Bool, newlang::Byte, newlang::Char, newlang::Class, newlang::Complex, newlang::Complex32, newlang::Complex64, newlang::Dictionary, newlang::Double, newlang::DWord, newlang::DWord64, newlang::Ellipsis, newlang::Enum, newlang::Eval, newlang::Float16, newlang::Float32, newlang::Float64, newlang::FmtChar, newlang::FmtWide, newlang::Function, newlang::Int16, newlang::Int32, newlang::Int64, newlang::Int8, newlang::Integer, newlang::Interface, newlang::NativeFunc, newlang::None, newlang::Number, newlang::Other, newlang::Plain, newlang::Pointer, newlang::PureFunc, newlang::Range, newlang::Rational, RegisterBuildinType(), newlang::Single, newlang::StrChar, newlang::String, newlang::Struct, newlang::StrWide, newlang::Tensor, newlang::Type, newlang::Union, VERIFY, and newlang::Word.
Referenced by InitInternal().
bool RunTime::RegisterSystemFunc | ( | const char * | source | ) |
Definition at line 1412 of file runtime.cpp.
References ASSERT, CreateNative(), newlang::NATIVE, ParseBuildin(), and newlang::GlobalObjects::RegisterObject().
Referenced by InitInternal().
|
virtual |
Reimplemented in newlang::JIT.
Definition at line 74 of file runtime.cpp.
References clear().
Referenced by newlang::JIT::Clear().
bool RunTime::RegisterBuildinFunc | ( | std::string | proto, |
void * | func ) |
Definition at line 1295 of file runtime.cpp.
References CreateFunction(), ParseBuildin(), and newlang::GlobalObjects::RegisterObject().
Referenced by InitInternal().
|
static |
Definition at line 1755 of file runtime.cpp.
References CreateNative(), LOG_RUNTIME, and newlang::Parser::Parse().
Referenced by CreateNative(), CreateNative(), newlang::Context::CreateNative_(), newlang::Context::EvalTerm(), RegisterSystemFunc(), and newlang::Context::StringPrintf().
|
static |
Definition at line 1775 of file runtime.cpp.
References ASSERT, CreateNative(), GetNativeAddress(), and NL_CHECK.
Definition at line 1786 of file runtime.cpp.
References ASSERT, newlang::Bool, newlang::Byte, newlang::Char, newlang::Obj::CreateType(), newlang::Double, newlang::DWord, newlang::DWord64, newlang::ELLIPSIS, newlang::Float32, newlang::Float64, newlang::GetBaseTypeFromString(), newlang::Int16, newlang::Int32, newlang::Int64, newlang::Int8, newlang::isNativeType(), newlang::NativeFunc, NL_CHECK, NL_PARSER, newlang::None, newlang::Pointer, result, newlang::Single, and newlang::Word.
Definition at line 1740 of file runtime.cpp.
References newlang::Term::CreateName(), newlang::Obj::CreateType(), newlang::Function, newlang::NAMESPACE, and result.
Referenced by RegisterBuildinFunc().
Definition at line 1748 of file runtime.cpp.
References newlang::Obj::CreateType(), newlang::Function, and result.
|
static |
Definition at line 2186 of file runtime.cpp.
References result.
Referenced by newlang::Context::Eval().
void RunTime::InitInternal | ( | const StringArray | args | ) |
Definition at line 1226 of file runtime.cpp.
References newlang::runtime::Base::__assert_abort__(), newlang::runtime::Base::__len__(), newlang::runtime::Base::__thread_get_id__(), newlang::runtime::Base::__thread_hardware_concurrency__(), newlang::runtime::Base::__thread_join__(), newlang::runtime::Base::__thread_joinable__(), newlang::runtime::Base::__thread_start__(), newlang::runtime::Base::__thread_this_id__(), newlang::runtime::Base::__timeit__(), GlobalNameBuildinRegister(), LOG_RUNTIME, m_load_runtime, ParseArgs(), RegisterBuildinFunc(), RegisterSystemFunc(), and VERIFY.
Referenced by RunTime().
|
static |
Definition at line 1222 of file runtime.cpp.
Referenced by Init(), and newlang::NLC::Run().
|
static |
Definition at line 1208 of file runtime.cpp.
References Init(), and MakeMainArgs().
|
static |
Definition at line 2237 of file runtime.cpp.
References ASSERT, and newlang::isNativeName().
bool RunTime::LoadModuleFromFile | ( | const char * | name_str, |
bool | init ) |
Definition at line 999 of file runtime.cpp.
Definition at line 1965 of file runtime.cpp.
References ASSERT, newlang::ExtractModuleName(), newlang::isModuleName(), m_module_loader, and NL_PARSER.
bool RunTime::UnLoadModule | ( | const char * | name_str, |
bool | deinit ) |
Definition at line 1121 of file runtime.cpp.
References result.
Definition at line 1190 of file runtime.cpp.
References LOG_RUNTIME.
|
static |
Definition at line 2032 of file runtime.cpp.
References newlang::BaseFileName(), newlang::FileModule::bytecode, newlang::FileModule::include, LOG_RUNTIME, newlang::RemoveFileExtension(), newlang::FileModule::source, and zip_save().
|
static |
Definition at line 2090 of file runtime.cpp.
References newlang::BaseFileName(), newlang::FileModule::bytecode, newlang::FileModule::include, LOG_INFO, LOG_RUNTIME, newlang::FileModule::name, newlang::RemoveFileExtension(), newlang::FileModule::source, and zip_read().
|
static |
Definition at line 2269 of file runtime.cpp.
References newlang::utf8_encode().
bool RunTime::RegisterBuildinType | ( | ObjType | type, |
std::vector< std::string > | parents ) |
Создает иерархию объектов с проверка типов и других семантических правил путём обхода AST
ast | - AST для анализа |
rt | - Объект для хранения глобальных переменных |
type | - Базовый тип данных ObjType |
parents | - Список сторок с именами родительских типов |
Definition at line 1438 of file runtime.cpp.
References ASSERT, newlang::Term::Create(), newlang::Obj::CreateBaseType(), newlang::FUNCTION, LOG_DEBUG, newlang::NormalizeName(), newlang::GlobalObjects::RegisterObject(), result, newlang::toString(), newlang::Type, and VERIFY.
Referenced by GlobalNameBuildinRegister().
|
static |
Definition at line 1525 of file runtime.cpp.
References newlang::GetBaseTypeFromString(), GetTypeFromString(), LOG_RUNTIME, and newlang::None.
Referenced by newlang::Context::CallNative_(), newlang::AstAnalysis::CheckArgs_(), newlang::Obj::op_class_test(), and newlang::typeFromString().
ObjPtr RunTime::GetTypeFromString | ( | const std::string_view | type, |
bool * | has_error = nullptr ) |
Definition at line 1494 of file runtime.cpp.
References newlang::Obj::CreateNone(), LOG_RUNTIME, and newlang::NormalizeName().
Referenced by BaseTypeFromString().
|
inlinestatic |
Definition at line 345 of file runtime.h.
Referenced by SelectPredict().
|
inline |
Definition at line 357 of file runtime.h.
References SelectPredict(), and newlang::utf8_encode().
Referenced by SelectPredict().
std::vector< std::wstring > RunTime::SelectPredict | ( | std::string | start, |
size_t | overage_count = 0 ) |
Definition at line 1595 of file runtime.cpp.
References newlang::isLocalName(), newlang::isMacroName(), newlang::isModuleName(), newlang::isTypeName(), pred_compare(), result, and newlang::utf8_decode().
void newlang::RunTime::CreateArgs_ | ( | ObjPtr & | args, |
const TermPtr & | term, | ||
Context * | runner = nullptr ) |
|
static |
Definition at line 1318 of file runtime.cpp.
Referenced by newlang::JIT::RunFile().
int newlang::RunTime::RunMain | ( | ) |
bool newlang::RunTime::CompileCppSource | ( | const std::string_view | source, |
std::string & | out, | ||
std::vector< std::string > | opts = {} ) |
TermPtr RunTime::ParseBuildin | ( | const std::string_view | src | ) |
Definition at line 1303 of file runtime.cpp.
References newlang::AstAnalysis::Analyze(), LOG_RUNTIME, m_diag, and newlang::Parser::Parse().
Referenced by RegisterBuildinFunc(), and RegisterSystemFunc().
|
static |
Definition at line 2796 of file jit.cpp.
Referenced by newlang::AstAnalysis::CheckNative_(), CreateNative(), newlang::Context::EvalTerm(), and RunTime().
|
inlinestatic |
|
inlinestatic |
Definition at line 426 of file runtime.h.
References newlang::Obj::CreateDict(), newlang::Obj::CreateString(), and result.
|
inlinestatic |
Definition at line 434 of file runtime.h.
References result.
Referenced by newlang::JIT::MakeLLVMModule().
|
inlinestatic |
Definition at line 456 of file runtime.h.
References result.
Referenced by newlang::runtime::System::getenviron(), and ParseArgs().
|
inlineprotected |
Definition at line 479 of file runtime.h.
References LOG_RUNTIME, m_assert_enable, m_cache_dir, m_diag, m_embed_source, m_eval_enable, m_exec_dir, m_import_module, m_import_native, m_link_jit, m_link_rt, m_load_dsl, m_load_runtime, m_search_dir, m_temp_dir, m_user_dir, m_work_dir, newlang::parseInteger(), and SplitString().
Referenced by InitInternal().
|
static |
|
static |
Definition at line 271 of file runtime.h.
Referenced by RunTime(), and ~RunTime().
|
static |
Definition at line 272 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 273 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 274 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
|
static |
Definition at line 276 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
|
static |
Definition at line 278 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
|
static |
Definition at line 280 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 281 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 282 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 283 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 285 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 286 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 287 of file runtime.h.
Referenced by newlang::Context::CallNative_(), and RunTime().
|
static |
Definition at line 289 of file runtime.h.
Referenced by newlang::AstAnalysis::CheckCall(), newlang::AstAnalysis::CheckIndex_(), RunTime(), and newlang::Context::SetIndexValue().
|
static |
|
static |
Definition at line 291 of file runtime.h.
Referenced by newlang::AstAnalysis::CheckIndex_(), and RunTime().
StringArray newlang::RunTime::m_module_loader |
Definition at line 378 of file runtime.h.
Referenced by OpLoadModule().
std::string newlang::RunTime::m_work_dir |
Definition at line 382 of file runtime.h.
Referenced by ParseArgs(), and RunTime().
std::string newlang::RunTime::m_exec_dir |
Definition at line 383 of file runtime.h.
Referenced by newlang::Parser::ExpandPredefMacro(), and ParseArgs().
std::string newlang::RunTime::m_cache_dir |
Definition at line 384 of file runtime.h.
Referenced by ParseArgs(), and RunTime().
std::string newlang::RunTime::m_temp_dir |
Definition at line 385 of file runtime.h.
Referenced by newlang::JIT::MakeLLVMModule(), ParseArgs(), and RunTime().
std::string newlang::RunTime::m_user_dir |
Definition at line 386 of file runtime.h.
Referenced by ParseArgs(), and RunTime().
std::vector<std::string> newlang::RunTime::m_search_dir |
Definition at line 387 of file runtime.h.
Referenced by ParseArgs().
bool newlang::RunTime::m_assert_enable |
Definition at line 388 of file runtime.h.
Referenced by newlang::JIT::JIT(), ParseArgs(), and RunTime().
bool newlang::RunTime::m_load_dsl |
Definition at line 389 of file runtime.h.
Referenced by newlang::JIT::JIT(), ParseArgs(), and RunTime().
bool newlang::RunTime::m_embed_source |
Definition at line 390 of file runtime.h.
Referenced by ParseArgs(), newlang::AstAnalysis::RecursiveAnalyzer(), and RunTime().
bool newlang::RunTime::m_import_module |
Definition at line 391 of file runtime.h.
Referenced by ParseArgs(), newlang::AstAnalysis::RecursiveAnalyzer(), and RunTime().
bool newlang::RunTime::m_import_native |
Definition at line 392 of file runtime.h.
Referenced by newlang::AstAnalysis::CheckNative_(), ParseArgs(), and RunTime().
bool newlang::RunTime::m_eval_enable |
Definition at line 393 of file runtime.h.
Referenced by newlang::Context::EvalEval_(), ParseArgs(), newlang::AstAnalysis::RecursiveAnalyzer(), and RunTime().
bool newlang::RunTime::m_load_runtime |
Definition at line 394 of file runtime.h.
Referenced by InitInternal(), ParseArgs(), and RunTime().
bool newlang::RunTime::m_link_rt |
Definition at line 395 of file runtime.h.
Referenced by newlang::JIT::MakeApplicationSource(), ParseArgs(), and RunTime().
bool newlang::RunTime::m_link_jit |
Definition at line 396 of file runtime.h.
Referenced by ParseArgs(), and RunTime().
int newlang::RunTime::m_typedef_limit |
Definition at line 397 of file runtime.h.
Referenced by newlang::Parser::PragmaEval(), and RunTime().
DiagPtr newlang::RunTime::m_diag |
Definition at line 402 of file runtime.h.
Referenced by newlang::Context::Call(), newlang::JIT::GetParser(), ParseArgs(), ParseBuildin(), and newlang::JIT::Run().
TermPtr newlang::RunTime::m_main_ast |
Definition at line 404 of file runtime.h.
Referenced by newlang::JIT::Run().