Skip to content

Commit f61f8b6

Browse files
authored
Merge branch 'WerWolv:master' into new_lexer
2 parents 2759c92 + f97999d commit f61f8b6

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

lib/include/pl/pattern_language.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ namespace pl {
127127
* @param source the source of the code
128128
* @return Key-value pairs of all pragmas that were set
129129
*/
130-
[[nodiscard]] std::map<std::string, std::string> getPragmaValues(const std::string &code, const std::string &source = api::Source::DefaultSource) const;
130+
[[nodiscard]] std::multimap<std::string, std::string> getPragmaValues(const std::string &code, const std::string &source = api::Source::DefaultSource) const;
131131

132132
/**
133133
* @brief Aborts the currently running execution asynchronously

lib/source/pl/lib/std/mem.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ namespace pl::lib::libstd::mem {
6565
section = ctx->getUserSectionId();
6666

6767
if (section != ptrn::Pattern::MainSectionId)
68-
return 0;
68+
return u128(0x00);
6969

7070
return u128(ctx->getDataBaseAddress());
7171
});
7272

7373
/* size() */
7474
runtime.addFunction(nsStdMem, "size", FunctionParameterCount::between(0, 1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
75-
auto section = params.size() == 1 ? params[0].toUnsigned() : ptrn::Pattern::MainSectionId;
75+
auto section = params.size() == 1 ? u64(params[0].toUnsigned()) : ptrn::Pattern::MainSectionId;
7676
if (section == 0xFFFF'FFFF'FFFF'FFFF)
7777
section = ctx->getUserSectionId();
7878

@@ -81,9 +81,9 @@ namespace pl::lib::libstd::mem {
8181

8282
/* find_sequence_in_range(occurrence_index, start_offset, end_offset, bytes...) */
8383
runtime.addFunction(nsStdMem, "find_sequence_in_range", FunctionParameterCount::moreThan(3), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
84-
const u64 occurrenceIndex = params[0].toUnsigned();
85-
const u64 offsetFrom = params[1].toUnsigned();
86-
const u64 offsetTo = params[2].toUnsigned();
84+
const auto occurrenceIndex = u64(params[0].toUnsigned());
85+
const auto offsetFrom = u64(params[1].toUnsigned());
86+
const auto offsetTo = u64(params[2].toUnsigned());
8787

8888
std::vector<u8> sequence;
8989
for (u32 i = 3; i < params.size(); i++) {
@@ -100,20 +100,20 @@ namespace pl::lib::libstd::mem {
100100

101101
/* find_string_in_range(occurrence_index, start_offset, end_offset, string) */
102102
runtime.addFunction(nsStdMem, "find_string_in_range", FunctionParameterCount::exactly(4), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
103-
const u64 occurrenceIndex = params[0].toUnsigned();
104-
const u64 offsetFrom = params[1].toUnsigned();
105-
const u64 offsetTo = params[2].toUnsigned();
106-
const auto string = params[3].toString(false);
103+
const auto occurrenceIndex = u64(params[0].toUnsigned());
104+
const auto offsetFrom = u64(params[1].toUnsigned());
105+
const auto offsetTo = u64(params[2].toUnsigned());
106+
const auto string = params[3].toString(false);
107107

108108
return findSequence(ctx, occurrenceIndex, offsetFrom, offsetTo, ctx->getUserSectionId(), std::vector<u8>(string.data(), string.data() + string.size())).value_or(-1);
109109
});
110110

111111
/* read_unsigned(address, size, endian, section) */
112112
runtime.addFunction(nsStdMem, "read_unsigned", FunctionParameterCount::between(3, 4), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
113-
const u64 address = params[0].toUnsigned();
114-
const size_t size = params[1].toSigned();
113+
const auto address = u64(params[0].toUnsigned());
114+
const auto size = std::size_t(params[1].toSigned());
115115
const types::Endian endian = params[2].toUnsigned();
116-
u64 section = params.size() == 4 ? params[3].toUnsigned() : ptrn::Pattern::MainSectionId;
116+
u64 section = params.size() == 4 ? u64(params[3].toUnsigned()) : ptrn::Pattern::MainSectionId;
117117
if (section == 0xFFFF'FFFF'FFFF'FFFF)
118118
section = ctx->getUserSectionId();
119119

@@ -129,10 +129,10 @@ namespace pl::lib::libstd::mem {
129129

130130
/* read_signed(address, size, endian, section) */
131131
runtime.addFunction(nsStdMem, "read_signed", FunctionParameterCount::between(3, 4), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
132-
const u64 address = params[0].toUnsigned();
133-
const size_t size = params[1].toSigned();
132+
const auto address = u64(params[0].toUnsigned());
133+
const auto size = std::size_t(params[1].toSigned());
134134
const types::Endian endian = params[2].toUnsigned();
135-
u64 section = params.size() == 4 ? params[3].toUnsigned() : ptrn::Pattern::MainSectionId;
135+
u64 section = params.size() == 4 ? u64(params[3].toUnsigned()) : ptrn::Pattern::MainSectionId;
136136
if (section == 0xFFFF'FFFF'FFFF'FFFF)
137137
section = ctx->getUserSectionId();
138138

@@ -149,9 +149,9 @@ namespace pl::lib::libstd::mem {
149149

150150
/* read_string(address, size, endian, section) */
151151
runtime.addFunction(nsStdMem, "read_string", FunctionParameterCount::between(2, 3), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
152-
const u64 address = params[0].toUnsigned();
153-
const size_t size = params[1].toSigned();
154-
u64 section = params.size() == 3 ? params[2].toUnsigned() : ptrn::Pattern::MainSectionId;
152+
const auto address = u64(params[0].toUnsigned());
153+
const auto size = std::size_t(params[1].toSigned());
154+
u64 section = params.size() == 3 ? u64(params[2].toUnsigned()) : ptrn::Pattern::MainSectionId;
155155
if (section == 0xFFFF'FFFF'FFFF'FFFF)
156156
section = ctx->getUserSectionId();
157157

lib/source/pl/pattern_language.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ namespace pl {
338338
return this->m_fileResolver.addVirtualFile(code, source, mainSource);
339339
}
340340

341-
std::map<std::string, std::string> PatternLanguage::getPragmaValues(const std::string &code, const std::string &source) const {
342-
std::map<std::string, std::string> pragmaValues;
341+
std::multimap<std::string, std::string> PatternLanguage::getPragmaValues(const std::string &code, const std::string &source) const {
342+
std::multimap<std::string, std::string> pragmaValues;
343343

344344
const api::Source plSource(code, source);
345345
const auto result = m_internals.lexer->lex(&plSource);

0 commit comments

Comments
 (0)