[gtk+/wip/otte/shader: 108/175] gskslexpression: References to const variables are const



commit 12531b595245ddbf86444dcfcb2e5efac4909b86
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 497de04..18a89cb 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -662,8 +662,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]