2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
19
* $Id: LangCall.java,v 1.2 2009/12/10 03:18:18 matthewoliver Exp $
22
package org.apache.xalan.xsltc.compiler;
24
import java.util.Vector;
26
import org.apache.bcel.generic.ConstantPoolGen;
27
import org.apache.bcel.generic.ILOAD;
28
import org.apache.bcel.generic.INVOKESTATIC;
29
import org.apache.bcel.generic.InstructionList;
30
import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
31
import org.apache.xalan.xsltc.compiler.util.FilterGenerator;
32
import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
33
import org.apache.xalan.xsltc.compiler.util.StringType;
34
import org.apache.xalan.xsltc.compiler.util.Type;
35
import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
38
* @author Morten Jorgensen
40
final class LangCall extends FunctionCall {
41
private Expression _lang;
42
private Type _langType;
45
* Get the parameters passed to function:
48
public LangCall(QName fname, Vector arguments) {
49
super(fname, arguments);
56
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
57
_langType = _lang.typeCheck(stable);
58
if (!(_langType instanceof StringType)) {
59
_lang = new CastExpr(_lang, Type.String);
67
public Type getType() {
72
* This method is called when the constructor is compiled in
73
* Stylesheet.compileConstructor() and not as the syntax tree is traversed.
75
public void translate(ClassGenerator classGen,
76
MethodGenerator methodGen) {
77
final ConstantPoolGen cpg = classGen.getConstantPool();
78
final InstructionList il = methodGen.getInstructionList();
80
final int tst = cpg.addMethodref(BASIS_LIBRARY_CLASS,
82
"("+STRING_SIG+DOM_INTF_SIG+"I)Z");
83
_lang.translate(classGen,methodGen);
84
il.append(methodGen.loadDOM());
85
if (classGen instanceof FilterGenerator)
86
il.append(new ILOAD(1));
88
il.append(methodGen.loadContextNode());
89
il.append(new INVOKESTATIC(tst));