Skip to content

Commit deb2fc4

Browse files
committed
Fixed error hints not showing correctly
1 parent d9a78cc commit deb2fc4

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/parser/sqf/default.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
12521252
auto s = std::string(node.children[1].content);
12531253
std::transform(s.begin(), s.end(), s.begin(), [](char& c) { return (char)std::tolower((int)c); });
12541254
auto inst = std::make_shared<::sqf::opcodes::call_binary>(s, (short)(((short)node.kind - (short)nodetype::BEXP1) + 1));
1255-
inst->diag_info({ node.children[1].line, node.children[1].column, node.children[1].file_offset, node.children[1].path, create_code_segment(m_contents, node.children[1].file_offset, node.children[1].length) });
1255+
inst->diag_info({ node.children[1].line, node.children[1].column, node.children[1].file_offset, node.children[1].path, create_code_segment(m_contents, node.children[1].adjusted_offset, node.children[1].length) });
12561256
set.push_back(inst);
12571257
}
12581258
break;
@@ -1262,7 +1262,7 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
12621262
auto s = std::string(node.children[0].content);
12631263
std::transform(s.begin(), s.end(), s.begin(), [](char& c) { return (char)std::tolower((int)c); });
12641264
auto inst = std::make_shared<::sqf::opcodes::call_unary>(s);
1265-
inst->diag_info({ node.children[0].line, node.children[0].column, node.children[0].file_offset, node.children[0].path, create_code_segment(m_contents, node.children[0].file_offset, node.children[0].length) });
1265+
inst->diag_info({ node.children[0].line, node.children[0].column, node.children[0].file_offset, node.children[0].path, create_code_segment(m_contents, node.children[0].adjusted_offset, node.children[0].length) });
12661266
set.push_back(inst);
12671267
}
12681268
break;
@@ -1271,7 +1271,7 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
12711271
auto s = std::string(node.content);
12721272
std::transform(s.begin(), s.end(), s.begin(), [](char& c) { return (char)std::tolower((int)c); });
12731273
auto inst = std::make_shared<::sqf::opcodes::call_nular>(s);
1274-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1274+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
12751275
set.push_back(inst);
12761276
}
12771277
break;
@@ -1280,13 +1280,13 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
12801280
try
12811281
{
12821282
auto inst = std::make_shared<::sqf::opcodes::push>(::sqf::runtime::value(std::make_shared<::sqf::types::d_scalar>((int64_t)std::stol(node.content, nullptr, 16))));
1283-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1283+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
12841284
set.push_back(inst);
12851285
}
12861286
catch (std::out_of_range&)
12871287
{
12881288
auto inst = std::make_shared<::sqf::opcodes::push>(::sqf::runtime::value(std::make_shared<::sqf::types::d_scalar>(std::nanf(""))));
1289-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1289+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
12901290
m_owner.log(logmessage::assembly::NumberOutOfRange(inst->diag_info()));
12911291
set.push_back(inst);
12921292
}
@@ -1297,13 +1297,13 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
12971297
try
12981298
{
12991299
auto inst = std::make_shared<::sqf::opcodes::push>(::sqf::runtime::value(std::make_shared<::sqf::types::d_scalar>((double)std::stod(node.content))));
1300-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1300+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13011301
set.push_back(inst);
13021302
}
13031303
catch (std::out_of_range&)
13041304
{
13051305
auto inst = std::make_shared<::sqf::opcodes::push>(::sqf::runtime::value(std::make_shared<::sqf::types::d_scalar>(std::nanf(""))));
1306-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1306+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13071307
m_owner.log(logmessage::assembly::NumberOutOfRange(inst->diag_info()));
13081308
set.push_back(inst);
13091309
}
@@ -1312,7 +1312,7 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
13121312
case nodetype::STRING:
13131313
{
13141314
auto inst = std::make_shared<::sqf::opcodes::push>(::sqf::runtime::value(std::make_shared<::sqf::types::d_string>(::sqf::types::d_string::from_sqf(node.content))));
1315-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1315+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13161316
set.push_back(inst);
13171317
}
13181318
break;
@@ -1325,15 +1325,15 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
13251325
if (i != 0)
13261326
{
13271327
auto inst = std::make_shared<::sqf::opcodes::end_statement>();
1328-
inst->diag_info({ previous_node.line, previous_node.column + previous_node.length, previous_node.file_offset, previous_node.path, create_code_segment(m_contents, previous_node.file_offset, previous_node.length) });
1328+
inst->diag_info({ previous_node.line, previous_node.column + previous_node.length, previous_node.file_offset, previous_node.path, create_code_segment(m_contents, previous_node.adjusted_offset, previous_node.length) });
13291329
tmp_set.push_back(inst);
13301330
}
13311331
previous_node = node.children[i];
13321332
to_assembly(previous_node, tmp_set);
13331333
}
13341334
auto inst_set = ::sqf::runtime::instruction_set(tmp_set);
13351335
auto inst = std::make_shared<::sqf::opcodes::push>(::sqf::runtime::value(std::make_shared<::sqf::types::d_code>(inst_set)));
1336-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1336+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13371337
set.push_back(inst);
13381338
}
13391339
break;
@@ -1344,30 +1344,30 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
13441344
to_assembly(subnode, set);
13451345
}
13461346
auto inst = std::make_shared<::sqf::opcodes::make_array>(node.children.size());
1347-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1347+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13481348
set.push_back(inst);
13491349
}
13501350
break;
13511351
case nodetype::ASSIGNMENT:
13521352
{
13531353
to_assembly(node.children[1], set);
13541354
auto inst = std::make_shared<::sqf::opcodes::assign_to>(node.children[0].content);
1355-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1355+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13561356
set.push_back(inst);
13571357
}
13581358
break;
13591359
case nodetype::ASSIGNMENTLOCAL:
13601360
{
13611361
to_assembly(node.children[1], set);
13621362
auto inst = std::make_shared<::sqf::opcodes::assign_to_local>(node.children[0].content);
1363-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1363+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13641364
set.push_back(inst);
13651365
}
13661366
break;
13671367
case nodetype::VARIABLE:
13681368
{
13691369
auto inst = std::make_shared<::sqf::opcodes::get_variable>(node.content);
1370-
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.file_offset, node.length) });
1370+
inst->diag_info({ node.line, node.column, node.file_offset, node.path, create_code_segment(m_contents, node.adjusted_offset, node.length) });
13711371
set.push_back(inst);
13721372
}
13731373
break;
@@ -1379,7 +1379,7 @@ bool sqf::parser::sqf::impl_default::instance::to_assembly(::sqf::parser::sqf::i
13791379
if (i != 0)
13801380
{
13811381
auto inst = std::make_shared<::sqf::opcodes::end_statement>();
1382-
inst->diag_info({ previous_node.line, previous_node.column + previous_node.length, previous_node.file_offset, previous_node.path, create_code_segment(m_contents, previous_node.file_offset, previous_node.length) });
1382+
inst->diag_info({ previous_node.line, previous_node.column + previous_node.length, previous_node.file_offset, previous_node.path, create_code_segment(m_contents, previous_node.adjusted_offset, previous_node.length) });
13831383
set.push_back(inst);
13841384
}
13851385
previous_node = node.children[i];

0 commit comments

Comments
 (0)