Skip to content

Commit

Permalink
fix: Various small fixes (#149)
Browse files Browse the repository at this point in the history
docs: Remove references to proc_conf
refactor: Remove references to proc_conf
fix: Inline macro not available when the matching instruction was deleted by OPSYN
fix: Vector register 16-31 not recognized.

* fixes #143, fixes #142
  • Loading branch information
slavek-kucera authored Jul 16, 2021
1 parent 3e85b98 commit c1a6896
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 366 deletions.
4 changes: 2 additions & 2 deletions clients/vscode-hlasmplugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ In this example, GROUP1 is used for all open code programs.

The `alwaysRecognize` option in `pgm_conf.json` has been deprecated in favour of the standard VSCode user and workspace level setting `file.associations`.

`proc_conf.json` can include an optional parameter `macro_extensions` which contains a list of extensions that are to be used to identify files with macro definitions.
`proc_grps.json` can include an optional parameter `macro_extensions` which contains a list of extensions that are to be used to identify files with macro definitions.
The options can be specified both at the top level of the file, providing the default list for all libraries in all process groups, and at the level of individual library definitions, overriding the default from the top level.

For example, with the extension `.hlasm`, a user can add the macro `MAC` to his source code even if it is in a file called `MAC.hlasm`.

The following example of `proc_conf.json` specifies that files with the extension `.hlasm` are recognized as macros, with the exception of macros in the `C:/external/project/macs` directory, where they need to have the extension `.mac`.
The following example of `proc_grps.json` specifies that files with the extension `.hlasm` are recognized as macros, with the exception of macros in the `C:/external/project/macs` directory, where they need to have the extension `.mac`.

```
{
Expand Down
6 changes: 5 additions & 1 deletion parser_library/src/checking/asm_instr_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ bool opsyn::check(const std::vector<const asm_operand*>& to_check,
{
if (!operands_size_corresponding(to_check, stmt_range, add_diagnostic))
return false;
if (has_one_comma(to_check))
return true;
if (to_check.size() == 1)
{
if (is_operand_complex(to_check[0]))
Expand Down Expand Up @@ -583,6 +585,8 @@ bool iseq::check(const std::vector<const asm_operand*>& to_check,
{
if (to_check.empty())
return true;
if (has_one_comma(to_check))
return true;
if (to_check.size() == 2)
{
auto first = get_simple_operand(to_check[0]);
Expand Down Expand Up @@ -1019,7 +1023,7 @@ bool expression_instruction::check(const std::vector<const asm_operand*>& to_che
if (to_check.empty())
return true;
// an if for the specific "SPACE , " case which should return true
if (to_check.size() == 2 && is_operand_empty(to_check[0]) && is_operand_empty(to_check[1]))
if (has_one_comma(to_check))
return true;
if (!operands_size_corresponding(to_check, stmt_range, add_diagnostic))
return false;
Expand Down
2 changes: 2 additions & 0 deletions parser_library/src/checking/asm_instr_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ bool assembler_instruction::operands_size_corresponding(const std::vector<const
{
if ((int)to_check.size() >= min_operands && ((int)to_check.size() <= max_operands || max_operands == -1))
return true;
if (min_operands == 0 && has_one_comma(to_check))
return true; // handles classic " instr , comment" pattern
if (max_operands == -1)
add_diagnostic(diagnostic_op::error_A010_minimum(name_of_instruction, min_operands, stmt_range));
else if (min_operands == max_operands)
Expand Down
4 changes: 2 additions & 2 deletions parser_library/src/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
target_sources(parser_library PRIVATE
pgm_conf.cpp
pgm_conf.h
proc_conf.cpp
proc_conf.h
proc_grps.cpp
proc_grps.h
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Broadcom, Inc. - initial API and implementation
*/

#include "proc_conf.h"
#include "proc_grps.h"

#include "nlohmann/json.hpp"

Expand Down Expand Up @@ -106,13 +106,13 @@ void from_json(const nlohmann::json& j, processor_group& p)
}
}

void to_json(nlohmann::json& j, const proc_conf& p)
void to_json(nlohmann::json& j, const proc_grps& p)
{
j = nlohmann::json { { "pgroups", p.pgroups } };
if (auto m = nlohmann::json(p.macro_extensions); !m.empty())
j["macro_extensions"] = std::move(m);
}
void from_json(const nlohmann::json& j, proc_conf& p)
void from_json(const nlohmann::json& j, proc_grps& p)
{
j.at("pgroups").get_to(p.pgroups);
if (auto it = j.find("macro_extensions"); it != j.end())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* Broadcom, Inc. - initial API and implementation
*/

#ifndef HLASMPARSER_PARSERLIBRARY_CONFIG_PROC_CONF_H
#define HLASMPARSER_PARSERLIBRARY_CONFIG_PROC_CONF_H
#ifndef HLASMPARSER_PARSERLIBRARY_CONFIG_PROC_GRPS_H
#define HLASMPARSER_PARSERLIBRARY_CONFIG_PROC_GRPS_H

#include <optional>
#include <string>
Expand Down Expand Up @@ -68,14 +68,14 @@ struct processor_group
void to_json(nlohmann::json& j, const processor_group& p);
void from_json(const nlohmann::json& j, processor_group& p);

struct proc_conf
struct proc_grps
{
std::vector<processor_group> pgroups;
std::vector<std::string> macro_extensions;
};
void to_json(nlohmann::json& j, const proc_conf& p);
void from_json(const nlohmann::json& j, proc_conf& p);
void to_json(nlohmann::json& j, const proc_grps& p);
void from_json(const nlohmann::json& j, proc_grps& p);

} // namespace hlasm_plugin::parser_library::config

#endif // HLASMPARSER_PARSERLIBRARY_CONFIG_PROC_CONF_H
#endif // HLASMPARSER_PARSERLIBRARY_CONFIG_PROC_GRPS_H
33 changes: 19 additions & 14 deletions parser_library/src/context/hlasm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,20 +676,25 @@ macro_def_ptr hlasm_context::add_macro(id_index name,
location definition_location,
std::unordered_set<copy_member_ptr> used_copy_members)
{
return macros_
.insert_or_assign(name,
std::make_shared<macro_definition>(name,
label_param_name,
std::move(params),
std::move(definition),
std::move(copy_nests),
std::move(labels),
std::move(definition_location),
std::move(used_copy_members)))
.first->second;
}

void hlasm_context::add_macro(macro_def_ptr macro) { macros_[macro->id] = std::move(macro); };
auto result = std::make_shared<macro_definition>(name,
label_param_name,
std::move(params),
std::move(definition),
std::move(copy_nests),
std::move(labels),
std::move(definition_location),
std::move(used_copy_members));
add_macro(result);
return result;
}

void hlasm_context::add_macro(macro_def_ptr macro)
{
const auto& m = macros_[macro->id] = std::move(macro);
// associate mnemonic if previously deleted by OPSYN
if (auto m_op = opcode_mnemo_.find(m->id); m_op != opcode_mnemo_.end() && !m_op->second)
m_op->second = opcode_t { m->id, m };
};

const hlasm_context::macro_storage& hlasm_context::macros() const { return macros_; }

Expand Down
Loading

0 comments on commit c1a6896

Please sign in to comment.