xo-expression: initial commit (constant + primitive)
This commit is contained in:
commit
2d94fd51bf
17 changed files with 544 additions and 0 deletions
41
include/xo/expression/ConstantInterface.hpp
Normal file
41
include/xo/expression/ConstantInterface.hpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/** @file ConstantInterface.hpp
|
||||
*
|
||||
* Author: Roland Conybeare
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Expression.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
#include "xo/reflect/TypeDescr.hpp"
|
||||
#include <type_traits>
|
||||
|
||||
namespace xo {
|
||||
namespace ast {
|
||||
/** @class ConstantInterface
|
||||
* @brief syntax for a literal constant.
|
||||
**/
|
||||
class ConstantInterface : public Expression {
|
||||
public:
|
||||
using TaggedPtr = xo::reflect::TaggedPtr;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
|
||||
public:
|
||||
/** @p extype sets expression-type; could be constant|primitive **/
|
||||
ConstantInterface(exprtype extype) : Expression{extype} {}
|
||||
|
||||
/** downcast from Expression **/
|
||||
static ref::brw<ConstantInterface> from(ref::brw<Expression> x) {
|
||||
return ref::brw<ConstantInterface>::from(x);
|
||||
}
|
||||
|
||||
/** type description for representation of literal value **/
|
||||
virtual TypeDescr value_td() const = 0;
|
||||
/** reflection-tagged pointer to literal value of this constant **/
|
||||
virtual TaggedPtr value_tp() const = 0;
|
||||
}; /*ConstantInterface*/
|
||||
|
||||
} /*namespace ast*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end ConstantInterface.hpp **/
|
||||
Loading…
Add table
Add a link
Reference in a new issue