[vala/wip/transform2] Move contains() call for the IN operator to emit()
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform2] Move contains() call for the IN operator to emit()
- Date: Mon, 29 Aug 2011 08:36:16 +0000 (UTC)
commit e7087d905e99e36f6d6d49119870a7e574929e65
Author: Luca Bruno <lucabru src gnome org>
Date: Mon Aug 29 10:18:09 2011 +0200
Move contains() call for the IN operator to emit()
vala/valabinaryexpression.vala | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 415bde2..b4b0ec9 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -490,9 +490,9 @@ public class Vala.BinaryExpression : Expression {
}
var contains_call = new MethodCall (new MemberAccess (right, "contains", source_reference), source_reference);
+ contains_call.parent_node = parent_node;
contains_call.add_argument (left);
- parent_node.replace_expression (this, contains_call);
- return contains_call.check (context);
+ error = !contains_call.check (context);
}
value_type = context.analyzer.bool_type;
@@ -505,6 +505,22 @@ public class Vala.BinaryExpression : Expression {
}
public override void emit (CodeGenerator codegen) {
+ var context = CodeContext.get ();
+ if (operator == BinaryOperator.IN &&
+ !((left.value_type.compatible (context.analyzer.int_type)
+ && right.value_type.compatible (context.analyzer.int_type))
+ || right.value_type is ArrayType)) {
+ // contains () method
+ var contains_method = (Method) right.value_type.get_member ("contains") as Method;
+ var contains_call = new MethodCall (new MemberAccess (right, "contains", source_reference), source_reference);
+ contains_call.parent_node = parent_node;
+ contains_call.add_argument (left);
+ contains_call.check (context);
+ contains_call.emit (codegen);
+ target_value = contains_call.target_value;
+ return;
+ }
+
left.emit (codegen);
right.emit (codegen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]