From 1107b245da5142e7bebc445b1bf9088ca2784d91 Mon Sep 17 00:00:00 2001 From: krangelov Date: Fri, 19 Nov 2021 09:38:04 +0100 Subject: [PATCH] remove obsolete code --- src/runtime/c/pgf/data.h | 7 +---- src/runtime/c/pgf/expr.cxx | 53 +---------------------------------- src/runtime/c/pgf/expr.h | 54 ------------------------------------ src/runtime/c/pgf/pgf.cxx | 9 ++---- src/runtime/c/pgf/reader.cxx | 3 +- src/runtime/c/pgf/writer.cxx | 4 +-- src/runtime/c/pgf/writer.h | 1 - 7 files changed, 8 insertions(+), 123 deletions(-) diff --git a/src/runtime/c/pgf/data.h b/src/runtime/c/pgf/data.h index 9ff288d12..a4d7a3ea1 100644 --- a/src/runtime/c/pgf/data.h +++ b/src/runtime/c/pgf/data.h @@ -74,18 +74,13 @@ struct PGF_INTERNAL_DECL PgfFlag { static void release(ref pgf); }; -typedef struct { - PgfExpr body; - Vector patts; -} PgfEquation; - struct PGF_INTERNAL_DECL PgfAbsFun { size_t ref_count; ref type; int arity; ref bytecode; - PgfExprProb ep; + prob_t prob; PgfText name; static void release(ref cat); diff --git a/src/runtime/c/pgf/expr.cxx b/src/runtime/c/pgf/expr.cxx index ccea7924f..468bb5bac 100644 --- a/src/runtime/c/pgf/expr.cxx +++ b/src/runtime/c/pgf/expr.cxx @@ -1055,7 +1055,7 @@ PgfExpr PgfExprProbEstimator::efun(PgfText *name) if (absfun == 0) prob = INFINITY; else - prob += absfun->ep.prob; + prob += absfun->prob; return 0; } @@ -1200,54 +1200,3 @@ void pgf_type_free(ref dtyp) PgfDB::free(dtyp); } - -PGF_INTERNAL -void pgf_patt_free(PgfPatt patt) -{ - switch (ref::get_tag(patt)) { - case PgfPattApp::tag: { - auto papp = ref::untagged(patt); - PgfDB::free(papp->ctor); - for (size_t i = 0; i < papp->args.len; i++) { - PgfPatt patt = *vector_elem(ref>::from_ptr(&papp->args), i); - pgf_patt_free(patt); - } - PgfDB::free(papp); - break; - } - case PgfPattVar::tag: { - PgfDB::free(ref::untagged(patt)); - break; - } - case PgfPattAs::tag: { - auto pas = ref::untagged(patt); - pgf_patt_free(pas->patt); - PgfDB::free(pas); - break; - } - case PgfPattWild::tag: { - PgfDB::free(ref::untagged(patt)); - break; - } - case PgfPattLit::tag: { - auto plit = ref::untagged(patt); - pgf_literal_free(plit->lit); - PgfDB::free(plit); - break; - } - case PgfPattImplArg::tag: { - auto pimpl = ref::untagged(patt); - pgf_patt_free(pimpl->patt); - PgfDB::free(pimpl); - break; - } - case PgfPattTilde::tag: { - auto ptilde = ref::untagged(patt); - pgf_patt_free(ptilde->expr); - PgfDB::free(ptilde); - break; - } - default: - throw pgf_error("Unknown pattern tag"); - } -} diff --git a/src/runtime/c/pgf/expr.h b/src/runtime/c/pgf/expr.h index a728c3e2a..edd093446 100644 --- a/src/runtime/c/pgf/expr.h +++ b/src/runtime/c/pgf/expr.h @@ -87,59 +87,8 @@ struct PGF_INTERNAL_DECL PgfExprImplArg { PgfExpr expr; }; -// PgfPatt - -typedef object PgfPatt; - -struct PGF_INTERNAL_DECL PgfPattApp { - static const uint8_t tag = 0; - - ref ctor; - Vector args; -}; - -struct PGF_INTERNAL_DECL PgfPattVar { - static const uint8_t tag = 1; - - PgfText name; -}; - -struct PGF_INTERNAL_DECL PgfPattAs { - static const uint8_t tag = 2; - - PgfPatt patt; - PgfText name; -}; - -struct PGF_INTERNAL_DECL PgfPattWild { - static const uint8_t tag = 3; -}; - -struct PGF_INTERNAL_DECL PgfPattLit { - static const uint8_t tag = 4; - - PgfLiteral lit; -}; - -struct PGF_INTERNAL_DECL PgfPattImplArg { - static const uint8_t tag = 5; - - PgfPatt patt; -}; - -struct PGF_INTERNAL_DECL PgfPattTilde { - static const uint8_t tag = 6; - - PgfExpr expr; -}; - typedef float prob_t; -typedef struct { - prob_t prob; - PgfExpr expr; -} PgfExprProb; - struct PGF_INTERNAL_DECL PgfDBMarshaller : public PgfMarshaller { virtual object match_lit(PgfUnmarshaller *u, PgfLiteral l); virtual object match_expr(PgfUnmarshaller *u, PgfExpr e); @@ -289,7 +238,4 @@ void pgf_context_free(ref> hypos); PGF_INTERNAL_DECL void pgf_type_free(ref dtyp); -PGF_INTERNAL_DECL -void pgf_patt_free(PgfPatt patt); - #endif /* EXPR_H_ */ diff --git a/src/runtime/c/pgf/pgf.cxx b/src/runtime/c/pgf/pgf.cxx index 2d172e7d7..9dd0c24ad 100644 --- a/src/runtime/c/pgf/pgf.cxx +++ b/src/runtime/c/pgf/pgf.cxx @@ -553,7 +553,7 @@ prob_t pgf_function_prob(PgfDB *db, PgfRevision revision, if (absfun == 0) return INFINITY; - return absfun->ep.prob; + return absfun->prob; } PGF_API_END return INFINITY; @@ -757,7 +757,7 @@ PgfText *pgf_print_function_internal(object o) printer.efun(&absfun->name); printer.puts(" : "); m.match_type(&printer, absfun->type.as_object()); - printer.nprintf(32, " ; -- %g", absfun->ep.prob); + printer.nprintf(32, " ; -- %g", absfun->prob); return printer.get_text(); } @@ -971,10 +971,7 @@ void pgf_create_function(PgfDB *db, PgfRevision revision, absfun->type = m->match_type(&u, ty); absfun->arity = arity; absfun->bytecode = bytecode ? PgfDB::malloc(0) : 0; - absfun->ep.prob = prob; - ref efun = - ref::from_ptr((PgfExprFun*) &absfun->name); - absfun->ep.expr = ref::tagged(efun); + absfun->prob = prob; memcpy(&absfun->name, name, sizeof(PgfText)+name->size+1); Namespace funs = diff --git a/src/runtime/c/pgf/reader.cxx b/src/runtime/c/pgf/reader.cxx index cafea6493..93d7cdd61 100644 --- a/src/runtime/c/pgf/reader.cxx +++ b/src/runtime/c/pgf/reader.cxx @@ -324,7 +324,6 @@ ref PgfReader::read_absfun() absfun->ref_count = 1; ref efun = ref::from_ptr((PgfExprFun*) &absfun->name); - absfun->ep.expr = ref::tagged(efun); absfun->type = read_type(); absfun->arity = read_int(); @@ -341,7 +340,7 @@ ref PgfReader::read_absfun() default: throw pgf_error("Unknown tag, 0 or 1 expected"); } - absfun->ep.prob = - log(read_double()); + absfun->prob = - log(read_double()); return absfun; } diff --git a/src/runtime/c/pgf/writer.cxx b/src/runtime/c/pgf/writer.cxx index b1ff4e5af..9e1a4fb6e 100644 --- a/src/runtime/c/pgf/writer.cxx +++ b/src/runtime/c/pgf/writer.cxx @@ -270,7 +270,7 @@ void PgfWriter::write_absfun(ref absfun) write_tag(1); write_len(0); } - write_double(exp(-absfun->ep.prob)); + write_double(exp(-absfun->prob)); } static @@ -297,7 +297,7 @@ void write_funs_by_cat(Namespace funs, PgfText *cat, PgfWriter *wtr) write_funs_by_cat(funs->left, cat, wtr); if (textcmp(&funs->value->name, cat) == 0) { - wtr->write_double(exp(-funs->value->ep.prob)); + wtr->write_double(exp(-funs->value->prob)); wtr->write_name(&funs->value->name); } diff --git a/src/runtime/c/pgf/writer.h b/src/runtime/c/pgf/writer.h index f6594fb3b..b0417a171 100644 --- a/src/runtime/c/pgf/writer.h +++ b/src/runtime/c/pgf/writer.h @@ -54,7 +54,6 @@ private: template void write_namespace_helper(Namespace nmsp, void (PgfWriter::*write_value)(ref)); - void write_patt(ref r) { write_patt(*r); }; void write_text(ref> r) { write_text(&(**r)); }; void write_lparam(ref> r) { write_lparam(*r); }; void write_seq(ref>> r) { write_seq(*r); };