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

#include <variable.h>

Inheritance diagram for newlang::Variable:

Public Member Functions

 Variable (ObjPtr obj)
 
template<class T , typename = typename std::enable_if<!is_shared_ptr<decltype(std::declval<T>())>::value, ::type >
 Variable (T value)
 
template<typename T , typename = typename std::enable_if<!is_shared_ptr<decltype(std::declval<T>())>::value, ::type >
 Variable (T value, const TermPtr &&term)
 
template<typename T , typename = typename std::enable_if<!is_shared_ptr<decltype(std::declval<T>())>::value, ::type >
 Variable (T value, const std::string_view ref)
 
bool is_undefined () const
 
bool is_taked () const
 
bool is_shared () const
 
Variable Ref (const std::string_view ref) const
 
Variable Take (bool edit_mode=false, const std::chrono::milliseconds &timeout_duration=Sync::SyncTimeoutDeedlock, const std::string_view message="", const std::source_location location=std::source_location::current()) const
 
const Variableoperator* () const
 
bool GetValueAsBoolean () const
 
int64_t GetValueAsInteger () const
 
double GetValueAsNumber () const
 
std::string & GetValueAsString ()
 
std::wstring & GetValueAsStringWide ()
 
Rational GetValueAsRational () const
 
ObjPtr GetValueAsObject () const
 
void * GetValueAsPointer () const
 
std::string toString () const
 
 operator bool () const
 
 operator int8_t () const
 
 operator uint8_t () const
 
 operator int16_t () const
 
 operator uint16_t () const
 
 operator int32_t () const
 
 operator uint32_t () const
 
 operator int64_t () const
 
 operator uint64_t () const
 
 operator std::string () const
 
 operator std::wstring () const
 
 operator void * () const
 
 operator Rational () const
 
Variableoperator+= (const Variable &other)
 
const Variable operator+ (const Variable &other)
 
Variableoperator-= (const Variable &other)
 
const Variable operator- (const Variable &other)
 
Variableoperator*= (const Variable &other)
 
const Variable operator* (const Variable &other)
 
Variableoperator/= (const Variable &other)
 
const Variable operator/ (const Variable &other)
 
Variableoperator%= (const Variable &other)
 
const Variable operator% (const Variable &other)
 
bool is_object_type () const
 
bool is_scalar_type () const
 
bool is_floating_type () const
 
bool is_complex_type () const
 
bool is_rational_type () const
 
bool is_string_type () const
 
bool operator== (const Variable &other) const
 
bool operator<= (const Variable &other) const
 
bool operator< (const Variable &other) const
 
bool operator>= (const Variable &other) const
 
bool operator> (const Variable &other) const
 
bool operator!= (const Variable &other) const
 
int compare (const Variable &other) const
 
bool strict_eq (const Variable &other) const
 

Static Public Member Functions

static ObjPtr Object (Variable *variable)
 
static ObjPtr Object (VariablePair *pair)
 

Protected Member Functions

Variable copy ()
 

Static Protected Member Functions

static bool isShared (const TermPtr &term)
 
static VariablePtr UndefinedPtr ()
 

Friends

class GlobalObjects
 

Detailed Description

Variable - главный класс для хранения объектов во время выполнения приложения. Все операции с объектами выполняются для этой струкутры.

Variable не зависит от типов переменных или ограничений для них во время компиляции. Он хранит не только значение, но и объект синхронизации досутпа к переменной.

Может хранить строго типизированные данные, тип которых задан во время компиляции или универсальный тип данных (словари, функции, классы и перечисления) в Obj (ObjPtr).

Для переменных по значению данные хранятся непосредственно в Variable Для ссылочных и защищенных переменных в Variable хранится std::shared_ptr<Variable>. У ссылок в Variable хранятся слабый указатель на std::shared_ptr<Variable> ссылочной переменной, а захваченные переменные содержат VariableTaken.

Definition at line 478 of file variable.h.

Constructor & Destructor Documentation

◆ Variable() [1/4]

newlang::Variable::Variable ( ObjPtr obj)
inlineexplicit

Definition at line 539 of file variable.h.

◆ Variable() [2/4]

template<class T , typename = typename std::enable_if<!is_shared_ptr<decltype(std::declval<T>())>::value, ::type >
newlang::Variable::Variable ( T value)
inline

Template for create variable by value

Parameters
value- Base type value (copyable)

Definition at line 547 of file variable.h.

◆ Variable() [3/4]

template<typename T , typename = typename std::enable_if<!is_shared_ptr<decltype(std::declval<T>())>::value, ::type >
newlang::Variable::Variable ( T value,
const TermPtr && term )
inline

Definition at line 551 of file variable.h.

◆ Variable() [4/4]

template<typename T , typename = typename std::enable_if<!is_shared_ptr<decltype(std::declval<T>())>::value, ::type >
newlang::Variable::Variable ( T value,
const std::string_view ref )
inline

Definition at line 556 of file variable.h.

Member Function Documentation

◆ isShared()

bool Variable::isShared ( const TermPtr & term)
staticprotected

Definition at line 166 of file variable.cpp.

◆ copy()

Variable newlang::Variable::copy ( )
inlineprotected

Definition at line 509 of file variable.h.

References newlang::VariableOp::copy.

◆ UndefinedPtr()

static VariablePtr newlang::Variable::UndefinedPtr ( )
inlinestaticprotected

Definition at line 513 of file variable.h.

◆ Object() [1/2]

ObjPtr Variable::Object ( Variable * variable)
static

◆ Object() [2/2]

ObjPtr Variable::Object ( VariablePair * pair)
static

Definition at line 177 of file variable.cpp.

References Object(), and newlang::VariablePair::var.

◆ is_undefined()

bool newlang::Variable::is_undefined ( ) const
inline

◆ is_taked()

◆ is_shared()

bool newlang::Variable::is_shared ( ) const
inline

Definition at line 601 of file variable.h.

◆ Ref()

Variable Variable::Ref ( const std::string_view ref) const

Definition at line 200 of file variable.cpp.

References LOG_RUNTIME, and newlang::VariableCaseToString().

◆ Take()

Variable newlang::Variable::Take ( bool edit_mode = false,
const std::chrono::milliseconds & timeout_duration = Sync::SyncTimeoutDeedlock,
const std::string_view message = "",
const std::source_location location = std::source_location::current() ) const
inline

Definition at line 610 of file variable.h.

Referenced by newlang::Context::EvalTerm(), and operator*().

◆ operator*() [1/2]

const Variable & newlang::Variable::operator* ( ) const
inline

Definition at line 615 of file variable.h.

References is_taked(), and Take().

◆ GetValueAsBoolean()

◆ GetValueAsInteger()

◆ GetValueAsNumber()

◆ GetValueAsString()

◆ GetValueAsStringWide()

◆ GetValueAsRational()

◆ GetValueAsObject()

◆ GetValueAsPointer()

◆ toString()

◆ operator bool()

newlang::Variable::operator bool ( ) const
inlineexplicit

Definition at line 639 of file variable.h.

References GetValueAsBoolean().

◆ operator int8_t()

newlang::Variable::operator int8_t ( ) const
inlineexplicit

Definition at line 659 of file variable.h.

◆ operator uint8_t()

newlang::Variable::operator uint8_t ( ) const
inlineexplicit

Definition at line 659 of file variable.h.

◆ operator int16_t()

newlang::Variable::operator int16_t ( ) const
inlineexplicit

Definition at line 660 of file variable.h.

◆ operator uint16_t()

newlang::Variable::operator uint16_t ( ) const
inlineexplicit

Definition at line 660 of file variable.h.

◆ operator int32_t()

newlang::Variable::operator int32_t ( ) const
inlineexplicit

Definition at line 661 of file variable.h.

◆ operator uint32_t()

newlang::Variable::operator uint32_t ( ) const
inlineexplicit

Definition at line 661 of file variable.h.

◆ operator int64_t()

newlang::Variable::operator int64_t ( ) const
inlineexplicit

Definition at line 663 of file variable.h.

References GetValueAsInteger().

◆ operator uint64_t()

newlang::Variable::operator uint64_t ( ) const
inlineexplicit

Definition at line 667 of file variable.h.

References GetValueAsInteger(), LOG_RUNTIME, result, and toString().

◆ operator std::string()

newlang::Variable::operator std::string ( ) const
inlineexplicit

Definition at line 696 of file variable.h.

References toString().

◆ operator std::wstring()

newlang::Variable::operator std::wstring ( ) const
inlineexplicit

Definition at line 700 of file variable.h.

References toString(), and newlang::utf8_decode().

◆ operator void *()

newlang::Variable::operator void * ( ) const
inlineexplicit

Definition at line 704 of file variable.h.

References GetValueAsPointer().

◆ operator Rational()

newlang::Variable::operator Rational ( ) const
inlineexplicit

Definition at line 708 of file variable.h.

References GetValueAsRational().

◆ operator+=()

Variable & newlang::Variable::operator+= ( const Variable & other)
inline

Definition at line 719 of file variable.h.

References newlang::VariableOp::iadd.

◆ operator+()

const Variable newlang::Variable::operator+ ( const Variable & other)
inline

Definition at line 723 of file variable.h.

References newlang::VariableOp::copy, and result.

◆ operator-=()

Variable & newlang::Variable::operator-= ( const Variable & other)
inline

Definition at line 729 of file variable.h.

References newlang::VariableOp::isub.

◆ operator-()

const Variable newlang::Variable::operator- ( const Variable & other)
inline

Definition at line 733 of file variable.h.

References newlang::VariableOp::copy, and result.

◆ operator*=()

Variable & newlang::Variable::operator*= ( const Variable & other)
inline

Definition at line 739 of file variable.h.

References newlang::VariableOp::imul.

◆ operator*() [2/2]

const Variable newlang::Variable::operator* ( const Variable & other)
inline

Definition at line 743 of file variable.h.

References newlang::VariableOp::copy, and result.

◆ operator/=()

Variable & newlang::Variable::operator/= ( const Variable & other)
inline

Definition at line 749 of file variable.h.

References newlang::VariableOp::itruediv.

◆ operator/()

const Variable newlang::Variable::operator/ ( const Variable & other)
inline

Definition at line 753 of file variable.h.

References newlang::VariableOp::copy, and result.

◆ operator%=()

Variable & newlang::Variable::operator%= ( const Variable & other)
inline

Definition at line 759 of file variable.h.

References newlang::VariableOp::imod.

◆ operator%()

const Variable newlang::Variable::operator% ( const Variable & other)
inline

Definition at line 763 of file variable.h.

References newlang::VariableOp::copy, and result.

◆ is_object_type()

bool Variable::is_object_type ( ) const

Definition at line 695 of file variable.cpp.

References newlang::OBJECT.

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

◆ is_scalar_type()

bool Variable::is_scalar_type ( ) const

◆ is_floating_type()

bool Variable::is_floating_type ( ) const

Definition at line 717 of file variable.cpp.

References newlang::DOUBLE, and newlang::OBJECT.

Referenced by newlang::VariableOp::__eq__().

◆ is_complex_type()

bool Variable::is_complex_type ( ) const

Definition at line 728 of file variable.cpp.

References newlang::OBJECT.

Referenced by newlang::VariableOp::__eq__().

◆ is_rational_type()

bool Variable::is_rational_type ( ) const

Definition at line 741 of file variable.cpp.

References newlang::OBJECT, and newlang::RATIONAL.

Referenced by newlang::VariableOp::__eq__().

◆ is_string_type()

bool Variable::is_string_type ( ) const

Definition at line 752 of file variable.cpp.

References newlang::OBJECT, newlang::STRING, and newlang::WSTRING.

Referenced by newlang::VariableOp::__eq__().

◆ operator==()

bool newlang::Variable::operator== ( const Variable & other) const
inline

Definition at line 784 of file variable.h.

References newlang::VariableOp::eq.

◆ operator<=()

bool newlang::Variable::operator<= ( const Variable & other) const
inline

Definition at line 788 of file variable.h.

References newlang::VariableOp::eq.

◆ operator<()

bool newlang::Variable::operator< ( const Variable & other) const
inline

Definition at line 793 of file variable.h.

References newlang::VariableOp::eq.

◆ operator>=()

bool newlang::Variable::operator>= ( const Variable & other) const
inline

Definition at line 798 of file variable.h.

References newlang::VariableOp::eq.

◆ operator>()

bool newlang::Variable::operator> ( const Variable & other) const
inline

Definition at line 803 of file variable.h.

References newlang::VariableOp::eq.

◆ operator!=()

bool newlang::Variable::operator!= ( const Variable & other) const
inline

Definition at line 808 of file variable.h.

References newlang::VariableOp::eq.

◆ compare()

int newlang::Variable::compare ( const Variable & other) const
inline

Definition at line 813 of file variable.h.

References newlang::VariableOp::eq.

Referenced by newlang::VariableOp::__eq__().

◆ strict_eq()

bool newlang::Variable::strict_eq ( const Variable & other) const
inline

Definition at line 818 of file variable.h.

References newlang::VariableOp::strict_eq.

Friends And Related Symbol Documentation

◆ GlobalObjects

friend class GlobalObjects
friend

Definition at line 479 of file variable.h.


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