summaryrefslogtreecommitdiff
path: root/src/lj_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_api.c')
-rw-r--r--src/lj_api.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index 34c57806..a6fbb1c6 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -24,6 +24,7 @@
24#include "lj_trace.h" 24#include "lj_trace.h"
25#include "lj_vm.h" 25#include "lj_vm.h"
26#include "lj_lex.h" 26#include "lj_lex.h"
27#include "lj_bcdump.h"
27#include "lj_parse.h" 28#include "lj_parse.h"
28 29
29/* -- Common helper functions --------------------------------------------- */ 30/* -- Common helper functions --------------------------------------------- */
@@ -1115,12 +1116,13 @@ LUA_API int lua_resume(lua_State *L, int nargs)
1115static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) 1116static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud)
1116{ 1117{
1117 LexState *ls = (LexState *)ud; 1118 LexState *ls = (LexState *)ud;
1119 GCproto *pt;
1118 GCfunc *fn; 1120 GCfunc *fn;
1119 UNUSED(dummy); 1121 UNUSED(dummy);
1120 cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ 1122 cframe_errfunc(L->cframe) = -1; /* Inherit error function. */
1121 lj_lex_setup(L, ls); 1123 pt = lj_lex_setup(L, ls) ? lj_bcread(ls) : lj_parse(ls);
1122 fn = lj_func_newL(L, lj_parse(ls), tabref(L->env)); 1124 fn = lj_func_newL_empty(L, pt, tabref(L->env));
1123 /* Parser may realloc stack. Don't combine above/below into one statement. */ 1125 /* Don't combine above/below into one statement. */
1124 setfuncV(L, L->top++, fn); 1126 setfuncV(L, L->top++, fn);
1125 return NULL; 1127 return NULL;
1126} 1128}
@@ -1142,9 +1144,12 @@ LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data,
1142 1144
1143LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data) 1145LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data)
1144{ 1146{
1147 cTValue *o = L->top-1;
1145 api_checknelems(L, 1); 1148 api_checknelems(L, 1);
1146 UNUSED(L); UNUSED(writer); UNUSED(data); 1149 if (tvisfunc(o) && isluafunc(funcV(o)))
1147 return 1; /* Error, not supported. */ 1150 return lj_bcwrite(L, funcproto(funcV(o)), writer, data, 0);
1151 else
1152 return 1;
1148} 1153}
1149 1154
1150/* -- GC and memory management -------------------------------------------- */ 1155/* -- GC and memory management -------------------------------------------- */