NewLang Project
Yet another programm language
|
#include <variable.h>
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 Variable & | operator* () 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 | |
Variable & | operator+= (const Variable &other) |
const Variable | operator+ (const Variable &other) |
Variable & | operator-= (const Variable &other) |
const Variable | operator- (const Variable &other) |
Variable & | operator*= (const Variable &other) |
const Variable | operator* (const Variable &other) |
Variable & | operator/= (const Variable &other) |
const Variable | operator/ (const Variable &other) |
Variable & | operator%= (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 |
Variable - главный класс для хранения объектов во время выполнения приложения. Все операции с объектами выполняются для этой струкутры.
Variable не зависит от типов переменных или ограничений для них во время компиляции. Он хранит не только значение, но и объект синхронизации досутпа к переменной.
Может хранить строго типизированные данные, тип которых задан во время компиляции или универсальный тип данных (словари, функции, классы и перечисления) в Obj (ObjPtr).
Для переменных по значению данные хранятся непосредственно в Variable Для ссылочных и защищенных переменных в Variable хранится std::shared_ptr<Variable>. У ссылок в Variable хранятся слабый указатель на std::shared_ptr<Variable> ссылочной переменной, а захваченные переменные содержат VariableTaken.
Definition at line 478 of file variable.h.
|
inlineexplicit |
Definition at line 539 of file variable.h.
|
inline |
Template for create variable by value
value | - Base type value (copyable) |
Definition at line 547 of file variable.h.
|
inline |
Definition at line 551 of file variable.h.
|
inline |
Definition at line 556 of file variable.h.
|
staticprotected |
Definition at line 166 of file variable.cpp.
|
inlineprotected |
Definition at line 509 of file variable.h.
References newlang::VariableOp::copy.
|
inlinestaticprotected |
Definition at line 513 of file variable.h.
Definition at line 181 of file variable.cpp.
References newlang::Obj::CreateRational(), newlang::Obj::CreateString(), newlang::Obj::CreateValue(), LOG_RUNTIME, and newlang::VariableCaseToString().
Referenced by Object().
|
static |
Definition at line 177 of file variable.cpp.
References Object(), and newlang::VariablePair::var.
|
inline |
Definition at line 591 of file variable.h.
Referenced by newlang::Context::EvalLeftVars_(), newlang::Context::EvalTerm(), and newlang::GlobalObjects::RegisterObject().
|
inline |
Definition at line 595 of file variable.h.
References STATIC_ASSERT, and newlang::TAKEN.
Referenced by newlang::VariableOp::__clone__(), newlang::VariableOp::__copy__(), GetValueAsBoolean(), GetValueAsInteger(), GetValueAsNumber(), GetValueAsObject(), GetValueAsPointer(), GetValueAsRational(), GetValueAsString(), GetValueAsStringWide(), operator*(), and toString().
|
inline |
Definition at line 601 of file variable.h.
Variable Variable::Ref | ( | const std::string_view | ref | ) | const |
Definition at line 200 of file variable.cpp.
References LOG_RUNTIME, and newlang::VariableCaseToString().
|
inline |
Definition at line 610 of file variable.h.
Referenced by newlang::Context::EvalTerm(), and operator*().
|
inline |
Definition at line 615 of file variable.h.
References is_taked(), and Take().
bool Variable::GetValueAsBoolean | ( | ) | const |
Definition at line 265 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, GetValueAsInteger(), newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Referenced by operator bool(), and newlang::Parser::PragmaStaticAssert().
int64_t Variable::GetValueAsInteger | ( | ) | const |
Definition at line 298 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Referenced by newlang::VariableOp::__eq__(), GetValueAsBoolean(), operator int64_t(), and operator uint64_t().
double Variable::GetValueAsNumber | ( | ) | const |
Definition at line 325 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Referenced by newlang::VariableOp::__eq__().
std::string & Variable::GetValueAsString | ( | ) |
Definition at line 360 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Referenced by newlang::VariableOp::__eq__().
std::wstring & Variable::GetValueAsStringWide | ( | ) |
Definition at line 390 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Rational Variable::GetValueAsRational | ( | ) | const |
Definition at line 421 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Referenced by newlang::VariableOp::__eq__(), and operator Rational().
ObjPtr Variable::GetValueAsObject | ( | ) | const |
Definition at line 458 of file variable.cpp.
References newlang::Obj::CreateNone(), newlang::Obj::CreateRational(), newlang::Obj::CreateString(), newlang::Obj::CreateValue(), newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Referenced by newlang::Context::Call(), newlang::Context::Call(), newlang::Context::EvalCreateAsEllipsis_(), newlang::Context::EvalCreateAsValue_(), newlang::Context::EvalInterrupt_(), newlang::Context::EvalIterator_(), newlang::Context::EvalOpCompare_(), newlang::Context::EvalOpMath_(), newlang::Context::EvalTerm(), newlang::Context::EvalTryBlock_(), newlang::Context::GetIndexValue(), newlang::JIT::Run(), and newlang::Context::SetIndexValue().
void * Variable::GetValueAsPointer | ( | ) | const |
Definition at line 507 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), LOG_RUNTIME, newlang::OBJECT, newlang::RATIONAL, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::VariableCaseToString(), newlang::WEAK, and newlang::WSTRING.
Referenced by operator void *().
std::string Variable::toString | ( | ) | const |
Definition at line 543 of file variable.cpp.
References newlang::DOUBLE, newlang::EMPTY, newlang::INTEGER, is_taked(), newlang::OBJECT, newlang::RATIONAL, result, newlang::SHARED, newlang::STRING, newlang::TAKEN, newlang::WEAK, and newlang::WSTRING.
Referenced by newlang::VariableTaken::MakeTimeoutMessage(), operator std::string(), operator std::wstring(), and operator uint64_t().
|
inlineexplicit |
Definition at line 639 of file variable.h.
References GetValueAsBoolean().
|
inlineexplicit |
Definition at line 659 of file variable.h.
|
inlineexplicit |
Definition at line 659 of file variable.h.
|
inlineexplicit |
Definition at line 660 of file variable.h.
|
inlineexplicit |
Definition at line 660 of file variable.h.
|
inlineexplicit |
Definition at line 661 of file variable.h.
|
inlineexplicit |
Definition at line 661 of file variable.h.
|
inlineexplicit |
Definition at line 663 of file variable.h.
References GetValueAsInteger().
|
inlineexplicit |
Definition at line 667 of file variable.h.
References GetValueAsInteger(), LOG_RUNTIME, result, and toString().
|
inlineexplicit |
Definition at line 696 of file variable.h.
References toString().
|
inlineexplicit |
Definition at line 700 of file variable.h.
References toString(), and newlang::utf8_decode().
|
inlineexplicit |
Definition at line 704 of file variable.h.
References GetValueAsPointer().
|
inlineexplicit |
Definition at line 708 of file variable.h.
References GetValueAsRational().
Definition at line 719 of file variable.h.
References newlang::VariableOp::iadd.
Definition at line 723 of file variable.h.
References newlang::VariableOp::copy, and result.
Definition at line 729 of file variable.h.
References newlang::VariableOp::isub.
Definition at line 733 of file variable.h.
References newlang::VariableOp::copy, and result.
Definition at line 739 of file variable.h.
References newlang::VariableOp::imul.
Definition at line 743 of file variable.h.
References newlang::VariableOp::copy, and result.
Definition at line 749 of file variable.h.
References newlang::VariableOp::itruediv.
Definition at line 753 of file variable.h.
References newlang::VariableOp::copy, and result.
Definition at line 759 of file variable.h.
References newlang::VariableOp::imod.
Definition at line 763 of file variable.h.
References newlang::VariableOp::copy, and result.
bool Variable::is_object_type | ( | ) | const |
Definition at line 695 of file variable.cpp.
References newlang::OBJECT.
Referenced by newlang::Context::EvalTryBlock_().
bool Variable::is_scalar_type | ( | ) | const |
Definition at line 704 of file variable.cpp.
References newlang::DOUBLE, newlang::INTEGER, newlang::OBJECT, and newlang::RATIONAL.
Referenced by newlang::VariableOp::__eq__().
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__().
bool Variable::is_complex_type | ( | ) | const |
Definition at line 728 of file variable.cpp.
References newlang::OBJECT.
Referenced by newlang::VariableOp::__eq__().
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__().
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__().
|
inline |
Definition at line 784 of file variable.h.
References newlang::VariableOp::eq.
|
inline |
Definition at line 788 of file variable.h.
References newlang::VariableOp::eq.
|
inline |
Definition at line 793 of file variable.h.
References newlang::VariableOp::eq.
|
inline |
Definition at line 798 of file variable.h.
References newlang::VariableOp::eq.
|
inline |
Definition at line 803 of file variable.h.
References newlang::VariableOp::eq.
|
inline |
Definition at line 808 of file variable.h.
References newlang::VariableOp::eq.
|
inline |
Definition at line 813 of file variable.h.
References newlang::VariableOp::eq.
Referenced by newlang::VariableOp::__eq__().
|
inline |
Definition at line 818 of file variable.h.
References newlang::VariableOp::strict_eq.
|
friend |
Definition at line 479 of file variable.h.