From bcc6cdf2d5161f8de56a5d5f1888b6848ace3821 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 26 May 2022 10:06:55 +0000 Subject: [PATCH] Checking null problem components Signed-off-by: Ubuntu --- src/VALfiles/SimpleEval.cpp | 7 ++++++- src/VALfiles/TimSupport.h | 2 +- src/VALfiles/TypedAnalyser.h | 4 ++-- src/VALfiles/instantiation.cpp | 6 +++--- src/VALfiles/instantiation.h | 2 +- src/VALfiles/typecheck.cpp | 2 +- src/popf/RPGBuilder.cpp | 6 +++--- src/popf/RPGBuilderNumerics.cpp | 4 ++-- 8 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/VALfiles/SimpleEval.cpp b/src/VALfiles/SimpleEval.cpp index eefa357..b0d62ab 100644 --- a/src/VALfiles/SimpleEval.cpp +++ b/src/VALfiles/SimpleEval.cpp @@ -43,7 +43,12 @@ void InitialStateEvaluator::setInitialState() { initState.clear(); init0State.clear(); - + + if (!current_analysis->the_problem->initial_state) { + return; + } + + for(pc_list::const_iterator i = current_analysis->the_problem->initial_state->add_effects.begin(); i != current_analysis->the_problem->initial_state->add_effects.end();++i) diff --git a/src/VALfiles/TimSupport.h b/src/VALfiles/TimSupport.h index 46f005e..d364a5a 100644 --- a/src/VALfiles/TimSupport.h +++ b/src/VALfiles/TimSupport.h @@ -935,7 +935,7 @@ class TIMAnalyser : public VAL::VisitController { virtual void visit_problem(VAL::problem * p) { initially = true; - p->initial_state->visit(this); + if (p->initial_state) p->initial_state->visit(this); initially = false; finally = true; if(p->the_goal) p->the_goal->visit(this); diff --git a/src/VALfiles/TypedAnalyser.h b/src/VALfiles/TypedAnalyser.h index 1ae5f53..23936d8 100644 --- a/src/VALfiles/TypedAnalyser.h +++ b/src/VALfiles/TypedAnalyser.h @@ -1274,7 +1274,7 @@ class TypePredSubstituter : public VisitController { }; virtual void visit_problem(problem * p) { - p->initial_state->visit(this); + if( p->initial_state) p->initial_state->visit(this); if(p->the_goal) p->the_goal->visit(this); if(p->constraints) p->constraints->visit(this); }; @@ -1504,7 +1504,7 @@ class Analyser : public VisitController { virtual void visit_problem(problem * p) { initially = true; - p->initial_state->visit(this); + if (p->initial_state) p->initial_state->visit(this); initially = false; finally = true; if(p->the_goal) p->the_goal->visit(this); diff --git a/src/VALfiles/instantiation.cpp b/src/VALfiles/instantiation.cpp index 68bf97c..c4f6da3 100644 --- a/src/VALfiles/instantiation.cpp +++ b/src/VALfiles/instantiation.cpp @@ -792,7 +792,7 @@ class InstQueueEntry { /** Lexicographic comparison of const_symbols, based on their names */ struct ConstSymbolLT { - bool operator()(const VAL::const_symbol* const a, const VAL::const_symbol* const b) { + bool operator()(const VAL::const_symbol* const a, const VAL::const_symbol* const b) const { return (a->getName() < b->getName()); } }; @@ -2163,9 +2163,9 @@ class Collector : public VisitController visit_operator_(p); }; virtual void visit_problem(VAL::problem * p) { - p->initial_state->visit(this); + if (p->initial_state) p->initial_state->visit(this); inpres = false; - p->the_goal->visit(this); + if (p->the_goal) p->the_goal->visit(this); if (p->constraints) p->constraints->visit(this); }; diff --git a/src/VALfiles/instantiation.h b/src/VALfiles/instantiation.h index 68810e3..65bd831 100644 --- a/src/VALfiles/instantiation.h +++ b/src/VALfiles/instantiation.h @@ -76,7 +76,7 @@ class instantiatedDrvUtils { struct indexLT { - bool operator() (const index & a, const index & b) { + bool operator() (const index & a, const index & b) const { VAL::pred_symbol * afirst = VAL::current_analysis->pred_tab.symbol_get(a.first->getName()); VAL::pred_symbol * bfirst = VAL::current_analysis->pred_tab.symbol_get(b.first->getName()); if (afirst < bfirst) return true; diff --git a/src/VALfiles/typecheck.cpp b/src/VALfiles/typecheck.cpp index f88afe1..d90a976 100644 --- a/src/VALfiles/typecheck.cpp +++ b/src/VALfiles/typecheck.cpp @@ -793,7 +793,7 @@ bool TypeChecker::typecheckProblem() if (Verbose) *report << "Type-checking goal failed\n"; return false; } - if (!typecheckEffects(thea->the_problem->initial_state)) { + if (thea->the_problem->initial_state && !typecheckEffects(thea->the_problem->initial_state)) { if (Verbose) *report << "Type-checking initial state failed\n"; return false; } diff --git a/src/popf/RPGBuilder.cpp b/src/popf/RPGBuilder.cpp index a873811..f78fd36 100644 --- a/src/popf/RPGBuilder.cpp +++ b/src/popf/RPGBuilder.cpp @@ -322,13 +322,13 @@ class GoalNumericCollector : public VisitController virtual void visit_problem(VAL::problem * p) { - + WhereAreWeNow = PARSE_GOAL; inpres = false; numToUse = numericGoals; litToUse = literalGoals; - p->the_goal->visit(this); + if(p->the_goal) p->the_goal->visit(this); WhereAreWeNow = PARSE_UNKNOWN; if (p->constraints) { WhereAreWeNow = PARSE_CONSTRAINTS; @@ -1867,7 +1867,7 @@ class InitialStateCollector : public VisitController virtual void visit_problem(VAL::problem * p) { TimedPrecEffCollector::toBlame = 0; WhereAreWeNow = PARSE_INITIAL; - p->initial_state->visit(this); + if (p->initial_state) p->initial_state->visit(this); WhereAreWeNow = PARSE_UNKNOWN; //inpres = false; //p->the_goal->visit(this); diff --git a/src/popf/RPGBuilderNumerics.cpp b/src/popf/RPGBuilderNumerics.cpp index a483c3c..aaec667 100644 --- a/src/popf/RPGBuilderNumerics.cpp +++ b/src/popf/RPGBuilderNumerics.cpp @@ -954,7 +954,7 @@ struct InvData { struct LTAVPointer { - bool operator()(const RPGBuilder::ArtificialVariable * const a, const RPGBuilder::ArtificialVariable * const b) { + bool operator()(const RPGBuilder::ArtificialVariable * const a, const RPGBuilder::ArtificialVariable * const b) const { return ((*a) < (*b)); }; @@ -962,7 +962,7 @@ struct InvData { struct LTRNPPointer { - bool operator()(const RPGBuilder::RPGNumericPrecondition * const a, const RPGBuilder::RPGNumericPrecondition * const b) { + bool operator()(const RPGBuilder::RPGNumericPrecondition * const a, const RPGBuilder::RPGNumericPrecondition * const b) const { return ((*a) < (*b)); };