diff options
author | Jürg Billeter <j@bitron.ch> | 2009-10-18 18:07:49 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2010-08-04 17:34:58 +0200 |
commit | 524a83b2907a1af7684ff2ccaaa8f643188c4f9b (patch) | |
tree | 7810d09193a7faf101506155aa7bf88cf4a430db /vala/valabooleantype.vala | |
parent | 2707980d20bce1c71d2ca9f2cbf4c681225129b9 (diff) | |
download | vala-524a83b2907a1af7684ff2ccaaa8f643188c4f9b.tar.gz |
Add experimental abstract interpreterabstract-interpreter
Diffstat (limited to 'vala/valabooleantype.vala')
-rw-r--r-- | vala/valabooleantype.vala | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vala/valabooleantype.vala b/vala/valabooleantype.vala index b224a9359..3f51538e8 100644 --- a/vala/valabooleantype.vala +++ b/vala/valabooleantype.vala @@ -26,6 +26,9 @@ using GLib; * A boolean type. */ public class Vala.BooleanType : ValueType { + public bool value { get; set; } + public bool value_set { get; set; } + public BooleanType (Struct type_symbol) { base (type_symbol); } @@ -35,6 +38,32 @@ public class Vala.BooleanType : ValueType { result.source_reference = source_reference; result.value_owned = value_owned; result.nullable = nullable; + result.value = value; + result.value_set = value_set; return result; } + + public override bool compatible (DataType target_type) { + if (CodeContext.get ().experimental_non_null && nullable && !target_type.nullable) { + return false; + } + + if (target_type.get_type_id () == "G_TYPE_VALUE") { + // allow implicit conversion to GValue + return true; + } + + var bool_target_type = target_type as BooleanType; + if (bool_target_type != null) { + if (!bool_target_type.value_set) { + return true; + } else if (!value_set) { + return false; + } else { + return (this.value == bool_target_type.value); + } + } + + return false; + } } |