From c2d64c9023ce438af7e3737ced4330a9f5f805bb Mon Sep 17 00:00:00 2001 From: slavek-kucera <53339291+slavek-kucera@users.noreply.github.com> Date: Tue, 14 Dec 2021 13:10:47 +0100 Subject: [PATCH] feat: Location counter length attribute support (#208) (closes #71) --- clients/vscode-hlasmplugin/CHANGELOG.md | 4 + .../src/parsing/grammar/machine_expr_rules.g4 | 24 ++++-- parser_library/src/parsing/parser_impl.cpp | 12 +++ parser_library/src/parsing/parser_impl.h | 2 + parser_library/src/processing/op_code.cpp | 17 ++++ parser_library/src/processing/op_code.h | 7 +- .../data_definition/data_definition_test.cpp | 14 +--- parser_library/test/common_testing.h | 32 ++++++- .../test/context/data_attribute_test.cpp | 77 +++++++++-------- parser_library/test/context/literals_test.cpp | 39 +++++++-- parser_library/test/context/ord_sym_test.cpp | 79 ++++++++--------- parser_library/test/parsing/string_test.cpp | 12 +-- .../test/processing/asm_instr_test.cpp | 20 ++--- parser_library/test/processing/dc_test.cpp | 39 ++++----- parser_library/test/processing/equ_test.cpp | 49 ++++------- parser_library/test/processing/loctr_test.cpp | 14 ++-- .../test/processing/mach_instr_test.cpp | 27 ++++++ parser_library/test/processing/org_test.cpp | 84 +++++++++---------- parser_library/test/processing/start_test.cpp | 2 +- 19 files changed, 321 insertions(+), 233 deletions(-) diff --git a/clients/vscode-hlasmplugin/CHANGELOG.md b/clients/vscode-hlasmplugin/CHANGELOG.md index 20365e0b5..d83f63ca6 100644 --- a/clients/vscode-hlasmplugin/CHANGELOG.md +++ b/clients/vscode-hlasmplugin/CHANGELOG.md @@ -2,6 +2,10 @@ ## ****Unreleased**** +#### Added +- Literal support +- Location counter length attribute support + ## [0.15.1](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/0.15.0...0.15.1) (2021-11-11) #### Fixed diff --git a/parser_library/src/parsing/grammar/machine_expr_rules.g4 b/parser_library/src/parsing/grammar/machine_expr_rules.g4 index 6a86399d7..5c71ff655 100644 --- a/parser_library/src/parsing/grammar/machine_expr_rules.g4 +++ b/parser_library/src/parsing/grammar/machine_expr_rules.g4 @@ -79,6 +79,9 @@ mach_term returns [mach_expr_ptr m_e] if constexpr (std::is_same_v,std::monostate>) { return std::make_unique(rng); } + else if constexpr (std::is_same_v,int>) { + return std::make_unique(arg, symbol_rng); + } else { return std::make_unique(std::move(arg), attr, rng, symbol_rng); } @@ -122,14 +125,24 @@ literal returns [std::optional value] add_diagnostic(diagnostic_severity::error, "S0013", "Invalid literal usage", provider.get_range($equals.ctx)); }; -mach_data_attribute returns [data_attr_kind attribute, std::variant> data, range symbol_rng] - : ORDSYMBOL (attr|apostrophe_as_attr) {auto lit_restore = enable_literals();} mach_data_attribute_value +mach_data_attribute returns [data_attr_kind attribute, std::variant, int> data, range symbol_rng] + : ORDSYMBOL (attr|apostrophe_as_attr) {auto lit_restore = enable_literals();} { collector.add_hl_symbol(token_info(provider.get_range($ORDSYMBOL), hl_scopes::data_attr_type)); $attribute = get_attribute($ORDSYMBOL->getText()); - $data = std::move($mach_data_attribute_value.data); - $symbol_rng = provider.get_range($mach_data_attribute_value.ctx); - }; + } + ( + { loctr_len_allowed($ORDSYMBOL.text) }? mach_location_counter + { + $data = (int)get_loctr_len(); + } + | + mach_data_attribute_value + { + std::visit([&data = $data](auto&x){data=std::move(x);}, $mach_data_attribute_value.data); + $symbol_rng = provider.get_range($mach_data_attribute_value.ctx); + } + ); mach_data_attribute_value returns [std::variant> data] : literal @@ -138,7 +151,6 @@ mach_data_attribute_value returns [std::variant(rng, std::move(lv.value()), $literal.text); } - | mach_location_counter | id { collector.add_hl_symbol(token_info(provider.get_range($id.ctx), hl_scopes::ordinary_symbol)); diff --git a/parser_library/src/parsing/parser_impl.cpp b/parser_library/src/parsing/parser_impl.cpp index f9ed42dfe..c4cc0428c 100644 --- a/parser_library/src/parsing/parser_impl.cpp +++ b/parser_library/src/parsing/parser_impl.cpp @@ -23,6 +23,7 @@ #include "hlasmparser.h" #include "lexing/token_stream.h" #include "processing/context_manager.h" +#include "processing/op_code.h" namespace hlasm_plugin::parser_library::parsing { @@ -119,6 +120,17 @@ context::id_index parser_impl::parse_identifier(std::string value, range id_rang return hlasm_ctx->ids().add(std::move(value)); } +size_t parser_impl::get_loctr_len() const +{ + auto [_, opcode] = *proc_status; + return processing::processing_status_cache_key::generate_loctr_len(opcode.value); +} + +bool parser_impl::loctr_len_allowed(const std::string& attr) const +{ + return (attr == "L" || attr == "l") && proc_status.has_value(); +} + void parser_impl::resolve_expression(expressions::ca_expr_ptr& expr, context::SET_t_enum type) const { expr->resolve_expression_tree(type); diff --git a/parser_library/src/parsing/parser_impl.h b/parser_library/src/parsing/parser_impl.h index 9ee91da81..91429114f 100644 --- a/parser_library/src/parsing/parser_impl.h +++ b/parser_library/src/parsing/parser_impl.h @@ -132,6 +132,8 @@ class parser_impl : public antlr4::Parser self_def_t parse_self_def_term(const std::string& option, const std::string& value, range term_range); context::data_attr_kind get_attribute(std::string attr_data); context::id_index parse_identifier(std::string value, range id_range); + size_t get_loctr_len() const; + bool loctr_len_allowed(const std::string& attr) const; void resolve_expression(expressions::ca_expr_ptr& expr, context::SET_t_enum type) const; void resolve_expression(std::vector& expr, context::SET_t_enum type) const; diff --git a/parser_library/src/processing/op_code.cpp b/parser_library/src/processing/op_code.cpp index 62ea0e341..c5ed1474e 100644 --- a/parser_library/src/processing/op_code.cpp +++ b/parser_library/src/processing/op_code.cpp @@ -34,10 +34,27 @@ inline unsigned char get_reladdr_bitmask(context::id_index id) return 0; } +// Generates value of L'* expression +unsigned char processing_status_cache_key::generate_loctr_len(context::id_index id) +{ + if (id && !id->empty()) + { + if (auto p_instr = context::instruction::machine_instructions.find(*id); + p_instr != context::instruction::machine_instructions.end()) + return static_cast(p_instr->second.size_for_alloc / 8); + + if (auto p_mnemo = context::instruction::mnemonic_codes.find(*id); + p_mnemo != context::instruction::mnemonic_codes.end()) + return static_cast(p_mnemo->second.instruction->size_for_alloc / 8); + } + return 1; +} + processing_status_cache_key::processing_status_cache_key(const processing_status& s) : form(s.first.form) , occurence(s.first.occurence) , is_alias(s.second.type == context::instruction_type::ASM && s.second.value && *s.second.value == "ALIAS") + , loctr_len(generate_loctr_len(s.second.value)) , rel_addr(get_reladdr_bitmask(s.second.value)) {} } // namespace hlasm_plugin::parser_library::processing diff --git a/parser_library/src/processing/op_code.h b/parser_library/src/processing/op_code.h index 6a30d9764..67d0a4242 100644 --- a/parser_library/src/processing/op_code.h +++ b/parser_library/src/processing/op_code.h @@ -45,17 +45,20 @@ class processing_status_cache_key { processing_form form; operand_occurence occurence; - bool is_alias; + unsigned char is_alias : 1, loctr_len : 7; unsigned char rel_addr; public: friend bool operator==(processing_status_cache_key l, processing_status_cache_key r) { - return l.form == r.form && l.occurence == r.occurence && l.is_alias == r.is_alias && l.rel_addr == r.rel_addr; + return l.form == r.form && l.occurence == r.occurence && l.is_alias == r.is_alias && l.loctr_len == r.loctr_len + && l.rel_addr == r.rel_addr; } friend bool operator!=(processing_status_cache_key l, processing_status_cache_key r) { return !(l == r); } explicit processing_status_cache_key(const processing_status& s); + + static unsigned char generate_loctr_len(context::id_index id); }; } // namespace hlasm_plugin::parser_library::processing diff --git a/parser_library/test/checking/data_definition/data_definition_test.cpp b/parser_library/test/checking/data_definition/data_definition_test.cpp index 68cfc3900..0b3d5a011 100644 --- a/parser_library/test/checking/data_definition/data_definition_test.cpp +++ b/parser_library/test/checking/data_definition/data_definition_test.cpp @@ -489,17 +489,9 @@ LZ EQU *-Z a.collect_diags(); EXPECT_EQ(a.diags().size(), (size_t)0); - auto LX = a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LX")); - auto LY = a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LY")); - auto LZ = a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LZ")); - - ASSERT_TRUE(LX && LX->value().value_kind() == context::symbol_value_kind::ABS); - ASSERT_TRUE(LY && LY->value().value_kind() == context::symbol_value_kind::ABS); - ASSERT_TRUE(LZ && LZ->value().value_kind() == context::symbol_value_kind::ABS); - - EXPECT_EQ(LX->value().get_abs(), 24); - EXPECT_EQ(LY->value().get_abs(), 6); - EXPECT_EQ(LZ->value().get_abs(), 15); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "LX"), 24); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "LY"), 6); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "LZ"), 15); } TEST(data_definition, no_loctr_ref) diff --git a/parser_library/test/common_testing.h b/parser_library/test/common_testing.h index 05338af15..6ed6eaba7 100644 --- a/parser_library/test/common_testing.h +++ b/parser_library/test/common_testing.h @@ -146,11 +146,37 @@ inline const section* get_section(hlasm_context& ctx, std::string name) inline const symbol* get_symbol(hlasm_context& ctx, std::string name) { - auto sect = ctx.ids().find(std::move(name)); - if (!sect) + auto symbol = ctx.ids().find(std::move(name)); + if (!symbol) return nullptr; - return ctx.ord_ctx.get_symbol(sect); + return ctx.ord_ctx.get_symbol(symbol); +} + +inline std::optional get_symbol_abs(hlasm_context& ctx, std::string name) +{ + auto symbol = ctx.ids().find(std::move(name)); + if (!symbol) + return std::nullopt; + + auto s = ctx.ord_ctx.get_symbol(symbol); + if (!s || s->kind() != symbol_value_kind::ABS) + return std::nullopt; + + return s->value().get_abs(); +} + +inline std::optional get_symbol_reloc(hlasm_context& ctx, std::string name) +{ + auto symbol = ctx.ids().find(std::move(name)); + if (!symbol) + return std::nullopt; + + auto s = ctx.ord_ctx.get_symbol(symbol); + if (!s || s->kind() != symbol_value_kind::RELOC) + return std::nullopt; + + return s->value().get_reloc(); } #endif diff --git a/parser_library/test/context/data_attribute_test.cpp b/parser_library/test/context/data_attribute_test.cpp index e3c35f7c9..3fd5bf405 100644 --- a/parser_library/test/context/data_attribute_test.cpp +++ b/parser_library/test/context/data_attribute_test.cpp @@ -216,12 +216,9 @@ C LOCTR analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->attributes().type(), - ebcdic_encoding::a2e[U'I']); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->attributes().type(), - ebcdic_encoding::a2e[U'J']); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("C"))->attributes().type(), - ebcdic_encoding::a2e[U'J']); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "A")->attributes().type(), ebcdic_encoding::a2e[U'I']); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "B")->attributes().type(), ebcdic_encoding::a2e[U'J']); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "C")->attributes().type(), ebcdic_encoding::a2e[U'J']); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -373,8 +370,8 @@ B EQU L'LBL analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 2); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -414,7 +411,7 @@ B EQU S'A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 12); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 12); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -451,16 +448,11 @@ EXTEND DC LS10'5.312' analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("HALFCON"))->attributes().integer(), - (symbol_attributes::len_attr)9); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("ONECON"))->attributes().integer(), - (symbol_attributes::len_attr)23); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("SHORT"))->attributes().integer(), - (symbol_attributes::len_attr)4); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LONG"))->attributes().integer(), - (symbol_attributes::len_attr)9); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("EXTEND"))->attributes().integer(), - (symbol_attributes::len_attr)18); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "HALFCON")->attributes().integer(), (symbol_attributes::len_attr)9); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "ONECON")->attributes().integer(), (symbol_attributes::len_attr)23); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "SHORT")->attributes().integer(), (symbol_attributes::len_attr)4); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "LONG")->attributes().integer(), (symbol_attributes::len_attr)9); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "EXTEND")->attributes().integer(), (symbol_attributes::len_attr)18); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -476,7 +468,7 @@ X EQU I'HALFCON analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 9); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 9); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -597,9 +589,8 @@ B EQU T'W analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), - symbol_attributes::undef_type); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), symbol_attributes::undef_type); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -619,8 +610,8 @@ W EQU 4,5,6 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 2); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 6); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 6); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -641,8 +632,7 @@ B EQU 1,11 a.analyze(); EXPECT_EQ(get_var_value(a.hlasm_ctx(), "V1"), 1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->attributes().length(), - (symbol_attributes::len_attr)1); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "A")->attributes().length(), (symbol_attributes::len_attr)1); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -677,12 +667,10 @@ B EQU L'A ASSERT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("A"))); ASSERT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("B"))); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 11); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->attributes().length(), - (symbol_attributes::len_attr)11); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 11); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->attributes().length(), - (symbol_attributes::len_attr)1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 11); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "A")->attributes().length(), (symbol_attributes::len_attr)11); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 11); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "B")->attributes().length(), (symbol_attributes::len_attr)1); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -703,7 +691,7 @@ C EQU 1,12 analyzer a(input); a.analyze(); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->kind(), symbol_value_kind::ABS); + ASSERT_EQ(get_symbol(a.hlasm_ctx(), "X")->kind(), symbol_value_kind::ABS); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -723,3 +711,24 @@ V EQU I'C a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)1); } + +TEST(data_attributes, loctr_length) +{ + std::string input = R"( +X1 DS (L'*)C +A EQU *-X1 +X2 DC (L'*)C' ' +B EQU *-X2 +C EQU L'* +)"; + + analyzer a(input); + a.analyze(); + + a.collect_diags(); + EXPECT_TRUE(a.diags().empty()); + + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "C"), 1); +} diff --git a/parser_library/test/context/literals_test.cpp b/parser_library/test/context/literals_test.cpp index ec6f0e940..5267ce0a1 100644 --- a/parser_library/test/context/literals_test.cpp +++ b/parser_library/test/context/literals_test.cpp @@ -88,11 +88,7 @@ A EQU L'=A(0) EXPECT_TRUE(a.diags().empty()); - const auto* symbol = get_symbol(a.hlasm_ctx(), "A"); - ASSERT_TRUE(symbol); - auto symbol_value = symbol->value(); - ASSERT_EQ(symbol_value.value_kind(), context::symbol_value_kind::ABS); - EXPECT_EQ(symbol_value.get_abs(), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 4); auto* sect = get_section(a.hlasm_ctx(), ""); ASSERT_TRUE(sect); @@ -474,3 +470,36 @@ TEST(literals, zero_length) EXPECT_TRUE(matches_message_codes(a.diags(), { "D031" })); } + +TEST(literals, deduplicate_loctr_len_reference) +{ + std::string input = R"( + LARL 0,=A(L'*) + LARL 0,=A(l'*) +)"; + analyzer a(input); + a.analyze(); + a.collect_diags(); + + EXPECT_TRUE(a.diags().empty()); + + auto* sect = get_section(a.hlasm_ctx(), ""); + ASSERT_TRUE(sect); + EXPECT_EQ(sect->location_counters().back()->current_address().offset(), 20); +} + +TEST(literals, invalid_loctr_references) +{ + std::string input = R"( +&VARP(3) SETC ' ','B','C' +&VARP(L'=CL(L'*)'1') SETC 'A' +&VARP(L'=CL(L'*)'2') LHI 0,0 +&VARP(L'*) SETC 'A' +&VARP(L'*) LHI 0,0 +)"; + analyzer a(input); + a.analyze(); + a.collect_diags(); + + EXPECT_TRUE(matches_message_codes(a.diags(), { "S0012", "S0012", "S0009", "S0009" })); +} diff --git a/parser_library/test/context/ord_sym_test.cpp b/parser_library/test/context/ord_sym_test.cpp index 8e5cdb3ae..bcea09dbe 100644 --- a/parser_library/test/context/ord_sym_test.cpp +++ b/parser_library/test/context/ord_sym_test.cpp @@ -83,9 +83,9 @@ C EQU 10 EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("B"))); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("C"))); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 12); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 11); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("C"))->value().get_abs(), 10); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 12); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 11); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "C"), 10); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -107,11 +107,9 @@ Y LR 1,1 EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("X"))); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("Y"))); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("D"))->value().get_abs(), 2); - EXPECT_EQ( - a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().value_kind(), symbol_value_kind::RELOC); - EXPECT_EQ( - a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().value_kind(), symbol_value_kind::RELOC); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "D"), 2); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "X")->value().value_kind(), symbol_value_kind::RELOC); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "Y")->value().value_kind(), symbol_value_kind::RELOC); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -131,9 +129,9 @@ C EQU A EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("B"))); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("C"))); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->kind() == symbol_value_kind::ABS); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->kind() == symbol_value_kind::ABS); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("C"))->kind() == symbol_value_kind::ABS); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "A")->kind() == symbol_value_kind::ABS); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "B")->kind() == symbol_value_kind::ABS); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "C")->kind() == symbol_value_kind::ABS); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)1); @@ -152,8 +150,8 @@ B EQU 100 EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("A"))); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("B"))); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 101); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 100); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 101); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 100); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)1); @@ -169,7 +167,7 @@ A LR 1,1 a.analyze(); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("A"))); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "A")->kind() == symbol_value_kind::RELOC); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)1); @@ -186,7 +184,7 @@ B LR A*2,1 EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("A"))); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("B"))); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "A")->kind() == symbol_value_kind::RELOC); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)2); @@ -204,8 +202,8 @@ Y LR 1,1 EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("X"))); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("Y"))); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "X")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "Y")->kind() == symbol_value_kind::RELOC); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -233,15 +231,15 @@ F EQU V-U analyzer a(input); a.analyze(); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X1"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y1"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X2"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y2"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("U"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("V"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("F"))->kind() == symbol_value_kind::ABS); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "X1")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "Y1")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "X2")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "Y2")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "U")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "V")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "F")->kind() == symbol_value_kind::ABS); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("F"))->value().get_abs(), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "F"), 4); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -269,14 +267,12 @@ X3 EQU F-E analyzer a(input); a.analyze(); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->kind() == symbol_value_kind::ABS); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("C"))->kind() == symbol_value_kind::ABS); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 2); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("C"))->value().get_abs(), 0); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X1"))->value().get_abs(), 1); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X2"))->value().get_abs(), 0); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X3"))->value().get_abs(), 2); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "A")->kind() == symbol_value_kind::RELOC); + ASSERT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 2); + ASSERT_EQ(get_symbol_abs(a.hlasm_ctx(), "C"), 0); + ASSERT_EQ(get_symbol_abs(a.hlasm_ctx(), "X1"), 1); + ASSERT_EQ(get_symbol_abs(a.hlasm_ctx(), "X2"), 0); + ASSERT_EQ(get_symbol_abs(a.hlasm_ctx(), "X3"), 2); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -301,12 +297,9 @@ X EQU 1 a.analyze(); a.collect_diags(); - EXPECT_EQ( - a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->symbol_location, location({ 6, 0 }, "test")); - EXPECT_EQ( - a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("XX"))->symbol_location, location({ 3, 0 }, "test")); - EXPECT_EQ( - a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("XXX"))->symbol_location, location({ 0, 0 }, "COPYF")); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "X")->symbol_location, location({ 6, 0 }, "test")); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "XX")->symbol_location, location({ 3, 0 }, "test")); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "XXX")->symbol_location, location({ 0, 0 }, "COPYF")); } TEST(ordinary_symbols, alignment_cycle) @@ -358,7 +351,7 @@ X EQU *-B a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 24); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 24); EXPECT_EQ(a.diags().size(), (size_t)0); } @@ -380,7 +373,7 @@ X EQU *-A a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 24); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 24); EXPECT_EQ(a.diags().size(), (size_t)0); } @@ -447,9 +440,7 @@ YD DS 0C a.collect_diags(); EXPECT_TRUE(a.diags().empty()); - auto test_aaa = a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("TEST_AAA")); - ASSERT_TRUE(test_aaa && test_aaa->kind() == context::symbol_value_kind::ABS); - EXPECT_EQ(test_aaa->value().get_abs(), 36); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "TEST_AAA"), 36); } TEST(ordinary_symbols, private_sections_valid) diff --git a/parser_library/test/parsing/string_test.cpp b/parser_library/test/parsing/string_test.cpp index 4fbbf1c30..a03d6011d 100644 --- a/parser_library/test/parsing/string_test.cpp +++ b/parser_library/test/parsing/string_test.cpp @@ -24,11 +24,7 @@ TEST(parser, mach_string_double_ampersand) analyzer a(input); a.analyze(); - auto& ctx = a.hlasm_ctx(); - - auto it = ctx.ids().find("A"); - - ASSERT_EQ(ctx.ord_ctx.get_symbol(it)->value().get_abs(), 80); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 80); } TEST(parser, ca_string_double_ampersand) @@ -37,11 +33,7 @@ TEST(parser, ca_string_double_ampersand) analyzer a(input); a.analyze(); - auto& ctx = a.hlasm_ctx(); - - auto it = ctx.ids().find("A"); - - ASSERT_EQ(ctx.get_var_sym(it)->access_set_symbol_base()->access_set_symbol()->get_value(), "&&"); + EXPECT_EQ(get_var_value(a.hlasm_ctx(), "A"), "&&"); } namespace { diff --git a/parser_library/test/processing/asm_instr_test.cpp b/parser_library/test/processing/asm_instr_test.cpp index cee90044b..0f7516437 100644 --- a/parser_library/test/processing/asm_instr_test.cpp +++ b/parser_library/test/processing/asm_instr_test.cpp @@ -35,7 +35,7 @@ ADDR DS CL4 auto& ctx = *a.context().hlasm_ctx; - auto symbol = ctx.ord_ctx.get_symbol(ctx.ids().add("CCWSYM")); + auto symbol = get_symbol(ctx, "CCWSYM"); ASSERT_NE(symbol, nullptr); EXPECT_EQ(symbol->value().get_reloc().offset(), 8); @@ -73,15 +73,15 @@ A LR 1,1 auto& ctx = *a.context().hlasm_ctx; - auto symbol = ctx.ord_ctx.get_symbol(ctx.ids().add("CNOPSYM")); + auto symbol = get_symbol(ctx, "CNOPSYM"); ASSERT_NE(symbol, nullptr); EXPECT_EQ(symbol->value().get_reloc().offset(), 2); EXPECT_EQ(symbol->attributes().get_attribute_value(context::data_attr_kind::T), 'I'_ebcdic); - auto symbol_after = ctx.ord_ctx.get_symbol(ctx.ids().add("A")); - ASSERT_NE(symbol_after, nullptr); - EXPECT_EQ(symbol_after->value().get_reloc().offset(), 8); + auto symbol_after = get_symbol_reloc(ctx, "A"); + ASSERT_TRUE(symbol_after.has_value()); + EXPECT_EQ(symbol_after->offset(), 8); } TEST(asm_instr_processing, CNOP_byte_expr) @@ -101,13 +101,13 @@ A LR 1,1 auto& ctx = *a.context().hlasm_ctx; - auto symbol = ctx.ord_ctx.get_symbol(ctx.ids().add("CNOPSYM")); + auto symbol = get_symbol(ctx, "CNOPSYM"); ASSERT_NE(symbol, nullptr); EXPECT_EQ(symbol->value().get_reloc().offset(), 4); - auto symbol_after = ctx.ord_ctx.get_symbol(ctx.ids().add("A")); - ASSERT_NE(symbol_after, nullptr); - EXPECT_EQ(symbol_after->value().get_reloc().offset(), 14); + auto symbol_after = get_symbol_reloc(ctx, "A"); + ASSERT_TRUE(symbol_after.has_value()); + EXPECT_EQ(symbol_after->offset(), 14); } TEST(asm_instr_processing, CNOP_non_absolute_expr) @@ -130,7 +130,7 @@ CNOPSYM CNOP ADDR,16 auto& ctx = *a.context().hlasm_ctx; - auto symbol = ctx.ord_ctx.get_symbol(ctx.ids().add("CNOPSYM")); + auto symbol = get_symbol(ctx, "CNOPSYM"); ASSERT_NE(symbol, nullptr); EXPECT_EQ(symbol->value().get_reloc().offset(), 4); } diff --git a/parser_library/test/processing/dc_test.cpp b/parser_library/test/processing/dc_test.cpp index c9ae7ec15..043688bc3 100644 --- a/parser_library/test/processing/dc_test.cpp +++ b/parser_library/test/processing/dc_test.cpp @@ -49,8 +49,7 @@ R EQU B-A a.collect_diags(); EXPECT_EQ(a.diags().size(), (size_t)0); - id_index R = a.hlasm_ctx().ids().add("R"); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(R)->value().get_abs(), 2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "R"), 2); } TEST(DC, previously_defined_length) @@ -69,8 +68,7 @@ R EQU C-B a.collect_diags(); EXPECT_EQ(a.diags().size(), (size_t)0); - id_index R = a.hlasm_ctx().ids().add("R"); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(R)->value().get_abs(), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "R"), 4); } TEST(DC, implicit_length) @@ -88,8 +86,7 @@ R EQU C-B a.collect_diags(); EXPECT_EQ(a.diags().size(), (size_t)0); - id_index R = a.hlasm_ctx().ids().add("R"); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(R)->value().get_abs(), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "R"), 4); } TEST(DC, implicit_length_deferred_checking) @@ -148,8 +145,7 @@ A DC CL(X+14)'A' a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("a"))->attributes().length(), - (symbol_attributes::len_attr)2); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "a")->attributes().length(), (symbol_attributes::len_attr)2); EXPECT_EQ(a.diags().size(), (size_t)0); } @@ -165,8 +161,7 @@ A DC FS(X+14)'1' a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("a"))->attributes().scale(), - (symbol_attributes::scale_attr)36); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "a")->attributes().scale(), (symbol_attributes::scale_attr)36); EXPECT_EQ(a.diags().size(), (size_t)0); } @@ -182,10 +177,8 @@ M DC FS-12'1' a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("P"))->attributes().scale(), - (symbol_attributes::scale_attr)12); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("M"))->attributes().scale(), - (symbol_attributes::scale_attr)-12); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "P")->attributes().scale(), (symbol_attributes::scale_attr)12); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "M")->attributes().scale(), (symbol_attributes::scale_attr)-12); EXPECT_EQ(a.diags().size(), (size_t)0); } @@ -201,7 +194,7 @@ A EQU L'X a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 0); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 0); EXPECT_EQ(a.diags().size(), (size_t)1); } @@ -217,7 +210,7 @@ X DC CL(A+1)'X' a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 1); EXPECT_EQ(a.diags().size(), (size_t)1); } @@ -234,10 +227,9 @@ Y EQU L'A a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->attributes().length(), - (symbol_attributes::len_attr)1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 1); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "X")->attributes().length(), (symbol_attributes::len_attr)1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 1); EXPECT_EQ(a.diags().size(), (size_t)0); } @@ -254,10 +246,9 @@ Y EQU A a.analyze(); a.collect_diags(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("A"))->value().get_abs(), 1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->attributes().length(), - (symbol_attributes::len_attr)1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 0); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 1); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "X")->attributes().length(), (symbol_attributes::len_attr)1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 0); EXPECT_EQ(a.diags().size(), (size_t)1); } diff --git a/parser_library/test/processing/equ_test.cpp b/parser_library/test/processing/equ_test.cpp index 3c4a97890..08deade12 100644 --- a/parser_library/test/processing/equ_test.cpp +++ b/parser_library/test/processing/equ_test.cpp @@ -27,10 +27,7 @@ A EQU 1 analyzer a(input); a.analyze(); - auto id = a.hlasm_ctx().ids().add("A"); - - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(id)); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(id)->value().get_abs(), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "A"), 1); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -47,9 +44,8 @@ B EQU A+A-10 a.analyze(); EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("A"))); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.symbol_defined(a.hlasm_ctx().ids().add("B"))); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), -8); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), -8); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)1); @@ -65,15 +61,11 @@ X EQU 5,2 analyzer a(input); a.analyze(); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->kind(), symbol_value_kind::ABS); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 5); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->attributes().length(), - (symbol_attributes::len_attr)(symbol_attributes::len_attr)2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 5); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "X")->attributes().length(), (symbol_attributes::len_attr)2); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->kind(), symbol_value_kind::ABS); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 5); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->attributes().length(), - (symbol_attributes::len_attr)12); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 5); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "Y")->attributes().length(), (symbol_attributes::len_attr)12); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -91,12 +83,9 @@ ZZ EQU *+X analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->attributes().length(), - (symbol_attributes::len_attr)2); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->attributes().length(), - (symbol_attributes::len_attr)1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("ZZ"))->attributes().length(), - (symbol_attributes::len_attr)1); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "Y")->attributes().length(), (symbol_attributes::len_attr)2); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "Z")->attributes().length(), (symbol_attributes::len_attr)1); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "ZZ")->attributes().length(), (symbol_attributes::len_attr)1); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -113,8 +102,7 @@ UNKNOWN EQU L'X analyzer a(input); a.analyze(); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->kind(), symbol_value_kind::ABS); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 11); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 11); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -131,10 +119,8 @@ LEM EQU A+1,100000 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LEN"))->attributes().length(), - (symbol_attributes::len_attr)1); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LEM"))->attributes().length(), - (symbol_attributes::len_attr)12); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "LEN")->attributes().length(), (symbol_attributes::len_attr)1); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "LEM")->attributes().length(), (symbol_attributes::len_attr)12); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)2); @@ -149,7 +135,7 @@ LEN EQU 11,3,4 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LEN"))->attributes().type(), 4); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "LEN")->attributes().type(), 4); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -164,8 +150,7 @@ LEN EQU 11,3 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LEN"))->attributes().type(), - symbol_attributes::undef_type); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "LEN")->attributes().type(), symbol_attributes::undef_type); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -181,10 +166,8 @@ LEM EQU 11,1,300 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LEN"))->attributes().type(), - symbol_attributes::undef_type); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("LEM"))->attributes().type(), - symbol_attributes::undef_type); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "LEN")->attributes().type(), symbol_attributes::undef_type); + EXPECT_EQ(get_symbol(a.hlasm_ctx(), "LEM")->attributes().type(), symbol_attributes::undef_type); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)2); diff --git a/parser_library/test/processing/loctr_test.cpp b/parser_library/test/processing/loctr_test.cpp index 38f91deda..16f2ac273 100644 --- a/parser_library/test/processing/loctr_test.cpp +++ b/parser_library/test/processing/loctr_test.cpp @@ -40,11 +40,10 @@ Z EQU Y-X analyzer a(input); a.analyze(); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->kind() == symbol_value_kind::ABS); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "X")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "Y")->kind() == symbol_value_kind::RELOC); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 16); + ASSERT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 16); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)2); @@ -68,11 +67,10 @@ Z EQU Y-X analyzer a(input); a.analyze(); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->kind() == symbol_value_kind::RELOC); - EXPECT_TRUE(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->kind() == symbol_value_kind::ABS); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "X")->kind() == symbol_value_kind::RELOC); + EXPECT_TRUE(get_symbol(a.hlasm_ctx(), "Y")->kind() == symbol_value_kind::RELOC); - ASSERT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 2); + ASSERT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 2); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); diff --git a/parser_library/test/processing/mach_instr_test.cpp b/parser_library/test/processing/mach_instr_test.cpp index 6337a0abb..bfde634a2 100644 --- a/parser_library/test/processing/mach_instr_test.cpp +++ b/parser_library/test/processing/mach_instr_test.cpp @@ -254,3 +254,30 @@ TEST(mach_instr_processing, rel_addr_bitmask) EXPECT_EQ(context::instruction::mnemonic_codes.at(instr).reladdr_mask.mask(), expected) << instr; } } + +TEST(mach_instr_processing, instr_size) +{ + for (const auto& [instr, expected] : std::initializer_list> { + { "LARL", 6 }, + { "LA", 4 }, + { "CLIJ", 6 }, + { "BR", 2 }, + { "DC", 1 }, + }) + { + EXPECT_EQ(processing::processing_status_cache_key::generate_loctr_len(&instr), expected) << instr; + } +} + +TEST(mach_instr_processing, loctr_len_reference) +{ + std::string input = R"( + LARL 0,A-1+L'*/6 +A DS 0H +)"; + analyzer a(input); + a.analyze(); + a.collect_diags(); + + EXPECT_TRUE(a.diags().empty()); +} diff --git a/parser_library/test/processing/org_test.cpp b/parser_library/test/processing/org_test.cpp index b06b5be18..a8d1f89c3 100644 --- a/parser_library/test/processing/org_test.cpp +++ b/parser_library/test/processing/org_test.cpp @@ -116,7 +116,7 @@ B EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 15); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 15); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -133,7 +133,7 @@ B EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 16); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 16); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)1); @@ -164,7 +164,7 @@ B EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 3); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 3); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -182,7 +182,7 @@ X EQU S-* analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 2); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -217,7 +217,7 @@ X EQU *-S2 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 2); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -254,7 +254,7 @@ X EQU 3 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 16); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 16); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -319,7 +319,7 @@ B EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 8); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 8); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -339,7 +339,7 @@ X EQU 1 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 4); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -405,7 +405,7 @@ B EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 20); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 20); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -435,7 +435,7 @@ X EQU A-* analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 3); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 3); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -451,7 +451,7 @@ X EQU *-B analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 4); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -483,8 +483,8 @@ Y EQU *-B analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 4); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 0); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 0); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -502,8 +502,8 @@ Y EQU *-B analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 4); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 0); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 0); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -522,8 +522,8 @@ Y EQU *-B analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 4); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 0); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 0); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -558,7 +558,7 @@ X EQU 2 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 4); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 4); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -575,7 +575,7 @@ X EQU 5 analyzer a2(input2); a2.analyze(); - EXPECT_EQ(a2.hlasm_ctx().ord_ctx.get_symbol(a2.hlasm_ctx().ids().add("Y"))->value().get_abs(), 5); + EXPECT_EQ(get_symbol_abs(a2.hlasm_ctx(), "Y"), 5); a2.collect_diags(); ASSERT_EQ(a2.diags().size(), (size_t)0); @@ -597,7 +597,7 @@ Z EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 10); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 10); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -617,7 +617,7 @@ X EQU 2 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Y"))->value().get_abs(), 6); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Y"), 6); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -634,7 +634,7 @@ Z EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 10); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 10); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -652,8 +652,8 @@ Z EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 5); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 10); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 5); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 10); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -671,8 +671,8 @@ Z EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("X"))->value().get_abs(), 8); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 13); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "X"), 8); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 13); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -712,8 +712,8 @@ Z2 EQU B-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 20); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z2"))->value().get_abs(), 20); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 20); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z2"), 20); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -736,7 +736,7 @@ Z EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 48); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 48); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -759,7 +759,7 @@ Z EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("Z"))->value().get_abs(), 48); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "Z"), 48); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -777,7 +777,7 @@ X EQU 10 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 6); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 6); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -792,7 +792,7 @@ Y EQU 4 analyzer a2(input2); a2.analyze(); - EXPECT_EQ(a2.hlasm_ctx().ord_ctx.get_symbol(a2.hlasm_ctx().ids().add("B"))->value().get_abs(), 6); + EXPECT_EQ(get_symbol_abs(a2.hlasm_ctx(), "B"), 6); a2.collect_diags(); ASSERT_EQ(a2.diags().size(), (size_t)0); @@ -811,7 +811,7 @@ X EQU 10 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 6); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 6); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -831,8 +831,8 @@ Y EQU 4 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 6); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("C"))->value().get_abs(), 2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 6); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "C"), 2); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -853,8 +853,8 @@ Y1 EQU 4 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 6); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("C"))->value().get_abs(), 2); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 6); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "C"), 2); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -873,7 +873,7 @@ X EQU 10 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 10); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 10); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -889,7 +889,7 @@ X EQU 10 analyzer a2(input2); a2.analyze(); - EXPECT_EQ(a2.hlasm_ctx().ord_ctx.get_symbol(a2.hlasm_ctx().ids().add("B"))->value().get_abs(), 14); + EXPECT_EQ(get_symbol_abs(a2.hlasm_ctx(), "B"), 14); a2.collect_diags(); ASSERT_EQ(a2.diags().size(), (size_t)0); @@ -909,7 +909,7 @@ X EQU 10 analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 10); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 10); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); @@ -926,7 +926,7 @@ X EQU 10 analyzer a2(input2); a2.analyze(); - EXPECT_EQ(a2.hlasm_ctx().ord_ctx.get_symbol(a2.hlasm_ctx().ids().add("B"))->value().get_abs(), 14); + EXPECT_EQ(get_symbol_abs(a2.hlasm_ctx(), "B"), 14); a2.collect_diags(); ASSERT_EQ(a2.diags().size(), (size_t)0); @@ -1001,7 +1001,7 @@ B EQU *-A analyzer a(input); a.analyze(); - EXPECT_EQ(a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("B"))->value().get_abs(), 1); + EXPECT_EQ(get_symbol_abs(a.hlasm_ctx(), "B"), 1); a.collect_diags(); ASSERT_EQ(a.diags().size(), (size_t)0); diff --git a/parser_library/test/processing/start_test.cpp b/parser_library/test/processing/start_test.cpp index 124d0ab4e..a5e2d8a95 100644 --- a/parser_library/test/processing/start_test.cpp +++ b/parser_library/test/processing/start_test.cpp @@ -44,7 +44,7 @@ E EQU * const auto* s = a.hlasm_ctx().ord_ctx.get_section(a.hlasm_ctx().ids().add("S")); ASSERT_TRUE(s); - const auto* e = a.hlasm_ctx().ord_ctx.get_symbol(a.hlasm_ctx().ids().add("E")); + const auto* e = get_symbol(a.hlasm_ctx(), "E"); ASSERT_TRUE(e); const auto& e_value = e->value();