< prev index next >

src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java

Print this page
rev 1481 : 8169112: java.lang.VerifyError: (class: GregorSamsa, method: template-bash signature: (LGregorSamsa8;)V) Register 10 contains wrong type
Reviewed-by: joehw


 111     /**
 112      * Set the do parameter optimization flag
 113      */
 114     public void setDoParameterOptimization(boolean flag) {
 115         _doParameterOptimization = flag;
 116     }
 117 
 118     /**
 119      * The contents of a <xsl:with-param> elements are either in the element's
 120      * 'select' attribute (this has precedence) or in the element body.
 121      */
 122     public void parseContents(Parser parser) {
 123         final String name = getAttribute("name");
 124         if (name.length() > 0) {
 125             if (!XML11Char.isXML11ValidQName(name)) {
 126                 ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
 127                                             this);
 128                 parser.reportError(Constants.ERROR, err);
 129             }
 130             setName(parser.getQNameIgnoreDefaultNs(name));
 131         }
 132         else {
 133             reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
 134         }
 135 
 136         final String select = getAttribute("select");
 137         if (select.length() > 0) {
 138             _select = parser.parseExpression(this, "select", null);
 139         }
 140 
 141         parseChildren(parser);
 142     }
 143 
 144     /**
 145      * Type-check either the select attribute or the element body, depending
 146      * on which is in use.
 147      */
 148     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
 149         if (_select != null) {
 150             final Type tselect = _select.typeCheck(stable);
 151             if (tselect instanceof ReferenceType == false) {
 152                 _select = new CastExpr(_select, Type.Reference);
 153             }
 154         }
 155         else {
 156             typeCheckContents(stable);
 157         }
 158         return Type.Void;
 159     }
 160 
 161     /**
 162      * Compile the value of the parameter, which is either in an expression in
 163      * a 'select' attribute, or in the with-param element's body
 164      */
 165     public void translateValue(ClassGenerator classGen,
 166                                MethodGenerator methodGen) {

 167         // Compile expression is 'select' attribute if present
 168         if (_select != null) {
 169             _select.translate(classGen, methodGen);
 170             _select.startIterator(classGen, methodGen);
 171         }
 172         // If not, compile result tree from parameter body if present.
 173         // Store result tree into local variable for releasing it later
 174         else if (hasContents()) {
 175             final InstructionList il = methodGen.getInstructionList();
 176             compileResultTree(classGen, methodGen);
 177             _domAdapter = methodGen.addLocalVariable2("@" + _escapedName, Type.ResultTree.toJCType(), il.getEnd());


 178             il.append(DUP);
 179             il.append(new ASTORE(_domAdapter.getIndex()));
 180         }
 181         // If neither are present then store empty string in parameter slot
 182         else {
 183             final ConstantPoolGen cpg = classGen.getConstantPool();
 184             final InstructionList il = methodGen.getInstructionList();
 185             il.append(new PUSH(cpg, Constants.EMPTYSTRING));
 186         }
 187     }
 188 
 189     /**
 190      * This code generates a sequence of bytecodes that call the
 191      * addParameter() method in AbstractTranslet. The method call will add
 192      * (or update) the parameter frame with the new parameter value.
 193      */
 194     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
 195         final ConstantPoolGen cpg = classGen.getConstantPool();
 196         final InstructionList il = methodGen.getInstructionList();
 197 
 198         // Translate the value and put it on the stack
 199         if (_doParameterOptimization) {
 200             translateValue(classGen, methodGen);
 201             return;
 202         }


 206 
 207         // Load reference to the translet (method is in AbstractTranslet)
 208         il.append(classGen.loadTranslet());
 209 
 210         // Load the name of the parameter
 211         il.append(new PUSH(cpg, name)); // TODO: namespace ?
 212         // Generete the value of the parameter (use value in 'select' by def.)
 213         translateValue(classGen, methodGen);
 214         // Mark this parameter value is not being the default value
 215         il.append(new PUSH(cpg, false));
 216         // Pass the parameter to the template
 217         il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
 218                                                      ADD_PARAMETER,
 219                                                      ADD_PARAMETER_SIG)));
 220         il.append(POP); // cleanup stack
 221     }
 222 
 223     /**
 224      * Release the compiled result tree.
 225      */
 226     public void releaseResultTree(ClassGenerator classGen, MethodGenerator methodGen) {


 227         if (_domAdapter != null) {
 228             final ConstantPoolGen cpg = classGen.getConstantPool();
 229             final InstructionList il = methodGen.getInstructionList();
 230             if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
 231                 final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");




 232                 il.append(methodGen.loadDOM());
 233                 il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
 234                 il.append(new ALOAD(_domAdapter.getIndex()));
 235                 il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
 236                 il.append(new INVOKEVIRTUAL(removeDA));
 237             }
 238             final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");

 239             il.append(new ALOAD(_domAdapter.getIndex()));
 240             il.append(new INVOKEINTERFACE(release, 1));


 241             _domAdapter = null;
 242          }
 243      }
 244 }


 111     /**
 112      * Set the do parameter optimization flag
 113      */
 114     public void setDoParameterOptimization(boolean flag) {
 115         _doParameterOptimization = flag;
 116     }
 117 
 118     /**
 119      * The contents of a <xsl:with-param> elements are either in the element's
 120      * 'select' attribute (this has precedence) or in the element body.
 121      */
 122     public void parseContents(Parser parser) {
 123         final String name = getAttribute("name");
 124         if (name.length() > 0) {
 125             if (!XML11Char.isXML11ValidQName(name)) {
 126                 ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
 127                                             this);
 128                 parser.reportError(Constants.ERROR, err);
 129             }
 130             setName(parser.getQNameIgnoreDefaultNs(name));
 131         } else {

 132             reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
 133         }
 134 
 135         final String select = getAttribute("select");
 136         if (select.length() > 0) {
 137             _select = parser.parseExpression(this, "select", null);
 138         }
 139 
 140         parseChildren(parser);
 141     }
 142 
 143     /**
 144      * Type-check either the select attribute or the element body, depending
 145      * on which is in use.
 146      */
 147     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
 148         if (_select != null) {
 149             final Type tselect = _select.typeCheck(stable);
 150             if (tselect instanceof ReferenceType == false) {
 151                 _select = new CastExpr(_select, Type.Reference);
 152             }
 153         } else {

 154             typeCheckContents(stable);
 155         }
 156         return Type.Void;
 157     }
 158 
 159     /**
 160      * Compile the value of the parameter, which is either in an expression in
 161      * a 'select' attribute, or in the with-param element's body
 162      */
 163     public void translateValue(ClassGenerator classGen,
 164                                MethodGenerator methodGen)
 165     {
 166         // Compile expression is 'select' attribute if present
 167         if (_select != null) {
 168             _select.translate(classGen, methodGen);
 169             _select.startIterator(classGen, methodGen);

 170         // If not, compile result tree from parameter body if present.
 171         // Store result tree into local variable for releasing it later
 172         } else if (hasContents()) {
 173             final InstructionList il = methodGen.getInstructionList();
 174             compileResultTree(classGen, methodGen);
 175             _domAdapter = methodGen.addLocalVariable2("@" + _escapedName,
 176                                                       Type.ResultTree.toJCType(),
 177                                                       il.getEnd());
 178             il.append(DUP);
 179             il.append(new ASTORE(_domAdapter.getIndex()));

 180         // If neither are present then store empty string in parameter slot
 181         } else {
 182             final ConstantPoolGen cpg = classGen.getConstantPool();
 183             final InstructionList il = methodGen.getInstructionList();
 184             il.append(new PUSH(cpg, Constants.EMPTYSTRING));
 185         }
 186     }
 187 
 188     /**
 189      * This code generates a sequence of bytecodes that call the
 190      * addParameter() method in AbstractTranslet. The method call will add
 191      * (or update) the parameter frame with the new parameter value.
 192      */
 193     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
 194         final ConstantPoolGen cpg = classGen.getConstantPool();
 195         final InstructionList il = methodGen.getInstructionList();
 196 
 197         // Translate the value and put it on the stack
 198         if (_doParameterOptimization) {
 199             translateValue(classGen, methodGen);
 200             return;
 201         }


 205 
 206         // Load reference to the translet (method is in AbstractTranslet)
 207         il.append(classGen.loadTranslet());
 208 
 209         // Load the name of the parameter
 210         il.append(new PUSH(cpg, name)); // TODO: namespace ?
 211         // Generete the value of the parameter (use value in 'select' by def.)
 212         translateValue(classGen, methodGen);
 213         // Mark this parameter value is not being the default value
 214         il.append(new PUSH(cpg, false));
 215         // Pass the parameter to the template
 216         il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
 217                                                      ADD_PARAMETER,
 218                                                      ADD_PARAMETER_SIG)));
 219         il.append(POP); // cleanup stack
 220     }
 221 
 222     /**
 223      * Release the compiled result tree.
 224      */
 225     public void releaseResultTree(ClassGenerator classGen,
 226                                   MethodGenerator methodGen)
 227     {
 228         if (_domAdapter != null) {
 229             final ConstantPoolGen cpg = classGen.getConstantPool();
 230             final InstructionList il = methodGen.getInstructionList();
 231             if (classGen.getStylesheet().callsNodeset() &&
 232                 classGen.getDOMClass().equals(MULTI_DOM_CLASS))
 233             {
 234                 final int removeDA =
 235                     cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter",
 236                                      "(" + DOM_ADAPTER_SIG + ")V");
 237                 il.append(methodGen.loadDOM());
 238                 il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
 239                 il.append(new ALOAD(_domAdapter.getIndex()));
 240                 il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
 241                 il.append(new INVOKEVIRTUAL(removeDA));
 242             }
 243             final int release =
 244                 cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
 245             il.append(new ALOAD(_domAdapter.getIndex()));
 246             il.append(new INVOKEINTERFACE(release, 1));
 247             _domAdapter.setEnd(il.getEnd());
 248             methodGen.removeLocalVariable(_domAdapter);
 249             _domAdapter = null;
 250         }
 251     }
 252 }
< prev index next >