xo-expression2: + IExpression_DVariable
This commit is contained in:
parent
b3215da360
commit
f38c90db91
13 changed files with 187 additions and 32 deletions
|
|
@ -5,48 +5,45 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "TypeRef.hpp"
|
||||
#include "exprtype.hpp"
|
||||
#include <xo/reflect/TaggedPtr.hpp>
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
#include "Binding.hpp"
|
||||
#include "DUniqueString.hpp"
|
||||
//#include "exprtype.hpp"
|
||||
//#include <xo/reflect/TaggedPtr.hpp>
|
||||
//#include <xo/gc/GCObject.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class DLocalSymtab
|
||||
* @brief Schematika expression respresenting a literal constant
|
||||
* @brief symbol table for a local stack frame
|
||||
**/
|
||||
struct DLocalSymtab {
|
||||
public:
|
||||
using TaggedPtr = xo::reflect::TaggedPtr;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using typeseq = xo::reflect::typeseq;
|
||||
// using TaggedPtr = xo::reflect::TaggedPtr;
|
||||
// using TypeDescr = xo::reflect::TypeDescr;
|
||||
// using AGCObject = xo::mm::AGCObject;
|
||||
// using typeseq = xo::reflect::typeseq;
|
||||
|
||||
struct Slot {
|
||||
// obj<Expression,DVariable> var_;
|
||||
Binding binding_;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit DLocalSymtab(obj<AGCObject> value) noexcept;
|
||||
// explicit DLocalSymtab(obj<AGCObject> value) noexcept;
|
||||
|
||||
bool is_resolved() const noexcept { return typeref_.is_resolved(); }
|
||||
/** @defgroup xo-expression2-symboltable-facet symboltable facet**/
|
||||
///@{
|
||||
|
||||
exprtype extype() const noexcept { return exprtype::constant; }
|
||||
TypeDescr value_td() const noexcept { return typeref_.td(); }
|
||||
TaggedPtr value_tp() const noexcept { return TaggedPtr(typeref_.td(), value_.data()); }
|
||||
/** true for global symbol table **/
|
||||
bool is_global_symtab() const noexcept { return false; }
|
||||
|
||||
TypeRef typeref() const noexcept { return typeref_; }
|
||||
TypeDescr valuetype() const noexcept { return typeref_.td(); }
|
||||
obj<AGCObject> value() const noexcept { return value_; }
|
||||
/** lookup binding for variable @p sym **/
|
||||
Binding lookup_binding(const DUniqueString * sym) const noexcept;
|
||||
|
||||
void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); }
|
||||
///@}
|
||||
|
||||
private:
|
||||
static TypeDescr _lookup_td(typeseq tseq);
|
||||
|
||||
private:
|
||||
/** type for value of this expression
|
||||
* or unification breadcrumb before unification
|
||||
**/
|
||||
TypeRef typeref_;
|
||||
/** literal value **/
|
||||
obj<AGCObject> value_;
|
||||
};
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
|
|
@ -18,4 +18,5 @@
|
|||
#include "detail/IExpression_Xfer.hpp"
|
||||
#include "detail/RExpression.hpp"
|
||||
|
||||
|
||||
/* end Expression.hpp */
|
||||
|
|
@ -21,6 +21,8 @@
|
|||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
||||
// {pretext} here
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
|
|
@ -37,6 +39,8 @@ public:
|
|||
// types
|
||||
/** integer identifying a type **/
|
||||
using typeseq = xo::facet::typeseq;
|
||||
using Copaque = const void *;
|
||||
using Opaque = void *;
|
||||
/** struct describing a type **/
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
///@}
|
||||
|
|
@ -75,4 +79,4 @@ using IExpression_ImplType = xo::facet::FacetImplType<AExpression, DRepr>;
|
|||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* */
|
||||
/* AExpression.hpp */
|
||||
|
|
@ -61,7 +61,7 @@ namespace scm {
|
|||
[[noreturn]] TypeDescr valuetype(Copaque) const noexcept override { _fatal(); }
|
||||
|
||||
// nonconst methods
|
||||
[[noreturn]] void assign_valuetype(Opaque, TypeDescr) noexcept override { _fatal(); }
|
||||
[[noreturn]] void assign_valuetype(Opaque, TypeDescr) noexcept override;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
|||
66
include/xo/expression2/detail/IExpression_DVariable.hpp
Normal file
66
include/xo/expression2/detail/IExpression_DVariable.hpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/** @file IExpression_DVariable.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IExpression_DVariable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IExpression_DVariable.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Expression.hpp"
|
||||
#include "Expression.hpp"
|
||||
#include "DVariable.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IExpression_DVariable; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::scm::AExpression,
|
||||
xo::scm::DVariable>
|
||||
{
|
||||
using ImplType = xo::scm::IExpression_Xfer
|
||||
<xo::scm::DVariable,
|
||||
xo::scm::IExpression_DVariable>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IExpression_DVariable
|
||||
**/
|
||||
class IExpression_DVariable {
|
||||
public:
|
||||
/** @defgroup scm-expression-dvariable-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::AExpression::TypeDescr;
|
||||
using Copaque = xo::scm::AExpression::Copaque;
|
||||
using Opaque = xo::scm::AExpression::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-expression-dvariable-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** expression type (constant | apply | ..) **/
|
||||
static exprtype extype(const DVariable & self) noexcept;
|
||||
/** placeholder for type giving possible values for this expression **/
|
||||
static TypeRef typeref(const DVariable & self) noexcept;
|
||||
/** type giving possible values for this expression. Maybe null before typecheck **/
|
||||
static TypeDescr valuetype(const DVariable & self) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** assing to valuetype member. Useful when scaffolding expressions **/
|
||||
static void assign_valuetype(DVariable & self, TypeDescr td) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -38,6 +38,9 @@ public:
|
|||
///@{
|
||||
RExpression() {}
|
||||
RExpression(Object::DataPtr data) : Object{std::move(data)} {}
|
||||
RExpression(const AExpression * iface, void * data)
|
||||
requires std::is_same_v<typename Object::DataType, xo::facet::DVariantPlaceholder>
|
||||
: Object(iface, data) {}
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expression-router-methods **/
|
||||
|
|
@ -55,9 +58,10 @@ public:
|
|||
return O::iface()->valuetype(O::data());
|
||||
}
|
||||
|
||||
// non-const methods
|
||||
// << do something for non-const methods >>
|
||||
//
|
||||
// non-const methods (still const in router!)
|
||||
void assign_valuetype(TypeDescr td) noexcept {
|
||||
return O::iface()->assign_valuetype(O::data(), td);
|
||||
}
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expression-member-vars **/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue