1 16 19 20 package org.apache.xalan.xsltc.compiler; 21 22 import org.apache.bcel.generic.CHECKCAST; 23 import org.apache.bcel.generic.ConstantPoolGen; 24 import org.apache.bcel.generic.GETFIELD; 25 import org.apache.bcel.generic.INVOKEINTERFACE; 26 import org.apache.bcel.generic.InstructionList; 27 import org.apache.xalan.xsltc.compiler.util.ClassGenerator; 28 import org.apache.xalan.xsltc.compiler.util.MethodGenerator; 29 import org.apache.xalan.xsltc.compiler.util.NodeSetType; 30 import org.apache.xalan.xsltc.runtime.BasisLibrary; 31 32 38 final class ParameterRef extends VariableRefBase { 39 40 43 QName _name = null; 44 45 public ParameterRef(Param param) { 46 super(param); 47 _name = param._name; 48 49 } 50 51 public String toString() { 52 return "parameter-ref("+_variable.getName()+'/'+_variable.getType()+')'; 53 } 54 55 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 56 final ConstantPoolGen cpg = classGen.getConstantPool(); 57 final InstructionList il = methodGen.getInstructionList(); 58 59 64 final String name = BasisLibrary.mapQNameToJavaName (_name.toString()); 65 final String signature = _type.toSignature(); 66 67 if (_variable.isLocal()) { 68 if (classGen.isExternal()) { 69 Closure variableClosure = _closure; 70 while (variableClosure != null) { 71 if (variableClosure.inInnerClass()) break; 72 variableClosure = variableClosure.getParentClosure(); 73 } 74 75 if (variableClosure != null) { 76 il.append(ALOAD_0); 77 il.append(new GETFIELD( 78 cpg.addFieldref(variableClosure.getInnerClassName(), 79 name, signature))); 80 } 81 else { 82 il.append(_variable.loadInstruction()); 83 _variable.removeReference(this); 84 } 85 } 86 else { 87 il.append(_variable.loadInstruction()); 88 _variable.removeReference(this); 89 } 90 } 91 else { 92 final String className = classGen.getClassName(); 93 il.append(classGen.loadTranslet()); 94 if (classGen.isExternal()) { 95 il.append(new CHECKCAST(cpg.addClass(className))); 96 } 97 il.append(new GETFIELD(cpg.addFieldref(className,name,signature))); 98 } 99 100 if (_variable.getType() instanceof NodeSetType) { 101 final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR, 103 "cloneIterator", 104 "()" + 105 NODE_ITERATOR_SIG); 106 il.append(new INVOKEINTERFACE(clone, 1)); 107 } 108 } 109 } 110 | Popular Tags |