1 2 17 20 21 package org.apache.xalan.xsltc.compiler; 22 23 import org.apache.bcel.generic.ConstantPoolGen; 24 import org.apache.bcel.generic.InstructionList; 25 import org.apache.bcel.generic.PUSH; 26 import org.apache.xalan.xsltc.compiler.util.ClassGenerator; 27 import org.apache.xalan.xsltc.compiler.util.MethodGenerator; 28 import org.apache.xalan.xsltc.compiler.util.Type; 29 import org.apache.xalan.xsltc.compiler.util.TypeCheckError; 30 31 35 final class LiteralExpr extends Expression { 36 private final String _value; 37 private final String _namespace; 38 39 43 public LiteralExpr(String value) { 44 _value = value; 45 _namespace = null; 46 } 47 48 53 public LiteralExpr(String value, String namespace) { 54 _value = value; 55 _namespace = namespace.equals(Constants.EMPTYSTRING) ? null : namespace; 56 } 57 58 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 59 return _type = Type.String; 60 } 61 62 public String toString() { 63 return "literal-expr(" + _value + ')'; 64 } 65 66 protected boolean contextDependent() { 67 return false; 68 } 69 70 protected String getValue() { 71 return _value; 72 } 73 74 protected String getNamespace() { 75 return _namespace; 76 } 77 78 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 79 final ConstantPoolGen cpg = classGen.getConstantPool(); 80 final InstructionList il = methodGen.getInstructionList(); 81 il.append(new PUSH(cpg, _value)); 82 } 83 } 84 | Popular Tags |