@solve.implementation(for_type=ast.Cast)<EOL>def solve_cast(expr, vars):
lhs = solve(expr.lhs, vars).value<EOL>t = solve(expr.rhs, vars).value<EOL>if t is None:<EOL><INDENT>raise errors.EfilterTypeError(<EOL>root=expr, query=expr.source,<EOL>message="<STR_LIT>" % expr.rhs.value)<EOL><DEDENT>if not isinstance(t, type):<EOL><INDENT>raise errors.EfilterTypeError(<EOL>root=expr.rhs, query=expr.source,<EOL>message="<STR_LIT>" % (t,))<EOL><DEDENT>try:<EOL><INDENT>cast_value = t(lhs)<EOL><DEDENT>except TypeError:<EOL><INDENT>raise errors.EfilterTypeError(<EOL>root=expr, query=expr.source,<EOL>message="<STR_LIT>" % (type(lhs), t))<EOL><DEDENT>return Result(cast_value, ())<EOL>
Get cast LHS to RHS.