diff options
| author | Li Jin <dragon-fly@qq.com> | 2023-05-23 15:57:49 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2023-05-23 15:57:49 +0800 |
| commit | 122599e78752581905dad6b1b7896534d48911fa (patch) | |
| tree | ab8dd4b2f5c24113a6ef5951bec3e3827114b204 /src/yuescript/yue_compiler.cpp | |
| parent | 78433df36c5b492f366ba57d852f5393b786cfff (diff) | |
| download | yuescript-122599e78752581905dad6b1b7896534d48911fa.tar.gz yuescript-122599e78752581905dad6b1b7896534d48911fa.tar.bz2 yuescript-122599e78752581905dad6b1b7896534d48911fa.zip | |
fix lineOffset option not working.
Diffstat (limited to '')
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 918ae2a..b623425 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -72,7 +72,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
| 72 | "close"s // Lua 5.4 | 72 | "close"s // Lua 5.4 |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | const std::string_view version = "0.16.6"sv; | 75 | const std::string_view version = "0.16.7"sv; |
| 76 | const std::string_view extension = "yue"sv; | 76 | const std::string_view extension = "yue"sv; |
| 77 | 77 | ||
| 78 | class CompileError : public std::logic_error { | 78 | class CompileError : public std::logic_error { |
| @@ -250,7 +250,7 @@ public: | |||
| 250 | for (const auto& var : _globals) { | 250 | for (const auto& var : _globals) { |
| 251 | int line, col; | 251 | int line, col; |
| 252 | std::tie(line, col) = var.second; | 252 | std::tie(line, col) = var.second; |
| 253 | globals->push_back({var.first, line, col}); | 253 | globals->push_back({var.first, line + _config.lineOffset, col}); |
| 254 | } | 254 | } |
| 255 | std::sort(globals->begin(), globals->end(), [](const GlobalVar& varA, const GlobalVar& varB) { | 255 | std::sort(globals->begin(), globals->end(), [](const GlobalVar& varA, const GlobalVar& varB) { |
| 256 | if (varA.line < varB.line) { | 256 | if (varA.line < varB.line) { |
| @@ -284,12 +284,13 @@ public: | |||
| 284 | #endif // YUE_NO_MACRO | 284 | #endif // YUE_NO_MACRO |
| 285 | return {std::move(out.back()), std::nullopt, std::move(globals), std::move(options), parseTime, compileTime}; | 285 | return {std::move(out.back()), std::nullopt, std::move(globals), std::move(options), parseTime, compileTime}; |
| 286 | } catch (const CompileError& error) { | 286 | } catch (const CompileError& error) { |
| 287 | auto displayMessage = _info.errorMessage(error.what(), error.line, error.col); | 287 | auto displayMessage = _info.errorMessage(error.what(), error.line, error.col, _config.lineOffset); |
| 288 | return { | 288 | return { |
| 289 | std::string(), | 289 | std::string(), |
| 290 | CompileInfo::Error{ | 290 | CompileInfo::Error{ |
| 291 | error.what(), | 291 | error.what(), |
| 292 | error.line, error.col, | 292 | error.line + _config.lineOffset, |
| 293 | error.col, | ||
| 293 | displayMessage}, | 294 | displayMessage}, |
| 294 | std::move(globals), | 295 | std::move(globals), |
| 295 | std::move(options), | 296 | std::move(options), |
| @@ -302,18 +303,20 @@ public: | |||
| 302 | std::string(), | 303 | std::string(), |
| 303 | CompileInfo::Error{ | 304 | CompileInfo::Error{ |
| 304 | error.msg, | 305 | error.msg, |
| 305 | error.line, error.col, | 306 | error.line + _config.lineOffset, |
| 307 | error.col, | ||
| 306 | ""}, | 308 | ""}, |
| 307 | std::move(globals), | 309 | std::move(globals), |
| 308 | std::move(options), | 310 | std::move(options), |
| 309 | parseTime, compileTime}; | 311 | parseTime, compileTime}; |
| 310 | } | 312 | } |
| 311 | auto displayMessage = _info.errorMessage(error.msg, error.line, error.col); | 313 | auto displayMessage = _info.errorMessage(error.msg, error.line, error.col, _config.lineOffset); |
| 312 | return { | 314 | return { |
| 313 | std::string(), | 315 | std::string(), |
| 314 | CompileInfo::Error{ | 316 | CompileInfo::Error{ |
| 315 | error.msg, | 317 | error.msg, |
| 316 | error.line, error.col, | 318 | error.line + _config.lineOffset, |
| 319 | error.col, | ||
| 317 | displayMessage}, | 320 | displayMessage}, |
| 318 | std::move(globals), | 321 | std::move(globals), |
| 319 | std::move(options), | 322 | std::move(options), |
