976 return null; 977 } finally { 978 log.useSource(source); 979 } 980 } 981 }); 982 } 983 984 /** 985 * The variable's constant value, if this is a constant. 986 * Before the constant value is evaluated, it points to an 987 * initalizer environment. If this is not a constant, it can 988 * be used for other stuff. 989 */ 990 private Object data; 991 992 public boolean isExceptionParameter() { 993 return data == ElementKind.EXCEPTION_PARAMETER; 994 } 995 996 public Object getConstValue() { 997 // TODO: Consider if getConstValue and getConstantValue can be collapsed 998 if (data == ElementKind.EXCEPTION_PARAMETER) { 999 return null; 1000 } else if (data instanceof Callable<?>) { 1001 // In this case, this is final a variable, with an as 1002 // yet unevaluated initializer. 1003 Callable<?> eval = (Callable<?>)data; 1004 data = null; // to make sure we don't evaluate this twice. 1005 try { 1006 data = eval.call(); 1007 } catch (Exception ex) { 1008 throw new AssertionError(ex); 1009 } 1010 } 1011 return data; 1012 } 1013 1014 public void setData(Object data) { 1015 assert !(data instanceof Env<?>) : this; 1016 this.data = data; 1017 } 1018 1019 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) { 1020 return v.visitVarSymbol(this, p); 1021 } | 976 return null; 977 } finally { 978 log.useSource(source); 979 } 980 } 981 }); 982 } 983 984 /** 985 * The variable's constant value, if this is a constant. 986 * Before the constant value is evaluated, it points to an 987 * initalizer environment. If this is not a constant, it can 988 * be used for other stuff. 989 */ 990 private Object data; 991 992 public boolean isExceptionParameter() { 993 return data == ElementKind.EXCEPTION_PARAMETER; 994 } 995 996 public boolean isResourceVariable() { 997 return data == ElementKind.RESOURCE_VARIABLE; 998 } 999 1000 public Object getConstValue() { 1001 // TODO: Consider if getConstValue and getConstantValue can be collapsed 1002 if (data == ElementKind.EXCEPTION_PARAMETER || 1003 data == ElementKind.RESOURCE_VARIABLE) { 1004 return null; 1005 } else if (data instanceof Callable<?>) { 1006 // In this case, this is a final variable, with an as 1007 // yet unevaluated initializer. 1008 Callable<?> eval = (Callable<?>)data; 1009 data = null; // to make sure we don't evaluate this twice. 1010 try { 1011 data = eval.call(); 1012 } catch (Exception ex) { 1013 throw new AssertionError(ex); 1014 } 1015 } 1016 return data; 1017 } 1018 1019 public void setData(Object data) { 1020 assert !(data instanceof Env<?>) : this; 1021 this.data = data; 1022 } 1023 1024 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) { 1025 return v.visitVarSymbol(this, p); 1026 } |