KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > 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 org.apache.xalan.xsltc.compiler;
21
22 import org.apache.bcel.generic.InstructionList;
23 import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
24 import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
25 import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
26 import org.apache.xalan.xsltc.compiler.util.Type;
27 import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
28 import org.apache.xalan.xsltc.compiler.util.Util;
29
30 class TopLevelElement extends SyntaxTreeNode {
31
32     /**
33      * Type check all the children of this node.
34      */

35     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
36     return typeCheckContents(stable);
37     }
38
39     /**
40      * Translate this node into JVM bytecodes.
41      */

42     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
43     ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR,
44                     getClass(), this);
45     getParser().reportError(FATAL, msg);
46     }
47     
48     /**
49      * Translate this node into a fresh instruction list.
50      * The original instruction list is saved and restored.
51      */

52     public InstructionList compile(ClassGenerator classGen,
53                    MethodGenerator methodGen) {
54     final InstructionList result, save = methodGen.getInstructionList();
55     methodGen.setInstructionList(result = new InstructionList());
56     translate(classGen, methodGen);
57     methodGen.setInstructionList(save);
58     return result;
59     }
60
61     public void display(int indent) {
62     indent(indent);
63     Util.println("TopLevelElement");
64     displayContents(indent + IndentIncrement);
65     }
66 }
67
Popular Tags