@@ -510,7 +510,7 @@ namespace Ark
510
510
// value on the stack
511
511
else [[likely]]
512
512
{
513
- Value* ip;
513
+ const Value* ip;
514
514
do
515
515
{
516
516
ip = popAndResolveAsPtr (context);
@@ -556,7 +556,7 @@ namespace Ark
556
556
if (!context.saved_scope )
557
557
context.saved_scope = Scope ();
558
558
559
- Value* ptr = findNearestVariable (arg, context);
559
+ const Value* ptr = findNearestVariable (arg, context);
560
560
if (!ptr)
561
561
throwVMError (ErrorKind::Scope, fmt::format (" Couldn't capture `{}' as it is currently unbound" , m_state.m_symbols [arg]));
562
562
else
@@ -992,49 +992,49 @@ namespace Ark
992
992
993
993
TARGET (GT)
994
994
{
995
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
995
+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
996
996
push ((*a != *b && !(*a < *b)) ? Builtins::trueSym : Builtins::falseSym, context);
997
997
DISPATCH ();
998
998
}
999
999
1000
1000
TARGET (LT)
1001
1001
{
1002
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1002
+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1003
1003
push ((*a < *b) ? Builtins::trueSym : Builtins::falseSym, context);
1004
1004
DISPATCH ();
1005
1005
}
1006
1006
1007
1007
TARGET (LE)
1008
1008
{
1009
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1009
+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1010
1010
push ((((*a < *b) || (*a == *b)) ? Builtins::trueSym : Builtins::falseSym), context);
1011
1011
DISPATCH ();
1012
1012
}
1013
1013
1014
1014
TARGET (GE)
1015
1015
{
1016
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1016
+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1017
1017
push (!(*a < *b) ? Builtins::trueSym : Builtins::falseSym, context);
1018
1018
DISPATCH ();
1019
1019
}
1020
1020
1021
1021
TARGET (NEQ)
1022
1022
{
1023
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1023
+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1024
1024
push ((*a != *b) ? Builtins::trueSym : Builtins::falseSym, context);
1025
1025
DISPATCH ();
1026
1026
}
1027
1027
1028
1028
TARGET (EQ)
1029
1029
{
1030
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1030
+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1031
1031
push ((*a == *b) ? Builtins::trueSym : Builtins::falseSym, context);
1032
1032
DISPATCH ();
1033
1033
}
1034
1034
1035
1035
TARGET (LEN)
1036
1036
{
1037
- Value* a = popAndResolveAsPtr (context);
1037
+ const Value* a = popAndResolveAsPtr (context);
1038
1038
1039
1039
if (a->valueType () == ValueType::List)
1040
1040
push (Value (static_cast <int >(a->constList ().size ())), context);
@@ -1051,7 +1051,7 @@ namespace Ark
1051
1051
1052
1052
TARGET (EMPTY)
1053
1053
{
1054
- Value* a = popAndResolveAsPtr (context);
1054
+ const Value* a = popAndResolveAsPtr (context);
1055
1055
1056
1056
if (a->valueType () == ValueType::List)
1057
1057
push (a->constList ().empty () ? Builtins::trueSym : Builtins::falseSym, context);
@@ -1068,28 +1068,29 @@ namespace Ark
1068
1068
1069
1069
TARGET (TAIL)
1070
1070
{
1071
- Value* a = popAndResolveAsPtr (context);
1071
+ Value* const a = popAndResolveAsPtr (context);
1072
1072
push (helper::tail (a), context);
1073
1073
DISPATCH ();
1074
1074
}
1075
1075
1076
1076
TARGET (HEAD)
1077
1077
{
1078
- Value* a = popAndResolveAsPtr (context);
1078
+ Value* const a = popAndResolveAsPtr (context);
1079
1079
push (helper::head (a), context);
1080
1080
DISPATCH ();
1081
1081
}
1082
1082
1083
1083
TARGET (ISNIL)
1084
1084
{
1085
- Value* a = popAndResolveAsPtr (context);
1085
+ const Value* a = popAndResolveAsPtr (context);
1086
1086
push ((*a == Builtins::nil) ? Builtins::trueSym : Builtins::falseSym, context);
1087
1087
DISPATCH ();
1088
1088
}
1089
1089
1090
1090
TARGET (ASSERT)
1091
1091
{
1092
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1092
+ Value* const b = popAndResolveAsPtr (context);
1093
+ Value* const a = popAndResolveAsPtr (context);
1093
1094
1094
1095
if (b->valueType () != ValueType::String)
1095
1096
types::generateError (
@@ -1104,7 +1105,7 @@ namespace Ark
1104
1105
1105
1106
TARGET (TO_NUM)
1106
1107
{
1107
- Value* a = popAndResolveAsPtr (context);
1108
+ const Value* a = popAndResolveAsPtr (context);
1108
1109
1109
1110
if (a->valueType () != ValueType::String)
1110
1111
types::generateError (
@@ -1122,15 +1123,15 @@ namespace Ark
1122
1123
1123
1124
TARGET (TO_STR)
1124
1125
{
1125
- Value* a = popAndResolveAsPtr (context);
1126
+ const Value* a = popAndResolveAsPtr (context);
1126
1127
push (Value (a->toString (*this )), context);
1127
1128
DISPATCH ();
1128
1129
}
1129
1130
1130
1131
TARGET (AT)
1131
1132
{
1132
1133
{
1133
- Value* b = popAndResolveAsPtr (context);
1134
+ const Value* b = popAndResolveAsPtr (context);
1134
1135
Value a = *popAndResolveAsPtr (context); // be careful, it's not a pointer
1135
1136
1136
1137
if (b->valueType () != ValueType::Number)
@@ -1173,8 +1174,8 @@ namespace Ark
1173
1174
TARGET (AT_AT)
1174
1175
{
1175
1176
{
1176
- Value* x = popAndResolveAsPtr (context);
1177
- Value* y = popAndResolveAsPtr (context);
1177
+ const Value* x = popAndResolveAsPtr (context);
1178
+ const Value* y = popAndResolveAsPtr (context);
1178
1179
Value list = *popAndResolveAsPtr (context); // be careful, it's not a pointer
1179
1180
1180
1181
if (y->valueType () != ValueType::Number || x->valueType () != ValueType::Number ||
@@ -1217,7 +1218,7 @@ namespace Ark
1217
1218
1218
1219
TARGET (MOD)
1219
1220
{
1220
- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1221
+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1221
1222
if (a->valueType () != ValueType::Number || b->valueType () != ValueType::Number)
1222
1223
types::generateError (
1223
1224
" mod" ,
@@ -1229,7 +1230,7 @@ namespace Ark
1229
1230
1230
1231
TARGET (TYPE)
1231
1232
{
1232
- Value* a = popAndResolveAsPtr (context);
1233
+ const Value* a = popAndResolveAsPtr (context);
1233
1234
if (a == &m_undefined_value) [[unlikely]]
1234
1235
types::generateError (
1235
1236
" type" ,
@@ -1243,14 +1244,15 @@ namespace Ark
1243
1244
TARGET (HASFIELD)
1244
1245
{
1245
1246
{
1246
- Value *field = popAndResolveAsPtr (context), *closure = popAndResolveAsPtr (context);
1247
+ Value* const field = popAndResolveAsPtr (context);
1248
+ Value* const closure = popAndResolveAsPtr (context);
1247
1249
if (closure->valueType () != ValueType::Closure || field->valueType () != ValueType::String)
1248
1250
types::generateError (
1249
1251
" hasField" ,
1250
1252
{ { types::Contract { { types::Typedef (" closure" , ValueType::Closure), types::Typedef (" field" , ValueType::String) } } } },
1251
1253
{ *closure, *field });
1252
1254
1253
- auto it = std::find (m_state.m_symbols . begin (), m_state. m_symbols . end () , field->stringRef ());
1255
+ auto it = std::ranges:: find (m_state.m_symbols , field->stringRef ());
1254
1256
if (it == m_state.m_symbols .end ())
1255
1257
{
1256
1258
push (Builtins::falseSym, context);
@@ -1265,7 +1267,7 @@ namespace Ark
1265
1267
1266
1268
TARGET (NOT)
1267
1269
{
1268
- Value* a = popAndResolveAsPtr (context);
1270
+ const Value* a = popAndResolveAsPtr (context);
1269
1271
push (!(*a) ? Builtins::trueSym : Builtins::falseSym, context);
1270
1272
DISPATCH ();
1271
1273
}
0 commit comments