yagl_glsl_parser: parsing '#if !defined()' block correctly 14/277414/1 accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix tizen_7.0 tizen_7.0_hotfix accepted/tizen/7.0/unified/20221110.062127 accepted/tizen/7.0/unified/hotfix/20221116.104403 accepted/tizen/unified/20220707.133343 submit/tizen/20220707.002536 tizen_7.0_m2_release
authorbyungchul.so <byungchul.so@samsung.com>
Wed, 6 Jul 2022 03:44:21 +0000 (12:44 +0900)
committerbyungchul.so <byungchul.so@samsung.com>
Wed, 6 Jul 2022 10:09:37 +0000 (19:09 +0900)
- 'state->pp_current_expr > 0' is added to ensure always 'token' is put on the top of expression stack.

- Increase the priority of yagl_glsl_pp_op_defined to ensure yagl_glsl_pp_op_defined is ahead of yagl_glsl_pp_op_not

- With this patch, #if !defined(TOKEN) is parsed from ['not', 'token', 'defined'] to ['token', 'defined', 'not'].

Change-Id: I8298c9cb2f36dd5412dde270deeaf2101bc5087d

GLESv2/yagl_glsl_state.c
packaging/emulator-yagl.spec

index a60785d86049971bd64efee51010a1e66133b74a..a9a74db98007a2f384d17ac4a79f4b452ee00669 100644 (file)
@@ -67,7 +67,7 @@ const int glsl_pp_op_prio[] = {
     11, // yagl_glsl_pp_op_bit_not
     11, // yagl_glsl_pp_op_negative
     11, // yagl_glsl_pp_op_positive
-    11, // yagl_glsl_pp_op_defined
+    12, // yagl_glsl_pp_op_defined
     0, // yagl_glsl_pp_op_par_open - lowest priority because of special handling
     0, // yagl_glsl_pp_op_par_close - lowest priority because of special handling
 };
@@ -665,7 +665,7 @@ void yagl_glsl_state_pp_condition_parse_add_op(struct yagl_glsl_state *state, ya
     }
 
     // move higher or equal priority operations to expression stack
-    while (state->pp_current_op > 0 &&
+    while (state->pp_current_op > 0 && state->pp_current_expr > 0 &&
            glsl_pp_op_prio[op] <= glsl_pp_op_prio[state->pp_ops[state->pp_current_op - 1]]) {
         assert(state->pp_current_expr < YAGL_GLSL_PP_EXPRESSION_STACK_SIZE);
         state->pp_current_op--;
@@ -834,7 +834,7 @@ yagl_glsl_pp_condition_status yagl_glsl_state_pp_condition_resolve(struct yagl_g
     assert(state->pp_condition_parse_started);
 
     // empty op stack into expression stack
-    while (state->pp_current_op > 0) {
+    while (state->pp_current_op > 0 && state->pp_current_expr > 0) {
         assert(state->pp_current_expr < YAGL_GLSL_PP_EXPRESSION_STACK_SIZE);
         state->pp_current_op--;
         state->pp_exprs[state->pp_current_expr].op = state->pp_ops[state->pp_current_op];
index 4cf9804ed9cd16350de0c9b0ab7f03b5eb024131..ab5e2c3580f301b154e4cc016880a1ae499d9bb4 100644 (file)
@@ -6,7 +6,7 @@
 Name:       emulator-yagl
 Summary:    YaGL - OpenGLES acceleration module for emulator
 Version:    1.6
-Release:    3
+Release:    4
 License:    MIT and LGPL-3.0+
 Group:      SDK/Libraries
 Source0:    %{name}-%{version}.tar.gz