Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions inkcpp/numeric_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ namespace casting
// int value can cast to float
case value_type::int32: return static_cast<float>(v.get<value_type::int32>());
case value_type::uint32: return static_cast<float>(v.get<value_type::uint32>());
case value_type::boolean: return v.get<value_type::boolean>() ? 1.0f : 0.0f;
default: inkFail("invalid numeric_cast!"); return 0;
}
}
Expand Down
19 changes: 10 additions & 9 deletions inkcpp/operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ template<typename... T>
ink::runtime::internal::value
ink::runtime::internal::value::redefine(const value& oth, T&... env) const
{
if (type() != oth.type() && (type() == value_type::list_flag || type() == value_type::list)
&& (oth.type() == value_type::list_flag || oth.type() == value_type::list)) {
/// @todo could break origin
if (oth.type() == value_type::list) {
return value{}.set<value_type::list>(oth.get<value_type::list>());
} else {
return value{}.set<value_type::list_flag>(oth.get<value_type::list_flag>());
}
if (type() != oth.type()) {

const value vs[] = {*this, oth};
inkAssert(
casting::common_base<2>(vs) != value_type::none,
"try to redefine value of other type with no cast available"
);

// There's a valid conversion, so redefine as input value.
return oth;
}
inkAssert(type() == oth.type(), "try to redefine value of other type");
return redefine<value_type::OP_BEGIN, T...>(oth, {&env...});
}
Loading