diff --git a/src/include/midend/IR.h b/src/include/midend/IR.h index 6d21f04..8828a79 100644 --- a/src/include/midend/IR.h +++ b/src/include/midend/IR.h @@ -359,12 +359,25 @@ public: // Helper methods to access constant values with appropriate casting int getInt() const { - assert(getType()->isInt() && "Calling getInt() on non-integer type"); - return std::get(getVal()); + auto val = getVal(); + if (std::holds_alternative(val)) { + return std::get(val); + } else if (std::holds_alternative(val)) { + return static_cast(std::get(val)); + } + // Handle other possible types if needed + return 0; // Default fallback } + float getFloat() const { - assert(getType()->isFloat() && "Calling getFloat() on non-float type"); - return std::get(getVal()); + auto val = getVal(); + if (std::holds_alternative(val)) { + return std::get(val); + } else if (std::holds_alternative(val)) { + return static_cast(std::get(val)); + } + // Handle other possible types if needed + return 0.0f; // Default fallback } template