[gtk+/wip/otte/shader: 344/367] gskslscope: Track function calls
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 344/367] gskslscope: Track function calls
- Date: Sun, 1 Oct 2017 03:16:18 +0000 (UTC)
commit 5d815238620b709a87074b8bb9fbd7d96dcce750
Author: Benjamin Otte <otte redhat com>
Date: Wed Sep 27 18:44:50 2017 +0200
gskslscope: Track function calls
gsk/gskslprogram.c | 1 +
gsk/gskslscope.c | 29 +++++++++++++++++++++++++++++
gsk/gskslscopeprivate.h | 4 ++++
3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskslprogram.c b/gsk/gskslprogram.c
index 04969a4..9220034 100644
--- a/gsk/gskslprogram.c
+++ b/gsk/gskslprogram.c
@@ -179,6 +179,7 @@ gsk_sl_program_parse_declaration (GskSlProgram *program,
preproc,
type,
name);
+ gsk_sl_scope_add_function (scope, function);
program->functions = g_slist_append (program->functions, function);
}
else
diff --git a/gsk/gskslscope.c b/gsk/gskslscope.c
index 0c65f28..85e4b72 100644
--- a/gsk/gskslscope.c
+++ b/gsk/gskslscope.c
@@ -21,6 +21,7 @@
#include "gskslscopeprivate.h"
#include "gsksltypeprivate.h"
+#include "gskslfunctionprivate.h"
#include "gskslvariableprivate.h"
#include <string.h>
@@ -33,6 +34,7 @@ struct _GskSlScope
GskSlType *return_type;
GHashTable *variables;
+ GHashTable *functions;
};
GskSlScope *
@@ -49,6 +51,7 @@ gsk_sl_scope_new (GskSlScope *parent,
if (return_type)
scope->return_type = gsk_sl_type_ref (return_type);
scope->variables = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)
gsk_sl_variable_unref);
+ scope->functions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)
gsk_sl_function_unref);
return scope;
}
@@ -74,6 +77,7 @@ gsk_sl_scope_unref (GskSlScope *scope)
return;
g_hash_table_unref (scope->variables);
+ g_hash_table_unref (scope->functions);
if (scope->parent)
gsk_sl_scope_unref (scope->parent);
@@ -113,3 +117,28 @@ gsk_sl_scope_lookup_variable (GskSlScope *scope,
return NULL;
}
+
+void
+gsk_sl_scope_add_function (GskSlScope *scope,
+ GskSlFunction *function)
+{
+ g_hash_table_replace (scope->functions, gsk_sl_function_get_name (function), gsk_sl_function_ref
(function));
+}
+
+GskSlFunction *
+gsk_sl_scope_lookup_function (GskSlScope *scope,
+ const char *name)
+{
+ GskSlFunction *result;
+
+ for (;
+ scope != NULL;
+ scope = scope->parent)
+ {
+ result = g_hash_table_lookup (scope->functions, name);
+ if (result)
+ return result;
+ }
+
+ return NULL;
+}
diff --git a/gsk/gskslscopeprivate.h b/gsk/gskslscopeprivate.h
index 9a41bef..869c94d 100644
--- a/gsk/gskslscopeprivate.h
+++ b/gsk/gskslscopeprivate.h
@@ -37,6 +37,10 @@ void gsk_sl_scope_add_variable (GskSlScope
GskSlVariable *variable);
GskSlVariable * gsk_sl_scope_lookup_variable (GskSlScope *scope,
const char *name);
+void gsk_sl_scope_add_function (GskSlScope *scope,
+ GskSlFunction *function);
+GskSlFunction * gsk_sl_scope_lookup_function (GskSlScope *scope,
+ const char *name);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]