@@ -510,7 +510,7 @@ namespace Ark
510510 // value on the stack
511511 else [[likely]]
512512 {
513- Value* ip;
513+ const Value* ip;
514514 do
515515 {
516516 ip = popAndResolveAsPtr (context);
@@ -556,7 +556,7 @@ namespace Ark
556556 if (!context.saved_scope )
557557 context.saved_scope = Scope ();
558558
559- Value* ptr = findNearestVariable (arg, context);
559+ const Value* ptr = findNearestVariable (arg, context);
560560 if (!ptr)
561561 throwVMError (ErrorKind::Scope, fmt::format (" Couldn't capture `{}' as it is currently unbound" , m_state.m_symbols [arg]));
562562 else
@@ -992,49 +992,49 @@ namespace Ark
992992
993993 TARGET (GT)
994994 {
995- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
995+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
996996 push ((*a != *b && !(*a < *b)) ? Builtins::trueSym : Builtins::falseSym, context);
997997 DISPATCH ();
998998 }
999999
10001000 TARGET (LT)
10011001 {
1002- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1002+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
10031003 push ((*a < *b) ? Builtins::trueSym : Builtins::falseSym, context);
10041004 DISPATCH ();
10051005 }
10061006
10071007 TARGET (LE)
10081008 {
1009- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1009+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
10101010 push ((((*a < *b) || (*a == *b)) ? Builtins::trueSym : Builtins::falseSym), context);
10111011 DISPATCH ();
10121012 }
10131013
10141014 TARGET (GE)
10151015 {
1016- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1016+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
10171017 push (!(*a < *b) ? Builtins::trueSym : Builtins::falseSym, context);
10181018 DISPATCH ();
10191019 }
10201020
10211021 TARGET (NEQ)
10221022 {
1023- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1023+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
10241024 push ((*a != *b) ? Builtins::trueSym : Builtins::falseSym, context);
10251025 DISPATCH ();
10261026 }
10271027
10281028 TARGET (EQ)
10291029 {
1030- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1030+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
10311031 push ((*a == *b) ? Builtins::trueSym : Builtins::falseSym, context);
10321032 DISPATCH ();
10331033 }
10341034
10351035 TARGET (LEN)
10361036 {
1037- Value* a = popAndResolveAsPtr (context);
1037+ const Value* a = popAndResolveAsPtr (context);
10381038
10391039 if (a->valueType () == ValueType::List)
10401040 push (Value (static_cast <int >(a->constList ().size ())), context);
@@ -1051,7 +1051,7 @@ namespace Ark
10511051
10521052 TARGET (EMPTY)
10531053 {
1054- Value* a = popAndResolveAsPtr (context);
1054+ const Value* a = popAndResolveAsPtr (context);
10551055
10561056 if (a->valueType () == ValueType::List)
10571057 push (a->constList ().empty () ? Builtins::trueSym : Builtins::falseSym, context);
@@ -1068,28 +1068,29 @@ namespace Ark
10681068
10691069 TARGET (TAIL)
10701070 {
1071- Value* a = popAndResolveAsPtr (context);
1071+ Value* const a = popAndResolveAsPtr (context);
10721072 push (helper::tail (a), context);
10731073 DISPATCH ();
10741074 }
10751075
10761076 TARGET (HEAD)
10771077 {
1078- Value* a = popAndResolveAsPtr (context);
1078+ Value* const a = popAndResolveAsPtr (context);
10791079 push (helper::head (a), context);
10801080 DISPATCH ();
10811081 }
10821082
10831083 TARGET (ISNIL)
10841084 {
1085- Value* a = popAndResolveAsPtr (context);
1085+ const Value* a = popAndResolveAsPtr (context);
10861086 push ((*a == Builtins::nil) ? Builtins::trueSym : Builtins::falseSym, context);
10871087 DISPATCH ();
10881088 }
10891089
10901090 TARGET (ASSERT)
10911091 {
1092- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1092+ Value* const b = popAndResolveAsPtr (context);
1093+ Value* const a = popAndResolveAsPtr (context);
10931094
10941095 if (b->valueType () != ValueType::String)
10951096 types::generateError (
@@ -1104,7 +1105,7 @@ namespace Ark
11041105
11051106 TARGET (TO_NUM)
11061107 {
1107- Value* a = popAndResolveAsPtr (context);
1108+ const Value* a = popAndResolveAsPtr (context);
11081109
11091110 if (a->valueType () != ValueType::String)
11101111 types::generateError (
@@ -1122,15 +1123,15 @@ namespace Ark
11221123
11231124 TARGET (TO_STR)
11241125 {
1125- Value* a = popAndResolveAsPtr (context);
1126+ const Value* a = popAndResolveAsPtr (context);
11261127 push (Value (a->toString (*this )), context);
11271128 DISPATCH ();
11281129 }
11291130
11301131 TARGET (AT)
11311132 {
11321133 {
1133- Value* b = popAndResolveAsPtr (context);
1134+ const Value* b = popAndResolveAsPtr (context);
11341135 Value a = *popAndResolveAsPtr (context); // be careful, it's not a pointer
11351136
11361137 if (b->valueType () != ValueType::Number)
@@ -1173,8 +1174,8 @@ namespace Ark
11731174 TARGET (AT_AT)
11741175 {
11751176 {
1176- Value* x = popAndResolveAsPtr (context);
1177- Value* y = popAndResolveAsPtr (context);
1177+ const Value* x = popAndResolveAsPtr (context);
1178+ const Value* y = popAndResolveAsPtr (context);
11781179 Value list = *popAndResolveAsPtr (context); // be careful, it's not a pointer
11791180
11801181 if (y->valueType () != ValueType::Number || x->valueType () != ValueType::Number ||
@@ -1217,7 +1218,7 @@ namespace Ark
12171218
12181219 TARGET (MOD)
12191220 {
1220- Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
1221+ const Value *b = popAndResolveAsPtr (context), *a = popAndResolveAsPtr (context);
12211222 if (a->valueType () != ValueType::Number || b->valueType () != ValueType::Number)
12221223 types::generateError (
12231224 " mod" ,
@@ -1229,7 +1230,7 @@ namespace Ark
12291230
12301231 TARGET (TYPE)
12311232 {
1232- Value* a = popAndResolveAsPtr (context);
1233+ const Value* a = popAndResolveAsPtr (context);
12331234 if (a == &m_undefined_value) [[unlikely]]
12341235 types::generateError (
12351236 " type" ,
@@ -1243,14 +1244,15 @@ namespace Ark
12431244 TARGET (HASFIELD)
12441245 {
12451246 {
1246- Value *field = popAndResolveAsPtr (context), *closure = popAndResolveAsPtr (context);
1247+ Value* const field = popAndResolveAsPtr (context);
1248+ Value* const closure = popAndResolveAsPtr (context);
12471249 if (closure->valueType () != ValueType::Closure || field->valueType () != ValueType::String)
12481250 types::generateError (
12491251 " hasField" ,
12501252 { { types::Contract { { types::Typedef (" closure" , ValueType::Closure), types::Typedef (" field" , ValueType::String) } } } },
12511253 { *closure, *field });
12521254
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 ());
12541256 if (it == m_state.m_symbols .end ())
12551257 {
12561258 push (Builtins::falseSym, context);
@@ -1265,7 +1267,7 @@ namespace Ark
12651267
12661268 TARGET (NOT)
12671269 {
1268- Value* a = popAndResolveAsPtr (context);
1270+ const Value* a = popAndResolveAsPtr (context);
12691271 push (!(*a) ? Builtins::trueSym : Builtins::falseSym, context);
12701272 DISPATCH ();
12711273 }
0 commit comments