pgf_create_lin now has access to the abstract function

This commit is contained in:
krangelov
2021-11-09 08:50:54 +01:00
parent 02a84b12da
commit a4ad17a478
7 changed files with 58 additions and 50 deletions

View File

@@ -180,6 +180,8 @@ struct PGF_INTERNAL_DECL PgfSymbolALLCAPIT {
struct PGF_INTERNAL_DECL PgfConcrLin {
size_t ref_count;
ref<PgfAbsFun> absfun;
ref<Vector<PgfPArg>> args;
ref<Vector<ref<PgfLParam>>> res;
ref<Vector<ref<Vector<PgfSymbol>>>> seqs;

View File

@@ -956,18 +956,35 @@ void pgf_drop_concrete(PgfDB *db, PgfRevision revision,
}
PGF_API
void pgf_create_lin(PgfDB *db, PgfConcrRevision revision,
void pgf_create_lin(PgfDB *db,
PgfRevision revision, PgfConcrRevision cnc_revision,
PgfText *name, size_t n_prods, PgfExn *err)
{
PGF_API_BEGIN {
DB_scope scope(db, WRITER_SCOPE);
ref<PgfConcr> concr = PgfDB::revision2concr(revision);
ref<PgfPGF> pgf = PgfDB::revision2pgf(revision);
ref<PgfConcr> concr = PgfDB::revision2concr(cnc_revision);
ref<PgfAbsFun> absfun =
namespace_lookup(pgf->abstract.funs, name);
if (absfun == 0) {
throw pgf_error("There is no corresponding function in the abstract syntax");
}
ref<PgfConcrLincat> lincat =
namespace_lookup(concr->lincats, &absfun->type->name);
if (lincat == 0) {
throw pgf_error("Missing linearization category");
}
ref<PgfConcrLin> lin = PgfDB::malloc<PgfConcrLin>(name->size+1);
memcpy(&lin->name, name, sizeof(PgfText)+name->size+1);
lin->ref_count = 1;
lin->res = vector_new<ref<PgfLParam>>(n_prods);
lin->absfun = absfun;
lin->args = vector_new<PgfPArg>(n_prods*absfun->type->hypos->len);
lin->res = vector_new<ref<PgfLParam>>(n_prods);
lin->seqs = vector_new<ref<Vector<PgfSymbol>>>(n_prods*lincat->fields->len);
for (size_t i = 0; i < n_prods; i++) {
}

View File

@@ -419,8 +419,9 @@ void pgf_drop_concrete(PgfDB *db, PgfRevision revision,
PgfExn *err);
PGF_API_DECL
void pgf_create_lin(PgfDB *db, PgfConcrRevision revision,
PgfText *name, size_t n_prods, PgfExn *exn);
void pgf_create_lin(PgfDB *db,
PgfRevision revision, PgfConcrRevision cnc_revision,
PgfText *name, size_t n_prods, PgfExn *err);
PGF_API_DECL
PgfLiteral pgf_get_global_flag(PgfDB *db, PgfRevision revision,

View File

@@ -7,7 +7,6 @@ PgfReader::PgfReader(FILE *in)
{
this->in = in;
this->abstract = 0;
this->concrete = 0;
}
uint8_t PgfReader::read_uint8()
@@ -553,6 +552,7 @@ ref<PgfConcrLin> PgfReader::read_lin()
{
ref<PgfConcrLin> lin = read_name(&PgfConcrLin::name);
lin->ref_count = 1;
lin->absfun = namespace_lookup(abstract->funs, &lin->name);
lin->args = read_vector(&PgfReader::read_parg);
lin->res = read_vector(&PgfReader::read_lparam);
lin->seqs = read_vector(&PgfReader::read_seq2);
@@ -570,8 +570,6 @@ ref<PgfConcrPrintname> PgfReader::read_printname()
ref<PgfConcr> PgfReader::read_concrete()
{
ref<PgfConcr> concr = read_name(&PgfConcr::name);
this->concrete = concr;
concr->ref_count = 1;
concr->ref_count_ex = 0;
concr->cflags = read_namespace<PgfFlag>(&PgfReader::read_flag);

View File

@@ -80,7 +80,6 @@ public:
private:
FILE *in;
ref<PgfAbstr> abstract;
ref<PgfConcr> concrete;
object read_name_internal(size_t struct_size);
object read_text_internal(size_t struct_size);