diff options
Diffstat (limited to 'vala/valatuple.vala')
-rw-r--r-- | vala/valatuple.vala | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/vala/valatuple.vala b/vala/valatuple.vala index b723d391d..a842ee6da 100644 --- a/vala/valatuple.vala +++ b/vala/valatuple.vala @@ -32,6 +32,16 @@ public class Vala.Tuple : Expression { this.source_reference = source_reference; } + public override void accept_children (CodeVisitor visitor) { + foreach (Expression expr in expression_list) { + expr.accept (visitor); + } + } + + public override void accept (CodeVisitor visitor) { + visitor.visit_tuple (this); + } + public void add_expression (Expression expr) { expression_list.add (expr); } @@ -44,6 +54,14 @@ public class Vala.Tuple : Expression { return false; } + public override void replace_expression (Expression old_node, Expression new_node) { + for (int i = 0; i < expression_list.size; i++) { + if (expression_list[i] == old_node) { + expression_list[i] = new_node; + } + } + } + public override bool check (SemanticAnalyzer analyzer) { if (checked) { return !error; @@ -51,9 +69,22 @@ public class Vala.Tuple : Expression { checked = true; - Report.error (source_reference, "tuples are not supported"); - error = true; - return false; + if (analyzer.context.profile != Profile.DOVA) { + Report.error (source_reference, "tuples are not supported"); + error = true; + return false; + } + + value_type = new ObjectType ((Class) analyzer.context.root.scope.lookup ("Dova").scope.lookup ("Tuple")); + value_type.value_owned = true; + + foreach (var expr in expression_list) { + if (!expr.check (analyzer)) { + return false; + } + value_type.add_type_argument (expr.value_type.copy ()); + } + + return !error; } } - |