/* Generated by: JJTree: Do not edit this line. BSHEnumConstant.java Version 1.0 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=BSH,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
/** Copyright 2018 Nick nickl- Lombard
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. */
package bsh;

public class BSHEnumConstant extends SimpleNode {
    private static final long serialVersionUID = 1L;
    Modifiers mods = new Modifiers(Modifiers.FIELD);
    {
        mods.setConstant();
        mods.addModifier("enum");
    }
    String name;

    public BSHEnumConstant(int id) { super(id); }

    public Object eval( CallStack callstack, Interpreter interpreter ) throws EvalError {
        NameSpace namespace = callstack.top();
        if ( !getName().equals(""+namespace.classInstance) )
            return Primitive.VOID;

        if (hasArguments(callstack, interpreter))
            This.CONTEXT_ARGS.get().put( namespace.classInstance.toString(), getArguments(callstack, interpreter) );

        for ( int i = 0; i < jjtGetNumChildren(); i++ )
            if ( jjtGetChild(i) instanceof BSHBlock )
                ((BSHBlock) jjtGetChild(i)).eval(callstack, interpreter, true);

        return Primitive.VOID;
    }

    public boolean hasArguments(CallStack callstack, Interpreter interpreter) throws EvalError {
        return null != getArguments(callstack, interpreter);
    }

    Object[] args;
    public Object[] getArguments(CallStack callstack, Interpreter interpreter) throws EvalError {
        if (args == null && jjtGetNumChildren() > 0 && jjtGetChild(0) instanceof BSHArguments) {
            BSHArguments arg = (BSHArguments)jjtGetChild(0);
            args = arg.getArguments(callstack, interpreter);
        }
        return args;
    }

    public Class<?> getType() {
        return Enum.class;
    }

    public String getName( ) {
        return name;
    }

    public String toString() {
        return super.toString() + ": " + mods + " " + getType() + " " + name;
    }
}
/* JavaCC - OriginalChecksum=6bf5bca59c6d351657103c4ff0e8d054 (do not edit this line) */
