Commit c78ab0f3 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

bugfix time in SBML, closes #54

parent 4c70b108
......@@ -9,6 +9,27 @@
PL_fail; \
}
void
replace_time(ASTNode_t* math) {
if (ASTNode_getType(math) == AST_NAME_TIME) {
ASTNode_setName(math, "Time");
} else if (ASTNode_getNumChildren(math) > 0) {
for (int n = 0; n < ASTNode_getNumChildren(math); ++n) {
replace_time(ASTNode_getChild(math, n));
}
}
}
static foreign_t
get_formula_from_math(const ASTNode_t* math, term_t formula_term) {
const char* formula;
ASTNode_t* newmath = ASTNode_deepCopy(math);
replace_time(newmath);
formula = SBML_formulaToString(newmath);
PL_check(PL_unify_atom_chars(formula_term, formula));
PL_succeed;
}
int
PL_get_sbmlDocument(term_t document_term, SBMLDocument_t **document) {
return PL_get_pointer(document_term, (void **) document);
......@@ -289,10 +310,10 @@ pl_reaction_getId(term_t reaction_term, term_t id_term) {
static foreign_t
pl_kineticLaw_getMath(term_t kineticLaw_term, term_t formula_term) {
KineticLaw_t *kineticLaw;
const char *formula;
const ASTNode_t *math;
PL_check(PL_get_kineticLaw(kineticLaw_term, &kineticLaw));
PL_check(formula = KineticLaw_getFormula(kineticLaw));
PL_check(PL_unify_atom_chars(formula_term, formula));
PL_check(math = KineticLaw_getMath(kineticLaw));
get_formula_from_math(math, formula_term);
PL_succeed;
}
......@@ -490,10 +511,10 @@ pl_rule_getVariable(term_t rule_term, term_t variable_term) {
static foreign_t
pl_rule_getMath(term_t rule_term, term_t formula_term) {
Rule_t *rule;
const char *formula;
const ASTNode_t *math;
PL_check(PL_get_rule(rule_term, &rule));
PL_check(formula = Rule_getFormula(rule));
PL_check(PL_unify_atom_chars(formula_term, formula));
PL_check(math = Rule_getMath(rule));
get_formula_from_math(math, formula_term);
PL_succeed;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment