1 /*
2  * [The "BSD license"]
3  *  Copyright (c) 2013 Terence Parr
4  *  Copyright (c) 2013 Sam Harwell
5  *  Copyright (c) 2017 Egbert Voigt
6  *  All rights reserved.
7  *
8  *  Redistribution and use in source and binary forms, with or without
9  *  modification, are permitted provided that the following conditions
10  *  are met:
11  *
12  *  1. Redistributions of source code must retain the above copyright
13  *     notice, this list of conditions and the following disclaimer.
14  *  2. Redistributions in binary form must reproduce the above copyright
15  *     notice, this list of conditions and the following disclaimer in the
16  *     documentation and/or other materials provided with the distribution.
17  *  3. The name of the author may not be used to endorse or promote products
18  *     derived from this software without specific prior written permission.
19  *
20  *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 module antlr.v4.runtime.atn.ATNDeserializationOptions;
33 
34 /**
35  * Options setting for deserialization
36  */
37 class ATNDeserializationOptions
38 {
39 
40     public static ATNDeserializationOptions defaultOptions;
41 
42     /**
43      * @uml
44      * @read
45      */
46     private bool readOnly_;
47 
48     /**
49      * @uml
50      * @read
51      * @write
52      */
53     private bool verifyATN_;
54 
55     /**
56      * @uml
57      * @read
58      * @write
59      */
60     private bool generateRuleBypassTransitions_;
61 
62     /**
63      * @uml
64      * @read
65      * @write
66      */
67     private bool optimize_;
68 
69     public static this()
70     {
71         defaultOptions = new ATNDeserializationOptions();
72         defaultOptions.readOnly_ = true;
73     }
74 
75     public this()
76     {
77         this.verifyATN_ = true;
78         this.generateRuleBypassTransitions_ = false;
79         this.optimize_ = true;
80     }
81 
82     public this(ATNDeserializationOptions options)
83     {
84         this.verifyATN_ = options.verifyATN;
85         this.generateRuleBypassTransitions_ = options.generateRuleBypassTransitions;
86         this.optimize_ = options.optimize;
87     }
88 
89     public void makeReadOnly()
90     {
91         readOnly_ = true;
92     }
93 
94     private void throwIfReadOnly()
95     {
96         assert(!readOnly_, "The object is read only.");
97     }
98 
99     public final bool readOnly()
100     {
101         return this.readOnly_;
102     }
103 
104     public final bool verifyATN()
105     {
106         return this.verifyATN_;
107     }
108 
109     public final void verifyATN(bool verifyATN)
110     {
111         this.verifyATN_ = verifyATN;
112     }
113 
114     public final bool generateRuleBypassTransitions()
115     {
116         return this.generateRuleBypassTransitions_;
117     }
118 
119     public final void generateRuleBypassTransitions(bool generateRuleBypassTransitions)
120     {
121         this.generateRuleBypassTransitions_ = generateRuleBypassTransitions;
122     }
123 
124     public final bool optimize()
125     {
126         return this.optimize_;
127     }
128 
129     public final void optimize(bool optimize)
130     {
131         this.optimize_ = optimize;
132     }
133 
134 }