nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
nk::Engine Class Reference
Inheritance diagram for nk::Engine:

Classes

struct  EvalResult

Public Types

enum class  Backend { VM , TreeWalker }
using OutputFunc = std::function<void(const std::string &)>
using InputProvider = std::function<std::string()>
using ResolvedPath = FsContext::ResolvedPath
using OpenFile = FsContext::OpenFile

Public Member Functions

 Engine (std::pmr::memory_resource *mr)
 Engine (const Engine &)=delete
Engine & operator= (const Engine &)=delete
 Engine (Engine &&)=delete
Engine & operator= (Engine &&)=delete
std::pmr::memory_resource * resource () const noexcept
void registerBinaryOp (const std::string &op, BinaryOpFunc func)
void registerUnaryOp (const std::string &op, UnaryOpFunc func)
void registerFunction (const std::string &name, ExternalFunc func)
void registerFunction (const std::string &ns, const std::string &name, ExternalFunc func)
void registerClass (BuiltinClass cls)
const BuiltinClass * findClass (const std::string &name) const
void registerCallbackBuiltin (const std::string &name, std::shared_ptr< CallbackBuiltin > cb)
CallbackBuiltin * callbackBuiltin (const std::string &name) const
bool isUserCodeHandle (const Value &handle) const
void registerBuiltinMSource (const std::string &src)
void registerBuiltinClassSource (const std::string &src)
void reinstallBuiltinSources ()
void registerClassDef (const ASTNode *classdef, const std::string &qualifiedName="")
void clearClassDefs ()
std::vector< Value > invokeClassMethod (const UserFunction &uf, Span< const Value > args, size_t nout)
Value invokeClassCtor (const UserFunction &ctor, const Value &seed, Span< const Value > args)
const BytecodeChunk * ensureClassMethodChunk (const UserFunction &uf)
void enforceMethodAccess (const std::string &className, const std::string &method)
const UserFunction * classGetter (const std::string &className, const std::string &prop) const
const UserFunction * classSetter (const std::string &className, const std::string &prop) const
void enforcePropGetAccess (const std::string &className, const std::string &prop)
void enforcePropSetAccess (const std::string &className, const std::string &prop)
const BytecodeChunk * resolveBinaryOpChunk (const std::string &op, const Value &lhs, const Value &rhs, std::string &ownerClassOut)
const BytecodeChunk * resolveUnaryOpChunk (const std::string &op, const Value &operand, std::string &ownerClassOut)
const BytecodeChunk * resolveSubsrefChunk (const Value &self, Span< const Value > idx, std::string &ownerClassOut, std::vector< Value > &argsOut)
const BytecodeChunk * resolveSubsasgnChunk (const Value &self, Span< const Value > idxAndVal, std::string &ownerClassOut, std::vector< Value > &argsOut)
Value superConstruct (const std::string &base, const Value &seed, Span< const Value > args)
std::vector< Value > superMethod (const std::string &base, const std::string &method, Span< const Value > args, size_t nout)
void pushClassCtx (std::string className, bool isCtor)
void popClassCtx ()
bool classCtxAllows (const std::string &declClass, bool privateOnly) const
bool classCtxInCtorOf (const std::string &declClass) const
Value constructChecked (const BuiltinClass *cls, Span< const Value > args, CallContext &ctx)
Value makeDefaultInstance (const std::string &className)
const UserFunction * classCtor (const std::string &className) const
void enforceCtorAccess (const std::string &className)
std::string formatObjectDisplay (const std::string &name, const Value &obj) const
void displayObject (const std::string &name, const Value &obj)
bool tryObjectBinaryOp (const std::string &op, const Value &lhs, const Value &rhs, Environment *env, Value &out)
bool tryObjectUnaryOp (const std::string &op, const Value &operand, Environment *env, Value &out)
Value applyBinaryOp (const std::string &op, const Value &lhs, const Value &rhs)
Value applyUnaryOp (const std::string &op, const Value &operand)
void objectStoreSlice (Value &dst, const std::vector< std::vector< size_t > > &perDim, const Value &val, Environment *env)
bool tryObjectSubsref (Value &self, Span< const Value > args, std::size_t nargout, Value &out, Environment *env)
const std::vector< std::string > & namespaces () const
const std::unordered_multimap< std::string, std::string > & shortNameIndex () const
const ExternalFunc * findExternal (const std::string &name, const Environment *env) const
std::string bareNameSource (const std::string &name) const
bool isKnownLeafName (const std::string &name) const
void setVariable (const std::string &name, Value val)
Value * getVariable (const std::string &name)
Value eval (const std::string &code, bool suppressTopLevelDisplay=false)
Value evalStatement (const ASTNode *stmt, std::shared_ptr< const std::string > src)
void rewriteVarHeadedCommands (ASTNode *root)
Value eval (const std::string &code, Environment *scope, bool suppressTopLevelDisplay=false)
EvalResult evalSafe (const std::string &code)
void setBackend (Backend b)
Backend backend () const
void addFusionRule (FusionRule rule)
const std::vector< FusionRule > & fusionRules () const
void setFusion (bool on)
bool fusionEnabled () const
void noteFusionHit ()
size_t fusionHits () const
void resetFusionHits ()
void setOutputFunc (OutputFunc f)
OutputFunc outputFunc () const
void setInputProvider (InputProvider p)
const InputProvider & inputProvider () const
void setMaxRecursionDepth (int depth)
std::vector< std::string > workspaceVarNames () const
std::string workspaceJSON () const
void outputText (const std::string &s)
FigureManager & figureManager ()
const FigureManager & figureManager () const
Environment & workspaceEnv ()
Environment & constantsEnv ()
Environment & globalsEnv ()
bool hasFunction (const std::string &name) const
bool hasUserFunction (const std::string &name) const
bool hasExternalFunction (const std::string &name) const
bool hasCallableName (const std::string &name) const
Value callFunctionHandle (const Value &handle, Span< const Value > args, Environment *env=nullptr)
std::vector< Value > callFunctionHandleMulti (const Value &handle, Span< const Value > args, size_t nout, Environment *env=nullptr)
const UserFunction * lookupUserFunction (const std::string &name, const Environment *env)
const UserFunction * lookupUserFunctionLocal (const std::string &name) const
void clearUserFunctions ()
void adoptUserFunction (const std::string &name, UserFunction uf, bool scriptScope=false)
void addPath (const std::string &dir)
void rmPath (const std::string &dir)
const std::vector< std::string > & path () const
void rehashMFiles ()
void refreshStaleMFiles ()
void reloadEvictedClassBases_ (const std::vector< std::string > &bases)
void beginScript (const ASTNode *ast)
void endScript ()
void promoteScriptLocalsToWorkspace ()
DebugFacade debug ()
void reinstallConstants ()
void registerConstant (const std::string &name, Value val)
bool isReservedName (const std::string &name) const
void setTicTimer (TimePoint tp)
TimePoint ticTimer () const
bool ticWasCalled () const
bool isInsideFunctionCall () const
Environment * callerEnv (int n=0)
int callerDepth () const
void assignToCaller (int n, const std::string &name, Value val)
std::string inputName (int k)
void registerVirtualFS (std::unique_ptr< VirtualFS > fs)
VirtualFS * findVirtualFS (const std::string &name) const
void pushScriptOrigin (const std::string &fsName)
void pushScriptOrigin (const std::string &fsName, const std::string &scriptDir)
void popScriptOrigin ()
const std::string * currentScriptOrigin () const
const std::string * currentScriptDir () const
const std::string & cwd () const
void setCwd (const std::string &p)
ResolvedPath resolvePath (const std::string &userPath) const
FsContext & fsContext () noexcept
const FsContext & fsContext () const noexcept
ops::RngContext & rng () noexcept
const ops::RngContext & rng () const noexcept
int openFile (const std::string &userPath, const std::string &mode)
bool closeFile (int fid)
void closeAllFiles ()
OpenFile * findFile (int fid)
std::vector< int > openFileIds () const
const std::string & lastFopenError () const
void markClearAll ()
Compiler * compilerPtr ()

Friends

class DebugFacade
class TreeWalker
class VM
class DebugSession

Detailed Description

Definition at line 31 of file engine.hpp.

Member Typedef Documentation

◆ InputProvider

using nk::Engine::InputProvider = std::function<std::string()>

Definition at line 390 of file engine.hpp.

◆ OpenFile

using nk::Engine::OpenFile = FsContext::OpenFile

Definition at line 670 of file engine.hpp.

◆ OutputFunc

using nk::Engine::OutputFunc = std::function<void(const std::string &)>

Definition at line 381 of file engine.hpp.

◆ ResolvedPath

using nk::Engine::ResolvedPath = FsContext::ResolvedPath

Definition at line 647 of file engine.hpp.

Member Enumeration Documentation

◆ Backend

enum class nk::Engine::Backend
strong

Definition at line 363 of file engine.hpp.

Member Function Documentation

◆ addFusionRule()

void nk::Engine::addFusionRule ( FusionRule rule)
inline

Definition at line 370 of file engine.hpp.

◆ backend()

Backend nk::Engine::backend ( ) const
inline

Definition at line 365 of file engine.hpp.

◆ closeAllFiles()

void nk::Engine::closeAllFiles ( )
inline

Definition at line 674 of file engine.hpp.

◆ closeFile()

bool nk::Engine::closeFile ( int fid)
inline

Definition at line 673 of file engine.hpp.

◆ compilerPtr()

Compiler * nk::Engine::compilerPtr ( )
inline

Definition at line 831 of file engine.hpp.

◆ constantsEnv()

Environment & nk::Engine::constantsEnv ( )
inline

Definition at line 403 of file engine.hpp.

◆ cwd()

const std::string & nk::Engine::cwd ( ) const
inline

Definition at line 642 of file engine.hpp.

◆ debug()

DebugFacade nk::Engine::debug ( )
inline

Definition at line 883 of file engine.hpp.

◆ figureManager() [1/2]

FigureManager & nk::Engine::figureManager ( )
inline

Definition at line 399 of file engine.hpp.

◆ figureManager() [2/2]

const FigureManager & nk::Engine::figureManager ( ) const
inline

Definition at line 400 of file engine.hpp.

◆ findFile()

OpenFile * nk::Engine::findFile ( int fid)
inline

Definition at line 675 of file engine.hpp.

◆ fsContext() [1/2]

const FsContext & nk::Engine::fsContext ( ) const
inlinenoexcept

Definition at line 655 of file engine.hpp.

◆ fsContext() [2/2]

FsContext & nk::Engine::fsContext ( )
inlinenoexcept

Definition at line 654 of file engine.hpp.

◆ fusionEnabled()

bool nk::Engine::fusionEnabled ( ) const
inline

Definition at line 373 of file engine.hpp.

◆ fusionHits()

size_t nk::Engine::fusionHits ( ) const
inline

Definition at line 378 of file engine.hpp.

◆ fusionRules()

const std::vector< FusionRule > & nk::Engine::fusionRules ( ) const
inline

Definition at line 371 of file engine.hpp.

◆ globalsEnv()

Environment & nk::Engine::globalsEnv ( )
inline

Definition at line 404 of file engine.hpp.

◆ inputProvider()

const InputProvider & nk::Engine::inputProvider ( ) const
inline

Definition at line 392 of file engine.hpp.

◆ isKnownLeafName()

bool nk::Engine::isKnownLeafName ( const std::string & name) const
inline

Definition at line 311 of file engine.hpp.

◆ lastFopenError()

const std::string & nk::Engine::lastFopenError ( ) const
inline

Definition at line 677 of file engine.hpp.

◆ markClearAll()

void nk::Engine::markClearAll ( )
inline

Definition at line 824 of file engine.hpp.

◆ namespaces()

const std::vector< std::string > & nk::Engine::namespaces ( ) const
inline

Definition at line 278 of file engine.hpp.

◆ noteFusionHit()

void nk::Engine::noteFusionHit ( )
inline

Definition at line 377 of file engine.hpp.

◆ openFile()

int nk::Engine::openFile ( const std::string & userPath,
const std::string & mode )
inline

Definition at line 671 of file engine.hpp.

◆ openFileIds()

std::vector< int > nk::Engine::openFileIds ( ) const
inline

Definition at line 676 of file engine.hpp.

◆ outputFunc()

OutputFunc nk::Engine::outputFunc ( ) const
inline

Definition at line 383 of file engine.hpp.

◆ path()

const std::vector< std::string > & nk::Engine::path ( ) const
inline

Definition at line 480 of file engine.hpp.

◆ resetFusionHits()

void nk::Engine::resetFusionHits ( )
inline

Definition at line 379 of file engine.hpp.

◆ resource()

std::pmr::memory_resource * nk::Engine::resource ( ) const
inlinenoexcept

Definition at line 49 of file engine.hpp.

◆ rng() [1/2]

const ops::RngContext & nk::Engine::rng ( ) const
inlinenoexcept

Definition at line 661 of file engine.hpp.

◆ rng() [2/2]

ops::RngContext & nk::Engine::rng ( )
inlinenoexcept

Definition at line 660 of file engine.hpp.

◆ setBackend()

void nk::Engine::setBackend ( Backend b)
inline

Definition at line 364 of file engine.hpp.

◆ setCwd()

void nk::Engine::setCwd ( const std::string & p)
inline

Definition at line 643 of file engine.hpp.

◆ setFusion()

void nk::Engine::setFusion ( bool on)
inline

Definition at line 372 of file engine.hpp.

◆ setInputProvider()

void nk::Engine::setInputProvider ( InputProvider p)
inline

Definition at line 391 of file engine.hpp.

◆ setTicTimer()

void nk::Engine::setTicTimer ( TimePoint tp)
inline

Definition at line 558 of file engine.hpp.

◆ shortNameIndex()

const std::unordered_multimap< std::string, std::string > & nk::Engine::shortNameIndex ( ) const
inline

Definition at line 283 of file engine.hpp.

◆ ticTimer()

TimePoint nk::Engine::ticTimer ( ) const
inline

Definition at line 563 of file engine.hpp.

◆ ticWasCalled()

bool nk::Engine::ticWasCalled ( ) const
inline

Definition at line 564 of file engine.hpp.

◆ workspaceEnv()

Environment & nk::Engine::workspaceEnv ( )
inline

Definition at line 402 of file engine.hpp.

◆ DebugFacade

friend class DebugFacade
friend

Definition at line 524 of file engine.hpp.

◆ DebugSession

friend class DebugSession
friend

Definition at line 861 of file engine.hpp.

◆ TreeWalker

friend class TreeWalker
friend

Definition at line 859 of file engine.hpp.

◆ VM

friend class VM
friend

Definition at line 860 of file engine.hpp.


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