1/*
2 * Copyright (c) 2005, 2015, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24package jdk.test.lib.jittester.classes;
25
26import java.util.ArrayList;
27import java.util.List;
28import jdk.test.lib.jittester.IRNode;
29import jdk.test.lib.jittester.types.TypeKlass;
30import jdk.test.lib.jittester.visitors.Visitor;
31
32
33public class Klass extends IRNode {
34
35    public TypeKlass getThisKlass() {
36        return thisKlass;
37    }
38
39    public List<TypeKlass> getInterfaces() {
40        return interfaces;
41    }
42
43    public TypeKlass getParentKlass() {
44        return parentKlass;
45    }
46
47    @Override
48    public String getName() {
49        return name;
50    }
51
52    public enum KlassPart {
53        DATA_MEMBERS,
54        CONSTRUCTORS,
55        REDEFINED_FUNCTIONS,
56        OVERRIDEN_FUNCTIONS,
57        MEMBER_FUNCTIONS,
58        MEMBER_FUNCTIONS_DECLARATIONS,
59        PRINT_VARIABLES,
60    }
61
62    protected final String name;
63    protected final TypeKlass thisKlass;
64    private final TypeKlass parentKlass;
65    private final ArrayList<TypeKlass> interfaces;
66
67    public Klass(TypeKlass thisKlass, TypeKlass parent,
68            ArrayList<TypeKlass> interfaces, String name, int level,
69            IRNode variableDeclarations, IRNode constructorDefinitions,
70            IRNode functionDefinitions, IRNode abstractFunctionRedefinitions,
71            IRNode overridenFunctionRedefitions, IRNode functionDeclarations,
72            IRNode printVariablesBlock) {
73        super(thisKlass);
74        this.thisKlass = thisKlass;
75        owner = thisKlass;
76        this.parentKlass = parent;
77        this.interfaces = interfaces;
78        this.name = name;
79        this.level = level;
80        resizeUpChildren(KlassPart.values().length);
81        setChild(KlassPart.DATA_MEMBERS.ordinal(), variableDeclarations);
82        setChild(KlassPart.CONSTRUCTORS.ordinal(), constructorDefinitions);
83        setChild(KlassPart.REDEFINED_FUNCTIONS.ordinal(), abstractFunctionRedefinitions);
84        setChild(KlassPart.OVERRIDEN_FUNCTIONS.ordinal(), overridenFunctionRedefitions);
85        setChild(KlassPart.MEMBER_FUNCTIONS.ordinal(), functionDefinitions);
86        setChild(KlassPart.MEMBER_FUNCTIONS_DECLARATIONS.ordinal(), functionDeclarations);
87        setChild(KlassPart.PRINT_VARIABLES.ordinal(), printVariablesBlock);
88    }
89
90    @Override
91    public long complexity() {
92        return 0;
93    }
94
95    @Override
96    public<T> T accept(Visitor<T> v) {
97        return v.visit(this);
98    }
99}
100