@@ -65,14 +65,14 @@ namespace pl::lib::libstd::mem {
65
65
section = ctx->getUserSectionId ();
66
66
67
67
if (section != ptrn::Pattern::MainSectionId)
68
- return 0 ;
68
+ return u128 ( 0x00 ) ;
69
69
70
70
return u128 (ctx->getDataBaseAddress ());
71
71
});
72
72
73
73
/* size() */
74
74
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;
76
76
if (section == 0xFFFF'FFFF'FFFF'FFFF )
77
77
section = ctx->getUserSectionId ();
78
78
@@ -81,9 +81,9 @@ namespace pl::lib::libstd::mem {
81
81
82
82
/* find_sequence_in_range(occurrence_index, start_offset, end_offset, bytes...) */
83
83
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 () );
87
87
88
88
std::vector<u8 > sequence;
89
89
for (u32 i = 3 ; i < params.size (); i++) {
@@ -100,20 +100,20 @@ namespace pl::lib::libstd::mem {
100
100
101
101
/* find_string_in_range(occurrence_index, start_offset, end_offset, string) */
102
102
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 );
107
107
108
108
return findSequence (ctx, occurrenceIndex, offsetFrom, offsetTo, ctx->getUserSectionId (), std::vector<u8 >(string.data (), string.data () + string.size ())).value_or (-1 );
109
109
});
110
110
111
111
/* read_unsigned(address, size, endian, section) */
112
112
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 () );
115
115
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;
117
117
if (section == 0xFFFF'FFFF'FFFF'FFFF )
118
118
section = ctx->getUserSectionId ();
119
119
@@ -129,10 +129,10 @@ namespace pl::lib::libstd::mem {
129
129
130
130
/* read_signed(address, size, endian, section) */
131
131
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 () );
134
134
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;
136
136
if (section == 0xFFFF'FFFF'FFFF'FFFF )
137
137
section = ctx->getUserSectionId ();
138
138
@@ -149,9 +149,9 @@ namespace pl::lib::libstd::mem {
149
149
150
150
/* read_string(address, size, endian, section) */
151
151
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;
155
155
if (section == 0xFFFF'FFFF'FFFF'FFFF )
156
156
section = ctx->getUserSectionId ();
157
157
0 commit comments