xo-expression2: + DVariable
This commit is contained in:
parent
e7de2c97fe
commit
2178d78540
3 changed files with 76 additions and 0 deletions
56
xo-expression2/include/xo/expression2/DVariable.hpp
Normal file
56
xo-expression2/include/xo/expression2/DVariable.hpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/** @file DVariable.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DUniqueString.hpp"
|
||||
#include "Binding.hpp"
|
||||
#include "TypeRef.hpp"
|
||||
#include "exprtype.hpp"
|
||||
#include <xo/reflect/TypeDescr.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/** @class DVariable*
|
||||
* @brief syntax for a variable reference
|
||||
**/
|
||||
class DVariable {
|
||||
public:
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
|
||||
public:
|
||||
DVariable(const DUniqueString & name, const TypeRef & typeref, Binding path)
|
||||
: name_{name}, typeref_{typeref}, path_{path} {}
|
||||
|
||||
const DUniqueString & name() const { return name_; }
|
||||
Binding path() const { return path_; }
|
||||
|
||||
/** @defgroup scm-variable-expression-facet**/
|
||||
///@{
|
||||
|
||||
exprtype extype() const noexcept { return exprtype::variable; }
|
||||
TypeRef typeref() const noexcept { return typeref_; }
|
||||
TypeDescr valuetype() const noexcept { return typeref_.td(); };
|
||||
void assign_valuetype(TypeDescr td) noexcept;
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** symbol name **/
|
||||
const DUniqueString & name_;
|
||||
/** variable value always has type consistent
|
||||
* with this description
|
||||
**/
|
||||
TypeRef typeref_;
|
||||
/** at runtime: navigate environemnt via this path to get
|
||||
* runtime memory location for this variable
|
||||
**/
|
||||
Binding path_;
|
||||
};
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DVariable.hpp */
|
||||
|
|
@ -4,6 +4,7 @@ set(SELF_LIB xo_expression2)
|
|||
set(SELF_SRCS
|
||||
init_expression2.cpp
|
||||
DConstant.cpp
|
||||
DVariable.cpp
|
||||
TypeRef.cpp
|
||||
IExpression_Any.cpp
|
||||
IExpression_DConstant.cpp
|
||||
|
|
|
|||
19
xo-expression2/src/expression2/DVariable.cpp
Normal file
19
xo-expression2/src/expression2/DVariable.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/** @file DVariable.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DVariable.hpp"
|
||||
#include "exprtype.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
void
|
||||
DVariable::assign_valuetype(TypeDescr td) noexcept
|
||||
{
|
||||
typeref_.resolve(td);
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DVariable.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue