Module: Mesa
Branch: glsl-pp-rework-2
Commit: 2f89e1a5a18c4c3c88d4e7613cbfc0f85a5fcfc9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f89e1a5a18c4c3c88d4e7613cbfc0f85a5fcfc9

Author: Michal Krol <[email protected]>
Date:   Wed Sep 23 09:37:37 2009 +0200

glsl/pp: Add `0' and `1' to dictionary.

---

 src/glsl/pp/sl_pp_dict.c |    3 +++
 src/glsl/pp/sl_pp_dict.h |    3 +++
 src/glsl/pp/sl_pp_if.c   |    9 +--------
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/glsl/pp/sl_pp_dict.c b/src/glsl/pp/sl_pp_dict.c
index f2885c7..0e1fa36 100644
--- a/src/glsl/pp/sl_pp_dict.c
+++ b/src/glsl/pp/sl_pp_dict.c
@@ -79,5 +79,8 @@ sl_pp_dict_init(struct sl_pp_context *context)
 
    ADD_NAME(context, version);
 
+   ADD_NAME_STR(context, _0, "0");
+   ADD_NAME_STR(context, _1, "1");
+
    return 0;
 }
diff --git a/src/glsl/pp/sl_pp_dict.h b/src/glsl/pp/sl_pp_dict.h
index ba82b38..683752e 100644
--- a/src/glsl/pp/sl_pp_dict.h
+++ b/src/glsl/pp/sl_pp_dict.h
@@ -64,6 +64,9 @@ struct sl_pp_dict {
    int undef;
 
    int version;
+
+   int _0;
+   int _1;
 };
 
 
diff --git a/src/glsl/pp/sl_pp_if.c b/src/glsl/pp/sl_pp_if.c
index 5fa27fc..c8e958e 100644
--- a/src/glsl/pp/sl_pp_if.c
+++ b/src/glsl/pp/sl_pp_if.c
@@ -82,14 +82,7 @@ _parse_defined(struct sl_pp_context *context,
    }
 
    result.token = SL_PP_UINT;
-   if (defined) {
-      result.data._uint = sl_pp_context_add_unique_str(context, "1");
-   } else {
-      result.data._uint = sl_pp_context_add_unique_str(context, "0");
-   }
-   if (result.data._uint == -1) {
-      return -1;
-   }
+   result.data._uint = (defined ? context->dict._1 : context->dict._0);
 
    if (sl_pp_process_out(state, &result)) {
       strcpy(context->error_msg, "out of memory");

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to