@@ -1168,6 +1168,21 @@ DEF_PRIMITIVE(string_startsWith)
11681168 RETURN_BOOL (memcmp (string -> value , search -> value , search -> length ) == 0 );
11691169}
11701170
1171+ static bool string_eqeq (Value lhs , Value rhs ) {
1172+ if (!IS_STRING (rhs )) return false;
1173+ return wrenStringEquals (AS_STRING (lhs ), AS_STRING (rhs ));
1174+ }
1175+
1176+ DEF_PRIMITIVE (string_eqeq )
1177+ {
1178+ RETURN_BOOL (string_eqeq (args [0 ], args [1 ]));
1179+ }
1180+
1181+ DEF_PRIMITIVE (string_bangeq )
1182+ {
1183+ RETURN_BOOL (!string_eqeq (args [0 ], args [1 ]));
1184+ }
1185+
11711186DEF_PRIMITIVE (string_plus )
11721187{
11731188 if (!validateString (vm , args [1 ], "Right operand" )) return false;
@@ -1568,6 +1583,8 @@ void wrenInitializeCore(WrenVM* vm)
15681583 vm -> stringClass = AS_CLASS (wrenFindVariable (vm , coreModule , "String" ));
15691584 PRIMITIVE (vm -> stringClass -> obj .classObj , "fromCodePoint(_)" , string_fromCodePoint );
15701585 PRIMITIVE (vm -> stringClass -> obj .classObj , "fromByte(_)" , string_fromByte );
1586+ PRIMITIVE (vm -> stringClass , "==(_)" , string_eqeq );
1587+ PRIMITIVE (vm -> stringClass , "!=(_)" , string_bangeq );
15711588 PRIMITIVE (vm -> stringClass , "+(_)" , string_plus );
15721589 PRIMITIVE (vm -> stringClass , "[_]" , string_subscript );
15731590 PRIMITIVE (vm -> stringClass , "byteAt_(_)" , string_byteAt );
0 commit comments