xo-expression2 xo-reader2: local symtab stack in PSM
This commit is contained in:
parent
298e05dd06
commit
94efaf46cd
27 changed files with 447 additions and 34 deletions
|
|
@ -39,6 +39,9 @@ set(SELF_SRCS
|
|||
|
||||
ISymbolTable_Any.cpp
|
||||
|
||||
ISymbolTable_DLocalSymtab.cpp
|
||||
IPrintable_DLocalSymtab.cpp
|
||||
|
||||
StringTable.cpp
|
||||
|
||||
DUniqueString.cpp
|
||||
|
|
|
|||
|
|
@ -5,14 +5,21 @@
|
|||
|
||||
#include "DLocalSymtab.hpp"
|
||||
#include "DUniqueString.hpp"
|
||||
#include <xo/expression2/detail/IPrintable_DVariable.hpp>
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::print::APrintable;
|
||||
using xo::facet::typeseq;
|
||||
using xo::print::ppstate;
|
||||
|
||||
namespace scm {
|
||||
|
||||
DLocalSymtab::DLocalSymtab(size_type n) : capacity_{n}, size_{0}
|
||||
DLocalSymtab::DLocalSymtab(DLocalSymtab * p,
|
||||
size_type n) : parent_{p},
|
||||
capacity_{n},
|
||||
size_{0}
|
||||
{
|
||||
for (size_type i = 0; i < n; ++i) {
|
||||
void * mem = &slots_[i];
|
||||
|
|
@ -21,12 +28,14 @@ namespace xo {
|
|||
}
|
||||
|
||||
DLocalSymtab *
|
||||
DLocalSymtab::_make_empty(obj<AAllocator> mm, size_type n)
|
||||
DLocalSymtab::_make_empty(obj<AAllocator> mm,
|
||||
DLocalSymtab * p,
|
||||
size_type n)
|
||||
{
|
||||
void * mem = mm.alloc(typeseq::id<DLocalSymtab>(),
|
||||
sizeof(DLocalSymtab) + (n * sizeof(Slot)));
|
||||
|
||||
return new (mem) DLocalSymtab(n);
|
||||
return new (mem) DLocalSymtab(p, n);
|
||||
}
|
||||
|
||||
Binding
|
||||
|
|
@ -68,6 +77,53 @@ namespace xo {
|
|||
return Binding();
|
||||
}
|
||||
|
||||
bool
|
||||
DLocalSymtab::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
ppstate * pps = ppii.pps();
|
||||
|
||||
if (ppii.upto()) {
|
||||
/* perhaps print on one line */
|
||||
if (!pps->print_upto("<LocalSymtab"))
|
||||
return false;
|
||||
if (!pps->print_upto(xrefrtag("size", size_)))
|
||||
return false;
|
||||
|
||||
for (size_type i = 0; i < size_; ++i) {
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "[%u]", i);
|
||||
|
||||
assert(slots_[i].var_);
|
||||
|
||||
obj<APrintable,DVariable> arg_pr(const_cast<DVariable*>(slots_[i].var_));
|
||||
|
||||
if (!pps->print_upto(xrefrtag(buf, arg_pr)))
|
||||
return false;
|
||||
}
|
||||
|
||||
pps->write(">");
|
||||
return true;
|
||||
} else {
|
||||
/* with line breaks */
|
||||
|
||||
pps->write("<LocalSymtab");
|
||||
pps->newline_pretty_tag(ppii.ci1(), "size", size_);
|
||||
|
||||
for (size_type i = 0; i < size_; ++i) {
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "[%u]", i);
|
||||
|
||||
assert(slots_[i].var_);
|
||||
|
||||
obj<APrintable,DVariable> arg_pr(const_cast<DVariable *>(slots_[i].var_));
|
||||
|
||||
pps->newline_pretty_tag(ppii.ci1(), buf, arg_pr);
|
||||
}
|
||||
|
||||
pps->write(">");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IExpression_DIfElseExpr.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DVariable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DIfElseExpr.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
|
|||
28
xo-expression2/src/expression2/IPrintable_DLocalSymtab.cpp
Normal file
28
xo-expression2/src/expression2/IPrintable_DLocalSymtab.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DLocalSymtab.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DLocalSymtab.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DLocalSymtab.json5]
|
||||
**/
|
||||
|
||||
#include "symtab/IPrintable_DLocalSymtab.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DLocalSymtab::pretty(const DLocalSymtab & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DLocalSymtab.cpp */
|
||||
34
xo-expression2/src/expression2/ISymbolTable_DLocalSymtab.cpp
Normal file
34
xo-expression2/src/expression2/ISymbolTable_DLocalSymtab.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/** @file ISymbolTable_DLocalSymtab.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISymbolTable_DLocalSymtab.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ISymbolTable_DLocalSymtab.json5]
|
||||
**/
|
||||
|
||||
#include "symtab/ISymbolTable_DLocalSymtab.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
ISymbolTable_DLocalSymtab::is_global_symtab(const DLocalSymtab & self) noexcept -> bool
|
||||
{
|
||||
return self.is_global_symtab();
|
||||
}
|
||||
|
||||
auto
|
||||
ISymbolTable_DLocalSymtab::lookup_binding(const DLocalSymtab & self, const DUniqueString * sym) noexcept -> Binding
|
||||
{
|
||||
return self.lookup_binding(sym);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end ISymbolTable_DLocalSymtab.cpp */
|
||||
|
|
@ -27,6 +27,9 @@
|
|||
#include <xo/expression2/detail/IExpression_DIfElseExpr.hpp>
|
||||
#include <xo/expression2/detail/IPrintable_DIfElseExpr.hpp>
|
||||
|
||||
#include <xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp>
|
||||
#include <xo/expression2/symtab/IPrintable_DLocalSymtab.hpp>
|
||||
|
||||
#include <xo/gc/detail/AGCObject.hpp>
|
||||
#include <xo/printable2/detail/APrintable.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
|
|
@ -74,6 +77,9 @@ namespace xo {
|
|||
FacetRegistry::register_impl<AExpression, DIfElseExpr>();
|
||||
FacetRegistry::register_impl<APrintable, DIfElseExpr>();
|
||||
|
||||
FacetRegistry::register_impl<ASymbolTable, DLocalSymtab>();
|
||||
FacetRegistry::register_impl<APrintable, DLocalSymtab>();
|
||||
|
||||
log && log(xtag("DUniqueString.tseq", typeseq::id<DUniqueString>()));
|
||||
log && log(xtag("DDefineExpr.tseq", typeseq::id<DDefineExpr>()));
|
||||
log && log(xtag("DVariable.tseq", typeseq::id<DVariable>()));
|
||||
|
|
@ -82,7 +88,10 @@ namespace xo {
|
|||
log && log(xtag("DLambdaExpr.tseq", typeseq::id<DLambdaExpr>()));
|
||||
log && log(xtag("DIfElseExpr.tseq", typeseq::id<DIfElseExpr>()));
|
||||
|
||||
log && log(xtag("DLocalSymtab.tseq", typeseq::id<DLocalSymtab>()));
|
||||
|
||||
log && log(xtag("AExpression.tqseq", typeseq::id<AExpression>()));
|
||||
log && log(xtag("ASymbolTable.tseq", typeseq::id<ASymbolTable>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue