1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler; 21 22 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 23 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; 24 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 25 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; 26 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; 27 28 31 final class UnresolvedRef extends VariableRefBase { 32 33 private QName _variableName = null; 34 private VariableRefBase _ref = null; 35 36 public UnresolvedRef(QName name) { 37 super(); 38 _variableName = name; 39 } 40 41 public QName getName() { 42 return(_variableName); 43 } 44 45 private ErrorMsg reportError() { 46 ErrorMsg err = new ErrorMsg(ErrorMsg.VARIABLE_UNDEF_ERR, 47 _variableName, this); 48 getParser().reportError(Constants.ERROR, err); 49 return(err); 50 } 51 52 private VariableRefBase resolve(Parser parser, SymbolTable stable) { 53 VariableBase ref = parser.lookupVariable(_variableName); 56 if (ref == null) { 57 ref = (VariableBase)stable.lookupName(_variableName); 58 } 59 if (ref == null) { 60 reportError(); 61 return null; 62 } 63 64 _variable = ref; 66 addParentDependency(); 67 68 if (ref instanceof Variable) { 69 return new VariableRef((Variable) ref); 70 } 71 else if (ref instanceof Param) { 72 return new ParameterRef((Param)ref); 73 } 74 return null; 75 } 76 77 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 78 if (_ref != null) { 79 final String name = _variableName.toString(); 80 ErrorMsg err = new ErrorMsg(ErrorMsg.CIRCULAR_VARIABLE_ERR, 81 name, this); 82 } 83 if ((_ref = resolve(getParser(), stable)) != null) { 84 return (_type = _ref.typeCheck(stable)); 85 } 86 throw new TypeCheckError(reportError()); 87 } 88 89 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 90 if (_ref != null) 91 _ref.translate(classGen, methodGen); 92 else 93 reportError(); 94 } 95 96 public String toString() { 97 return "unresolved-ref()"; 98 } 99 100 } 101 | Popular Tags |