Refactor get_string_constant function into string_ptr context method