mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
remove obsolete code
This commit is contained in:
@@ -74,18 +74,13 @@ struct PGF_INTERNAL_DECL PgfFlag {
|
|||||||
static void release(ref<PgfFlag> pgf);
|
static void release(ref<PgfFlag> pgf);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PgfExpr body;
|
|
||||||
Vector<PgfPatt> patts;
|
|
||||||
} PgfEquation;
|
|
||||||
|
|
||||||
struct PGF_INTERNAL_DECL PgfAbsFun {
|
struct PGF_INTERNAL_DECL PgfAbsFun {
|
||||||
size_t ref_count;
|
size_t ref_count;
|
||||||
|
|
||||||
ref<PgfDTyp> type;
|
ref<PgfDTyp> type;
|
||||||
int arity;
|
int arity;
|
||||||
ref<char> bytecode;
|
ref<char> bytecode;
|
||||||
PgfExprProb ep;
|
prob_t prob;
|
||||||
PgfText name;
|
PgfText name;
|
||||||
|
|
||||||
static void release(ref<PgfAbsFun> cat);
|
static void release(ref<PgfAbsFun> cat);
|
||||||
|
|||||||
@@ -1055,7 +1055,7 @@ PgfExpr PgfExprProbEstimator::efun(PgfText *name)
|
|||||||
if (absfun == 0)
|
if (absfun == 0)
|
||||||
prob = INFINITY;
|
prob = INFINITY;
|
||||||
else
|
else
|
||||||
prob += absfun->ep.prob;
|
prob += absfun->prob;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1200,54 +1200,3 @@ void pgf_type_free(ref<PgfDTyp> dtyp)
|
|||||||
|
|
||||||
PgfDB::free(dtyp);
|
PgfDB::free(dtyp);
|
||||||
}
|
}
|
||||||
|
|
||||||
PGF_INTERNAL
|
|
||||||
void pgf_patt_free(PgfPatt patt)
|
|
||||||
{
|
|
||||||
switch (ref<PgfPatt>::get_tag(patt)) {
|
|
||||||
case PgfPattApp::tag: {
|
|
||||||
auto papp = ref<PgfPattApp>::untagged(patt);
|
|
||||||
PgfDB::free(papp->ctor);
|
|
||||||
for (size_t i = 0; i < papp->args.len; i++) {
|
|
||||||
PgfPatt patt = *vector_elem(ref<Vector<PgfPatt>>::from_ptr(&papp->args), i);
|
|
||||||
pgf_patt_free(patt);
|
|
||||||
}
|
|
||||||
PgfDB::free(papp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PgfPattVar::tag: {
|
|
||||||
PgfDB::free(ref<PgfPattVar>::untagged(patt));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PgfPattAs::tag: {
|
|
||||||
auto pas = ref<PgfPattAs>::untagged(patt);
|
|
||||||
pgf_patt_free(pas->patt);
|
|
||||||
PgfDB::free(pas);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PgfPattWild::tag: {
|
|
||||||
PgfDB::free(ref<PgfPattWild>::untagged(patt));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PgfPattLit::tag: {
|
|
||||||
auto plit = ref<PgfPattLit>::untagged(patt);
|
|
||||||
pgf_literal_free(plit->lit);
|
|
||||||
PgfDB::free(plit);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PgfPattImplArg::tag: {
|
|
||||||
auto pimpl = ref<PgfPattImplArg>::untagged(patt);
|
|
||||||
pgf_patt_free(pimpl->patt);
|
|
||||||
PgfDB::free(pimpl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PgfPattTilde::tag: {
|
|
||||||
auto ptilde = ref<PgfPattTilde>::untagged(patt);
|
|
||||||
pgf_patt_free(ptilde->expr);
|
|
||||||
PgfDB::free(ptilde);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw pgf_error("Unknown pattern tag");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -87,59 +87,8 @@ struct PGF_INTERNAL_DECL PgfExprImplArg {
|
|||||||
PgfExpr expr;
|
PgfExpr expr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// PgfPatt
|
|
||||||
|
|
||||||
typedef object PgfPatt;
|
|
||||||
|
|
||||||
struct PGF_INTERNAL_DECL PgfPattApp {
|
|
||||||
static const uint8_t tag = 0;
|
|
||||||
|
|
||||||
ref<PgfText> ctor;
|
|
||||||
Vector<PgfPatt> 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 float prob_t;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
prob_t prob;
|
|
||||||
PgfExpr expr;
|
|
||||||
} PgfExprProb;
|
|
||||||
|
|
||||||
struct PGF_INTERNAL_DECL PgfDBMarshaller : public PgfMarshaller {
|
struct PGF_INTERNAL_DECL PgfDBMarshaller : public PgfMarshaller {
|
||||||
virtual object match_lit(PgfUnmarshaller *u, PgfLiteral l);
|
virtual object match_lit(PgfUnmarshaller *u, PgfLiteral l);
|
||||||
virtual object match_expr(PgfUnmarshaller *u, PgfExpr e);
|
virtual object match_expr(PgfUnmarshaller *u, PgfExpr e);
|
||||||
@@ -289,7 +238,4 @@ void pgf_context_free(ref<Vector<PgfHypo>> hypos);
|
|||||||
PGF_INTERNAL_DECL
|
PGF_INTERNAL_DECL
|
||||||
void pgf_type_free(ref<PgfDTyp> dtyp);
|
void pgf_type_free(ref<PgfDTyp> dtyp);
|
||||||
|
|
||||||
PGF_INTERNAL_DECL
|
|
||||||
void pgf_patt_free(PgfPatt patt);
|
|
||||||
|
|
||||||
#endif /* EXPR_H_ */
|
#endif /* EXPR_H_ */
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ prob_t pgf_function_prob(PgfDB *db, PgfRevision revision,
|
|||||||
if (absfun == 0)
|
if (absfun == 0)
|
||||||
return INFINITY;
|
return INFINITY;
|
||||||
|
|
||||||
return absfun->ep.prob;
|
return absfun->prob;
|
||||||
} PGF_API_END
|
} PGF_API_END
|
||||||
|
|
||||||
return INFINITY;
|
return INFINITY;
|
||||||
@@ -757,7 +757,7 @@ PgfText *pgf_print_function_internal(object o)
|
|||||||
printer.efun(&absfun->name);
|
printer.efun(&absfun->name);
|
||||||
printer.puts(" : ");
|
printer.puts(" : ");
|
||||||
m.match_type(&printer, absfun->type.as_object());
|
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();
|
return printer.get_text();
|
||||||
}
|
}
|
||||||
@@ -971,10 +971,7 @@ void pgf_create_function(PgfDB *db, PgfRevision revision,
|
|||||||
absfun->type = m->match_type(&u, ty);
|
absfun->type = m->match_type(&u, ty);
|
||||||
absfun->arity = arity;
|
absfun->arity = arity;
|
||||||
absfun->bytecode = bytecode ? PgfDB::malloc<char>(0) : 0;
|
absfun->bytecode = bytecode ? PgfDB::malloc<char>(0) : 0;
|
||||||
absfun->ep.prob = prob;
|
absfun->prob = prob;
|
||||||
ref<PgfExprFun> efun =
|
|
||||||
ref<PgfExprFun>::from_ptr((PgfExprFun*) &absfun->name);
|
|
||||||
absfun->ep.expr = ref<PgfExprFun>::tagged(efun);
|
|
||||||
memcpy(&absfun->name, name, sizeof(PgfText)+name->size+1);
|
memcpy(&absfun->name, name, sizeof(PgfText)+name->size+1);
|
||||||
|
|
||||||
Namespace<PgfAbsFun> funs =
|
Namespace<PgfAbsFun> funs =
|
||||||
|
|||||||
@@ -324,7 +324,6 @@ ref<PgfAbsFun> PgfReader::read_absfun()
|
|||||||
absfun->ref_count = 1;
|
absfun->ref_count = 1;
|
||||||
ref<PgfExprFun> efun =
|
ref<PgfExprFun> efun =
|
||||||
ref<PgfExprFun>::from_ptr((PgfExprFun*) &absfun->name);
|
ref<PgfExprFun>::from_ptr((PgfExprFun*) &absfun->name);
|
||||||
absfun->ep.expr = ref<PgfExprFun>::tagged(efun);
|
|
||||||
absfun->type = read_type();
|
absfun->type = read_type();
|
||||||
absfun->arity = read_int();
|
absfun->arity = read_int();
|
||||||
|
|
||||||
@@ -341,7 +340,7 @@ ref<PgfAbsFun> PgfReader::read_absfun()
|
|||||||
default:
|
default:
|
||||||
throw pgf_error("Unknown tag, 0 or 1 expected");
|
throw pgf_error("Unknown tag, 0 or 1 expected");
|
||||||
}
|
}
|
||||||
absfun->ep.prob = - log(read_double());
|
absfun->prob = - log(read_double());
|
||||||
return absfun;
|
return absfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ void PgfWriter::write_absfun(ref<PgfAbsFun> absfun)
|
|||||||
write_tag(1);
|
write_tag(1);
|
||||||
write_len(0);
|
write_len(0);
|
||||||
}
|
}
|
||||||
write_double(exp(-absfun->ep.prob));
|
write_double(exp(-absfun->prob));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -297,7 +297,7 @@ void write_funs_by_cat(Namespace<PgfAbsFun> funs, PgfText *cat, PgfWriter *wtr)
|
|||||||
write_funs_by_cat(funs->left, cat, wtr);
|
write_funs_by_cat(funs->left, cat, wtr);
|
||||||
|
|
||||||
if (textcmp(&funs->value->name, cat) == 0) {
|
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);
|
wtr->write_name(&funs->value->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ private:
|
|||||||
template<class V>
|
template<class V>
|
||||||
void write_namespace_helper(Namespace<V> nmsp, void (PgfWriter::*write_value)(ref<V>));
|
void write_namespace_helper(Namespace<V> nmsp, void (PgfWriter::*write_value)(ref<V>));
|
||||||
|
|
||||||
void write_patt(ref<PgfPatt> r) { write_patt(*r); };
|
|
||||||
void write_text(ref<ref<PgfText>> r) { write_text(&(**r)); };
|
void write_text(ref<ref<PgfText>> r) { write_text(&(**r)); };
|
||||||
void write_lparam(ref<ref<PgfLParam>> r) { write_lparam(*r); };
|
void write_lparam(ref<ref<PgfLParam>> r) { write_lparam(*r); };
|
||||||
void write_seq(ref<ref<Vector<PgfSymbol>>> r) { write_seq(*r); };
|
void write_seq(ref<ref<Vector<PgfSymbol>>> r) { write_seq(*r); };
|
||||||
|
|||||||
Reference in New Issue
Block a user