KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xalan > internal > xsltc > compiler > TopLevelElement


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: TopLevelElement.java,v 1.7 2004/02/16 22:25:10 minchau Exp $
18  */

19
20 package com.sun.org.apache.xalan.internal.xsltc.compiler;
21
22 import java.util.Vector JavaDoc;
23
24 import com.sun.org.apache.bcel.internal.generic.InstructionList;
25 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
26 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
27 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
28 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
29 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
31
32 class TopLevelElement extends SyntaxTreeNode {
33
34    /*
35     * List of dependencies with other variables, parameters or
36     * keys defined at the top level.
37     */

38     protected Vector JavaDoc _dependencies = null;
39
40     /**
41      * Type check all the children of this node.
42      */

43     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
44     return typeCheckContents(stable);
45     }
46
47     /**
48      * Translate this node into JVM bytecodes.
49      */

50     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
51     ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR,
52                     getClass(), this);
53     getParser().reportError(FATAL, msg);
54     }
55     
56     /**
57      * Translate this node into a fresh instruction list.
58      * The original instruction list is saved and restored.
59      */

60     public InstructionList compile(ClassGenerator classGen,
61                    MethodGenerator methodGen) {
62     final InstructionList result, save = methodGen.getInstructionList();
63     methodGen.setInstructionList(result = new InstructionList());
64     translate(classGen, methodGen);
65     methodGen.setInstructionList(save);
66     return result;
67     }
68
69     public void display(int indent) {
70     indent(indent);
71     Util.println("TopLevelElement");
72     displayContents(indent + IndentIncrement);
73     }
74
75     /**
76       * Add a dependency with other top-level elements like
77       * variables, parameters or keys.
78       */

79     public void addDependency(TopLevelElement other) {
80        if (_dependencies == null) {
81            _dependencies = new Vector JavaDoc();
82        }
83        if (!_dependencies.contains(other)) {
84            _dependencies.addElement(other);
85        }
86     }
87
88     /**
89       * Get the list of dependencies with other top-level elements
90       * like variables, parameteres or keys.
91       */

92     public Vector JavaDoc getDependencies() {
93         return _dependencies;
94     }
95 }
96
Popular Tags