[gtk+/wip/otte/shader: 199/200] gsksldeclaration: Correctly parse initializers
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 199/200] gsksldeclaration: Correctly parse initializers
- Date: Mon, 16 Oct 2017 23:16:40 +0000 (UTC)
commit 4178f2476f4819fe58966d3b2a8772e0a5aea783
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 17 00:55:06 2017 +0200
gsksldeclaration: Correctly parse initializers
And store them as initializers for later.
gsk/gsksldeclaration.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gsksldeclaration.c b/gsk/gsksldeclaration.c
index 8be61c0..48e2665 100644
--- a/gsk/gsksldeclaration.c
+++ b/gsk/gsksldeclaration.c
@@ -28,6 +28,7 @@
#include "gsksltokenizerprivate.h"
#include "gsksltypeprivate.h"
#include "gskslqualifierprivate.h"
+#include "gskslvalueprivate.h"
#include "gskslvariableprivate.h"
#include "gskspvwriterprivate.h"
@@ -221,13 +222,13 @@ gsk_sl_declaration_parse_variable (GskSlScope *scope,
const char *name)
{
GskSlDeclarationVariable *variable;
+ GskSlValue *initial_value = NULL;
+ GskSlExpression *initial = NULL;
const GskSlToken *token;
token = gsk_sl_preprocessor_get (preproc);
if (gsk_sl_token_is (token, GSK_SL_TOKEN_EQUAL))
{
- GskSlExpression *initial;
-
gsk_sl_preprocessor_consume (preproc, NULL);
initial = gsk_sl_expression_parse_assignment (scope, preproc);
@@ -239,6 +240,16 @@ gsk_sl_declaration_parse_variable (GskSlScope *scope,
gsk_sl_type_get_name (gsk_sl_expression_get_return_type (initial)),
gsk_sl_type_get_name (type));
gsk_sl_expression_unref (initial);
+ initial = NULL;
+ }
+ else
+ {
+ GskSlValue *unconverted = gsk_sl_expression_get_constant (initial);
+ if (unconverted)
+ {
+ initial_value = gsk_sl_value_new_convert (unconverted, type);
+ gsk_sl_value_free (unconverted);
+ }
}
token = gsk_sl_preprocessor_get (preproc);
@@ -252,7 +263,8 @@ gsk_sl_declaration_parse_variable (GskSlScope *scope,
gsk_sl_preprocessor_consume (preproc, NULL);
variable = gsk_sl_declaration_new (&GSK_SL_DECLARATION_VARIABLE);
- variable->variable = gsk_sl_variable_new (name, type, qualifier, NULL);
+ variable->variable = gsk_sl_variable_new (name, type, qualifier, initial_value);
+ variable->initial = initial;
gsk_sl_scope_add_variable (scope, variable->variable);
return &variable->parent;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]