NewLang Project
Yet another programm language
Loading...
Searching...
No Matches
newlang::RunTime Class Reference

#include <runtime.h>

Inheritance diagram for newlang::RunTime:

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)
 
- Public Types inherited from newlang::GlobalObjects
typedef std::pair< std::string, VariablePairPairType
 

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 RunTimeoperator= (const RunTime &)=delete
 
- Public Member Functions inherited from newlang::GlobalObjects
bool RegisterObject (bool only_new, const std::string_view name, TermPtr term, Variable var)
 

 
VariablePairFindObject (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
 
- Public Attributes inherited from newlang::GlobalObjects
ModulePtr m_curr_module
 
std::map< std::string, ModulePtrm_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_typem_ffi_prep_cif = nullptr
 
static ffi_prep_cif_var_typem_ffi_prep_cif_var = nullptr
 
static ffi_call_typem_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)
 

Detailed Description

Definition at line 189 of file runtime.h.

Member Typedef Documentation

◆ ffi_prep_cif_type

typedef ffi_status newlang::RunTime::ffi_prep_cif_type(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes)

Definition at line 266 of file runtime.h.

◆ ffi_prep_cif_var_type

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)

Definition at line 267 of file runtime.h.

◆ ffi_call_type

typedef void newlang::RunTime::ffi_call_type(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)

Definition at line 268 of file runtime.h.

Constructor & Destructor Documentation

◆ RunTime() [1/2]

◆ ~RunTime()

RunTime::~RunTime ( )
virtual

Definition at line 2285 of file runtime.cpp.

References m_ffi_handle.

◆ RunTime() [2/2]

newlang::RunTime::RunTime ( const RunTime & )
delete

Member Function Documentation

◆ GlobalNameBuildinRegister()

◆ RegisterSystemFunc()

bool RunTime::RegisterSystemFunc ( const char * source)

◆ Clear()

void RunTime::Clear ( )
virtual

Reimplemented in newlang::JIT.

Definition at line 74 of file runtime.cpp.

References clear().

Referenced by newlang::JIT::Clear().

◆ RegisterBuildinFunc()

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().

◆ CreateNative() [1/3]

ObjPtr RunTime::CreateNative ( const char * proto,
const char * module = nullptr,
bool lazzy = false,
const char * mangle_name = nullptr )
static

◆ CreateNative() [2/3]

ObjPtr RunTime::CreateNative ( TermPtr proto,
const char * module = nullptr,
bool lazzy = false,
const char * mangle_name = nullptr )
static

Definition at line 1775 of file runtime.cpp.

References ASSERT, CreateNative(), GetNativeAddress(), and NL_CHECK.

◆ CreateNative() [3/3]

◆ CreateFunction() [1/2]

ObjPtr RunTime::CreateFunction ( TermPtr proto,
TermPtr block )

◆ CreateFunction() [2/2]

ObjPtr RunTime::CreateFunction ( TermPtr proto,
void * addr )

Definition at line 1748 of file runtime.cpp.

References newlang::Obj::CreateType(), newlang::Function, and result.

◆ Escape()

std::string RunTime::Escape ( const std::string_view str)
static

Definition at line 2186 of file runtime.cpp.

References result.

Referenced by newlang::Context::Eval().

◆ InitInternal()

◆ Init() [1/2]

RuntimePtr RunTime::Init ( StringArray args)
static

Definition at line 1222 of file runtime.cpp.

Referenced by Init(), and newlang::NLC::Run().

◆ Init() [2/2]

RuntimePtr RunTime::Init ( int argc = 0,
const char ** argv = nullptr,
const char ** penv = nullptr )
static

Definition at line 1208 of file runtime.cpp.

References Init(), and MakeMainArgs().

◆ NativeNameMangling() [1/2]

static std::string newlang::RunTime::NativeNameMangling ( const Term * term,
RunTime * rt )
static

◆ NativeNameMangling() [2/2]

std::string RunTime::NativeNameMangling ( std::string_view name)
static

Definition at line 2237 of file runtime.cpp.

References ASSERT, and newlang::isNativeName().

◆ LoadModuleFromFile()

bool RunTime::LoadModuleFromFile ( const char * name_str,
bool init )

Definition at line 999 of file runtime.cpp.

References ASSERT, and LOG_ERROR.

◆ OpLoadModule()

ObjPtr RunTime::OpLoadModule ( TermPtr term)

◆ ObjFromModule()

ObjPtr newlang::RunTime::ObjFromModule ( ModulePtr module,
TermPtr term )

◆ UnLoadModule()

bool RunTime::UnLoadModule ( const char * name_str,
bool deinit )

Definition at line 1121 of file runtime.cpp.

References result.

◆ ExecModule()

ObjPtr RunTime::ExecModule ( const char * module,
const char * output,
bool cached,
Context * ctx )

Definition at line 1190 of file runtime.cpp.

References LOG_RUNTIME.

◆ ModuleSave()

bool RunTime::ModuleSave ( const FileModule & data,
const std::string_view filename,
const std::string_view module_name = "" )
static

◆ ModuleRead()

bool RunTime::ModuleRead ( FileModule & data,
const std::string_view filename,
const std::string_view modulename = "" )
static

◆ GetLastErrorMessage()

std::string RunTime::GetLastErrorMessage ( )
static

Definition at line 2269 of file runtime.cpp.

References newlang::utf8_encode().

◆ RegisterBuildinType()

bool RunTime::RegisterBuildinType ( ObjType type,
std::vector< std::string > parents )

Создает иерархию объектов с проверка типов и других семантических правил путём обхода AST

Parameters
ast- AST для анализа
rt- Объект для хранения глобальных переменных
Returns
Семантический корректный модуль с иерархией глобальных и локальных объектов Функция для организации встроенных типов в иерархию наследования. Другие функции: CreateBaseType - создает базовые типы данных (для расширения классов требуется контекст) и BaseTypeConstructor - функция обратного вызова при создании нового объекта базового типа данных
Parameters
type- Базовый тип данных ObjType
parents- Список сторок с именами родительских типов
Returns
- Успешность регистрации базовго типа в иерархии

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().

◆ BaseTypeFromString()

ObjType RunTime::BaseTypeFromString ( RunTime * rt,
const std::string_view text,
bool * has_error = nullptr )
static

◆ GetTypeFromString()

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().

◆ pred_compare()

static bool newlang::RunTime::pred_compare ( const std::string & find,
const std::string & str )
inlinestatic

Definition at line 345 of file runtime.h.

Referenced by SelectPredict().

◆ SelectPredict() [1/2]

std::vector< std::wstring > newlang::RunTime::SelectPredict ( std::wstring wstart,
size_t overage_count = 0 )
inline

Definition at line 357 of file runtime.h.

References SelectPredict(), and newlang::utf8_encode().

Referenced by SelectPredict().

◆ SelectPredict() [2/2]

std::vector< std::wstring > RunTime::SelectPredict ( std::string start,
size_t overage_count = 0 )

◆ CreateArgs_()

void newlang::RunTime::CreateArgs_ ( ObjPtr & args,
const TermPtr & term,
Context * runner = nullptr )

◆ CreateDict()

ObjPtr newlang::RunTime::CreateDict ( const TermPtr & term,
Context * runner = nullptr )

◆ CreateTensor()

ObjPtr newlang::RunTime::CreateTensor ( const TermPtr & term,
Context * runner = nullptr )

◆ ExpandFileName()

bool RunTime::ExpandFileName ( std::string & filename)
static

Definition at line 1318 of file runtime.cpp.

Referenced by newlang::JIT::RunFile().

◆ RunMain()

int newlang::RunTime::RunMain ( )

◆ CompileCppSource()

bool newlang::RunTime::CompileCppSource ( const std::string_view source,
std::string & out,
std::vector< std::string > opts = {} )

◆ ParseBuildin()

TermPtr RunTime::ParseBuildin ( const std::string_view src)

◆ GetNativeAddress()

void * RunTime::GetNativeAddress ( void * handle,
const std::string_view name )
static

◆ MakeMainArgs()

static StringArray newlang::RunTime::MakeMainArgs ( int argc,
const char ** argv,
const char ** penv )
inlinestatic

Definition at line 418 of file runtime.h.

References result.

Referenced by Init().

◆ MakeObjArgs()

static ObjPtr newlang::RunTime::MakeObjArgs ( int argc,
const char ** argv )
inlinestatic

Definition at line 426 of file runtime.h.

References newlang::Obj::CreateDict(), newlang::Obj::CreateString(), and result.

◆ SplitChar()

static std::vector< std::string > newlang::RunTime::SplitChar ( std::string_view str,
const std::string_view delimiter )
inlinestatic

Definition at line 434 of file runtime.h.

References result.

Referenced by newlang::JIT::MakeLLVMModule().

◆ SplitString()

static std::vector< std::string > newlang::RunTime::SplitString ( const std::string_view str,
const std::string_view delim )
inlinestatic

Definition at line 456 of file runtime.h.

References result.

Referenced by newlang::runtime::System::getenviron(), and ParseArgs().

◆ ParseArgs()

◆ operator=()

const RunTime & newlang::RunTime::operator= ( const RunTime & )
delete

Member Data Documentation

◆ ffi_file

std::string RunTime::ffi_file
static

Definition at line 270 of file runtime.h.

Referenced by RunTime().

◆ m_ffi_handle

void * RunTime::m_ffi_handle = nullptr
static

Definition at line 271 of file runtime.h.

Referenced by RunTime(), and ~RunTime().

◆ m_ffi_type_void

ffi_type * RunTime::m_ffi_type_void = nullptr
static

Definition at line 272 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_uint8

ffi_type * RunTime::m_ffi_type_uint8 = nullptr
static

Definition at line 273 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_sint8

ffi_type * RunTime::m_ffi_type_sint8 = nullptr
static

Definition at line 274 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_uint16

ffi_type * RunTime::m_ffi_type_uint16 = nullptr
static

Definition at line 275 of file runtime.h.

Referenced by RunTime().

◆ m_ffi_type_sint16

ffi_type * RunTime::m_ffi_type_sint16 = nullptr
static

Definition at line 276 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_uint32

ffi_type * RunTime::m_ffi_type_uint32 = nullptr
static

Definition at line 277 of file runtime.h.

Referenced by RunTime().

◆ m_ffi_type_sint32

ffi_type * RunTime::m_ffi_type_sint32 = nullptr
static

Definition at line 278 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_uint64

ffi_type * RunTime::m_ffi_type_uint64 = nullptr
static

Definition at line 279 of file runtime.h.

Referenced by RunTime().

◆ m_ffi_type_sint64

ffi_type * RunTime::m_ffi_type_sint64 = nullptr
static

Definition at line 280 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_float

ffi_type * RunTime::m_ffi_type_float = nullptr
static

Definition at line 281 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_double

ffi_type * RunTime::m_ffi_type_double = nullptr
static

Definition at line 282 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_type_pointer

ffi_type * RunTime::m_ffi_type_pointer = nullptr
static

Definition at line 283 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_prep_cif

RunTime::ffi_prep_cif_type * RunTime::m_ffi_prep_cif = nullptr
static

Definition at line 285 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_prep_cif_var

RunTime::ffi_prep_cif_var_type * RunTime::m_ffi_prep_cif_var = nullptr
static

Definition at line 286 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_ffi_call

RunTime::ffi_call_type * RunTime::m_ffi_call = nullptr
static

Definition at line 287 of file runtime.h.

Referenced by newlang::Context::CallNative_(), and RunTime().

◆ m_wide_char_type

ObjType RunTime::m_wide_char_type
static

◆ m_wide_char_type_ffi

ffi_type * RunTime::m_wide_char_type_ffi = nullptr
static

Definition at line 290 of file runtime.h.

Referenced by RunTime().

◆ m_integer_type

ObjType RunTime::m_integer_type
static

Definition at line 291 of file runtime.h.

Referenced by newlang::AstAnalysis::CheckIndex_(), and RunTime().

◆ m_main

TermPtr newlang::RunTime::m_main

Definition at line 377 of file runtime.h.

◆ m_module_loader

StringArray newlang::RunTime::m_module_loader

Definition at line 378 of file runtime.h.

Referenced by OpLoadModule().

◆ m_work_dir

std::string newlang::RunTime::m_work_dir

Definition at line 382 of file runtime.h.

Referenced by ParseArgs(), and RunTime().

◆ m_exec_dir

std::string newlang::RunTime::m_exec_dir

Definition at line 383 of file runtime.h.

Referenced by newlang::Parser::ExpandPredefMacro(), and ParseArgs().

◆ m_cache_dir

std::string newlang::RunTime::m_cache_dir

Definition at line 384 of file runtime.h.

Referenced by ParseArgs(), and RunTime().

◆ m_temp_dir

std::string newlang::RunTime::m_temp_dir

Definition at line 385 of file runtime.h.

Referenced by newlang::JIT::MakeLLVMModule(), ParseArgs(), and RunTime().

◆ m_user_dir

std::string newlang::RunTime::m_user_dir

Definition at line 386 of file runtime.h.

Referenced by ParseArgs(), and RunTime().

◆ m_search_dir

std::vector<std::string> newlang::RunTime::m_search_dir

Definition at line 387 of file runtime.h.

Referenced by ParseArgs().

◆ m_assert_enable

bool newlang::RunTime::m_assert_enable

Definition at line 388 of file runtime.h.

Referenced by newlang::JIT::JIT(), ParseArgs(), and RunTime().

◆ m_load_dsl

bool newlang::RunTime::m_load_dsl

Definition at line 389 of file runtime.h.

Referenced by newlang::JIT::JIT(), ParseArgs(), and RunTime().

◆ m_embed_source

bool newlang::RunTime::m_embed_source

Definition at line 390 of file runtime.h.

Referenced by ParseArgs(), newlang::AstAnalysis::RecursiveAnalyzer(), and RunTime().

◆ m_import_module

bool newlang::RunTime::m_import_module

Definition at line 391 of file runtime.h.

Referenced by ParseArgs(), newlang::AstAnalysis::RecursiveAnalyzer(), and RunTime().

◆ m_import_native

bool newlang::RunTime::m_import_native

Definition at line 392 of file runtime.h.

Referenced by newlang::AstAnalysis::CheckNative_(), ParseArgs(), and RunTime().

◆ m_eval_enable

bool newlang::RunTime::m_eval_enable

◆ m_load_runtime

bool newlang::RunTime::m_load_runtime

Definition at line 394 of file runtime.h.

Referenced by InitInternal(), ParseArgs(), and RunTime().

◆ m_link_rt

bool newlang::RunTime::m_link_rt

Definition at line 395 of file runtime.h.

Referenced by newlang::JIT::MakeApplicationSource(), ParseArgs(), and RunTime().

◆ m_link_jit

bool newlang::RunTime::m_link_jit

Definition at line 396 of file runtime.h.

Referenced by ParseArgs(), and RunTime().

◆ m_typedef_limit

int newlang::RunTime::m_typedef_limit

Definition at line 397 of file runtime.h.

Referenced by newlang::Parser::PragmaEval(), and RunTime().

◆ m_diag

DiagPtr newlang::RunTime::m_diag

◆ m_main_ast

TermPtr newlang::RunTime::m_main_ast

Definition at line 404 of file runtime.h.

Referenced by newlang::JIT::Run().


The documentation for this class was generated from the following files: