diff --git a/parser_library/src/checking/asm_instr_check.cpp b/parser_library/src/checking/asm_instr_check.cpp index d1a6c4034..fffa184bb 100644 --- a/parser_library/src/checking/asm_instr_check.cpp +++ b/parser_library/src/checking/asm_instr_check.cpp @@ -32,7 +32,7 @@ namespace hlasm_plugin::parser_library::checking { xattr::xattr(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, -1) {}; -bool xattr::check(const std::vector& to_check, +bool xattr::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -150,7 +150,7 @@ bool xattr::check(const std::vector& to_check, using_instr::using_instr(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 2, 17) {}; -bool using_instr::check(const std::vector& to_check, +bool using_instr::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -198,7 +198,7 @@ bool using_instr::check(const std::vector& to_check, title::title(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 1) {}; -bool title::check(const std::vector& to_check, +bool title::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -228,7 +228,7 @@ bool title::check(const std::vector& to_check, rmode::rmode(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 1) {}; -bool rmode::check(const std::vector& to_check, +bool rmode::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -246,7 +246,7 @@ bool rmode::check(const std::vector& to_check, punch::punch(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 1) {}; -bool punch::check(const std::vector& to_check, +bool punch::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -256,7 +256,7 @@ bool punch::check(const std::vector& to_check, print::print(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, -1) {}; -bool print::check(const std::vector& to_check, +bool print::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -283,7 +283,7 @@ bool print::check(const std::vector& to_check, stack_instr::stack_instr(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 4) {}; -bool stack_instr::check(const std::vector& to_check, +bool stack_instr::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -373,7 +373,7 @@ bool stack_instr::check(const std::vector& to_check, org::org(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 0, 3) {}; -bool org::check(const std::vector& to_check, +bool org::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -430,7 +430,7 @@ bool org::check(const std::vector& to_check, opsyn::opsyn(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 0, 1) {}; -bool opsyn::check(const std::vector& to_check, +bool opsyn::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -454,7 +454,7 @@ bool opsyn::check(const std::vector& to_check, mnote::mnote(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 2) {}; -bool mnote::check(const std::vector& to_check, +bool mnote::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -517,7 +517,7 @@ bool mnote::check(const std::vector& to_check, iseq::iseq(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 0, 2) {}; -bool iseq::check(const std::vector& to_check, +bool iseq::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -554,7 +554,7 @@ bool iseq::check(const std::vector& to_check, ictl::ictl(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 3) {}; -bool ictl::check(const std::vector& to_check, +bool ictl::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -624,7 +624,7 @@ bool ictl::check(const std::vector& to_check, external::external(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, -1) {}; -bool external::check(const std::vector& to_check, +bool external::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -671,7 +671,7 @@ bool external::check(const std::vector& to_check, exitctl::exitctl(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 2, 5) {}; -bool exitctl::check(const std::vector& to_check, +bool exitctl::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -711,15 +711,12 @@ bool exitctl::check(const std::vector& to_check, equ::equ(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 5) {}; -bool equ::check(const std::vector&, const range&, const diagnostic_collector&) const -{ - return true; -} +bool equ::check(std::span, const range&, const diagnostic_collector&) const { return true; } entry::entry(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, -1) {}; -bool entry::check(const std::vector& to_check, +bool entry::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -745,7 +742,7 @@ bool entry::check(const std::vector& to_check, end::end(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 0, 2) {}; -bool end::check(const std::vector& to_check, +bool end::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -822,7 +819,7 @@ drop::drop(const std::vector& allowed_types, std::string_view name_ : assembler_instruction(allowed_types, name_of_instruction, 0, -1) {}; bool drop::check( - const std::vector& to_check, const range&, const diagnostic_collector& add_diagnostic) const + std::span to_check, const range&, const diagnostic_collector& add_diagnostic) const { // TODO: at this point the check is more or less redundant to the one performed in the process_DROP function if (has_one_comma(to_check)) @@ -841,7 +838,7 @@ bool drop::check( copy::copy(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 1) {}; -bool copy::check(const std::vector& to_check, +bool copy::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -862,7 +859,7 @@ bool copy::check(const std::vector& to_check, cnop::cnop(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 2, 2) {}; -bool cnop::check(const std::vector& to_check, +bool cnop::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -908,7 +905,7 @@ ccw::ccw(const std::vector& allowed_types, std::string_view name_of , variant_(variant) {}; -bool ccw::check(const std::vector& to_check, +bool ccw::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -958,7 +955,7 @@ expression_instruction::expression_instruction( const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 0, 1) {}; -bool expression_instruction::check(const std::vector& to_check, +bool expression_instruction::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -975,7 +972,7 @@ bool expression_instruction::check(const std::vector& to_che add_diagnostic(diagnostic_op::error_A240_expression_format(name_of_instruction, to_check[0]->operand_range)); return false; } - if (first->is_default || !is_positive_number(first->value)) + if (first->is_default || first->value <= 0) { add_diagnostic(diagnostic_op::error_A148_EXPR_op_format(name_of_instruction, first->operand_range)); return false; @@ -986,7 +983,7 @@ bool expression_instruction::check(const std::vector& to_che cattr::cattr(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, -1) {}; -bool cattr::check(const std::vector& to_check, +bool cattr::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -1077,7 +1074,7 @@ bool cattr::check(const std::vector& to_check, else if (complex_op->operand_identifier == "PRIORITY") { if (parameter == nullptr || !has_all_digits(parameter->operand_identifier) || parameter->is_default - || !is_positive_number(parameter->value)) + || parameter->value <= 0) { add_diagnostic(diagnostic_op::error_A208_PRIORITY_param_format( name_of_instruction, complex_op->operand_parameters[0]->operand_range)); @@ -1097,7 +1094,7 @@ bool cattr::check(const std::vector& to_check, amode::amode(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 1) {}; -bool amode::check(const std::vector& to_check, +bool amode::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -1116,7 +1113,7 @@ bool amode::check(const std::vector& to_check, alias::alias(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, 1) {}; -bool alias::check(const std::vector& to_check, +bool alias::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -1184,7 +1181,7 @@ bool alias::check(const std::vector& to_check, ainsert::ainsert(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 2, 2) {}; -bool ainsert::check(const std::vector& to_check, +bool ainsert::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -1222,7 +1219,7 @@ bool ainsert::check(const std::vector& to_check, adata::adata(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 5, 5) {}; -bool adata::check(const std::vector& to_check, +bool adata::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -1265,7 +1262,7 @@ bool adata::check(const std::vector& to_check, no_operands::no_operands(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 0, 0) {}; -bool no_operands::check(const std::vector& to_check, +bool no_operands::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -1275,7 +1272,7 @@ bool no_operands::check(const std::vector& to_check, process::process(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, -1) {}; -bool process::check(const std::vector& to_check, +bool process::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -1283,8 +1280,8 @@ bool process::check(const std::vector& to_check, return false; // OVERRIDE can be used together with assembler options despite what the doc says - auto b = to_check.cbegin(); - auto e = to_check.cend(); + auto b = to_check.begin(); + auto e = to_check.end(); if (auto process_operands = get_complex_operand(to_check.back()); process_operands && process_operands->operand_identifier == "OVERRIDE") // everything parsed is parameter of operand @@ -1306,7 +1303,7 @@ bool process::check(const std::vector& to_check, acontrol::acontrol(const std::vector& allowed_types, std::string_view name_of_instruction) : assembler_instruction(allowed_types, name_of_instruction, 1, -1) {}; -bool acontrol::check(const std::vector& to_check, +bool acontrol::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { diff --git a/parser_library/src/checking/asm_instr_check.h b/parser_library/src/checking/asm_instr_check.h index 42f6fb417..55a329800 100644 --- a/parser_library/src/checking/asm_instr_check.h +++ b/parser_library/src/checking/asm_instr_check.h @@ -65,7 +65,7 @@ class xattr final : public assembler_instruction { public: xattr(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -74,7 +74,7 @@ class using_instr final : public assembler_instruction { public: using_instr(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -83,7 +83,7 @@ class title final : public assembler_instruction { public: title(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -92,7 +92,7 @@ class rmode final : public assembler_instruction { public: rmode(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -101,7 +101,7 @@ class punch final : public assembler_instruction { public: punch(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -110,7 +110,7 @@ class print final : public assembler_instruction { public: print(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -119,7 +119,7 @@ class stack_instr final : public assembler_instruction { public: stack_instr(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -128,7 +128,7 @@ class org final : public assembler_instruction { public: org(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -138,7 +138,7 @@ class opsyn final : public assembler_instruction { public: opsyn(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -147,7 +147,7 @@ class mnote final : public assembler_instruction { public: mnote(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -156,7 +156,7 @@ class iseq final : public assembler_instruction { public: iseq(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -165,7 +165,7 @@ class ictl final : public assembler_instruction { public: ictl(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -175,7 +175,7 @@ class external final : public assembler_instruction { public: external(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -184,7 +184,7 @@ class exitctl final : public assembler_instruction { public: exitctl(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -194,7 +194,7 @@ class equ final : public assembler_instruction { public: equ(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -204,7 +204,7 @@ class entry final : public assembler_instruction { public: entry(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -213,7 +213,7 @@ class end final : public assembler_instruction { public: end(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -222,7 +222,7 @@ class drop final : public assembler_instruction { public: drop(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector&) const override; }; @@ -235,14 +235,14 @@ class data : public assembler_instruction protected: template bool check_data( - const std::vector& to_check, const range& stmt_range, const diagnostic_collector&) const; + std::span to_check, const range& stmt_range, const diagnostic_collector&) const; }; class dc final : public data { public: dc(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector&) const override; }; @@ -251,7 +251,7 @@ class ds_dxd final : public data { public: ds_dxd(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector&) const override; }; @@ -261,7 +261,7 @@ class copy final : public assembler_instruction { public: copy(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -270,7 +270,7 @@ class cnop final : public assembler_instruction { public: cnop(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -288,7 +288,7 @@ class ccw final : public assembler_instruction public: ccw(const std::vector& allowed_types, std::string_view name_of_instruction, CCW_variant variant); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -299,7 +299,7 @@ class expression_instruction final : public assembler_instruction { public: expression_instruction(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -308,7 +308,7 @@ class cattr final : public assembler_instruction { public: cattr(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -317,7 +317,7 @@ class amode final : public assembler_instruction { public: amode(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -326,7 +326,7 @@ class alias final : public assembler_instruction { public: alias(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -335,7 +335,7 @@ class ainsert final : public assembler_instruction { public: ainsert(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -344,7 +344,7 @@ class acontrol final : public assembler_instruction { public: acontrol(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -353,7 +353,7 @@ class adata final : public assembler_instruction { public: adata(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -363,7 +363,7 @@ class no_operands final : public assembler_instruction { public: no_operands(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; @@ -373,7 +373,7 @@ class process final : public assembler_instruction { public: process(const std::vector& allowed_types, std::string_view name_of_instruction); - bool check(const std::vector& to_check, + bool check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const override; }; diff --git a/parser_library/src/checking/asm_instr_class.cpp b/parser_library/src/checking/asm_instr_class.cpp index da3185b68..ec4ad594b 100644 --- a/parser_library/src/checking/asm_instr_class.cpp +++ b/parser_library/src/checking/asm_instr_class.cpp @@ -31,7 +31,7 @@ bool assembler_instruction::is_param_in_vector( return std::find(options.cbegin(), options.cend(), parameter) != options.cend(); } -bool assembler_instruction::operands_size_corresponding(const std::vector& to_check, +bool assembler_instruction::operands_size_corresponding(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { diff --git a/parser_library/src/checking/asm_instr_class.h b/parser_library/src/checking/asm_instr_class.h index 596b376cf..b90db37a8 100644 --- a/parser_library/src/checking/asm_instr_class.h +++ b/parser_library/src/checking/asm_instr_class.h @@ -15,6 +15,7 @@ #ifndef HLASMPLUGIN_PARSERLIBRARY_INSTR_CLASS_H #define HLASMPLUGIN_PARSERLIBRARY_INSTR_CLASS_H +#include #include #include @@ -51,7 +52,7 @@ class assembler_instruction int max_operands = 0; // maximum number of operands, -1 if upper bound is not defined public: - virtual bool check(const std::vector&, const range&, const diagnostic_collector&) const = 0; + virtual bool check(std::span, const range&, const diagnostic_collector&) const = 0; assembler_instruction(std::vector allowed_types, std::string_view name_of_instruction, @@ -66,7 +67,7 @@ class assembler_instruction protected: bool is_param_in_vector(std::string_view parameter, const std::vector& options) const; - bool operands_size_corresponding(const std::vector& to_check, + bool operands_size_corresponding(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const; diff --git a/parser_library/src/checking/checker_helper.h b/parser_library/src/checking/checker_helper.h index 2eaae2922..e8b5cf739 100644 --- a/parser_library/src/checking/checker_helper.h +++ b/parser_library/src/checking/checker_helper.h @@ -56,7 +56,7 @@ inline bool is_operand_empty(const asm_operand* to_check_operand) return dynamic_cast(to_check_operand) != nullptr; } -inline bool has_one_comma(const std::vector& to_check) +inline bool has_one_comma(std::span to_check) { return to_check.size() == 2 && is_operand_empty(to_check[0]) && is_operand_empty(to_check[1]); } @@ -66,8 +66,6 @@ inline bool has_all_digits(std::string_view str) return std::all_of(str.begin(), str.end(), [](unsigned char c) { return std::isdigit(c); }); } -inline bool is_positive_number(int to_test) { return to_test > 0; } - // function to convert numbers less than 64000 to hexadecimal inline std::string dec_to_hexa(int to_convert) { diff --git a/parser_library/src/checking/data_definition/data_instruction.cpp b/parser_library/src/checking/data_definition/data_instruction.cpp index 762232d4d..6b6c69a60 100644 --- a/parser_library/src/checking/data_definition/data_instruction.cpp +++ b/parser_library/src/checking/data_definition/data_instruction.cpp @@ -30,7 +30,7 @@ data::data(const std::vector& allowed_types, std::string_view name_ {} template -bool data::check_data(const std::vector& to_check, +bool data::check_data(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -72,7 +72,7 @@ dc::dc(const std::vector& allowed_types, std::string_view name_of_i : data(allowed_types, name_of_instruction) {} -bool dc::check(const std::vector& to_check, +bool dc::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -82,7 +82,7 @@ bool dc::check(const std::vector& to_check, ds_dxd::ds_dxd(const std::vector& allowed_types, std::string_view name_of_instruction) : data(allowed_types, name_of_instruction) {}; -bool ds_dxd::check(const std::vector& to_check, +bool ds_dxd::check(std::span to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { diff --git a/parser_library/src/checking/instr_operand.cpp b/parser_library/src/checking/instr_operand.cpp index b1c18103c..76196afc4 100644 --- a/parser_library/src/checking/instr_operand.cpp +++ b/parser_library/src/checking/instr_operand.cpp @@ -108,28 +108,23 @@ diagnostic_op address_operand::get_first_parameter_error(machine_operand_type op return diagnostic_op::error_I999(instr_name, stmt_range); } -bool address_operand::check(diagnostic_op& diag, - const machine_operand_format& to_check, - std::string_view instr_name, - const range& stmt_range) const +std::optional address_operand::check( + machine_operand_format to_check, std::string_view instr_name, const range& stmt_range) const { if (is_simple_operand(to_check)) { // operand must be simple - diag = get_simple_operand_expected(to_check, instr_name, stmt_range); - return false; + return get_simple_operand_expected(to_check, instr_name, stmt_range); } if (op_state == operand_state::SECOND_OMITTED) { - diag = diagnostic_op::error_M004(instr_name, stmt_range); - return false; + return diagnostic_op::error_M004(instr_name, stmt_range); } if (state == address_state::RES_VALID) - return true; + return std::nullopt; else if (state == address_state::RES_INVALID) { - diag = diagnostic_op::error_M010(instr_name, stmt_range); - return false; + return diagnostic_op::error_M010(instr_name, stmt_range); } else { @@ -139,11 +134,10 @@ bool address_operand::check(diagnostic_op& diag, if (to_check.identifier.is_signed) { auto boundary = 1ll << (to_check.identifier.size - 1); - diag = diagnostic_op::error_M130(instr_name, -boundary, boundary - 1, operand_range); + return diagnostic_op::error_M130(instr_name, -boundary, boundary - 1, operand_range); } else - diag = diagnostic_op::error_M130(instr_name, 0, (1ll << to_check.identifier.size) - 1, operand_range); - return false; + return diagnostic_op::error_M130(instr_name, 0, (1ll << to_check.identifier.size) - 1, operand_range); } // check the D(B) operand format if (to_check.first.is_empty()) @@ -151,14 +145,12 @@ bool address_operand::check(diagnostic_op& diag, if (op_state != operand_state::ONE_OP) { // error, cannot be present - diag = diagnostic_op::error_M104(instr_name, operand_range); - return false; + return diagnostic_op::error_M104(instr_name, operand_range); } // check second parameter, in all cases this is the base parameter if (!is_operand_corresponding(second_op, to_check.second)) { - diag = diagnostic_op::error_M131(instr_name, operand_range); - return false; + return diagnostic_op::error_M131(instr_name, operand_range); } } else @@ -170,8 +162,7 @@ bool address_operand::check(diagnostic_op& diag, { if (!is_operand_corresponding(second_op, to_check.second)) { - diag = diagnostic_op::error_M131(instr_name, operand_range); - return false; + return diagnostic_op::error_M131(instr_name, operand_range); } } // base is now checked, now check the first parameter, which is specified either in D(X,B) or D(X) @@ -188,21 +179,19 @@ bool address_operand::check(diagnostic_op& diag, if (to_check.first.type == machine_operand_type::LENGTH && !is_length_corresponding(first_op, to_check.first.size)) { - diag = get_first_parameter_error( + return get_first_parameter_error( to_check.first.type, instr_name, 0, 1ll << to_check.first.size, stmt_range); - return false; } if (to_check.first.type != machine_operand_type::LENGTH && !is_operand_corresponding(first_op, to_check.first)) { assert(!to_check.first.is_signed); - diag = get_first_parameter_error( + return get_first_parameter_error( to_check.first.type, instr_name, 0, (1ll << to_check.first.size) - 1, stmt_range); - return false; } } } - return true; + return std::nullopt; } } @@ -279,26 +268,24 @@ one_operand::one_operand(const one_operand& op) , value(op.value) , is_default(op.is_default) {}; -bool one_operand::check( - diagnostic_op& diag, const machine_operand_format& to_check, std::string_view instr_name, const range&) const +std::optional one_operand::check( + machine_operand_format to_check, std::string_view instr_name, const range&) const { if (!is_simple_operand(to_check)) { // therefore it is an address operand, but represented only by a single value // check only the displacement - if (!is_operand_corresponding(value, to_check.identifier)) + if (is_operand_corresponding(value, to_check.identifier)) + return std::nullopt; + + if (to_check.identifier.is_signed) { - if (to_check.identifier.is_signed) - { - auto boundary = 1ll << (to_check.identifier.size - 1); - diag = diagnostic_op::error_M130(instr_name, -boundary, boundary - 1, operand_range); - } - else - diag = diagnostic_op::error_M130(instr_name, 0, (1ll << to_check.identifier.size) - 1, operand_range); - return false; + auto boundary = 1ll << (to_check.identifier.size - 1); + return diagnostic_op::error_M130(instr_name, -boundary, boundary - 1, operand_range); } - return true; + else + return diagnostic_op::error_M130(instr_name, 0, (1ll << to_check.identifier.size) - 1, operand_range); } // it is a simple operand @@ -308,15 +295,12 @@ bool one_operand::check( switch (to_check.identifier.type) { case machine_operand_type::IMM: - diag = diagnostic_op::warn_M137(instr_name, -boundary, boundary - 1, operand_range); - break; + return diagnostic_op::warn_M137(instr_name, -boundary, boundary - 1, operand_range); case machine_operand_type::RELOC_IMM: - diag = diagnostic_op::error_M123(instr_name, -boundary, boundary - 1, operand_range); - break; + return diagnostic_op::error_M123(instr_name, -boundary, boundary - 1, operand_range); default: assert(false); } - return false; } if (!to_check.identifier.is_signed && (!is_size_corresponding_unsigned(value, to_check.identifier.size) @@ -327,26 +311,21 @@ bool one_operand::check( switch (to_check.identifier.type) { case machine_operand_type::REG: - diag = diagnostic_op::error_M120(instr_name, + return diagnostic_op::error_M120(instr_name, operand_range, reg_qual[(int)to_check.identifier.evenodd], to_check.identifier.min_register); - break; case machine_operand_type::MASK: - diag = diagnostic_op::error_M121(instr_name, operand_range); - break; + return diagnostic_op::error_M121(instr_name, operand_range); case machine_operand_type::IMM: - diag = diagnostic_op::warn_M137(instr_name, 0, boundary, operand_range); - break; + return diagnostic_op::warn_M137(instr_name, 0, boundary, operand_range); case machine_operand_type::VEC_REG: - diag = diagnostic_op::error_M124(instr_name, operand_range); - break; + return diagnostic_op::error_M124(instr_name, operand_range); default: assert(false); } - return false; } - return true; + return std::nullopt; } empty_operand::empty_operand() = default; @@ -354,11 +333,10 @@ empty_operand::empty_operand(range r) : operand(r) {} -bool empty_operand::check( - diagnostic_op& diag, const machine_operand_format&, std::string_view instr_name, const range&) const +std::optional empty_operand::check( + machine_operand_format, std::string_view instr_name, const range&) const { - diag = diagnostic_op::error_M003(instr_name, operand_range); - return false; + return diagnostic_op::error_M003(instr_name, operand_range); } std::string parameter::to_string() const diff --git a/parser_library/src/checking/instr_operand.h b/parser_library/src/checking/instr_operand.h index 8dc43e2c7..c18a8638d 100644 --- a/parser_library/src/checking/instr_operand.h +++ b/parser_library/src/checking/instr_operand.h @@ -16,15 +16,11 @@ #define HLASMPLUGIN_PARSERLIBRARY_INSTR_OPERAND_H #include -#include #include #include #include -#include #include -#include "context/ordinary_assembly/alignment.h" -#include "diagnostic.h" #include "diagnostic_op.h" #include "operand.h" @@ -130,10 +126,8 @@ class machine_operand : public virtual operand machine_operand(); // check whether the operand satisfies its format - virtual bool check(diagnostic_op& diag, - const machine_operand_format& to_check, - std::string_view instr_name, - const range& stmt_range) const = 0; + virtual std::optional check( + machine_operand_format to_check, std::string_view instr_name, const range& stmt_range) const = 0; diagnostic_op get_simple_operand_expected( const machine_operand_format& op_format, std::string_view instr_name, const range& stmt_range) const; @@ -163,10 +157,8 @@ class address_operand final : public machine_operand long long to, const range& stmt_range) const; - bool check(diagnostic_op& diag, - const machine_operand_format& to_check, - std::string_view instr_name, - const range& range) const override; + std::optional check( + machine_operand_format to_check, std::string_view instr_name, const range& range) const override; bool is_length_corresponding(int param_value, int length_size) const; }; @@ -194,10 +186,8 @@ class one_operand final : public asm_operand, public machine_operand one_operand(const one_operand& op); - bool check(diagnostic_op& diag, - const machine_operand_format& to_check, - std::string_view instr_name, - const range& stmt_range) const override; + std::optional check( + machine_operand_format to_check, std::string_view instr_name, const range& stmt_range) const override; }; class empty_operand final : public machine_operand, public asm_operand @@ -206,10 +196,8 @@ class empty_operand final : public machine_operand, public asm_operand empty_operand(); explicit empty_operand(range r); - bool check(diagnostic_op& diag, - const machine_operand_format& to_check, - std::string_view instr_name, - const range& stmt_range) const override; + std::optional check( + machine_operand_format to_check, std::string_view instr_name, const range& stmt_range) const override; }; } // namespace hlasm_plugin::parser_library::checking diff --git a/parser_library/src/checking/instruction_checker.cpp b/parser_library/src/checking/instruction_checker.cpp index 988328d36..3f9a67a1e 100644 --- a/parser_library/src/checking/instruction_checker.cpp +++ b/parser_library/src/checking/instruction_checker.cpp @@ -14,29 +14,18 @@ #include "instruction_checker.h" -#include +#include -namespace hlasm_plugin::parser_library::checking { - -bool assembler_checker::check(std::string_view instruction_name, - const std::vector& operand_vector, - const range& stmt_range, - const diagnostic_collector& add_diagnostic) const -{ - const auto it = assembler_instruction_map.find(instruction_name); - if (it == assembler_instruction_map.end()) - return false; +#include "checking/asm_instr_check.h" +#include "checking/asm_instr_class.h" +#include "context/instruction.h" - std::vector ops; - for (auto& op : operand_vector) - ops.push_back(dynamic_cast(op)); - return it->second->check(ops, stmt_range, add_diagnostic); -} +namespace hlasm_plugin::parser_library::checking { namespace { struct instruction_adder { - std::map>& target; + std::unordered_map>& target; void add(std::string_view name, std::unique_ptr value) const { @@ -49,94 +38,83 @@ struct instruction_adder add(name, std::make_unique(std::vector(labels), name, std::forward(rest)...)); }; }; + +const std::unordered_map> assembler_instruction_map = [] { + std::unordered_map> result; + instruction_adder a { result }; + + using enum label_types; + + a.add("*PROCESS", { NO_LABEL }); + a.add("ACONTROL", { SEQUENCE_SYMBOL, OPTIONAL }); + a.add("ADATA", { SEQUENCE_SYMBOL, OPTIONAL }); + a.add("AINSERT", { SEQUENCE_SYMBOL, OPTIONAL }); + a.add("ALIAS", { ORD_SYMBOL, VAR_SYMBOL }); + a.add("AMODE", { OPTIONAL, NAME }); + a.add("CATTR", { CLASS_NAME }); + a.add("CCW", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }, CCW_variant::CCW_CCW0); + a.add("CCW0", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }, CCW_variant::CCW_CCW0); + a.add("CCW1", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }, CCW_variant::CCW1); + a.add("CEJECT", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("CNOP", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("COM", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("COPY", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("CSECT", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("CXD", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("DC", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("DROP", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("DS", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("DSECT", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("DXD", { OPTIONAL, ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + a.add("EJECT", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("END", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("ENTRY", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("EQU", { ORD_SYMBOL, VAR_SYMBOL }); + a.add("EXITCTL", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("EXTRN", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("ICTL", { NO_LABEL }); + a.add("ISEQ", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("LOCTR", { ORD_SYMBOL, VAR_SYMBOL }); + a.add("LTORG", { ORD_SYMBOL, VAR_SYMBOL, SEQUENCE_SYMBOL, OPTIONAL }); + a.add("MNOTE", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("OPSYN", { ORD_SYMBOL, VAR_SYMBOL, OPERATION_CODE }); + a.add("ORG", { ORD_SYMBOL, VAR_SYMBOL, SEQUENCE_SYMBOL, OPTIONAL }); + a.add("POP", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("PRINT", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("PUNCH", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("PUSH", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("REPRO", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("RMODE", { OPTIONAL, NAME }); + a.add("RSECT", { OPTIONAL, ORD_SYMBOL, VAR_SYMBOL, SEQUENCE_SYMBOL }); + a.add("SPACE", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add("START", { OPTIONAL, SEQUENCE_SYMBOL, ORD_SYMBOL, VAR_SYMBOL }); + a.add("TITLE", { OPTIONAL, SEQUENCE_SYMBOL, VAR_SYMBOL, STRING }); + a.add<using_instr>("USING", { OPTIONAL, SEQUENCE_SYMBOL, VAR_SYMBOL, ORD_SYMBOL }); + a.add<external>("WXTRN", { OPTIONAL, SEQUENCE_SYMBOL }); + a.add<xattr>("XATTR", { ORD_SYMBOL, SEQUENCE_SYMBOL, VAR_SYMBOL }); + + return result; +}(); + } // namespace -const std::map<std::string_view, std::unique_ptr<assembler_instruction>> assembler_checker::assembler_instruction_map = - [] { - std::map<std::string_view, std::unique_ptr<assembler_instruction>> result; - instruction_adder a { result }; - - a.add<process>("*PROCESS", { label_types::NO_LABEL }); - a.add<acontrol>("ACONTROL", { label_types::SEQUENCE_SYMBOL, label_types::OPTIONAL }); - a.add<adata>("ADATA", { label_types::SEQUENCE_SYMBOL, label_types::OPTIONAL }); - a.add<ainsert>("AINSERT", { label_types::SEQUENCE_SYMBOL, label_types::OPTIONAL }); - a.add<alias>("ALIAS", { label_types::ORD_SYMBOL, label_types::VAR_SYMBOL }); - a.add<amode>("AMODE", { label_types::OPTIONAL, label_types::NAME }); - a.add<cattr>("CATTR", { label_types::CLASS_NAME }); - a.add<ccw>("CCW", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }, - CCW_variant::CCW_CCW0); - a.add<ccw>("CCW0", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }, - CCW_variant::CCW_CCW0); - a.add<ccw>("CCW1", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }, - CCW_variant::CCW1); - a.add<expression_instruction>("CEJECT", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<cnop>("CNOP", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<no_operands>("COM", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<copy>("COPY", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<no_operands>("CSECT", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<no_operands>("CXD", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<dc>("DC", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<drop>("DROP", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<ds_dxd>("DS", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<no_operands>("DSECT", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<ds_dxd>("DXD", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - a.add<no_operands>("EJECT", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<end>("END", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<entry>("ENTRY", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<equ>("EQU", { label_types::ORD_SYMBOL, label_types::VAR_SYMBOL }); - a.add<exitctl>("EXITCTL", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<external>("EXTRN", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<ictl>("ICTL", { label_types::NO_LABEL }); - a.add<iseq>("ISEQ", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<no_operands>("LOCTR", { label_types::ORD_SYMBOL, label_types::VAR_SYMBOL }); - a.add<no_operands>("LTORG", - { label_types::ORD_SYMBOL, label_types::VAR_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::OPTIONAL }); - a.add<mnote>("MNOTE", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<opsyn>("OPSYN", { label_types::ORD_SYMBOL, label_types::VAR_SYMBOL, label_types::OPERATION_CODE }); - a.add<org>("ORG", - { label_types::ORD_SYMBOL, label_types::VAR_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::OPTIONAL }); - a.add<stack_instr>("POP", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<print>("PRINT", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<punch>("PUNCH", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<stack_instr>("PUSH", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<no_operands>("REPRO", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<rmode>("RMODE", { label_types::OPTIONAL, label_types::NAME }); - a.add<no_operands>("RSECT", - { label_types::OPTIONAL, label_types::ORD_SYMBOL, label_types::VAR_SYMBOL, label_types::SEQUENCE_SYMBOL }); - a.add<expression_instruction>("SPACE", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<expression_instruction>("START", - { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL, label_types::ORD_SYMBOL, label_types::VAR_SYMBOL }); - a.add<title>("TITLE", - { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL, label_types::STRING }); - a.add<using_instr>("USING", - { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL, label_types::ORD_SYMBOL }); - a.add<external>("WXTRN", { label_types::OPTIONAL, label_types::SEQUENCE_SYMBOL }); - a.add<xattr>("XATTR", { label_types::ORD_SYMBOL, label_types::SEQUENCE_SYMBOL, label_types::VAR_SYMBOL }); - - return result; - }(); - -bool machine_checker::check(std::string_view instruction_name, - const std::vector<const operand*>& operand_vector, +bool check_asm_ops(std::string_view instruction_name, + std::span<const asm_operand* const> ops, const range& stmt_range, - const diagnostic_collector& add_diagnostic) const + const diagnostic_collector& add_diagnostic) { - // get operands - std::vector<const machine_operand*> ops; - for (auto& op : operand_vector) - ops.push_back(dynamic_cast<const machine_operand*>(op)); + const auto it = assembler_instruction_map.find(instruction_name); + if (it == assembler_instruction_map.end()) + return false; + return it->second->check(ops, stmt_range, add_diagnostic); +} + +bool check_mach_ops(std::string_view instruction_name, + std::span<const machine_operand* const> ops, + const range& stmt_range, + const diagnostic_collector& add_diagnostic) +{ // instruction name is the mnemonic name in case of a mnemonic instruction auto [mi, _] = context::instruction::find_machine_instruction_or_mnemonic(instruction_name); diff --git a/parser_library/src/checking/instruction_checker.h b/parser_library/src/checking/instruction_checker.h index db6b8afe2..9252d1b82 100644 --- a/parser_library/src/checking/instruction_checker.h +++ b/parser_library/src/checking/instruction_checker.h @@ -15,48 +15,27 @@ #ifndef HLASMPLUGIN_PARSERLIBRARY_INSTRUCTION_CHECKER_H #define HLASMPLUGIN_PARSERLIBRARY_INSTRUCTION_CHECKER_H -#include <map> +#include <span> #include <string_view> -#include "asm_instr_check.h" -#include "context/instruction.h" +namespace hlasm_plugin::parser_library { +class diagnostic_collector; +struct range; +} // namespace hlasm_plugin::parser_library namespace hlasm_plugin::parser_library::checking { - -// interface for unified checking -class instruction_checker -{ -public: - virtual bool check(std::string_view instruction_name, - const std::vector<const operand*>& operand_vector, - const range& stmt_range, - const diagnostic_collector& add_diagnostic) const = 0; -}; - -// derived checker for assembler instructions -class assembler_checker final : public instruction_checker - -{ -public: - bool check(std::string_view instruction_name, - const std::vector<const operand*>& operand_vector, - const range& stmt_range, - const diagnostic_collector& add_diagnostic) const override; - // map of all assembler instruction names to their representations - static const std::map<std::string_view, - std::unique_ptr<hlasm_plugin::parser_library::checking::assembler_instruction>> - assembler_instruction_map; -}; - -// derived checker for machine instructions -class machine_checker final : public instruction_checker -{ -public: - bool check(std::string_view instruction_name, - const std::vector<const operand*>& operand_vector, - const range& stmt_range, - const diagnostic_collector& add_diagnostic) const override; -}; +class asm_operand; +class machine_operand; + +bool check_asm_ops(std::string_view instruction_name, + std::span<const asm_operand* const> operand_vector, + const range& stmt_range, + const diagnostic_collector& add_diagnostic); + +bool check_mach_ops(std::string_view instruction_name, + std::span<const machine_operand* const> operand_vector, + const range& stmt_range, + const diagnostic_collector& add_diagnostic); } // namespace hlasm_plugin::parser_library::checking diff --git a/parser_library/src/context/instruction.cpp b/parser_library/src/context/instruction.cpp index 7fecccb4c..800d8b480 100644 --- a/parser_library/src/context/instruction.cpp +++ b/parser_library/src/context/instruction.cpp @@ -416,7 +416,7 @@ std::span<const assembler_instruction> instruction::all_assembler_instructions() } bool hlasm_plugin::parser_library::context::machine_instruction::check(std::string_view name_of_instruction, - const std::vector<const checking::machine_operand*>& to_check, + std::span<const checking::machine_operand* const> to_check, const range& stmt_range, const diagnostic_collector& add_diagnostic) const { @@ -429,17 +429,16 @@ bool hlasm_plugin::parser_library::context::machine_instruction::check(std::stri return false; } bool error = false; - for (size_t i = 0; i < to_check.size(); i++) + for (const auto* fmt = m_operands; const auto* op : to_check) { - assert(to_check[i] != nullptr); - diagnostic_op diag; - if (!(*to_check[i]).check(diag, m_operands[i], name_of_instruction, stmt_range)) + assert(op != nullptr); + if (auto diag = op->check(*fmt++, name_of_instruction, stmt_range); diag.has_value()) { - add_diagnostic(diag); + add_diagnostic(std::move(diag).value()); error = true; } }; - return (!error); + return !error; } template<mach_format F, const machine_operand_format&... Ops> diff --git a/parser_library/src/context/instruction.h b/parser_library/src/context/instruction.h index 9921dd786..bd1992b56 100644 --- a/parser_library/src/context/instruction.h +++ b/parser_library/src/context/instruction.h @@ -567,7 +567,7 @@ class machine_instruction constexpr const instruction_set_affiliation& instr_set_affiliation() const { return m_instr_set_affiliation; }; bool check(std::string_view name_of_instruction, - const std::vector<const checking::machine_operand*>& operands, + std::span<const checking::machine_operand* const> operands, const range& stmt_range, const diagnostic_collector& add_diagnostic) const; // input vector is the vector of the actual incoming values diff --git a/parser_library/src/processing/statement_processors/ordinary_processor.cpp b/parser_library/src/processing/statement_processors/ordinary_processor.cpp index 92c7eee2a..0f5986316 100644 --- a/parser_library/src/processing/statement_processors/ordinary_processor.cpp +++ b/parser_library/src/processing/statement_processors/ordinary_processor.cpp @@ -20,6 +20,7 @@ #include "checking/instruction_checker.h" #include "checking/using_label_checker.h" #include "context/hlasm_context.h" +#include "context/instruction.h" #include "context/literal_pool.h" #include "context/ordinary_assembly/location_counter.h" #include "context/ordinary_assembly/ordinary_assembly_dependency_solver.h" @@ -321,7 +322,8 @@ checking::check_op_ptr get_check_op(const semantics::operand* op, return uniq; } -std::optional<std::vector<checking::check_op_ptr>> transform_mnemonic(const resolved_statement& stmt, +bool transform_mnemonic(std::vector<checking::check_op_ptr>& result, + const resolved_statement& stmt, context::dependency_solver& dep_solver, const context::mnemonic_code& mnemonic, const diagnostic_collector& add_diagnostic) @@ -340,7 +342,7 @@ std::optional<std::vector<checking::check_op_ptr>> transform_mnemonic(const reso { add_diagnostic( diagnostic_op::error_optional_number_of_operands(instr_name, high - low, high, stmt.stmt_range_ref())); - return std::nullopt; + return false; } assert(operands.size() <= context::machine_instruction::max_operand_count); @@ -372,7 +374,7 @@ std::optional<std::vector<checking::check_op_ptr>> transform_mnemonic(const reso { t = get_check_op(operand.get(), dep_solver, add_diagnostic, stmt, op_id, mnemonic.instruction()); if (!t) - return std::nullopt; // contains dependencies + return false; // contains dependencies t->operand_range = operand->operand_range; if (const auto* ao = dynamic_cast<const checking::one_operand*>(t.get()); ao) provided_operand_values[po_id].value = ao->value; @@ -392,7 +394,7 @@ std::optional<std::vector<checking::check_op_ptr>> transform_mnemonic(const reso std::span<checking::check_op_ptr> provided_operands(po.data(), operands.size()); // create vector of empty operands - std::vector<checking::check_op_ptr> result(curr_instr->operands().size()); + result.resize(curr_instr->operands().size()); // add other for (size_t processed = 0; auto& op : result) @@ -442,67 +444,33 @@ std::optional<std::vector<checking::check_op_ptr>> transform_mnemonic(const reso ++processed; } std::erase_if(result, [](const auto& x) { return !x; }); - return result; + return true; } -std::optional<std::vector<checking::check_op_ptr>> transform_default(const resolved_statement& stmt, +bool transform_default(std::vector<checking::check_op_ptr>& result, + const resolved_statement& stmt, context::dependency_solver& dep_solver, const diagnostic_collector& add_diagnostic, const context::machine_instruction* mi) { - std::vector<checking::check_op_ptr> operand_vector; - const auto& ops = stmt.operands_ref().value; - operand_vector.reserve(ops.size()); - for (const auto& op : ops) + for (const auto& op : stmt.operands_ref().value) { // check whether operand isn't empty if (op->type == semantics::operand_type::EMPTY) { - operand_vector.push_back(std::make_unique<checking::empty_operand>(op->operand_range)); + result.push_back(std::make_unique<checking::empty_operand>(op->operand_range)); continue; } - auto uniq = get_check_op(op.get(), dep_solver, add_diagnostic, stmt, operand_vector.size(), mi); + auto uniq = get_check_op(op.get(), dep_solver, add_diagnostic, stmt, result.size(), mi); if (!uniq) - return std::nullopt; // contains dependencies + return false; // contains dependencies uniq->operand_range = op.get()->operand_range; - operand_vector.push_back(std::move(uniq)); + result.push_back(std::move(uniq)); } - return operand_vector; -} - -bool statement_check(const resolved_statement& stmt, - const context::processing_stack_t& processing_stack, - context::dependency_solver& dep_solver, - const checking::instruction_checker& checker, - const diagnosable_ctx& diagnoser) -{ - diagnostic_collector collector(&diagnoser, processing_stack); - - std::vector<const checking::operand*> operand_ptr_vector; - std::optional<std::vector<checking::check_op_ptr>> operand_vector; - - std::string_view instruction_name = stmt.opcode_ref().value.to_string_view(); - - if (const auto [mi, mn] = context::instruction::find_machine_instruction_or_mnemonic(instruction_name); mn) - { - operand_vector = transform_mnemonic(stmt, dep_solver, *mn, collector); - } - else - { - operand_vector = transform_default(stmt, dep_solver, collector, mi); - } - - if (!operand_vector) - return false; - - operand_ptr_vector.reserve(operand_vector->size()); - for (const auto& op : *operand_vector) - operand_ptr_vector.push_back(op.get()); - - return checker.check(instruction_name, operand_ptr_vector, stmt.stmt_range_ref(), collector); + return true; } } // namespace @@ -510,8 +478,9 @@ bool statement_check(const resolved_statement& stmt, void ordinary_processor::check_postponed_statements( const std::vector<std::pair<context::post_stmt_ptr, context::dependency_evaluation_context>>& stmts) { - static const checking::assembler_checker asm_checker; - static const checking::machine_checker mach_checker; + std::vector<const checking::asm_operand*> operand_asm_vector; + std::vector<const checking::machine_operand*> operand_mach_vector; + std::vector<checking::check_op_ptr> operand_vector; for (const auto& [stmt, dep_ctx] : stmts) { @@ -521,14 +490,37 @@ void ordinary_processor::check_postponed_statements( context::ordinary_assembly_dependency_solver dep_solver(hlasm_ctx.ord_ctx, dep_ctx, lib_info); const auto* rs = stmt->resolved_stmt(); + diagnostic_collector collector(this, stmt->location_stack()); + + operand_vector.clear(); + + std::string_view instruction_name = rs->opcode_ref().value.to_string_view(); + + if (const auto [mi, mn] = context::instruction::find_machine_instruction_or_mnemonic(instruction_name); mn) + { + if (!transform_mnemonic(operand_vector, *rs, dep_solver, *mn, collector)) + continue; + } + else + { + if (!transform_default(operand_vector, *rs, dep_solver, collector, mi)) + continue; + } + switch (const auto& opcode = rs->opcode_ref(); opcode.type) { case hlasm_plugin::parser_library::context::instruction_type::MACH: - statement_check(*rs, stmt->location_stack(), dep_solver, mach_checker, *this); + operand_mach_vector.clear(); + for (const auto& op : operand_vector) + operand_mach_vector.push_back(dynamic_cast<const checking::machine_operand*>(op.get())); + checking::check_mach_ops(instruction_name, operand_mach_vector, rs->stmt_range_ref(), collector); break; case hlasm_plugin::parser_library::context::instruction_type::ASM: - statement_check(*rs, stmt->location_stack(), dep_solver, asm_checker, *this); + operand_asm_vector.clear(); + for (const auto& op : operand_vector) + operand_asm_vector.push_back(dynamic_cast<const checking::asm_operand*>(op.get())); + checking::check_asm_ops(instruction_name, operand_asm_vector, rs->stmt_range_ref(), collector); break; default: diff --git a/parser_library/test/checking/asm_instr_check_test.cpp b/parser_library/test/checking/asm_instr_check_test.cpp index 142a4bc7a..7afc3559f 100644 --- a/parser_library/test/checking/asm_instr_check_test.cpp +++ b/parser_library/test/checking/asm_instr_check_test.cpp @@ -747,162 +747,161 @@ class instruction_test : public testing::Test one_operand equ_CR32 = one_operand("CR32"); one_operand equ_A1 = one_operand("A1"); - assembler_checker checker; diagnostic_collector collector; - std::vector<const checking::operand*> test_no_operand_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_adata_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_adata_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_acontrol_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_ainsert_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_ainsert_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_ainsert_false = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_alias_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_alias_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_alias_false = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_amode_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_cattr_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_expression_true = std::vector<const checking::operand*>(); - - std::vector<const checking::operand*> test_cnop_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_cnop_one_false = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_cnop_two_false = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_copy_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_data_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_data_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_drop_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_drop_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_end_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_end_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_end_false = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_equ_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_exitctl_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_exitctl_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_extrn_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_extrn_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_ictl_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_ictl_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_ictl_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_ictl_false_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_iseq_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_iseq_false = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_mnote_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_mnote_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_mnote_true_three = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_mnote_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_mnote_false_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_opsyn_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_org_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_org_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_org_false = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_stack_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_stack_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_stack_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_stack_false_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_print_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_punch_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_punch_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_punch_false_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_rmode_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_rmode_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_using_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_using_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_using_true_three = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_using_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_using_false_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_xattr_true = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_xattr_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_xattr_false_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_true_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_true_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_true_three = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_one = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_two = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_three = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_four = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_five = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_six = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_seven = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_eight = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_process_false_nine = std::vector<const checking::operand*>(); - std::vector<const checking::operand*> test_entry_false = std::vector<const checking::operand*>(); + std::vector<const checking::asm_operand*> test_no_operand_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_adata_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_adata_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_acontrol_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_ainsert_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_ainsert_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_ainsert_false = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_alias_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_alias_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_alias_false = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_amode_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_cattr_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_expression_true = std::vector<const checking::asm_operand*>(); + + std::vector<const checking::asm_operand*> test_cnop_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_cnop_one_false = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_cnop_two_false = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_copy_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_data_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_data_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_drop_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_drop_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_end_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_end_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_end_false = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_equ_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_exitctl_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_exitctl_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_extrn_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_extrn_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_ictl_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_ictl_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_ictl_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_ictl_false_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_iseq_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_iseq_false = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_mnote_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_mnote_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_mnote_true_three = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_mnote_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_mnote_false_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_opsyn_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_org_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_org_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_org_false = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_stack_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_stack_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_stack_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_stack_false_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_print_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_punch_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_punch_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_punch_false_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_rmode_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_rmode_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_using_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_using_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_using_true_three = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_using_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_using_false_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_xattr_true = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_xattr_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_xattr_false_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_true_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_true_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_true_three = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_one = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_two = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_three = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_four = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_five = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_six = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_seven = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_eight = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_process_false_nine = std::vector<const checking::asm_operand*>(); + std::vector<const checking::asm_operand*> test_entry_false = std::vector<const checking::asm_operand*>(); }; TEST_F(instruction_test, process) { - EXPECT_FALSE(checker.check("*PROCESS", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("*PROCESS", test_process_true_one, range(), collector)); - EXPECT_TRUE(checker.check("*PROCESS", test_process_true_two, range(), collector)); - EXPECT_TRUE(checker.check("*PROCESS", test_process_true_three, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_one, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_two, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_three, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_four, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_five, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_six, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_seven, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_eight, range(), collector)); - EXPECT_FALSE(checker.check("*PROCESS", test_process_false_nine, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("*PROCESS", test_process_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("*PROCESS", test_process_true_two, range(), collector)); + EXPECT_TRUE(check_asm_ops("*PROCESS", test_process_true_three, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_three, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_four, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_five, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_six, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_seven, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_eight, range(), collector)); + EXPECT_FALSE(check_asm_ops("*PROCESS", test_process_false_nine, range(), collector)); } TEST_F(instruction_test, no_operand) { - EXPECT_TRUE(checker.check("LOCTR", test_no_operand_true, range(), collector)); - EXPECT_FALSE(checker.check("LOCTR", test_acontrol_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("LOCTR", test_no_operand_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("LOCTR", test_acontrol_true, range(), collector)); } TEST_F(instruction_test, adata) { - EXPECT_FALSE(checker.check("ADATA", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("ADATA", test_adata_true_one, range(), collector)); - EXPECT_TRUE(checker.check("ADATA", test_adata_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("ADATA", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("ADATA", test_adata_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("ADATA", test_adata_true_two, range(), collector)); } TEST_F(instruction_test, acontrol) { - EXPECT_FALSE(checker.check("ACONTROL", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("ACONTROL", test_acontrol_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("ACONTROL", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("ACONTROL", test_acontrol_true, range(), collector)); } TEST_F(instruction_test, ainsert) { - EXPECT_TRUE(checker.check("AINSERT", test_ainsert_true_one, range(), collector)); - EXPECT_TRUE(checker.check("AINSERT", test_ainsert_true_two, range(), collector)); - EXPECT_FALSE(checker.check("AINSERT", test_ainsert_false, range(), collector)); - EXPECT_FALSE(checker.check("AINSERT", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("AINSERT", test_ainsert_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("AINSERT", test_ainsert_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("AINSERT", test_ainsert_false, range(), collector)); + EXPECT_FALSE(check_asm_ops("AINSERT", test_no_operand_true, range(), collector)); } TEST_F(instruction_test, alias) { - EXPECT_FALSE(checker.check("ALIAS", test_alias_false, range(), collector)); - EXPECT_TRUE(checker.check("ALIAS", test_alias_true_one, range(), collector)); - EXPECT_TRUE(checker.check("ALIAS", test_alias_true_two, range(), collector)); - EXPECT_FALSE(checker.check("ALIAS", test_acontrol_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("ALIAS", test_alias_false, range(), collector)); + EXPECT_TRUE(check_asm_ops("ALIAS", test_alias_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("ALIAS", test_alias_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("ALIAS", test_acontrol_true, range(), collector)); } TEST_F(instruction_test, amode) { - EXPECT_FALSE(checker.check("AMODE", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("AMODE", test_amode_true, range(), collector)); - EXPECT_FALSE(checker.check("AMODE", test_alias_true_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("AMODE", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("AMODE", test_amode_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("AMODE", test_alias_true_one, range(), collector)); } TEST_F(instruction_test, cattr) { - EXPECT_FALSE(checker.check("CATTR", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("CATTR", test_cattr_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("CATTR", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("CATTR", test_cattr_true, range(), collector)); } TEST_F(instruction_test, expression) { - EXPECT_TRUE(checker.check("CEJECT", test_no_operand_true, range(), collector)); - EXPECT_FALSE(checker.check("CEJECT", test_acontrol_true, range(), collector)); - EXPECT_TRUE(checker.check("CEJECT", test_expression_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("CEJECT", test_no_operand_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("CEJECT", test_acontrol_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("CEJECT", test_expression_true, range(), collector)); } TEST_F(instruction_test, ccw) { - EXPECT_FALSE(checker.check("CCW", test_no_operand_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("CCW", test_no_operand_true, range(), collector)); one_operand ccw_first("X'06'", 6); // Current value of relocatable symbols for checker is one_operand("0", 0), see @@ -911,179 +910,179 @@ TEST_F(instruction_test, ccw) one_operand big_absolute("17000000", 17000000); one_operand ccw_third("X'40'", 64); one_operand ccw_fourth("MyBlkSize", 20); - std::vector<const checking::operand*> test_ccw_true { &ccw_first, &relocatable, &ccw_third, &ccw_fourth }; - EXPECT_TRUE(checker.check("CCW", test_ccw_true, range(), collector)); + std::vector<const checking::asm_operand*> test_ccw_true { &ccw_first, &relocatable, &ccw_third, &ccw_fourth }; + EXPECT_TRUE(check_asm_ops("CCW", test_ccw_true, range(), collector)); - std::vector<const checking::operand*> ccw_big_absolute_address { + std::vector<const checking::asm_operand*> ccw_big_absolute_address { &ccw_first, &big_absolute, &ccw_third, &ccw_fourth }; - EXPECT_FALSE(checker.check("CCW", ccw_big_absolute_address, range(), collector)); - EXPECT_TRUE(checker.check("CCW1", ccw_big_absolute_address, range(), collector)); + EXPECT_FALSE(check_asm_ops("CCW", ccw_big_absolute_address, range(), collector)); + EXPECT_TRUE(check_asm_ops("CCW1", ccw_big_absolute_address, range(), collector)); - EXPECT_FALSE(checker.check("CCW", test_expression_true, range(), collector)); - EXPECT_FALSE(checker.check("CCW", test_acontrol_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("CCW", test_expression_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("CCW", test_acontrol_true, range(), collector)); } TEST_F(instruction_test, cnop) { - EXPECT_FALSE(checker.check("CNOP", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("CNOP", test_cnop_true, range(), collector)); - EXPECT_FALSE(checker.check("CNOP", test_cnop_one_false, range(), collector)); - EXPECT_FALSE(checker.check("CNOP", test_cnop_two_false, range(), collector)); - EXPECT_FALSE(checker.check("CNOP", test_acontrol_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("CNOP", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("CNOP", test_cnop_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("CNOP", test_cnop_one_false, range(), collector)); + EXPECT_FALSE(check_asm_ops("CNOP", test_cnop_two_false, range(), collector)); + EXPECT_FALSE(check_asm_ops("CNOP", test_acontrol_true, range(), collector)); } TEST_F(instruction_test, copy) { - EXPECT_FALSE(checker.check("COPY", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("COPY", test_copy_true, range(), collector)); - EXPECT_FALSE(checker.check("COPY", test_acontrol_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("COPY", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("COPY", test_copy_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("COPY", test_acontrol_true, range(), collector)); } TEST_F(instruction_test, drop) { - EXPECT_TRUE(checker.check("DROP", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("DROP", test_drop_true_one, range(), collector)); - EXPECT_TRUE(checker.check("DROP", test_drop_true_two, range(), collector)); - EXPECT_FALSE(checker.check("DROP", test_acontrol_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("DROP", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("DROP", test_drop_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("DROP", test_drop_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("DROP", test_acontrol_true, range(), collector)); } TEST_F(instruction_test, end) { - EXPECT_TRUE(checker.check("END", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("END", test_end_true_one, range(), collector)); - EXPECT_TRUE(checker.check("END", test_end_true_two, range(), collector)); - EXPECT_FALSE(checker.check("END", test_end_false, range(), collector)); - EXPECT_FALSE(checker.check("END", test_exitctl_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("END", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("END", test_end_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("END", test_end_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("END", test_end_false, range(), collector)); + EXPECT_FALSE(check_asm_ops("END", test_exitctl_true, range(), collector)); } TEST_F(instruction_test, entry) { - EXPECT_FALSE(checker.check("ENTRY", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("ENTRY", test_data_true_one, range(), collector)); - EXPECT_TRUE(checker.check("ENTRY", test_ainsert_true_one, range(), collector)); - EXPECT_FALSE(checker.check("ENTRY", test_end_true_one, range(), collector)); - EXPECT_FALSE(checker.check("ENTRY", test_entry_false, range(), collector)); + EXPECT_FALSE(check_asm_ops("ENTRY", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("ENTRY", test_data_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("ENTRY", test_ainsert_true_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("ENTRY", test_end_true_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("ENTRY", test_entry_false, range(), collector)); } TEST_F(instruction_test, exitctl) { - EXPECT_FALSE(checker.check("EXITCTL", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("EXITCTL", test_exitctl_true, range(), collector)); - EXPECT_FALSE(checker.check("EXITCTL", test_exitctl_false_one, range(), collector)); - EXPECT_FALSE(checker.check("EXITCTL", test_exitctl_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("EXITCTL", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("EXITCTL", test_exitctl_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("EXITCTL", test_exitctl_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("EXITCTL", test_exitctl_false_one, range(), collector)); } TEST_F(instruction_test, external) { - EXPECT_FALSE(checker.check("EXTRN", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("EXTRN", test_extrn_true_one, range(), collector)); - EXPECT_TRUE(checker.check("EXTRN", test_extrn_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("EXTRN", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("EXTRN", test_extrn_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("EXTRN", test_extrn_true_two, range(), collector)); } TEST_F(instruction_test, ictl) { - EXPECT_FALSE(checker.check("ICTL", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("ICTL", test_ictl_true_one, range(), collector)); - EXPECT_TRUE(checker.check("ICTL", test_ictl_true_two, range(), collector)); - EXPECT_FALSE(checker.check("ICTL", test_ictl_false_one, range(), collector)); - EXPECT_FALSE(checker.check("ICTL", test_ictl_false_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("ICTL", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("ICTL", test_ictl_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("ICTL", test_ictl_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("ICTL", test_ictl_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("ICTL", test_ictl_false_two, range(), collector)); } TEST_F(instruction_test, iseq) { - EXPECT_TRUE(checker.check("ISEQ", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("ISEQ", test_iseq_true, range(), collector)); - EXPECT_FALSE(checker.check("ISEQ", test_iseq_false, range(), collector)); - EXPECT_FALSE(checker.check("ISEQ", test_ainsert_true_one, range(), collector)); - EXPECT_FALSE(checker.check("ISEQ", test_extrn_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("ISEQ", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("ISEQ", test_iseq_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("ISEQ", test_iseq_false, range(), collector)); + EXPECT_FALSE(check_asm_ops("ISEQ", test_ainsert_true_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("ISEQ", test_extrn_true_one, range(), collector)); } TEST_F(instruction_test, mnote) { - EXPECT_FALSE(checker.check("MNOTE", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("MNOTE", test_mnote_true_one, range(), collector)); - EXPECT_TRUE(checker.check("MNOTE", test_mnote_true_two, range(), collector)); - EXPECT_TRUE(checker.check("MNOTE", test_mnote_true_three, range(), collector)); - EXPECT_FALSE(checker.check("MNOTE", test_mnote_false_one, range(), collector)); - EXPECT_FALSE(checker.check("MNOTE", test_mnote_false_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("MNOTE", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("MNOTE", test_mnote_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("MNOTE", test_mnote_true_two, range(), collector)); + EXPECT_TRUE(check_asm_ops("MNOTE", test_mnote_true_three, range(), collector)); + EXPECT_FALSE(check_asm_ops("MNOTE", test_mnote_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("MNOTE", test_mnote_false_two, range(), collector)); } TEST_F(instruction_test, opsyn) { - EXPECT_TRUE(checker.check("OPSYN", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("OPSYN", test_opsyn_true, range(), collector)); - EXPECT_FALSE(checker.check("OPSYN", test_mnote_true_one, range(), collector)); - EXPECT_FALSE(checker.check("OPSYN", test_extrn_true_two, range(), collector)); + EXPECT_TRUE(check_asm_ops("OPSYN", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("OPSYN", test_opsyn_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("OPSYN", test_mnote_true_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("OPSYN", test_extrn_true_two, range(), collector)); } TEST_F(instruction_test, org) { - EXPECT_TRUE(checker.check("ORG", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("ORG", test_org_true_one, range(), collector)); - EXPECT_TRUE(checker.check("ORG", test_org_true_two, range(), collector)); - EXPECT_FALSE(checker.check("ORG", test_org_false, range(), collector)); - EXPECT_FALSE(checker.check("ORG", test_equ_true_two, range(), collector)); + EXPECT_TRUE(check_asm_ops("ORG", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("ORG", test_org_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("ORG", test_org_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("ORG", test_org_false, range(), collector)); + EXPECT_FALSE(check_asm_ops("ORG", test_equ_true_two, range(), collector)); } TEST_F(instruction_test, stack) { - EXPECT_FALSE(checker.check("POP", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("POP", test_stack_true_one, range(), collector)); - EXPECT_TRUE(checker.check("POP", test_stack_true_two, range(), collector)); - EXPECT_FALSE(checker.check("POP", test_stack_false_one, range(), collector)); - EXPECT_FALSE(checker.check("POP", test_stack_false_two, range(), collector)); - EXPECT_FALSE(checker.check("POP", test_extrn_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("POP", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("POP", test_stack_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("POP", test_stack_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("POP", test_stack_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("POP", test_stack_false_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("POP", test_extrn_true_two, range(), collector)); } TEST_F(instruction_test, print) { - EXPECT_FALSE(checker.check("PRINT", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("PRINT", test_print_true, range(), collector)); - EXPECT_FALSE(checker.check("PRINT", test_stack_true_one, range(), collector)); - EXPECT_FALSE(checker.check("PRINT", test_extrn_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("PRINT", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("PRINT", test_print_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("PRINT", test_stack_true_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("PRINT", test_extrn_true_two, range(), collector)); } TEST_F(instruction_test, rmode) { - EXPECT_FALSE(checker.check("RMODE", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("RMODE", test_rmode_true_one, range(), collector)); - EXPECT_TRUE(checker.check("RMODE", test_rmode_true_two, range(), collector)); - EXPECT_FALSE(checker.check("RMODE", test_amode_true, range(), collector)); - EXPECT_FALSE(checker.check("RMODE", test_extrn_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("RMODE", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("RMODE", test_rmode_true_one, range(), collector)); + EXPECT_TRUE(check_asm_ops("RMODE", test_rmode_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("RMODE", test_amode_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("RMODE", test_extrn_true_two, range(), collector)); } TEST_F(instruction_test, title) { - EXPECT_FALSE(checker.check("TITLE", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("TITLE", test_punch_true, range(), collector)); - EXPECT_FALSE(checker.check("TITLE", test_punch_false_two, range(), collector)); - EXPECT_FALSE(checker.check("TITLE", test_punch_false_one, range(), collector)); - EXPECT_FALSE(checker.check("TITLE", test_amode_true, range(), collector)); - EXPECT_FALSE(checker.check("TITLE", test_extrn_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("TITLE", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("TITLE", test_punch_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("TITLE", test_punch_false_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("TITLE", test_punch_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("TITLE", test_amode_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("TITLE", test_extrn_true_two, range(), collector)); } TEST_F(instruction_test, using_instr) { - EXPECT_FALSE(checker.check("USING", test_no_operand_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("USING", test_no_operand_true, range(), collector)); /* TO DO once using is resolved - EXPECT_FALSE(checker.check("USING", test_extrn_true_two, range(), collector)); - EXPECT_TRUE(checker.check("USING", test_using_true_one, range(), collector)); - EXPECT_TRUE(checker.check("USING", test_using_true_two, range(), collector)); - EXPECT_TRUE(checker.check("USING", test_using_true_three, range(), collector)); - EXPECT_FALSE(checker.check("USING", test_using_false_one, range(), collector)); - EXPECT_FALSE(checker.check("USING", test_using_false_two, range(), collector)); - EXPECT_FALSE(checker.check("USING", test_rmode_true_one, range(), collector)); */ + EXPECT_FALSE(check_assembler_instruction("USING", test_extrn_true_two, range(), collector)); + EXPECT_TRUE(check_assembler_instruction("USING", test_using_true_one, range(), collector)); + EXPECT_TRUE(check_assembler_instruction("USING", test_using_true_two, range(), collector)); + EXPECT_TRUE(check_assembler_instruction("USING", test_using_true_three, range(), collector)); + EXPECT_FALSE(check_assembler_instruction("USING", test_using_false_one, range(), collector)); + EXPECT_FALSE(check_assembler_instruction("USING", test_using_false_two, range(), collector)); + EXPECT_FALSE(check_assembler_instruction("USING", test_rmode_true_one, range(), collector)); */ } TEST_F(instruction_test, xattr) { - EXPECT_FALSE(checker.check("XATTR", test_no_operand_true, range(), collector)); - EXPECT_TRUE(checker.check("XATTR", test_xattr_true, range(), collector)); - EXPECT_FALSE(checker.check("XATTR", test_xattr_false_one, range(), collector)); - EXPECT_FALSE(checker.check("XATTR", test_xattr_false_two, range(), collector)); - EXPECT_FALSE(checker.check("XATTR", test_extrn_true_two, range(), collector)); - EXPECT_FALSE(checker.check("XATTR", test_acontrol_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("XATTR", test_no_operand_true, range(), collector)); + EXPECT_TRUE(check_asm_ops("XATTR", test_xattr_true, range(), collector)); + EXPECT_FALSE(check_asm_ops("XATTR", test_xattr_false_one, range(), collector)); + EXPECT_FALSE(check_asm_ops("XATTR", test_xattr_false_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("XATTR", test_extrn_true_two, range(), collector)); + EXPECT_FALSE(check_asm_ops("XATTR", test_acontrol_true, range(), collector)); } diff --git a/parser_library/test/checking/data_definition/data_definition_check_test.cpp b/parser_library/test/checking/data_definition/data_definition_check_test.cpp index 8f4bf22d6..b27606d20 100644 --- a/parser_library/test/checking/data_definition/data_definition_check_test.cpp +++ b/parser_library/test/checking/data_definition/data_definition_check_test.cpp @@ -12,6 +12,8 @@ * Broadcom, Inc. - initial API and implementation */ +#include <span> + #include "../../common_testing.h" #include "data_definition_common.h" @@ -23,11 +25,12 @@ TEST(data_def_checker, unknown_type) { dc d({}, "DC"); - data_definition_operand op = setup_data_def_op('W', '\0', ""); - diag_collector col; - EXPECT_FALSE(d.check({ &op }, {}, ADD_DIAG(col))); + data_definition_operand op = setup_data_def_op('W', '\0', ""); + const checking::asm_operand* const ops[] = { &op }; + + EXPECT_FALSE(d.check(std::span(ops), {}, ADD_DIAG(col))); EXPECT_TRUE(matches_message_codes(col.diags(), { "D012" })); } @@ -38,7 +41,9 @@ TEST(data_def_checker, unknown_extension) diag_collector col; data_definition_operand op = setup_data_def_op('B', 'A', ""); - EXPECT_FALSE(d.check({ &op }, {}, ADD_DIAG(col))); + const checking::asm_operand* const ops[] = { &op }; + + EXPECT_FALSE(d.check(std::span(ops), {}, ADD_DIAG(col))); EXPECT_TRUE(matches_message_codes(col.diags(), { "D013" })); } @@ -50,8 +55,9 @@ TEST(data_def_checker, operands_too_long) data_definition_operand op = setup_data_def_op('C', '\0', 1); op.dupl_factor = 1 << 30; + const checking::asm_operand* const ops[] = { &op, &op }; - EXPECT_FALSE(d.check({ &op, &op }, {}, ADD_DIAG(col))); + EXPECT_FALSE(d.check(std::span(ops), {}, ADD_DIAG(col))); EXPECT_TRUE(matches_message_codes(col.diags(), { "D029" })); }