xo-expression2: + IExpression_DVariable
This commit is contained in:
parent
b3215da360
commit
f38c90db91
13 changed files with 187 additions and 32 deletions
|
|
@ -54,6 +54,18 @@ xo_add_genfacetimpl(
|
|||
OUTPUT_CPP_DIR src/expression2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-expression2-facetimpl-expression-variable
|
||||
FACET_PKG xo_expression2
|
||||
FACET Expression
|
||||
REPR Variable
|
||||
INPUT idl/IExpression_DVariable.json5
|
||||
OUTPUT_HPP_DIR include/xo/expression2
|
||||
OUTPUT_IMPL_SUBDIR detail
|
||||
OUTPUT_CPP_DIR src/expression2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-expression2-facetimpl-gcobject-uniquestring
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@
|
|||
includes: [ "\"TypeRef.hpp\"",
|
||||
"\"exprtype.hpp\"",
|
||||
"<xo/reflect/TypeDescr.hpp>"],
|
||||
|
||||
// extra includes in Expression.hpp, if any
|
||||
user_hpp_includes: [],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
// text after includes, before AExpression
|
||||
pretext: [ "// {pretext} here" ],
|
||||
facet: "Expression",
|
||||
detail_subdir: "detail",
|
||||
brief: "a schematika expression",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
includes: [ "\"Expression.hpp\"" ],
|
||||
local_types: [ ],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/Expression.json5",
|
||||
|
|
|
|||
12
idl/IExpression_DVariable.json5
Normal file
12
idl/IExpression_DVariable.json5
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
includes: [ "\"Expression.hpp\"" ],
|
||||
local_types: [ ],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/Expression.json5",
|
||||
brief: "provide AExpression interface for DVariable state",
|
||||
using_doxygen: true,
|
||||
repr: "DVariable",
|
||||
doc: ["doc for IExpression+DVariable" ],
|
||||
}
|
||||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ set(SELF_SRCS
|
|||
|
||||
IExpression_Any.cpp
|
||||
IExpression_DConstant.cpp
|
||||
IExpression_DVariable.cpp
|
||||
|
||||
ISymbolTable_Any.cpp
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,15 @@ bool
|
|||
IExpression_Any::_valid
|
||||
= valid_facet_implementation<AExpression, IExpression_Any>();
|
||||
|
||||
// nonconst methods
|
||||
|
||||
auto
|
||||
IExpression_Any::assign_valuetype(Opaque, TypeDescr) noexcept -> void
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
45
src/expression2/IExpression_DVariable.cpp
Normal file
45
src/expression2/IExpression_DVariable.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/** @file IExpression_DVariable.cpp
|
||||
*
|
||||
* 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_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IExpression_DVariable.json5]
|
||||
**/
|
||||
|
||||
#include "detail/IExpression_DVariable.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IExpression_DVariable::extype(const DVariable & self) noexcept -> exprtype
|
||||
{
|
||||
return self.extype();
|
||||
}
|
||||
|
||||
auto
|
||||
IExpression_DVariable::typeref(const DVariable & self) noexcept -> TypeRef
|
||||
{
|
||||
return self.typeref();
|
||||
}
|
||||
|
||||
auto
|
||||
IExpression_DVariable::valuetype(const DVariable & self) noexcept -> TypeDescr
|
||||
{
|
||||
return self.valuetype();
|
||||
}
|
||||
|
||||
auto
|
||||
IExpression_DVariable::assign_valuetype(DVariable & self, TypeDescr td) noexcept -> void
|
||||
{
|
||||
self.assign_valuetype(td);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IExpression_DVariable.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue