From bdf6eca6f7a72c8e8583921521c2e4205fff498c Mon Sep 17 00:00:00 2001 From: Dominik Drexler Date: Tue, 2 Jan 2024 12:21:08 +0100 Subject: [PATCH] iteration on some code --- include/common/pddl/context.hpp | 2 +- include/common/pddl/position.hpp | 8 +++++--- include/common/pddl/position.tpp | 8 ++++---- include/common/pddl/reference.hpp | 3 +-- include/common/pddl/types.hpp | 4 ++++ include/domain/pddl/declarations.hpp | 16 ---------------- include/problem/pddl/declarations.hpp | 5 ----- src/domain/pddl/parser/types.cpp | 1 - 8 files changed, 15 insertions(+), 32 deletions(-) diff --git a/include/common/pddl/context.hpp b/include/common/pddl/context.hpp index d5a4b6e3..3074c8cb 100644 --- a/include/common/pddl/context.hpp +++ b/include/common/pddl/context.hpp @@ -34,7 +34,7 @@ namespace loki PDDLPositionCache& positions; // For referencing to existing bindings ScopeStack& scopes; - // For checking that binding pointers were referenced at least once + // For checking that certain PDDL objects were referenced at least once ReferencedPDDLObjects references; // For convenience, to avoid an additional parameter during semantic parsing pddl::Requirements requirements; diff --git a/include/common/pddl/position.hpp b/include/common/pddl/position.hpp index 8c602537..65b89eef 100644 --- a/include/common/pddl/position.hpp +++ b/include/common/pddl/position.hpp @@ -19,6 +19,8 @@ #define LOKI_INCLUDE_LOKI_COMMON_PDDL_POSITION_HPP_ #include "config.hpp" +#include "declarations.hpp" + #include "../ast/error_reporting.hpp" #include "../filesystem.hpp" @@ -27,7 +29,7 @@ namespace loki { template -using PositionMapType = std::unordered_map>; +using PositionMapType = std::unordered_map, std::vector>; /// @brief Stores all occurrences of a PDDL object in the input file for each PDDL type T. template @@ -41,10 +43,10 @@ class PositionCache { PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs=4); template - void push_back(const T* object, const PositionType& position); + void push_back(const PDDLElement& element, const PositionType& position); template - std::vector get(const T* object) const; + std::vector get(const PDDLElement& element) const; const PDDLErrorHandler& get_error_handler() const; }; diff --git a/include/common/pddl/position.tpp b/include/common/pddl/position.tpp index 7fc6d5ca..8b09768c 100644 --- a/include/common/pddl/position.tpp +++ b/include/common/pddl/position.tpp @@ -25,16 +25,16 @@ PositionCache::PositionCache(const X3ErrorHandler& error_handler, const f template template -void PositionCache::push_back(const T* object, const PositionType& position) { +void PositionCache::push_back(const PDDLElement& element, const PositionType& position) { auto& t_positions = std::get>(m_positions); - t_positions[object].push_back(position); + t_positions[element].push_back(position); } template template -std::vector PositionCache::get(const T* object) const { +std::vector PositionCache::get(const PDDLElement& element) const { auto& t_positions = std::get>(m_positions); - auto it = t_positions.find(object); + auto it = t_positions.find(element); if (it != t_positions.end()) { return it->second; } diff --git a/include/common/pddl/reference.hpp b/include/common/pddl/reference.hpp index 974a22c1..0b3a4dc4 100644 --- a/include/common/pddl/reference.hpp +++ b/include/common/pddl/reference.hpp @@ -65,8 +65,7 @@ class References { void untrack(T reference); }; -using ReferencedPDDLObjects = References; using TypeFactory = PersistentFactory; using VariableFactory = PersistentFactory; diff --git a/include/domain/pddl/declarations.hpp b/include/domain/pddl/declarations.hpp index 1df5ab9b..7c5c522c 100644 --- a/include/domain/pddl/declarations.hpp +++ b/include/domain/pddl/declarations.hpp @@ -22,12 +22,8 @@ #include -#include -#include #include -#include #include -#include #include @@ -38,12 +34,10 @@ namespace loki::pddl { class TypeImpl; using Type = const TypeImpl*; using TypeList = boost::container::small_vector; // often single type - using TypeSet = std::set; class ObjectImpl; using Object = const ObjectImpl*; using ObjectList = std::vector; - using ObjectSet = std::set; class VariableImpl; using Variable = const VariableImpl*; @@ -68,12 +62,10 @@ namespace loki::pddl { class PredicateImpl; using Predicate = const PredicateImpl*; using PredicateList = std::vector; - using PredicateSet = std::set; class LiteralImpl; using Literal = const LiteralImpl*; using LiteralList = std::vector; - using LiteralSet = std::set; class ConditionLiteralImpl; class ConditionAndImpl; @@ -91,7 +83,6 @@ namespace loki::pddl { , ConditionForallImpl>; using Condition = const ConditionImpl*; using ConditionList = std::vector; - using ConditionSet = std::set; class EffectLiteralImpl; class EffectAndImpl; @@ -105,7 +96,6 @@ namespace loki::pddl { , EffectConditionalWhenImpl>; using Effect = const EffectImpl*; using EffectList = std::vector; - using EffectSet = std::set; class FunctionExpressionNumberImpl; class FunctionExpressionBinaryOperatorImpl; @@ -123,32 +113,26 @@ namespace loki::pddl { class FunctionSkeletonImpl; using FunctionSkeleton = const FunctionSkeletonImpl*; using FunctionSkeletonList = std::vector; - using FunctionSkeletonSet = std::set; class FunctionImpl; using Function = const FunctionImpl*; using FunctionList = std::vector; - using FunctionSet = std::set; class ConstraintImpl; using Constraint = const ConstraintImpl*; using ConstraintList = std::vector; - using ConstraintSet = std::set; class ActionImpl; using Action = const ActionImpl*; using ActionList = std::vector; - using ActionSet = std::set; class DerivedPredicateImpl; using DerivedPredicate = const DerivedPredicateImpl*; using DerivedPredicateList = std::vector; - using DerivedPredicateSet = std::set; class DomainImpl; using Domain = const DomainImpl*; using DomainList = std::vector; - using DomainSet = std::set; } #endif diff --git a/include/problem/pddl/declarations.hpp b/include/problem/pddl/declarations.hpp index 34b99764..ea562469 100644 --- a/include/problem/pddl/declarations.hpp +++ b/include/problem/pddl/declarations.hpp @@ -20,11 +20,6 @@ #include "../../domain/pddl/declarations.hpp" -#include -#include -#include -#include -#include #include diff --git a/src/domain/pddl/parser/types.cpp b/src/domain/pddl/parser/types.cpp index b1698c84..6170758f 100644 --- a/src/domain/pddl/parser/types.cpp +++ b/src/domain/pddl/parser/types.cpp @@ -113,7 +113,6 @@ static void test_reserved_type(const pddl::Type& type, const domain::ast::Name& static void insert_context_information(const pddl::Type& type, const domain::ast::Name& node, Context& context) { context.positions.push_back(type, node); context.scopes.insert(type->get_name(), type, node); - context.references.track(type); }