aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-02-01 15:22:54 +0800
committerLi Jin <dragon-fly@qq.com>2023-02-01 15:22:54 +0800
commit72cc9bd0ae4bf847c4519b0c508c300db8141eb3 (patch)
tree0808337894562193606a27225da5aef02a7523cc /src
parente3e45fb330e29cc9b203a70b649e61f62697f88d (diff)
downloadyuescript-72cc9bd0ae4bf847c4519b0c508c300db8141eb3.tar.gz
yuescript-72cc9bd0ae4bf847c4519b0c508c300db8141eb3.tar.bz2
yuescript-72cc9bd0ae4bf847c4519b0c508c300db8141eb3.zip
fix yue.to_ast().
Diffstat (limited to 'src')
-rw-r--r--src/yuescript/yuescript.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/yuescript/yuescript.cpp b/src/yuescript/yuescript.cpp
index 20fa258..ed09aaa 100644
--- a/src/yuescript/yuescript.cpp
+++ b/src/yuescript/yuescript.cpp
@@ -161,7 +161,7 @@ struct yue_stack {
161static int yuetoast(lua_State* L) { 161static int yuetoast(lua_State* L) {
162 size_t size = 0; 162 size_t size = 0;
163 const char* input = luaL_checklstring(L, 1, &size); 163 const char* input = luaL_checklstring(L, 1, &size);
164 int flattenLevel = 2; 164 int flattenLevel = 0;
165 if (lua_isnoneornil(L, 2) == 0) { 165 if (lua_isnoneornil(L, 2) == 0) {
166 flattenLevel = static_cast<int>(luaL_checkinteger(L, 2)); 166 flattenLevel = static_cast<int>(luaL_checkinteger(L, 2));
167 flattenLevel = std::max(std::min(2, flattenLevel), 0); 167 flattenLevel = std::max(std::min(2, flattenLevel), 0);
@@ -270,8 +270,10 @@ static int yuetoast(lua_State* L) {
270 lua_pushinteger(L, node->m_begin.m_col); 270 lua_pushinteger(L, node->m_begin.m_col);
271 lua_rawseti(L, -2, 3); 271 lua_rawseti(L, -2, 3);
272 for (int i = count, j = 4; i >= 1; i--, j++) { 272 for (int i = count, j = 4; i >= 1; i--, j++) {
273 lua_rawgeti(L, tableIndex, len); 273 lua_rawgeti(L, tableIndex, len - i + 1);
274 lua_rawseti(L, -2, j); 274 lua_rawseti(L, -2, j);
275 }
276 for (int i = 1; i <= count; i++) {
275 lua_pushnil(L); 277 lua_pushnil(L);
276 lua_rawseti(L, tableIndex, len); 278 lua_rawseti(L, tableIndex, len);
277 len--; 279 len--;