6
|
1 |
/*
|
|
2 |
* reserved comment block
|
|
3 |
* DO NOT REMOVE OR ALTER!
|
|
4 |
*/
|
|
5 |
/*
|
|
6 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
7 |
*
|
|
8 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9 |
* you may not use this file except in compliance with the License.
|
|
10 |
* You may obtain a copy of the License at
|
|
11 |
*
|
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13 |
*
|
|
14 |
* Unless required by applicable law or agreed to in writing, software
|
|
15 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17 |
* See the License for the specific language governing permissions and
|
|
18 |
* limitations under the License.
|
|
19 |
*/
|
|
20 |
/*
|
|
21 |
* $Id: TopLevelElement.java,v 1.5 2005/09/28 13:48:17 pvedula Exp $
|
|
22 |
*/
|
|
23 |
|
|
24 |
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
|
25 |
|
|
26 |
import java.util.Vector;
|
|
27 |
|
|
28 |
import com.sun.org.apache.bcel.internal.generic.InstructionList;
|
|
29 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
|
|
30 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
|
|
31 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
|
32 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
|
33 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
|
34 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
|
35 |
|
|
36 |
class TopLevelElement extends SyntaxTreeNode {
|
|
37 |
|
|
38 |
/*
|
|
39 |
* List of dependencies with other variables, parameters or
|
|
40 |
* keys defined at the top level.
|
|
41 |
*/
|
|
42 |
protected Vector _dependencies = null;
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Type check all the children of this node.
|
|
46 |
*/
|
|
47 |
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
|
|
48 |
return typeCheckContents(stable);
|
|
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Translate this node into JVM bytecodes.
|
|
53 |
*/
|
|
54 |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
|
|
55 |
ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR,
|
|
56 |
getClass(), this);
|
|
57 |
getParser().reportError(FATAL, msg);
|
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Translate this node into a fresh instruction list.
|
|
62 |
* The original instruction list is saved and restored.
|
|
63 |
*/
|
|
64 |
public InstructionList compile(ClassGenerator classGen,
|
|
65 |
MethodGenerator methodGen) {
|
|
66 |
final InstructionList result, save = methodGen.getInstructionList();
|
|
67 |
methodGen.setInstructionList(result = new InstructionList());
|
|
68 |
translate(classGen, methodGen);
|
|
69 |
methodGen.setInstructionList(save);
|
|
70 |
return result;
|
|
71 |
}
|
|
72 |
|
|
73 |
public void display(int indent) {
|
|
74 |
indent(indent);
|
|
75 |
Util.println("TopLevelElement");
|
|
76 |
displayContents(indent + IndentIncrement);
|
|
77 |
}
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Add a dependency with other top-level elements like
|
|
81 |
* variables, parameters or keys.
|
|
82 |
*/
|
|
83 |
public void addDependency(TopLevelElement other) {
|
|
84 |
if (_dependencies == null) {
|
|
85 |
_dependencies = new Vector();
|
|
86 |
}
|
|
87 |
if (!_dependencies.contains(other)) {
|
|
88 |
_dependencies.addElement(other);
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Get the list of dependencies with other top-level elements
|
|
94 |
* like variables, parameteres or keys.
|
|
95 |
*/
|
|
96 |
public Vector getDependencies() {
|
|
97 |
return _dependencies;
|
|
98 |
}
|
|
99 |
|
|
100 |
}
|