|
NewLang Project
Yet another programm language
|
#include <jit.h>

Public Member Functions | |
| TermPtrConst & | GetAst () |
| Context & | GetCtx () |
| JIT (const StringArray &args={}) | |
| virtual | ~JIT () |
| void | Clear () override |
| JIT (const JIT &)=delete | |
| const JIT & | operator= (const JIT &)=delete |
| bool | CreateMacro (const std::string_view text) |
| ParserPtr | GetParser () |
| ObjPtr | Run (const std::string_view str, Obj *args=nullptr) |
| ObjPtr | Run (Module *module, Obj *args=nullptr) |
| ObjPtr | RunFile (std::string file, Obj *args=nullptr) |
| bool | ModuleCreate (FileModule &data, const std::string_view source) |
| std::string | MakeCodeModule (const TermPtr &term, std::string_view name, bool is_main) |
| std::string | MakeCodeFunction (const TermPtr &term) |
| std::string | MakeFuncDeclarations_ (const TermPtr &term) |
| std::string | MakeCodeRepl (const std::string_view source, const std::string_view name) |
| void | MakeFunctionRecursive_ (const TermPtr &term, std::string &output, const std::string_view module) |
| std::unique_ptr< llvm::Module > | MakeLLVMModule (std::string_view source, const std::vector< std::string > opts, std::string temp_dir="") |
| bool | MakeObjFile (const std::string_view filename, llvm::Module &module, const std::vector< std::string > opts) |
| bool | LinkObjToExec (const std::string_view filename, std::vector< std::string > objs, std::vector< std::string > opts={}) |
| bool | MakeCppExec (const std::string_view source, const std::string_view filename, std::vector< std::string > opts={}) |
| std::string | MakeApplicationSource (const TermPtr &ast) |
Public Member Functions inherited from newlang::RunTime | |
| void | GlobalNameBuildinRegister () |
| bool | RegisterSystemFunc (const char *source) |
| 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 |
Public Member Functions inherited from newlang::GlobalObjects | |
| 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 JIT * | ReCreate (const StringArray &args={}) |
| static JIT * | Instance (const StringArray &args={}) |
| static bool | LLVMInitialize () |
| static bool | LLVMInitializeJIT () |
| static bool | ModuleCreate (FileModule &data, const std::string_view module_name, const TermPtr &include, const std::string_view source, llvm::Module *bc=nullptr) |
| static std::string | ExtractFunctionDecls (const TermPtr &ast, const std::string_view module) |
| static std::string | ExtractStaticVars (const TermPtr &ast, const std::string_view module) |
| static std::string | MakeBodyFunction (const TermPtr &ast) |
| static std::string | MakeFunctionPrototype (const TermPtr &func, const std::string_view module) |
| static std::string | RegExpInlineComment (const std::string_view src) |
| static std::string | MakeCommentPlace (const TermPtr &term) |
| static std::string | ReplaceObjectInEmbedSource (const std::string_view embed, std::vector< std::string > &include, const TermPtr args=nullptr) |
| static std::string | MakeMain (const std::vector< std::string > &include) |
| static std::string | MakeMainEmbed (const std::string_view embed_source, const std::vector< std::string > &include) |
| static TermPtr | MainArgs () |
Static Public Member Functions inherited from newlang::RunTime | |
| 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 | |
| StorageTerm::ModuleMapType | m_external |
| NameLookupStack | m_stack |
| MacroPtr | m_macro |
| size_t | m_repl_count |
| std::vector< ModulePtr > | m_module |
| std::vector< std::shared_ptr< Context > > | m_ctx |
| clang::IntrusiveRefCntPtr< clang::DiagnosticOptions > | DiagOpts |
| clang::TextDiagnosticPrinter * | textDiagPrinter |
| clang::IntrusiveRefCntPtr< clang::DiagnosticIDs > | pDiagIDs |
| clang::DiagnosticsEngine * | pDiagnosticsEngine |
| std::vector< std::string > | m_includes |
Public Attributes inherited from newlang::RunTime | |
| 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, ModulePtr > | m_modules |
Static Public Attributes | |
| static JIT * | m_instance = nullptr |
Static Public Attributes inherited from newlang::RunTime | |
| 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 |
Additional Inherited Members | |
Public Types inherited from newlang::RunTime | |
| 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, VariablePair > | PairType |
Protected Member Functions inherited from newlang::RunTime | |
| bool | ParseArgs (StringArray args) |
| JIT::JIT | ( | const StringArray & | args = {} | ) |
Definition at line 2656 of file jit.cpp.
References CreateMacro(), DiagOpts, LLVMInitialize(), newlang::RunTime::m_assert_enable, newlang::RunTime::m_load_dsl, m_repl_count, pDiagIDs, pDiagnosticsEngine, textDiagPrinter, and VERIFY.
|
inlinevirtual |
Definition at line 116 of file jit.h.
References DiagOpts, pDiagIDs, and pDiagnosticsEngine.
|
delete |
|
inline |
|
inline |
|
inlineoverridevirtual |
Reimplemented from newlang::RunTime.
Definition at line 131 of file jit.h.
References newlang::RunTime::Clear(), and m_instance.
|
inlinestatic |
|
inlinestatic |
| bool JIT::CreateMacro | ( | const std::string_view | text | ) |
Definition at line 2783 of file jit.cpp.
References m_macro, and newlang::Parser::ParseTerm().
Referenced by JIT().
|
inlinestatic |
|
inlinestatic |
Definition at line 191 of file jit.h.
Referenced by MakeObjFile().
| ParserPtr JIT::GetParser | ( | ) |
Definition at line 2535 of file jit.cpp.
References newlang::RunTime::m_diag, and m_macro.
Referenced by Run().
Definition at line 2558 of file jit.cpp.
References newlang::AstAnalysis::Analyze(), ASSERT, newlang::Term::Create(), newlang::Obj::CreateNone(), newlang::Context::Execute(), GetCtx(), GetParser(), newlang::Variable::GetValueAsObject(), newlang::LatterType::GetVariablePair(), LOG_PARSER, m_ctx, newlang::RunTime::m_diag, newlang::RunTime::m_main_ast, m_module, m_stack, result, SCOPE_LOCK_WRITE, newlang::SEQUENCE, and newlang::VariablePair::var.
Referenced by newlang::NLC::Run(), and RunFile().
Definition at line 2605 of file jit.cpp.
References LOG_RUNTIME.
Definition at line 2540 of file jit.cpp.
References newlang::RunTime::ExpandFileName(), LOG_RUNTIME, newlang::ReadFile(), and Run().
Referenced by newlang::NLC::Run().
| bool JIT::ModuleCreate | ( | FileModule & | data, |
| const std::string_view | source ) |
|
static |
Definition at line 2644 of file jit.cpp.
References newlang::FileModule::bytecode, newlang::FileModule::include, newlang::AstAnalysis::MakeInclude(), newlang::FileModule::name, and newlang::FileModule::source.
| std::string JIT::MakeCodeModule | ( | const TermPtr & | term, |
| std::string_view | name, | ||
| bool | is_main ) |
Definition at line 822 of file jit.cpp.
References newlang::Term::CreateName(), ExtractFunctionDecls(), ExtractStaticVars(), newlang::Parser::GetCurrentTimeStamp(), MakeBodyFunction(), MakeFunctionPrototype(), MakeFunctionRecursive_(), newlang::NormalizeName(), result, and VERSION_SOURCE_FULL_ID.
| std::string JIT::MakeFuncDeclarations_ | ( | const TermPtr & | term | ) |
| std::string JIT::MakeCodeRepl | ( | const std::string_view | source, |
| const std::string_view | name ) |
| void JIT::MakeFunctionRecursive_ | ( | const TermPtr & | term, |
| std::string & | output, | ||
| const std::string_view | module ) |
Definition at line 929 of file jit.cpp.
References MakeBodyFunction(), MakeCommentPlace(), MakeFunctionPrototype(), and MakeFunctionRecursive_().
Referenced by MakeCodeModule(), and MakeFunctionRecursive_().
| std::unique_ptr< llvm::Module > JIT::MakeLLVMModule | ( | std::string_view | source, |
| const std::vector< std::string > | opts, | ||
| std::string | temp_dir = "" ) |
Definition at line 362 of file jit.cpp.
References LOG_RUNTIME, newlang::RunTime::m_temp_dir, pDiagnosticsEngine, newlang::RunTime::SplitChar(), and textDiagPrinter.
| bool JIT::MakeObjFile | ( | const std::string_view | filename, |
| llvm::Module & | module, | ||
| const std::vector< std::string > | opts ) |
Definition at line 584 of file jit.cpp.
References newlang::Error, LLVMInitializeJIT(), and LOG_ERROR.
| bool JIT::LinkObjToExec | ( | const std::string_view | filename, |
| std::vector< std::string > | objs, | ||
| std::vector< std::string > | opts = {} ) |
Definition at line 624 of file jit.cpp.
References pDiagnosticsEngine.
|
static |
Definition at line 665 of file jit.cpp.
References ExtractFunctionDecls(), MakeCommentPlace(), MakeFunctionPrototype(), and result.
Referenced by ExtractFunctionDecls(), and MakeCodeModule().
|
static |
Definition at line 913 of file jit.cpp.
Referenced by MakeCodeModule().
|
static |
Definition at line 925 of file jit.cpp.
Referenced by MakeCodeModule(), and MakeFunctionRecursive_().
|
static |
Definition at line 684 of file jit.cpp.
References ASSERT, NEWLANG_NS, NL_PARSER, and result.
Referenced by ExtractFunctionDecls(), MakeCodeModule(), and MakeFunctionRecursive_().
|
static |
Definition at line 704 of file jit.cpp.
Referenced by MakeCommentPlace().
|
static |
Definition at line 695 of file jit.cpp.
References RegExpInlineComment().
Referenced by ExtractFunctionDecls(), and MakeFunctionRecursive_().
|
static |
Definition at line 792 of file jit.cpp.
References newlang::MakeName(), and result.
Referenced by MakeApplicationSource().
| bool newlang::JIT::MakeCppExec | ( | const std::string_view | source, |
| const std::string_view | filename, | ||
| std::vector< std::string > | opts = {} ) |
| std::string JIT::MakeApplicationSource | ( | const TermPtr & | ast | ) |
Definition at line 722 of file jit.cpp.
References newlang::EMBED, LOG_RUNTIME, m_includes, newlang::RunTime::m_link_rt, MainArgs(), MakeMain(), MakeMainEmbed(), ReplaceObjectInEmbedSource(), and result.
|
static |
Definition at line 749 of file jit.cpp.
References MakeMainEmbed(), NEWLANG_INDENT_OP, and result.
Referenced by MakeApplicationSource().
|
static |
Definition at line 755 of file jit.cpp.
References newlang::Parser::GetCurrentTimeStamp(), NEWLANG_INDENT_OP, result, and VERSION_SOURCE_FULL_ID.
Referenced by MakeApplicationSource(), and MakeMain().
|
static |
Definition at line 711 of file jit.cpp.
References newlang::Term::CreateDict(), newlang::Term::CreateName(), result, and newlang::TYPE.
Referenced by MakeApplicationSource().
| StorageTerm::ModuleMapType newlang::JIT::m_external |
| NameLookupStack newlang::JIT::m_stack |
| MacroPtr newlang::JIT::m_macro |
Definition at line 93 of file jit.h.
Referenced by CreateMacro(), and GetParser().
| std::vector<ModulePtr> newlang::JIT::m_module |
| std::vector<std::shared_ptr<Context> > newlang::JIT::m_ctx |
| clang::IntrusiveRefCntPtr<clang::DiagnosticOptions> newlang::JIT::DiagOpts |
| clang::TextDiagnosticPrinter* newlang::JIT::textDiagPrinter |
Definition at line 109 of file jit.h.
Referenced by JIT(), and MakeLLVMModule().
| clang::IntrusiveRefCntPtr<clang::DiagnosticIDs> newlang::JIT::pDiagIDs |
| clang::DiagnosticsEngine* newlang::JIT::pDiagnosticsEngine |
Definition at line 111 of file jit.h.
Referenced by JIT(), LinkObjToExec(), MakeLLVMModule(), and ~JIT().
| std::vector<std::string> newlang::JIT::m_includes |
Definition at line 260 of file jit.h.
Referenced by MakeApplicationSource().