[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] pkl,poke: Pass pk_values in callback pk_map_decl_fn
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH] pkl,poke: Pass pk_values in callback pk_map_decl_fn |
Date: |
Sat, 4 Dec 2021 22:53:24 +0330 |
2021-12-04 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/libpoke.h (pk_map_decl_fn): Add new param (`pk_val value`).
* libpoke/libpoke.c (my_decl_map_fn): Lookup var name in runtime env.
(pk_decl_map): Pass runtime env to the callback.
* poke/pk-cmd-def.c (print_var_decl): Add new param.
(print_fun_decl): Likewise.
(print_type_decl): Likewise.
---
ChangeLog | 9 +++++++++
libpoke/libpoke.c | 6 +++++-
libpoke/libpoke.h | 1 +
poke/pk-cmd-def.c | 3 +++
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index ea6b8ec6..79389574 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-12-03 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * libpoke/libpoke.h (pk_map_decl_fn): Add new param (`pk_val value`).
+ * libpoke/libpoke.c (my_decl_map_fn): Lookup var name in runtime env.
+ (pk_decl_map): Pass runtime env to the callback.
+ * poke/pk-cmd-def.c (print_var_decl): Add new param.
+ (print_fun_decl): Likewise.
+ (print_type_decl): Likewise.
+
2021-12-03 Jordan Yelloz <jordan@yelloz.me>
* libpoke/std.pk (atoi): Added code that extracts any single leading '+'
diff --git a/libpoke/libpoke.c b/libpoke/libpoke.c
index be64d659..072205cf 100644
--- a/libpoke/libpoke.c
+++ b/libpoke/libpoke.c
@@ -570,6 +570,7 @@ pk_ios_map (pk_compiler pkc,
struct decl_map_fn_payload
{
pk_map_decl_fn cb;
+ pvm_env runtime_env;
void *data;
};
@@ -582,6 +583,7 @@ my_decl_map_fn (pkl_ast_node decl, void *data)
pkl_ast_node initial = PKL_AST_DECL_INITIAL (decl);
pkl_ast_loc loc = PKL_AST_LOC (decl);
char *source = PKL_AST_DECL_SOURCE (decl);
+ int order = PKL_AST_DECL_ORDER (decl);
char *type = NULL;
int kind;
@@ -612,6 +614,7 @@ my_decl_map_fn (pkl_ast_node decl, void *data)
type,
loc.first_line, loc.last_line,
loc.first_column, loc.last_column,
+ pvm_env_lookup (payload->runtime_env, 0, order),
payload->data);
free (type);
}
@@ -620,7 +623,8 @@ void
pk_decl_map (pk_compiler pkc, int kind,
pk_map_decl_fn handler, void *data)
{
- struct decl_map_fn_payload payload = { handler, data };
+ struct decl_map_fn_payload payload
+ = { handler, pvm_get_env (pkc->vm), data };
pkl_env compiler_env = pkl_get_env (pkc->compiler);
int pkl_kind;
diff --git a/libpoke/libpoke.h b/libpoke/libpoke.h
index e9fcd557..7d6d6134 100644
--- a/libpoke/libpoke.h
+++ b/libpoke/libpoke.h
@@ -422,6 +422,7 @@ typedef void (*pk_map_decl_fn) (int kind,
const char *type,
int first_line, int last_line,
int first_column, int last_column,
+ pk_val value,
void *data);
void pk_decl_map (pk_compiler pkc, int kind,
pk_map_decl_fn handler, void *data) LIBPOKE_API;
diff --git a/poke/pk-cmd-def.c b/poke/pk-cmd-def.c
index b6a63384..219910ba 100644
--- a/poke/pk-cmd-def.c
+++ b/poke/pk-cmd-def.c
@@ -33,6 +33,7 @@ print_var_decl (int kind,
const char *type,
int first_line, int last_line,
int first_column, int last_column,
+ pk_val val,
void *data)
{
char *source_str = NULL;
@@ -58,6 +59,7 @@ print_fun_decl (int kind,
const char *type,
int first_line, int last_line,
int first_column, int last_column,
+ pk_val val,
void *data)
{
char *source_str = NULL;
@@ -85,6 +87,7 @@ print_type_decl (int kind,
const char *type,
int first_line, int last_line,
int first_column, int last_column,
+ pk_val val,
void *data)
{
char *source_str = NULL;
--
2.34.1
- [PATCH] pkl,poke: Pass pk_values in callback pk_map_decl_fn,
Mohammad-Reza Nabipoor <=