[gtk+/wip/otte/shader: 3/48] gskslexpression: References to const variables are const



commit 47d33fb42202bf04dab8e6bff8c59c755562ba76
Author: Benjamin Otte <otte redhat com>
Date:   Tue Sep 26 18:27:01 2017 +0200

    gskslexpression: References to const variables are const
    
    So we return a const value if that happens.

 gsk/gskslexpression.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskslexpression.c b/gsk/gskslexpression.c
index 1da5b85..4fa07a5 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -663,8 +663,17 @@ gsk_sl_expression_reference_get_return_type (const GskSlExpression *expression)
 static GskSlValue *
 gsk_sl_expression_reference_get_constant (const GskSlExpression *expression)
 {
-  /* FIXME: values for constant variables need to be returned here */
-  return NULL;
+  GskSlExpressionReference *reference = (GskSlExpressionReference *) expression;
+  const GskSlValue *initial_value;
+
+  if (!gsk_sl_variable_is_constant (reference->variable))
+    return NULL;
+
+  initial_value = gsk_sl_variable_get_initial_value (reference->variable);
+  if (initial_value == NULL)
+    return NULL;
+
+  return gsk_sl_value_copy (initial_value);
 }
 
 static guint32


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]