[vala/wip/baedert/nullable: 14/25] expression: Add get_null_state vfunc
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/baedert/nullable: 14/25] expression: Add get_null_state vfunc
- Date: Tue, 8 Nov 2016 21:19:14 +0000 (UTC)
commit f56fae538f12060d650ac6781f3c57d79535a5c9
Author: Timm Bäder <mail baedert org>
Date: Mon Nov 7 19:29:30 2016 +0100
expression: Add get_null_state vfunc
vala/valaexpression.vala | 11 +++++++++++
vala/valaliteral.vala | 4 ++++
vala/valanullliteral.vala | 4 ++++
3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/vala/valaexpression.vala b/vala/valaexpression.vala
index 5f7a023..28a536d 100644
--- a/vala/valaexpression.vala
+++ b/vala/valaexpression.vala
@@ -22,6 +22,13 @@
using GLib;
+
+public enum Vala.NullabilityState {
+ NULL,
+ NON_NULL,
+ NULLABLE
+}
+
/**
* Base class for all code nodes that might be used as an expression.
*/
@@ -71,6 +78,10 @@ public abstract class Vala.Expression : CodeNode {
*/
public abstract bool is_pure ();
+ public virtual NullabilityState get_null_state () {
+ return NullabilityState.NULLABLE;
+ }
+
/**
* Returns whether this expression is guaranteed to be non-null.
*/
diff --git a/vala/valaliteral.vala b/vala/valaliteral.vala
index 62f17a3..3550ff7 100644
--- a/vala/valaliteral.vala
+++ b/vala/valaliteral.vala
@@ -33,4 +33,8 @@ public abstract class Vala.Literal : Expression {
public override bool is_pure () {
return true;
}
+
+ public override NullabilityState get_null_state () {
+ return NullabilityState.NON_NULL;
+ }
}
diff --git a/vala/valanullliteral.vala b/vala/valanullliteral.vala
index b5f95d0..015dd7e 100644
--- a/vala/valanullliteral.vala
+++ b/vala/valanullliteral.vala
@@ -50,6 +50,10 @@ public class Vala.NullLiteral : Literal {
return true;
}
+ public override NullabilityState get_null_state () {
+ return NullabilityState.NULL;
+ }
+
public override bool check (CodeContext context) {
if (checked) {
return !error;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]