Update: use resource protection section there as the arrays for var intro are now global
@@ -208,6 +208,8 @@ int appearing_left[ATOMS_MAX] = {0};
int appearing_right[ATOMS_MAX] = {0};
char variable_id[ATOMS_MAX] = {0};
Term Variable_IntroduceImplicationVariables(Term implication, bool *success, bool extensionally)
+{
+ #pragma omp critical(VarIntro)
{
assert(Narsese_copulaEquals(implication.atoms[0], TEMPORAL_IMPLICATION) || Narsese_copulaEquals(implication.atoms[0], IMPLICATION) || Narsese_copulaEquals(implication.atoms[0], EQUIVALENCE), "An implication is expected here!");
Term left_side = Term_ExtractSubterm(&implication, 1);
@@ -220,6 +222,7 @@ Term Variable_IntroduceImplicationVariables(Term implication, bool *success, boo
char indepvar_i = 1;
memset(variable_id, 0, ATOMS_MAX*sizeof(char));
Term implication_copy = implication;
+ *success = true;
for(int i=0; i<COMPOUND_TERM_SIZE_MAX; i++)
{
Atom atom = implication_copy.atoms[i];
@@ -235,7 +238,7 @@ Term Variable_IntroduceImplicationVariables(Term implication, bool *success, boo
if(!Term_OverrideSubterm(&implication, i, &varterm))
{
*success = false;
- return implication;
+ break;
}
}
}
@@ -249,18 +252,19 @@ Term Variable_IntroduceImplicationVariables(Term implication, bool *success, boo
if(!Term_OverrideSubterm(&implication, i, &varterm))
{
*success = false;
- return implication;
+ break;
+ }
}
}
}
}
-
}
- *success = true;
return implication;
}
Term Variable_IntroduceConjunctionVariables(Term conjunction, bool *success, bool extensionally)
+{
+ #pragma omp critical(VarIntro)
{
assert(Narsese_copulaEquals(conjunction.atoms[0], CONJUNCTION), "A conjunction is expected here!");
memset(appearing_left, 0, ATOMS_MAX*sizeof(int));
@@ -269,6 +273,7 @@ Term Variable_IntroduceConjunctionVariables(Term conjunction, bool *success, boo
char depvar_i = 1;
memset(variable_id, 0, ATOMS_MAX*sizeof(char));
Term conjunction_copy = conjunction;
+ *success = true;
for(int i=0; i<COMPOUND_TERM_SIZE_MAX; i++)
{
Atom atom = conjunction_copy.atoms[i];
@@ -282,12 +287,12 @@ Term Variable_IntroduceConjunctionVariables(Term conjunction, bool *success, boo
if(!Term_OverrideSubterm(&conjunction, i, &varterm))
{
*success = false;
- return conjunction;
+ break;
+ }
}
}
}
}
- *success = true;
return conjunction;
}
