Skip to content

Commit

Permalink
fix: Empty arrays now behave similarly to other subscripted variables…
Browse files Browse the repository at this point in the history
… in the macro tracer
  • Loading branch information
jirimosinger authored Apr 13, 2022
1 parent fee9e33 commit ce0ba21
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 190 deletions.
9 changes: 5 additions & 4 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Improve detection of HLASM files
- Reaching ACTR limit now only generates warnings
- Parsing of negative numbers in machine expressions
- Empty arrays now behave similarly to other subscripted variables in macro tracer

## [1.1.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/1.0.0...1.1.0) (2022-03-29)

Expand All @@ -38,7 +39,7 @@

#### Fixed
- Highlighting now fully works with themes, not just categories dark, light and contrast.
- Incorrect module layout generated when data defintion operands have different alignments
- Incorrect module layout generated when data definition operands have different alignments
- Data definition grammar is too greedy
- Readme update

Expand Down Expand Up @@ -75,7 +76,7 @@
- Infinite loop during lookahead processing when model statement is located in copybook
- DOT operator in string concatenation is optional
- AINSERT operand length validation
- HLASM Listing highligting of lines with trimmed whitespace
- HLASM Listing highlighting of lines with trimmed whitespace
- Macro tracer: step over sometimes stops inside a macro or a copy file

## [0.14.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/0.13.0...0.14.0) (2021-08-18)
Expand All @@ -94,9 +95,9 @@
- Improved OPSYN processing
- Language server crashes while evaluating conditional assembly statements
- Allow self-reference in previously undefined array variables
- Tolerate '+' in modifiers in data defintions
- Tolerate '+' in modifiers in data definitions
- Empty TITLE argument must be tolerated
- Statements skipped by conditinal assembly emmiting errors in macros and copy files
- Statements skipped by conditional assembly emitting errors in macros and copy files
- Location counter in machine instruction sometimes evaluating incorrectly
- WASM variant of the language server not working with the V8 JavaScript machine version 9 or later
- Improve language server stability
Expand Down
7 changes: 6 additions & 1 deletion parser_library/src/debugging/set_symbol_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ std::string set_symbol_variable::get_string_array_value() const
array_value.append("(");

auto keys = set_symbol_.keys();
assert(!keys.empty());

if (keys.empty())
{
array_value.append(")");
return array_value;
}

for (const auto& key : keys)
{
Expand Down
29 changes: 29 additions & 0 deletions parser_library/test/common_testing.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,35 @@ std::optional<std::vector<T>> get_var_vector(hlasm_context& ctx, std::string nam
return result;
}

template<typename T>
std::optional<std::unordered_map<size_t, T>> get_var_vector_map(hlasm_context& ctx, std::string name)
{
auto var = ctx.get_var_sym(ctx.ids().find(name));
if (!var)
return std::nullopt;

if (var->var_kind != context::variable_kind::SET_VAR_KIND)
return std::nullopt;
auto var_ = var->access_set_symbol_base();
if (var_->type != object_traits<T>::type_enum || var_->is_scalar)
return std::nullopt;

auto symbol = var_->template access_set_symbol<T>();
if (!symbol)
return std::nullopt;

auto keys = symbol->keys();

std::unordered_map<size_t, T> result;
result.reserve(keys.size());
for (size_t i = 0; i < keys.size(); ++i)
{
result.emplace(keys[i], symbol->get_value(keys[i]));
}

return result;
}

inline bool matches_message_codes(const std::vector<diagnostic_op>& d, std::initializer_list<std::string> m)
{
std::vector<std::string> codes;
Expand Down
11 changes: 8 additions & 3 deletions parser_library/test/debugging/debugger_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,15 +774,16 @@ TEST(debugger, positional_parameters)
d.disconnect();
}

TEST(debugger, var_symbol_array)
TEST(debugger, arrays)
{
using list = std::unordered_map<std::string, std::shared_ptr<test_var_value>>;

std::string open_code = R"(
&VAR(30) SETA 1,456,48,7
&BOOL(15) SETB 0,1,0
&STR(6) SETC 'a','b'
LR 1,1
GBLC &ARR(10)
END
)";


Expand Down Expand Up @@ -823,6 +824,10 @@ TEST(debugger, var_symbol_array)
list { { "6", std::make_shared<test_var_value>("a") }, { "7", std::make_shared<test_var_value>("b") } }));
EXPECT_TRUE(check_step(d, exp_frames, exp_frame_vars));

step_over_by(1, d, m, exp_frames, 5);
exp_frame_vars[0].globals.emplace("&ARR", test_var_value("()", list {}));
EXPECT_TRUE(check_step(d, exp_frames, exp_frame_vars));

d.disconnect();
}

Expand Down Expand Up @@ -923,4 +928,4 @@ TEST(debugger, breakpoints_set_get)

ASSERT_EQ(bps.size(), 1);
EXPECT_EQ(bp.line, bps.begin()->line);
}
}
Loading

0 comments on commit ce0ba21

Please sign in to comment.