NewLang Project
Yet another programm language
Loading...
Searching...
No Matches
runtime.h File Reference
#include <sys/time.h>
#include <ffi.h>
#include <dlfcn.h>
#include <cstring>
#include "nlc-rt.h"
#include "term.h"
#include "diag.h"
#include "module.h"
#include "context.h"
Include dependency graph for runtime.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  newlang::FileModule
 
struct  newlang::Func
 
class  newlang::RunTime
 

Namespaces

namespace  newlang
 

Macros

#define INCLUDED_RUNTIME_CPP_
 
#define DEADLOCK_TIMEOUT   std::chrono::seconds(5)
 
#define SCOPE_LOCK_DEADLOCK_MESSAGE(THIS)   LOG_RUNTIME("Deadlock timeout!")
 
#define SCOPE_LOCK_READ_NAME(THIS, VARNAME)
 
#define SCOPE_LOCK_WRITE_NAME(THIS, VARNAME)
 
#define SCOPE_LOCK_READ(THIS)   SCOPE_LOCK_READ_NAME(THIS, r_lock)
 
#define SCOPE_LOCK_WRITE(THIS)   SCOPE_LOCK_WRITE_NAME(THIS, w_lock)
 

Typedefs

typedef std::shared_timed_mutex newlang::Lock
 
typedef std::unique_lock< Locknewlang::WriteLock
 
typedef std::shared_lock< Locknewlang::ReadLock
 

Functions

ObjPtr CreateTensor (torch::Tensor tensor)
 
void ConvertStringToTensor (const std::string &from, torch::Tensor &to, ObjType type)
 
EXTERN_C int newlang::nlc_prinft_sub_ (char const *format,...)
 
int newlang::RunMain (const int arg, const char **argv, const char **penv)
 
std::string newlang::GetFileExt (const char *str)
 
std::string newlang::AddDefaultFileExt (const char *str, const char *ext_default)
 
std::string newlang::ReplaceFileExt (const char *str, const char *ext_old, const char *ext_new)
 
std::string newlang::ReadFile (const char *fileName)
 
std::string newlang::GetDoc (std::string name)
 
std::string newlang::MakeConstructorName (std::string name)
 
std::string newlang::MakeLocalName (std::string name)
 
ObjType newlang::typeFromString (TermPtr &term, RunTime *rt, bool *has_error)
 

Macro Definition Documentation

◆ INCLUDED_RUNTIME_CPP_

#define INCLUDED_RUNTIME_CPP_

Definition at line 3 of file runtime.h.

◆ DEADLOCK_TIMEOUT

#define DEADLOCK_TIMEOUT   std::chrono::seconds(5)

Definition at line 159 of file runtime.h.

◆ SCOPE_LOCK_DEADLOCK_MESSAGE

#define SCOPE_LOCK_DEADLOCK_MESSAGE ( THIS)    LOG_RUNTIME("Deadlock timeout!")

Definition at line 172 of file runtime.h.

◆ SCOPE_LOCK_READ_NAME

#define SCOPE_LOCK_READ_NAME ( THIS,
VARNAME )
Value:
ReadLock VARNAME(*THIS, std::defer_lock);\
if (!VARNAME.try_lock_for(DEADLOCK_TIMEOUT)) \
SCOPE_LOCK_DEADLOCK_MESSAGE(THIS)
std::shared_lock< Lock > ReadLock
Definition runtime.h:169
#define DEADLOCK_TIMEOUT
Definition runtime.h:159

Definition at line 174 of file runtime.h.

◆ SCOPE_LOCK_WRITE_NAME

#define SCOPE_LOCK_WRITE_NAME ( THIS,
VARNAME )
Value:
WriteLock VARNAME(*THIS, std::defer_lock);\
if (!VARNAME.try_lock_for(DEADLOCK_TIMEOUT)) \
SCOPE_LOCK_DEADLOCK_MESSAGE(THIS)
std::unique_lock< Lock > WriteLock
Definition runtime.h:168

Definition at line 178 of file runtime.h.

◆ SCOPE_LOCK_READ

#define SCOPE_LOCK_READ ( THIS)    SCOPE_LOCK_READ_NAME(THIS, r_lock)

Definition at line 182 of file runtime.h.

◆ SCOPE_LOCK_WRITE

#define SCOPE_LOCK_WRITE ( THIS)    SCOPE_LOCK_WRITE_NAME(THIS, w_lock)

Definition at line 183 of file runtime.h.

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

Function Documentation

◆ CreateTensor()

ObjPtr CreateTensor ( torch::Tensor tensor)

Definition at line 52 of file object.cpp.

◆ ConvertStringToTensor()

void ConvertStringToTensor ( const std::string & from,
torch::Tensor & to,
ObjType type )

Definition at line 2151 of file object.cpp.

References LOG_RUNTIME, and toTorchType().

Referenced by newlang::Obj::toType_().