line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2171
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
33
|
|
2
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
19
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
########################################################################### |
7
|
|
|
|
|
|
|
########################################################################### |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
{ package Muldis::DB::Engine::Example::Operators; # module |
10
|
|
|
|
|
|
|
our $VERSION = 0.004000; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use bigint; # this is experimental |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
898
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
462
|
use Muldis::DB::Engine::Example::PhysType qw(ptBool ptOrder ptInt |
17
|
|
|
|
|
|
|
ptBlob ptText ptTuple ptQuasiTuple ptRelation ptQuasiRelation |
18
|
|
|
|
|
|
|
ptTypeInvo ptQuasiTypeInvo ptTypeDict ptQuasiTypeDict ptValueDict |
19
|
1
|
|
|
1
|
|
5
|
ptQuasiTypeDict); |
|
1
|
|
|
|
|
2
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $OPS = { # Hash |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
########################################################################### |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## sys.Core.Universal.Universal ## |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
'sys.Core.Universal.is_equal' => sub { |
28
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
29
|
|
|
|
|
|
|
my ($v1, $v2) = @{$ro_args}{'v1', 'v2'}; |
30
|
|
|
|
|
|
|
return ptBool({ 'v' => $v1->equal( $v2 ) }); |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
'sys.Core.Universal.is_not_equal' => sub { |
34
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
35
|
|
|
|
|
|
|
my ($v1, $v2) = @{$ro_args}{'v1', 'v2'}; |
36
|
|
|
|
|
|
|
return ptBool({ 'v' => !$v1->equal( $v2 ) }); |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
'sys.Core.Universal.assign' => sub { |
40
|
|
|
|
|
|
|
my ($dbms, $upd_args, $ro_args) = @_; |
41
|
|
|
|
|
|
|
my ($target) = @{$upd_args}{'target'}; |
42
|
|
|
|
|
|
|
my ($v) = @{$ro_args}{'v'}; |
43
|
|
|
|
|
|
|
$target->store( $v ); |
44
|
|
|
|
|
|
|
return; |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
## sys.Core.Bool.Bool ## |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
## sys.Core.Order.Order ## |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## sys.Core.Int.Int ## |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
'sys.Core.Int.sum' => sub { |
56
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
57
|
|
|
|
|
|
|
my ($addends) = @{$ro_args}{'addends'}; |
58
|
|
|
|
|
|
|
my $sum = 0; |
59
|
|
|
|
|
|
|
for my $addend (@{$addends->array_from_value_attr()}) { |
60
|
|
|
|
|
|
|
$sum += $addend->v(); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
return ptInt({ 'v' => $sum }); |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
'sys.Core.Int.difference' => sub { |
66
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
67
|
|
|
|
|
|
|
my ($minuend, $subtrahend) = @{$ro_args}{'minuend', 'subtrahend'}; |
68
|
|
|
|
|
|
|
return ptInt({ 'v' => $minuend->v() - $subtrahend->v() }); |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
'sys.Core.Int.product' => sub { |
72
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
73
|
|
|
|
|
|
|
my ($factors) = @{$ro_args}{'factors'}; |
74
|
|
|
|
|
|
|
my $product = 1; |
75
|
|
|
|
|
|
|
for my $factor (@{$factors->array_from_value_attr()}) { |
76
|
|
|
|
|
|
|
$product *= $factor->v(); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
return ptInt({ 'v' => $product }); |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
'sys.Core.Int.quotient' => sub { |
82
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
83
|
|
|
|
|
|
|
my ($dividend, $divisor) = @{$ro_args}{'dividend', 'divisor'}; |
84
|
|
|
|
|
|
|
my $divisor_v = $divisor->v(); |
85
|
|
|
|
|
|
|
confess q{sys.Core.Int.quotient(): Arg :$divisor is zero.} |
86
|
|
|
|
|
|
|
if $divisor_v == 0; |
87
|
|
|
|
|
|
|
my $p5_num = $dividend->v() / $divisor_v; |
88
|
|
|
|
|
|
|
my $p5_int |
89
|
|
|
|
|
|
|
= int $p5_num == $p5_num ? $p5_num # includes $p5_num == 0 |
90
|
|
|
|
|
|
|
: $p5_num > 0 ? int $p5_num # floor(2.3) -> 2 |
91
|
|
|
|
|
|
|
: int $p5_num - 1 # floor(-2.3) -> -3 |
92
|
|
|
|
|
|
|
; |
93
|
|
|
|
|
|
|
return ptInt({ 'v' => $p5_int }); |
94
|
|
|
|
|
|
|
}, |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
'sys.Core.Int.remainder' => sub { |
97
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
98
|
|
|
|
|
|
|
my ($dividend, $divisor) = @{$ro_args}{'dividend', 'divisor'}; |
99
|
|
|
|
|
|
|
my $divisor_v = $divisor->v(); |
100
|
|
|
|
|
|
|
confess q{sys.Core.Int.remainder(): Arg :$divisor is zero.} |
101
|
|
|
|
|
|
|
if $divisor_v == 0; |
102
|
|
|
|
|
|
|
return ptInt({ 'v' => $dividend->v() % $divisor_v }); |
103
|
|
|
|
|
|
|
}, |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
'sys.Core.Int.abs' => sub { |
106
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
107
|
|
|
|
|
|
|
my ($v) = @{$ro_args}{'v'}; |
108
|
|
|
|
|
|
|
return ptInt({ 'v' => abs $v->v() }); |
109
|
|
|
|
|
|
|
}, |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
'sys.Core.Int.power' => sub { |
112
|
|
|
|
|
|
|
my ($dbms, $ro_args) = @_; |
113
|
|
|
|
|
|
|
my ($radix, $exponent) = @{$ro_args}{'radix', 'exponent'}; |
114
|
|
|
|
|
|
|
return ptInt({ 'v' => $radix->v() ** $exponent->v() }); |
115
|
|
|
|
|
|
|
}, |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
## sys.Core.Num.Num ## |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
## sys.Core.Blob.Blob ## |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
## sys.Core.Text.Text ## |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
## sys.Core.Tuple.Tuple ## |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
## sys.Core.Relation.Relation ## |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
########################################################################### |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
}; # my Hash $OPS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub get_ops { |
137
|
0
|
|
|
0
|
0
|
|
return $OPS; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} # module Muldis::DB::Engine::Example::Operators |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
########################################################################### |
143
|
|
|
|
|
|
|
########################################################################### |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; # Magic true value required at end of a reusable file's code. |
146
|
|
|
|
|
|
|
__END__ |