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: PositionCall.java,v 1.2.4.1 2005/09/02 11:17:10 pvedula Exp $
|
|
22 |
*/
|
|
23 |
|
|
24 |
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
|
25 |
|
|
26 |
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
|
|
27 |
import com.sun.org.apache.bcel.internal.generic.ILOAD;
|
|
28 |
import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
|
|
29 |
import com.sun.org.apache.bcel.internal.generic.InstructionList;
|
|
30 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
|
|
31 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.CompareGenerator;
|
|
32 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
|
33 |
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TestGenerator;
|
|
34 |
|
|
35 |
/**
|
|
36 |
* @author Jacek Ambroziak
|
|
37 |
* @author Santiago Pericas-Geertsen
|
|
38 |
* @author Morten Jorgensen
|
|
39 |
*/
|
|
40 |
final class PositionCall extends FunctionCall {
|
|
41 |
|
|
42 |
public PositionCall(QName fname) {
|
|
43 |
super(fname);
|
|
44 |
}
|
|
45 |
|
|
46 |
public boolean hasPositionCall() {
|
|
47 |
return true;
|
|
48 |
}
|
|
49 |
|
|
50 |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
|
|
51 |
final InstructionList il = methodGen.getInstructionList();
|
|
52 |
|
|
53 |
if (methodGen instanceof CompareGenerator) {
|
|
54 |
il.append(((CompareGenerator)methodGen).loadCurrentNode());
|
|
55 |
}
|
|
56 |
else if (methodGen instanceof TestGenerator) {
|
|
57 |
il.append(new ILOAD(POSITION_INDEX));
|
|
58 |
}
|
|
59 |
else {
|
|
60 |
final ConstantPoolGen cpg = classGen.getConstantPool();
|
|
61 |
final int index = cpg.addInterfaceMethodref(NODE_ITERATOR,
|
|
62 |
"getPosition",
|
|
63 |
"()I");
|
|
64 |
|
|
65 |
il.append(methodGen.loadIterator());
|
|
66 |
il.append(new INVOKEINTERFACE(index,1));
|
|
67 |
}
|
|
68 |
}
|
|
69 |
}
|