line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sidef::Convert::Convert { |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This module is used only as parent! |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
439
|
use 5.014; |
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
10
|
use overload; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
71
|
use Sidef::Types::Bool::Bool; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
784
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub to_str { |
10
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
11
|
0
|
0
|
0
|
|
|
|
UNIVERSAL::isa($self, 'SCALAR') |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|| UNIVERSAL::isa($self, 'REF') |
13
|
|
|
|
|
|
|
? Sidef::Types::String::String->new(overload::StrVal($self) ? "$self" : defined($$self) ? "$$self" : "") |
14
|
|
|
|
|
|
|
: $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
*to_s = \&to_str; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub to_obj { |
20
|
0
|
|
|
0
|
1
|
|
my ($self, $obj) = @_; |
21
|
0
|
0
|
|
|
|
|
return $self if ref($self) eq ref($obj); |
22
|
0
|
|
|
|
|
|
$obj->new($self); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub to_int { |
26
|
0
|
|
|
0
|
0
|
|
Sidef::Types::Number::Number->new($_[0])->int; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
*to_i = \&to_int; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub to_num { |
32
|
0
|
|
|
0
|
0
|
|
Sidef::Types::Number::Number->new($_[0]); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
*to_n = \&to_num; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub to_float { |
38
|
0
|
|
|
0
|
0
|
|
Sidef::Types::Number::Number->new($_[0])->float; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
*to_f = \&to_float; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub to_rat { |
44
|
0
|
|
|
0
|
0
|
|
Sidef::Types::Number::Number->new($_[0])->rat; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
*to_r = \&to_rat; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub to_array { |
50
|
0
|
|
|
0
|
0
|
|
Sidef::Types::Array::Array->new($_[0]); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
*to_a = \&to_array; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub to_file { |
56
|
0
|
|
|
0
|
1
|
|
Sidef::Types::Glob::File->new("$_[0]"); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub to_dir { |
60
|
0
|
|
|
0
|
1
|
|
Sidef::Types::Glob::Dir->new("$_[0]"); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub to_bool { |
64
|
0
|
0
|
|
0
|
0
|
|
$_[0] |
65
|
|
|
|
|
|
|
? (Sidef::Types::Bool::Bool::TRUE) |
66
|
|
|
|
|
|
|
: (Sidef::Types::Bool::Bool::FALSE); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
*to_b = \&to_bool; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub to_regex { |
72
|
0
|
|
|
0
|
0
|
|
Sidef::Types::Regex::Regex->new("$_[0]"); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
*to_re = \&to_regex; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub to_caller { |
78
|
0
|
|
|
0
|
1
|
|
Sidef::Module::OO->__NEW__("$_[0]"); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub to_fcaller { |
82
|
0
|
|
|
0
|
1
|
|
Sidef::Module::Func->__NEW__("$_[0]"); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1 |