@@ -628,15 +628,15 @@ void LLVMBuildUtils::createValueStore(LLVMRegister *reg, llvm::Value *targetPtr,
628628{
629629 llvm::Value *converted = nullptr ;
630630
631- if (sourceType != Compiler::StaticType::Unknown)
632- converted = castValue (reg, sourceType );
631+ if (targetType != Compiler::StaticType::Unknown)
632+ converted = castValue (reg, targetType );
633633
634- auto it = std::find_if (TYPE_MAP.begin (), TYPE_MAP.end (), [sourceType ](const std::pair<ValueType, Compiler::StaticType> &pair) { return pair.second == sourceType ; });
634+ auto it = std::find_if (TYPE_MAP.begin (), TYPE_MAP.end (), [targetType ](const std::pair<ValueType, Compiler::StaticType> &pair) { return pair.second == targetType ; });
635635 const ValueType mappedType = it == TYPE_MAP.cend () ? ValueType::Number : it->first ; // unknown type can be ignored
636636
637- switch (sourceType ) {
637+ switch (targetType ) {
638638 case Compiler::StaticType::Number:
639- switch (targetType ) {
639+ switch (sourceType ) {
640640 case Compiler::StaticType::Number: {
641641 // Write number to number directly
642642 llvm::Value *ptr = m_builder.CreateStructGEP (m_valueDataType, targetPtr, 0 );
@@ -661,7 +661,7 @@ void LLVMBuildUtils::createValueStore(LLVMRegister *reg, llvm::Value *targetPtr,
661661 break ;
662662
663663 case Compiler::StaticType::Bool:
664- switch (targetType ) {
664+ switch (sourceType ) {
665665 case Compiler::StaticType::Number: {
666666 // Write bool to number value directly and change type
667667 llvm::Value *ptr = m_builder.CreateStructGEP (m_valueDataType, targetPtr, 0 );
@@ -705,10 +705,10 @@ void LLVMBuildUtils::createReusedValueStore(LLVMRegister *reg, llvm::Value *targ
705705 // Same as createValueStore(), but ensures that type is updated
706706 createValueStore (reg, targetPtr, sourceType, targetType);
707707
708- auto it = std::find_if (TYPE_MAP.begin (), TYPE_MAP.end (), [sourceType ](const std::pair<ValueType, Compiler::StaticType> &pair) { return pair.second == sourceType ; });
708+ auto it = std::find_if (TYPE_MAP.begin (), TYPE_MAP.end (), [targetType ](const std::pair<ValueType, Compiler::StaticType> &pair) { return pair.second == targetType ; });
709709 const ValueType mappedType = it == TYPE_MAP.cend () ? ValueType::Number : it->first ; // unknown type can be ignored
710710
711- if ((sourceType == Compiler::StaticType::Number || sourceType == Compiler::StaticType::Bool) && sourceType == targetType ) {
711+ if ((targetType == Compiler::StaticType::Number || targetType == Compiler::StaticType::Bool) && targetType == sourceType ) {
712712 // Update type when writing number to number and bool to bool
713713 llvm::Value *typePtr = m_builder.CreateStructGEP (m_valueDataType, targetPtr, 1 );
714714 m_builder.CreateStore (m_builder.getInt32 (static_cast <uint32_t >(mappedType)), typePtr);
0 commit comments