1/*
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package jdk.nashorn.internal.ir;
27
28/**
29 * Interface implemented by all nodes that have flags in
30 * a lexical context. This is needed as we sometimes have to save
31 * the setting of flags in the lexical context until a block
32 * is completely finished and its final version (after multiple
33 * copy on writes) is placed in the lexical context
34 *
35 * @param <T> lexical context node that can have flags set during code generation
36 */
37public interface Flags<T extends LexicalContextNode> {
38
39    /**
40     * Get all flags of a LexicalContextNode
41     * @return flags
42     */
43    public int getFlags();
44
45    /**
46     * Check if a flag is set in a lexical context node
47     * @param flag flag to check
48     * @return flags
49     */
50    public boolean getFlag(int flag);
51
52    /**
53     * Clear a flag of a LexicalContextNode
54     * @param lc lexical context
55     * @param flag flag to clear
56     * @return the new LexicalContext node if flags were changed, same otherwise
57     */
58    public T clearFlag(final LexicalContext lc, int flag);
59
60    /**
61     * Set a flag of a LexicalContextNode
62     * @param lc lexical context
63     * @param flag flag to set
64     * @return the new LexicalContext node if flags were changed, same otherwise
65     */
66    public T setFlag(final LexicalContext lc, int flag);
67
68    /**
69     * Set all flags of a LexicalContextNode, overwriting previous flags
70     * @param lc lexical context
71     * @param flags new flags value
72     * @return the new LexicalContext node if flags were changed, same otherwise
73     */
74    public T setFlags(final LexicalContext lc, int flags);
75}
76