/* valaconstant.vala
*
- * Copyright (C) 2006-2010 Jürg Billeter
+ * Copyright (C) 2006-2011 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Report.error (source_reference, "Cannot convert from `%s' to `%s'".printf (value.value_type.to_string (), type_reference.to_string ()));
return false;
}
+
+ if (!value.is_constant ()) {
+ error = true;
+ Report.error (value.source_reference, "Value must be constant");
+ return false;
+ }
}
} else {
if (value != null) {
/* valainitializerlist.vala
*
- * Copyright (C) 2006-2010 Jürg Billeter
+ * Copyright (C) 2006-2011 Jürg Billeter
* Copyright (C) 2006-2008 Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
visitor.visit_initializer_list (this);
}
+ public override bool is_constant () {
+ foreach (Expression initializer in initializers) {
+ if (!initializer.is_constant ()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public override bool is_pure () {
foreach (Expression initializer in initializers) {
if (!initializer.is_pure ()) {
/* valamemberaccess.vala
*
- * Copyright (C) 2006-2010 Jürg Billeter
+ * Copyright (C) 2006-2011 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
public override bool is_constant () {
+ var method = symbol_reference as Method;
if (symbol_reference is Constant) {
return true;
+ } else if (method != null &&
+ (method.binding == MemberBinding.STATIC || prototype_access)) {
+ return true;
} else {
return false;
}
/* valaunaryexpression.vala
*
- * Copyright (C) 2006-2010 Jürg Billeter
+ * Copyright (C) 2006-2011 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
return false;
}
+ if (operator == UnaryOperator.REF || operator == UnaryOperator.OUT) {
+ var field = inner.symbol_reference as Field;
+ if (field != null && field.binding == MemberBinding.STATIC) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
return inner.is_constant ();
}