Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
2a410c0e
Commit
2a410c0e
authored
Jul 18, 2019
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid making top-level `env` in initialization code; ref #4581
parent
0b5e1550
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
31 deletions
+32
-31
mrbgems/mruby-complex/mrblib/complex.rb
mrbgems/mruby-complex/mrblib/complex.rb
+11
-11
mrbgems/mruby-rational/mrblib/rational.rb
mrbgems/mruby-rational/mrblib/rational.rb
+21
-20
No files found.
mrbgems/mruby-complex/mrblib/complex.rb
View file @
2a410c0e
...
...
@@ -104,18 +104,18 @@ class Complex < Numeric
end
alias_method
:imag
,
:imaginary
end
[
Fixnum
,
Float
].
each
do
|
cls
|
[:
+
,
:
-
,
:
*
,
:/
,
:==
].
each
do
|
op
|
cls
.
instance_exec
do
original_operator_name
=
"__original_operator_
#{
op
}
_complex"
alias_method
original_operator_name
,
op
define_method
op
do
|
rhs
|
if
rhs
.
is_a?
Complex
Complex
(
self
).
send
(
op
,
rhs
)
else
send
(
original_operator_name
,
rhs
)
[
Fixnum
,
Float
].
each
do
|
cls
|
[:
+
,
:
-
,
:
*
,
:/
,
:==
].
each
do
|
op
|
cls
.
instance_exec
do
original_operator_name
=
"__original_operator_
#{
op
}
_complex"
alias_method
original_operator_name
,
op
define_method
op
do
|
rhs
|
if
rhs
.
is_a?
Complex
Complex
(
self
).
send
(
op
,
rhs
)
else
send
(
original_operator_name
,
rhs
)
end
end
end
end
...
...
mrbgems/mruby-rational/mrblib/rational.rb
View file @
2a410c0e
...
...
@@ -89,28 +89,29 @@ module Kernel
a
,
b
=
b
,
a
%
b
until
b
==
0
Rational
.
_new
(
numerator
.
div
(
a
),
denominator
.
div
(
a
))
end
end
[:
+
,
:
-
,
:
*
,
:/
,
:<=>
,
:==
,
:<
,
:<=
,
:
>
,
:
>=
].
each
do
|
op
|
Fixnum
.
instance_eval
do
original_operator_name
=
"__original_operator_
#{
op
}
_rational"
alias_method
original_operator_name
,
op
define_method
op
do
|
rhs
|
if
rhs
.
is_a?
Rational
Rational
(
self
).
__send__
(
op
,
rhs
)
else
__send__
(
original_operator_name
,
rhs
)
[:
+
,
:
-
,
:
*
,
:/
,
:<=>
,
:==
,
:<
,
:<=
,
:
>
,
:
>=
].
each
do
|
op
|
Fixnum
.
instance_eval
do
original_operator_name
=
"__original_operator_
#{
op
}
_rational"
alias_method
original_operator_name
,
op
define_method
op
do
|
rhs
|
if
rhs
.
is_a?
Rational
Rational
(
self
).
__send__
(
op
,
rhs
)
else
__send__
(
original_operator_name
,
rhs
)
end
end
end
end
Float
.
instance_eval
do
original_operator_name
=
"__original_operator_
#{
op
}
_rational"
alias_method
original_operator_name
,
op
define_method
op
do
|
rhs
|
if
rhs
.
is_a?
Rational
rhs
=
rhs
.
to_f
Float
.
instance_eval
do
original_operator_name
=
"__original_operator_
#{
op
}
_rational"
alias_method
original_operator_name
,
op
define_method
op
do
|
rhs
|
if
rhs
.
is_a?
Rational
rhs
=
rhs
.
to_f
end
__send__
(
original_operator_name
,
rhs
)
end
__send__
(
original_operator_name
,
rhs
)
end
end
if
Object
.
const_defined?
(
:Float
)
end
if
Object
.
const_defined?
(
:Float
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment