Skip to content

Commit 227b387

Browse files
authored
Merge pull request #85 from sssooonnnggg/master
fix: support statement execution in debugger console REPL
2 parents 9581ca5 + 1c0f659 commit 227b387

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

emmy_debugger/src/debugger/emmy_debugger.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2019. tangzx(love.tangzx@qq.com)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -984,9 +984,16 @@ bool Debugger::DoEval(std::shared_ptr<EvalContext> evalContext) {
984984

985985
if (r == LUA_ERRSYNTAX) {
986986
lua_pop(L, 1); // 弹出错误信息
987-
evalContext->error = "syntax err: ";
988-
evalContext->error.append(evalContext->expr);
989-
return false;
987+
// 尝试作为语句执行(例如 a.b = 123 这样的赋值语句)
988+
if (!evalContext->setValue) {
989+
r = luaL_loadstring(L, evalContext->expr.c_str());
990+
}
991+
if (r == LUA_ERRSYNTAX) {
992+
lua_pop(L, 1);
993+
evalContext->error = "syntax err: ";
994+
evalContext->error.append(evalContext->expr);
995+
return false;
996+
}
990997
}
991998
}
992999
// call

0 commit comments

Comments
 (0)