aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-16 21:42:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-03-16 21:48:41 -0700
commit155f6a80276bf2844085f9f28ca05e15d4df3836 (patch)
treef3cb7595ce041c800297b0a7edbb6366b7c9418f
parentfffcc8b9abf43a69d71c37c92fc149f661dd6da1 (diff)
downloadteliva-155f6a80276bf2844085f9f28ca05e15d4df3836.tar.gz
standardize some names
-rw-r--r--src/lua.c2
-rw-r--r--src/teliva.c19
-rw-r--r--src/teliva.h2
3 files changed, 12 insertions, 11 deletions
diff --git a/src/lua.c b/src/lua.c
index 5445e86..c78b051 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -249,7 +249,7 @@ static int pmain (lua_State *L) {
if (s->status != 0) return 0;
/* call main() */
- assign_call_graph_depth_to_name(L, /*depth*/2, "main"); /* manually seed debug info */
+ save_call_graph_depth(L, /*depth*/2, "main"); /* manually seed debug info */
lua_getglobal(L, "main");
s->status = docall(L, 0, 1);
if (s->status != 0) return report_in_developer_mode(L, s->status);
diff --git a/src/teliva.c b/src/teliva.c
index 1e2eb34..4e0542a 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -276,7 +276,7 @@ void draw_highlighted_definition_name(const char* definition_name) {
addstr(" ");
}
-void assign_call_graph_depth_to_name(lua_State* L, int depth, const char* name) {
+void save_call_graph_depth(lua_State* L, int depth, const char* name) {
/* Maintain a global table mapping from function name to call-stack depth
* at first call to it.
*
@@ -298,7 +298,7 @@ void assign_call_graph_depth_to_name(lua_State* L, int depth, const char* name)
lua_pop(L, 1); // table
}
-static void save_caller_as(lua_State* L, const char* name, const char* caller_name) {
+static void save_caller(lua_State* L, const char* name, const char* caller_name) {
// push table of caller tables
luaL_newmetatable(L, "__teliva_caller");
int ct = lua_gettop(L);
@@ -323,16 +323,16 @@ void record_metadata_about_function_call (lua_State *L, CallInfo *ci) {
lua_Debug f;
lua_getstack(L, 0, &f);
lua_getinfo(L, "n", &f);
- long int call_depth = ci - L->base_ci;
+ long int call_graph_depth = ci - L->base_ci;
/* note to self: the function pointer is at ci_func(ci) */
if (f.name) {
- assign_call_graph_depth_to_name(L, call_depth, f.name);
- if (call_depth <= 1) return;
+ save_call_graph_depth(L, call_graph_depth, f.name);
+ if (call_graph_depth <= 1) return;
lua_Debug caller_f;
lua_getstack(L, 1, &caller_f);
lua_getinfo(L, "n", &caller_f);
if (caller_f.name)
- save_caller_as(L, f.name, caller_f.name);
+ save_caller(L, f.name, caller_f.name);
}
}
@@ -1243,7 +1243,7 @@ static int run_tests(lua_State* L) {
return 1;
}
-static void clear_call_graph(lua_State* L) {
+static void clear_call_graph_depth(lua_State* L) {
int oldtop = lua_gettop(L);
luaL_newmetatable(L, "__teliva_call_graph_depth");
int cgt = lua_gettop(L);
@@ -1764,10 +1764,11 @@ int load_image(lua_State* L, char** argv, int n) {
//? exit(1);
status = load_definitions(L);
if (status != 0) return 0;
+ /* run tests */
status = run_tests(L);
if (status != 0) return report_in_developer_mode(L, status);
- /* clear callgraph stats from running tests */
- clear_call_graph(L);
+ /* clear stats from running tests */
+ clear_call_graph_depth(L);
clear_caller(L);
/* initialize permissions */
load_permissions_from_user_configuration(L);
diff --git a/src/teliva.h b/src/teliva.h
index 5808382..4fdb9f4 100644
--- a/src/teliva.h
+++ b/src/teliva.h
@@ -164,7 +164,7 @@ extern void save_to_current_definition_and_editor_buffer(lua_State* L, const cha
extern void save_editor_state(int rowoff, int coloff, int cy, int cx);
int editor_view_in_progress(lua_State* L);
-extern void assign_call_graph_depth_to_name(lua_State* L, int depth, const char* name);
+extern void save_call_graph_depth(lua_State* L, int depth, const char* name);
extern void draw_callers_of_current_definition(lua_State* L);
extern void append_to_audit_log(lua_State* L, const char* buffer);