xo-reader2 xo-expresion2: work on define-expressions [WIP]
This commit is contained in:
parent
f0e7a186a8
commit
da0d736946
14 changed files with 431 additions and 4 deletions
|
|
@ -6,12 +6,17 @@ set(SELF_SRCS
|
|||
|
||||
DConstant.cpp
|
||||
DVariable.cpp
|
||||
DDefineExpr.cpp
|
||||
|
||||
TypeRef.cpp
|
||||
|
||||
IExpression_Any.cpp
|
||||
IExpression_DConstant.cpp
|
||||
IExpression_DVariable.cpp
|
||||
IExpression_DDefineExpr.cpp
|
||||
|
||||
DLocalSymtab.cpp
|
||||
DGlobalSymtab.cpp
|
||||
|
||||
ISymbolTable_Any.cpp
|
||||
|
||||
|
|
|
|||
71
src/expression2/DDefineExpr.cpp
Normal file
71
src/expression2/DDefineExpr.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/** @file DDefineExpr.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DDefineExpr.hpp"
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::typeseq;
|
||||
|
||||
namespace scm {
|
||||
|
||||
DDefineExpr::DDefineExpr(DVariable * lhs_var,
|
||||
obj<AExpression> rhs)
|
||||
: lhs_var_{lhs_var}, rhs_{rhs}
|
||||
{}
|
||||
|
||||
DDefineExpr *
|
||||
DDefineExpr::make(obj<AAllocator> mm,
|
||||
const DUniqueString * lhs_name,
|
||||
obj<AExpression> rhs_expr)
|
||||
{
|
||||
void * mem = mm.alloc(typeseq::id<DDefineExpr>(),
|
||||
sizeof(DDefineExpr));
|
||||
|
||||
auto lhs_var = DVariable::make(mm,
|
||||
lhs_name,
|
||||
rhs_expr.typeref());
|
||||
|
||||
return new (mem) DDefineExpr(lhs_var, rhs_expr);
|
||||
}
|
||||
|
||||
DDefineExpr *
|
||||
DDefineExpr::make_empty(obj<AAllocator> mm)
|
||||
{
|
||||
return make(mm,
|
||||
nullptr /*lhs_name*/,
|
||||
obj<AExpression>() /*rhs_expr*/);
|
||||
}
|
||||
|
||||
const DUniqueString *
|
||||
DDefineExpr::name() const noexcept
|
||||
{
|
||||
return lhs_var_->name();
|
||||
}
|
||||
|
||||
void
|
||||
DDefineExpr::assign_lhs_name(const DUniqueString * name)
|
||||
{
|
||||
lhs_var_->assign_name(name);
|
||||
}
|
||||
|
||||
void
|
||||
DDefineExpr::assign_lhs_name(std::string_view name)
|
||||
{
|
||||
scope log(XO_DEBUG(true), "bogus impl - will require unique string");
|
||||
log && log(xtag("name", name));
|
||||
|
||||
//lhs_var_->assign_name(name);
|
||||
}
|
||||
|
||||
void
|
||||
DDefineExpr::assign_valuetype(TypeDescr td) noexcept
|
||||
{
|
||||
lhs_var_->assign_valuetype(td);
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DDefineExpr.cpp */
|
||||
27
src/expression2/DGlobalSymtab.cpp
Normal file
27
src/expression2/DGlobalSymtab.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/** @file DGlobalSymtab.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DGlobalSymtab.hpp"
|
||||
#include "DUniqueString.hpp"
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
Binding
|
||||
DGlobalSymtab::lookup_binding(const DUniqueString * sym) const noexcept
|
||||
{
|
||||
(void)sym;
|
||||
|
||||
scope log(XO_DEBUG(true), "stub");
|
||||
log && log(xtag("sym", std::string_view(*sym)));
|
||||
|
||||
return Binding();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DGlobalSymtab.cpp */
|
||||
25
src/expression2/DLocalSymtab.cpp
Normal file
25
src/expression2/DLocalSymtab.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/** @file DLocalSymtab.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DLocalSymtab.hpp"
|
||||
#include "DUniqueString.hpp"
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
Binding
|
||||
DLocalSymtab::lookup_binding(const DUniqueString * sym) const noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(true), "stub impl");
|
||||
log && log(xtag("sym", std::string_view(*sym)));
|
||||
|
||||
return Binding();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DLocalSymtab.cpp */
|
||||
|
|
@ -7,12 +7,34 @@
|
|||
#include "exprtype.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::typeseq;
|
||||
|
||||
namespace scm {
|
||||
|
||||
DVariable *
|
||||
DVariable::make(obj<AAllocator> mm,
|
||||
const DUniqueString * name,
|
||||
const TypeRef & typeref,
|
||||
Binding path)
|
||||
{
|
||||
void * mem = mm.alloc(typeseq::id<DVariable>(),
|
||||
sizeof(DVariable));
|
||||
|
||||
return new (mem) DVariable(name, typeref, path);
|
||||
}
|
||||
|
||||
DVariable::DVariable(const DUniqueString * name,
|
||||
const TypeRef & typeref,
|
||||
Binding path)
|
||||
: name_{name}, typeref_{typeref}, path_{path}
|
||||
{}
|
||||
|
||||
void
|
||||
DVariable::assign_valuetype(TypeDescr td) noexcept
|
||||
{
|
||||
typeref_.resolve(td);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
45
src/expression2/IExpression_DDefineExpr.cpp
Normal file
45
src/expression2/IExpression_DDefineExpr.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/** @file IExpression_DDefineExpr.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IExpression_DDefineExpr.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IExpression_DDefineExpr.json5]
|
||||
**/
|
||||
|
||||
#include "detail/IExpression_DDefineExpr.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IExpression_DDefineExpr::extype(const DDefineExpr & self) noexcept -> exprtype
|
||||
{
|
||||
return self.extype();
|
||||
}
|
||||
|
||||
auto
|
||||
IExpression_DDefineExpr::typeref(const DDefineExpr & self) noexcept -> TypeRef
|
||||
{
|
||||
return self.typeref();
|
||||
}
|
||||
|
||||
auto
|
||||
IExpression_DDefineExpr::valuetype(const DDefineExpr & self) noexcept -> TypeDescr
|
||||
{
|
||||
return self.valuetype();
|
||||
}
|
||||
|
||||
auto
|
||||
IExpression_DDefineExpr::assign_valuetype(DDefineExpr & self, TypeDescr td) noexcept -> void
|
||||
{
|
||||
self.assign_valuetype(td);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IExpression_DDefineExpr.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue