summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vala/valadatatype.vala2
-rw-r--r--vala/valasemanticanalyzer.vala2
-rw-r--r--vala/valastruct.vala66
-rw-r--r--vapigen/valagidlparser.vala2
4 files changed, 35 insertions, 37 deletions
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index 1bbbc82b6..e25e5a417 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -336,7 +336,7 @@ public abstract class Vala.DataType : CodeNode {
if ((expr_struct.is_integer_type () && expect_struct.is_integer_type ()) ||
(expr_struct.is_floating_type () && expect_struct.is_floating_type ())) {
- if (expr_struct.get_rank () <= expect_struct.get_rank ()) {
+ if (expr_struct.rank <= expect_struct.rank) {
return true;
}
}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index 73b0b61ef..8f4335bd2 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -991,7 +991,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
if (left.is_floating_type () == right.is_floating_type ()) {
// both operands integer or floating type
- if (left.get_rank () >= right.get_rank ()) {
+ if (left.rank >= right.rank) {
return left_type;
} else {
return right_type;
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 972b4bdab..23c005363 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -38,7 +38,7 @@ public class Vala.Struct : TypeSymbol {
private bool? floating_type;
private bool? decimal_floating_type;
private bool? simple_type;
- private int? rank;
+ private int? _rank;
private int? _width;
private bool? _signed;
private bool? _is_immutable;
@@ -125,6 +125,37 @@ public class Vala.Struct : TypeSymbol {
}
/**
+ * Specifies the rank of this integer or floating point type.
+ */
+ public int rank {
+ get {
+ if (_rank == null) {
+ if (is_integer_type () && has_attribute_argument ("IntegerType", "rank")) {
+ _rank = get_attribute_integer ("IntegerType", "rank");
+ } else if (has_attribute_argument ("FloatingType", "rank")) {
+ _rank = get_attribute_integer ("FloatingType", "rank");
+ } else {
+ var st = base_struct;
+ if (st != null) {
+ _rank = st.rank;
+ } else {
+ Report.error (source_reference, "internal error: struct has no rank");
+ }
+ }
+ }
+ return _rank;
+ }
+ set {
+ _rank = value;
+ if (is_integer_type ()) {
+ set_attribute_integer ("IntegerType", "rank", _rank);
+ } else {
+ set_attribute_integer ("FloatingType", "rank", _rank);
+ }
+ }
+ }
+
+ /**
* Creates a new struct.
*
* @param name type name
@@ -353,39 +384,6 @@ public class Vala.Struct : TypeSymbol {
return decimal_floating_type;
}
- /**
- * Returns the rank of this integer or floating point type.
- *
- * @return the rank if this is an integer or floating point type
- */
- public int get_rank () {
- if (rank == null) {
- if (is_integer_type () && has_attribute_argument ("IntegerType", "rank")) {
- rank = get_attribute_integer ("IntegerType", "rank");
- } else if (has_attribute_argument ("FloatingType", "rank")) {
- rank = get_attribute_integer ("FloatingType", "rank");
- } else {
- var st = base_struct;
- if (st != null) {
- rank = st.get_rank ();
- }
- }
- }
- return rank;
- }
-
- /**
- * Sets the rank of this integer or floating point type.
- */
- public void set_rank (int rank) {
- this.rank = rank;
- if (is_integer_type ()) {
- set_attribute_integer ("IntegerType", "rank", rank);
- } else {
- set_attribute_integer ("FloatingType", "rank", rank);
- }
- }
-
public override int get_type_parameter_index (string name) {
int i = 0;
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index bb3c4bb86..e0ffca52b 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -799,7 +799,7 @@ public class Vala.GIdlParser : CodeVisitor {
} else if (nv[0] == "base_type") {
st.base_type = parse_type_string (eval (nv[1]));
} else if (nv[0] == "rank") {
- st.set_rank (int.parse (eval (nv[1])));
+ st.rank = int.parse (eval (nv[1]));
} else if (nv[0] == "simple_type") {
if (eval (nv[1]) == "1") {
st.set_simple_type (true);