@@ -158,16 +158,36 @@ class IROptimizer {
158158 case InputOpcode . ADDON_CALL :
159159 break ;
160160
161+ case InputOpcode . CAST_BOOLEAN : {
162+ const innerType = inputs . target . type ;
163+ if ( innerType & InputType . BOOLEAN ) return innerType ;
164+ return InputType . BOOLEAN ;
165+ }
166+
161167 case InputOpcode . CAST_NUMBER : {
162168 const innerType = inputs . target . type ;
163169 if ( innerType & InputType . NUMBER ) return innerType ;
164170 return InputType . NUMBER ;
165- } case InputOpcode . CAST_NUMBER_OR_NAN : {
171+ }
172+
173+ case InputOpcode . CAST_NUMBER_INDEX : {
174+ const innerType = inputs . target . type ;
175+ if ( innerType & InputType . NUMBER_INDEX ) return innerType ;
176+ return InputType . NUMBER_INDEX ;
177+ }
178+
179+ case InputOpcode . CAST_NUMBER_OR_NAN : {
166180 const innerType = inputs . target . type ;
167181 if ( innerType & InputType . NUMBER_OR_NAN ) return innerType ;
168182 return InputType . NUMBER_OR_NAN ;
169183 }
170184
185+ case InputOpcode . CAST_STRING : {
186+ const innerType = inputs . target . type ;
187+ if ( innerType & InputType . STRING ) return innerType ;
188+ return InputType . STRING ;
189+ }
190+
171191 case InputOpcode . OP_ADD : {
172192 const leftType = inputs . left . type ;
173193 const rightType = inputs . right . type ;
@@ -703,19 +723,45 @@ class IROptimizer {
703723 }
704724
705725 switch ( input . opcode ) {
726+ case InputOpcode . CAST_BOOLEAN : {
727+ const targetType = input . inputs . target . type ;
728+ if ( ( targetType & InputType . BOOLEAN ) === targetType ) {
729+ return input . inputs . target ;
730+ }
731+ return input ;
732+ }
733+
706734 case InputOpcode . CAST_NUMBER : {
707735 const targetType = input . inputs . target . type ;
708736 if ( ( targetType & InputType . NUMBER ) === targetType ) {
709737 return input . inputs . target ;
710738 }
711739 return input ;
712- } case InputOpcode . CAST_NUMBER_OR_NAN : {
740+ }
741+
742+ case InputOpcode . CAST_NUMBER_INDEX : {
743+ const targetType = input . inputs . target . type ;
744+ if ( ( targetType & InputType . NUMBER_INDEX ) === targetType ) {
745+ return input . inputs . target ;
746+ }
747+ return input ;
748+ }
749+
750+ case InputOpcode . CAST_NUMBER_OR_NAN : {
713751 const targetType = input . inputs . target . type ;
714752 if ( ( targetType & InputType . NUMBER_OR_NAN ) === targetType ) {
715753 return input . inputs . target ;
716754 }
717755 return input ;
718756 }
757+
758+ case InputOpcode . CAST_STRING : {
759+ const targetType = input . inputs . target . type ;
760+ if ( ( targetType & InputType . STRING ) === targetType ) {
761+ return input . inputs . target ;
762+ }
763+ return input ;
764+ }
719765 }
720766
721767 return input ;
0 commit comments