1 16 19 20 package org.apache.xalan.xsltc.compiler; 21 22 import java.util.Vector ; 23 24 import org.apache.bcel.generic.ConstantPoolGen; 25 import org.apache.bcel.generic.INVOKESTATIC; 26 import org.apache.bcel.generic.InstructionList; 27 import org.apache.bcel.generic.PUSH; 28 29 import org.apache.xalan.xsltc.compiler.util.ClassGenerator; 30 import org.apache.xalan.xsltc.compiler.util.ErrorMsg; 31 import org.apache.xalan.xsltc.compiler.util.MethodGenerator; 32 import org.apache.xalan.xsltc.compiler.util.Type; 33 import org.apache.xalan.xsltc.compiler.util.TypeCheckError; 34 import org.apache.xalan.xsltc.compiler.util.Util; 35 36 39 final class UnsupportedElement extends SyntaxTreeNode { 40 41 private Vector _fallbacks = null; 42 private ErrorMsg _message = null; 43 private boolean _isExtension = false; 44 45 48 public UnsupportedElement(String uri, String prefix, String local, boolean isExtension) { 49 super(uri, prefix, local); 50 _isExtension = isExtension; 51 } 52 53 62 public void setErrorMessage(ErrorMsg message) { 63 _message = message; 64 } 65 66 69 public void display(int indent) { 70 indent(indent); 71 Util.println("Unsupported element = " + _qname.getNamespace() + 72 ":" + _qname.getLocalPart()); 73 displayContents(indent + IndentIncrement); 74 } 75 76 77 80 private void processFallbacks(Parser parser) { 81 82 Vector children = getContents(); 83 if (children != null) { 84 final int count = children.size(); 85 for (int i = 0; i < count; i++) { 86 SyntaxTreeNode child = (SyntaxTreeNode)children.elementAt(i); 87 if (child instanceof Fallback) { 88 Fallback fallback = (Fallback)child; 89 fallback.activate(); 90 fallback.parseContents(parser); 91 if (_fallbacks == null) { 92 _fallbacks = new Vector (); 93 } 94 _fallbacks.addElement(child); 95 } 96 } 97 } 98 } 99 100 103 public void parseContents(Parser parser) { 104 processFallbacks(parser); 105 } 106 107 110 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 111 if (_fallbacks != null) { 112 int count = _fallbacks.size(); 113 for (int i = 0; i < count; i++) { 114 Fallback fallback = (Fallback)_fallbacks.elementAt(i); 115 fallback.typeCheck(stable); 116 } 117 } 118 return Type.Void; 119 } 120 121 124 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 125 if (_fallbacks != null) { 126 int count = _fallbacks.size(); 127 for (int i = 0; i < count; i++) { 128 Fallback fallback = (Fallback)_fallbacks.elementAt(i); 129 fallback.translate(classGen, methodGen); 130 } 131 } 132 else { 135 ConstantPoolGen cpg = classGen.getConstantPool(); 139 InstructionList il = methodGen.getInstructionList(); 140 141 final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF", 142 "(" + STRING_SIG + "Z)V"); 143 il.append(new PUSH(cpg, getQName().toString())); 144 il.append(new PUSH(cpg, _isExtension)); 145 il.append(new INVOKESTATIC(unsupportedElem)); 146 } 147 } 148 } 149 | Popular Tags |