2 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3 * Use of this file is governed by the BSD 3-clause license that
4 * can be found in the LICENSE.txt file in the project root.
9 #include "atn/PredictionContext.h"
14 class SingletonPredictionContext;
16 class ANTLR4CPP_PUBLIC ArrayPredictionContext : public PredictionContext {
18 /// Parent can be empty only if full ctx mode and we make an array
19 /// from EMPTY and non-empty. We merge EMPTY by using null parent and
20 /// returnState == EMPTY_RETURN_STATE.
21 // Also here: we use a strong reference to our parents to avoid having them freed prematurely.
22 // See also SinglePredictionContext.
23 const std::vector<Ref<PredictionContext>> parents;
25 /// Sorted for merge, no duplicates; if present, EMPTY_RETURN_STATE is always last.
26 const std::vector<size_t> returnStates;
28 ArrayPredictionContext(Ref<SingletonPredictionContext> const& a);
29 ArrayPredictionContext(std::vector<Ref<PredictionContext>> const& parents_, std::vector<size_t> const& returnStates);
30 virtual ~ArrayPredictionContext();
32 virtual bool isEmpty() const override;
33 virtual size_t size() const override;
34 virtual Ref<PredictionContext> getParent(size_t index) const override;
35 virtual size_t getReturnState(size_t index) const override;
36 bool operator == (const PredictionContext &o) const override;
38 virtual std::string toString() const override;