Skip to content

Commit

Permalink
good view
Browse files Browse the repository at this point in the history
  • Loading branch information
grencez committed Nov 20, 2023
1 parent 9260d06 commit 297a863
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
7 changes: 4 additions & 3 deletions src/pfmla.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ PFmla::cycle_ck(const PFmla& pf) const
* \param pfx Prefix to output before every valuation.
* \param sfx Suffix to output after every valuation.
**/
ostream&
PFmlaCtx::oput(ostream& of, const PFmla& a, uint setIdx,
const String& pfx, const String& sfx) const
std::ostream&
PFmlaCtx::oput(
std::ostream& of, const PFmla& a, unsigned setIdx,
std::string_view pfx, std::string_view sfx) const
{
(void) a;
(void) setIdx;
Expand Down
20 changes: 10 additions & 10 deletions src/pfmla.hh
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,8 @@ public:
void nullify_context()
{ ctx = 0; }

uint add_vbl(const String& name, uint domsz)
{
return add_vbl_PFmlaCtx(ctx, name.c_str(), domsz);
unsigned add_vbl(std::string_view name, unsigned domsz) {
return add_vbl_PFmlaCtx(ctx, std::string(name).c_str(), domsz);
}

uint add_vbl_list()
Expand All @@ -600,19 +599,20 @@ public:
return PFmlaVbl( vbl_of_PFmlaCtx (ctx, id) );
}

const PFmlaVbl vbl(const String& s) const
{
const PFmlaVbl vbl(const std::string& s) const {
return PFmlaVbl(vbl_lookup_PFmlaCtx(ctx, s.c_str()));
}

PFmla pfmla_of_state(const uint* state, const Table<uint>& vbls) const;
PFmla pfmla_of_img_state(const uint* state, const Table<uint>& vbls) const;

ostream& oput(ostream& of,
const PFmla& a,
uint setIdx,
const String& pfx = "",
const String& sfx = "") const;
std::ostream&
oput(std::ostream& of,
const PFmla& a,
uint setIdx,
std::string_view pfx = "",
std::string_view sfx = "") const;

friend void PFmla::ensure_ctx (const PFmlaCtx& ctx);
};

Expand Down
26 changes: 17 additions & 9 deletions src/xnpc.hh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#ifndef XnPc_HH_
#define XnPc_HH_

#include "cx/synhax.hh"
#include <sstream>

#include "cx/set.hh"
#include "cx/table.hh"
Expand All @@ -11,6 +10,8 @@
#include "xfmlae.hh"
#include "xnspec.hh"

#include "cx/synhax.hh"

#include "namespace.hh"
namespace Xn {
class Vbl;
Expand Down Expand Up @@ -129,8 +130,10 @@ public:
bool puppet_ck() const { return spec->puppet_ck(); }
};

inline String name_of(const Vbl& vbl) {
return vbl.symm->spec->name + "[" + vbl.symm_idx + "]";
inline std::string name_of(const Vbl& vbl) {
std::ostringstream oss;
oss << vbl.symm->spec->name << '[' << vbl.symm_idx << ']';
return oss.str();
}

class ActSymm {
Expand Down Expand Up @@ -224,9 +227,11 @@ public:
InitDomMax( representative_pcidx );
}

String vbl_name(uint i) const {
const String& name = rvbl_symms[i]->spec->name;
return name + "[" + vbl_indices[i].expression + "]";
std::string vbl_name(uint i) const {
std::ostringstream oss;
oss << rvbl_symms[i]->spec->name
<< '[' << vbl_indices[i].expression << ']';
return oss.str();
}

bool read_ck(uint ridx) const {
Expand All @@ -253,8 +258,11 @@ public:
}
};

inline String name_of(const Pc& pc) {
return pc.symm->spec->name + "[" + pc.symm->mapped_indices.eval(pc.symm_idx) + "]";
inline std::string name_of(const Pc& pc) {
std::ostringstream oss;
oss << pc.symm->spec->name
<< '[' << pc.symm->mapped_indices.eval(pc.symm_idx) << ']';
return oss.str();
}

inline uint ActSymm::guard (uint vidx) const { return vals[vidx]; }
Expand Down
9 changes: 5 additions & 4 deletions src/xnsys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Net::fixup_pc_xns()
}

VblSymm*
Net::add_variables(const String& name, uint nmembs, uint domsz,
Net::add_variables(std::string_view name, uint nmembs, uint domsz,
Xn::ShadowPuppetRole role)
{
// Cannot add variables after committing them.
Expand Down Expand Up @@ -202,7 +202,8 @@ Net::commit_variables()
}

PcSymm*
Net::add_processes(const String& name, const String& idx_name, uint nmembs)
Net::add_processes(
std::string_view name, std::string_view idx_name, unsigned nmembs)
{
if (vbls.sz() == 0) {
commit_variables();
Expand Down Expand Up @@ -479,8 +480,8 @@ Net::unroll_action(Table<Xn::ActSymm>& dst, uint actid, bool include_shadow) con
ostream&
Net::oput(ostream& of,
const P::Fmla& pf,
const String& pfx,
const String& sfx) const
std::string_view pfx,
std::string_view sfx) const
{

(void) pf;
Expand Down
9 changes: 5 additions & 4 deletions src/xnsys.hh
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ public:
void fixup_pc_xns();

VblSymm*
add_variables(const String& name, uint nmembs, uint domsz,
add_variables(std::string_view name, uint nmembs, uint domsz,
Xn::ShadowPuppetRole role = Xn::Direct);
private:
void commit_variable(VblSymm& symm, uint i);
public:
void commit_variables();
PcSymm*
add_processes(const String& name, const String& idx_name, uint nmembs);
add_processes(
std::string_view name, std::string_view idx_name, unsigned nmembs);
void add_access (PcSymm* pc_symm, const VblSymm* vbl_symm,
const NatMap& indices,
Xn::VariableAccessType access_type);
Expand Down Expand Up @@ -156,8 +157,8 @@ public:

std::ostream& oput(std::ostream& of,
const Cx::PFmla& pf,
const String& pfx,
const String& sfx) const;
std::string_view pfx,
std::string_view sfx) const;

std::ostream& oput_vbl_names(std::ostream& ofile) const;
std::ostream& oput_pfmla(std::ostream& ofile, Cx::PFmla pf,
Expand Down

0 comments on commit 297a863

Please sign in to comment.