opal 1.6.0 → 1.7.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +17 -0
- data/CHANGELOG.md +15 -1
- data/Gemfile +2 -0
- data/HACKING.md +47 -26
- data/UNRELEASED.md +27 -0
- data/benchmark/benchmarks +415 -103
- data/benchmark/bm_call_overhead.yml +28 -0
- data/benchmark/run.rb +61 -40
- data/docs/cdp_common.json +3364 -0
- data/docs/cdp_common.md +18 -0
- data/docs/{headless_chrome.md → headless_browsers.md} +31 -12
- data/lib/opal/ast/builder.rb +1 -1
- data/lib/opal/builder.rb +8 -2
- data/lib/opal/builder_processors.rb +5 -3
- data/lib/opal/builder_scheduler.rb +1 -1
- data/lib/opal/cache.rb +1 -7
- data/lib/opal/cli_options.rb +72 -58
- data/lib/opal/cli_runners/chrome.rb +47 -9
- data/lib/opal/cli_runners/chrome_cdp_interface.rb +238 -112
- data/lib/opal/cli_runners/compiler.rb +146 -13
- data/lib/opal/cli_runners/deno.rb +32 -0
- data/lib/opal/cli_runners/firefox.rb +350 -0
- data/lib/opal/cli_runners/firefox_cdp_interface.rb +212 -0
- data/lib/opal/cli_runners/node_modules/.bin/chrome-remote-interface.cmd +17 -0
- data/lib/opal/cli_runners/node_modules/.bin/chrome-remote-interface.ps1 +28 -0
- data/lib/opal/cli_runners/node_modules/.package-lock.json +41 -0
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/LICENSE +1 -1
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/README.md +322 -182
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/bin/client.js +99 -114
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/chrome-remote-interface.js +1 -11
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/index.js +16 -11
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/api.js +41 -33
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/chrome.js +224 -214
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/devtools.js +71 -191
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/external-request.js +26 -6
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/protocol.json +20788 -9049
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/websocket-wrapper.js +10 -3
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/package.json +59 -123
- data/lib/opal/cli_runners/node_modules/chrome-remote-interface/webpack.config.js +25 -32
- data/lib/opal/cli_runners/node_modules/commander/History.md +298 -0
- data/lib/opal/cli_runners/node_modules/commander/LICENSE +22 -0
- data/lib/opal/cli_runners/node_modules/commander/Readme.md +217 -61
- data/lib/opal/cli_runners/node_modules/commander/index.js +431 -145
- data/lib/opal/cli_runners/node_modules/commander/package.json +16 -79
- data/lib/opal/cli_runners/node_modules/ws/README.md +334 -98
- data/lib/opal/cli_runners/node_modules/ws/browser.js +8 -0
- data/lib/opal/cli_runners/node_modules/ws/index.js +5 -10
- data/lib/opal/cli_runners/node_modules/ws/lib/buffer-util.js +129 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/constants.js +10 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/event-target.js +184 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/extension.js +223 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/limiter.js +55 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/permessage-deflate.js +518 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/receiver.js +607 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/sender.js +409 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/stream.js +180 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/validation.js +104 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/websocket-server.js +447 -0
- data/lib/opal/cli_runners/node_modules/ws/lib/websocket.js +1195 -0
- data/lib/opal/cli_runners/node_modules/ws/package.json +40 -106
- data/lib/opal/cli_runners/package-lock.json +62 -0
- data/lib/opal/cli_runners/package.json +1 -1
- data/lib/opal/cli_runners.rb +26 -4
- data/lib/opal/nodes/args/prepare_post_args.rb +2 -2
- data/lib/opal/nodes/def.rb +8 -8
- data/lib/opal/nodes/iter.rb +12 -12
- data/lib/opal/nodes/logic.rb +1 -1
- data/lib/opal/nodes/masgn.rb +2 -2
- data/lib/opal/parser/with_ruby_lexer.rb +1 -1
- data/lib/opal/paths.rb +14 -0
- data/lib/opal/rewriter.rb +2 -0
- data/lib/opal/rewriters/forward_args.rb +52 -4
- data/lib/opal/rewriters/targeted_patches.rb +94 -0
- data/lib/opal/version.rb +1 -1
- data/opal/corelib/basic_object.rb +1 -1
- data/opal/corelib/boolean.rb +2 -2
- data/opal/corelib/class.rb +11 -0
- data/opal/corelib/constants.rb +3 -3
- data/opal/corelib/enumerable.rb +4 -0
- data/opal/corelib/enumerator.rb +1 -1
- data/opal/corelib/hash.rb +2 -2
- data/opal/corelib/helpers.rb +1 -1
- data/opal/corelib/kernel.rb +3 -3
- data/opal/corelib/method.rb +1 -1
- data/opal/corelib/module.rb +29 -8
- data/opal/corelib/proc.rb +7 -5
- data/opal/corelib/runtime.js +141 -78
- data/opal/corelib/set.rb +252 -0
- data/opal/corelib/string.rb +2 -1
- data/opal/corelib/time.rb +2 -2
- data/opal/opal.rb +1 -0
- data/opal.gemspec +1 -0
- data/spec/filters/bugs/array.rb +22 -13
- data/spec/filters/bugs/base64.rb +5 -5
- data/spec/filters/bugs/basicobject.rb +16 -8
- data/spec/filters/bugs/bigdecimal.rb +161 -160
- data/spec/filters/bugs/binding.rb +10 -10
- data/spec/filters/bugs/class.rb +8 -8
- data/spec/filters/bugs/complex.rb +2 -1
- data/spec/filters/bugs/date.rb +79 -81
- data/spec/filters/bugs/datetime.rb +29 -29
- data/spec/filters/bugs/delegate.rb +1 -3
- data/spec/filters/bugs/encoding.rb +69 -69
- data/spec/filters/bugs/enumerable.rb +22 -20
- data/spec/filters/bugs/enumerator.rb +88 -85
- data/spec/filters/bugs/exception.rb +46 -40
- data/spec/filters/bugs/file.rb +32 -32
- data/spec/filters/bugs/float.rb +26 -21
- data/spec/filters/bugs/freeze.rb +88 -0
- data/spec/filters/bugs/hash.rb +39 -38
- data/spec/filters/bugs/integer.rb +57 -44
- data/spec/filters/bugs/io.rb +1 -1
- data/spec/filters/bugs/kernel.rb +349 -269
- data/spec/filters/bugs/language.rb +220 -188
- data/spec/filters/bugs/main.rb +5 -3
- data/spec/filters/bugs/marshal.rb +38 -38
- data/spec/filters/bugs/math.rb +2 -1
- data/spec/filters/bugs/method.rb +73 -62
- data/spec/filters/bugs/module.rb +163 -143
- data/spec/filters/bugs/numeric.rb +6 -6
- data/spec/filters/bugs/objectspace.rb +16 -16
- data/spec/filters/bugs/openstruct.rb +1 -1
- data/spec/filters/bugs/pack_unpack.rb +51 -51
- data/spec/filters/bugs/pathname.rb +7 -7
- data/spec/filters/bugs/proc.rb +63 -63
- data/spec/filters/bugs/random.rb +7 -6
- data/spec/filters/bugs/range.rb +12 -9
- data/spec/filters/bugs/rational.rb +8 -7
- data/spec/filters/bugs/regexp.rb +49 -48
- data/spec/filters/bugs/ruby-32.rb +56 -0
- data/spec/filters/bugs/set.rb +30 -30
- data/spec/filters/bugs/singleton.rb +4 -4
- data/spec/filters/bugs/string.rb +187 -99
- data/spec/filters/bugs/stringio.rb +7 -0
- data/spec/filters/bugs/stringscanner.rb +68 -68
- data/spec/filters/bugs/struct.rb +11 -9
- data/spec/filters/bugs/symbol.rb +1 -1
- data/spec/filters/bugs/time.rb +78 -63
- data/spec/filters/bugs/trace_point.rb +4 -4
- data/spec/filters/bugs/unboundmethod.rb +32 -17
- data/spec/filters/bugs/warnings.rb +8 -12
- data/spec/filters/unsupported/array.rb +24 -107
- data/spec/filters/unsupported/basicobject.rb +12 -12
- data/spec/filters/unsupported/bignum.rb +27 -52
- data/spec/filters/unsupported/class.rb +1 -2
- data/spec/filters/unsupported/delegator.rb +3 -3
- data/spec/filters/unsupported/enumerable.rb +2 -9
- data/spec/filters/unsupported/enumerator.rb +2 -11
- data/spec/filters/unsupported/file.rb +1 -1
- data/spec/filters/unsupported/float.rb +28 -47
- data/spec/filters/unsupported/hash.rb +8 -14
- data/spec/filters/unsupported/integer.rb +75 -91
- data/spec/filters/unsupported/kernel.rb +17 -35
- data/spec/filters/unsupported/language.rb +11 -19
- data/spec/filters/unsupported/marshal.rb +22 -41
- data/spec/filters/unsupported/matchdata.rb +28 -52
- data/spec/filters/unsupported/math.rb +1 -1
- data/spec/filters/unsupported/privacy.rb +229 -285
- data/spec/filters/unsupported/range.rb +1 -5
- data/spec/filters/unsupported/regexp.rb +40 -66
- data/spec/filters/unsupported/set.rb +2 -2
- data/spec/filters/unsupported/singleton.rb +4 -4
- data/spec/filters/unsupported/string.rb +305 -508
- data/spec/filters/unsupported/struct.rb +3 -4
- data/spec/filters/unsupported/symbol.rb +15 -18
- data/spec/filters/unsupported/thread.rb +1 -7
- data/spec/filters/unsupported/time.rb +159 -202
- data/spec/filters/unsupported/usage_of_files.rb +170 -259
- data/spec/lib/builder_spec.rb +14 -4
- data/spec/lib/rewriters/forward_args_spec.rb +32 -12
- data/spec/mspec-opal/runner.rb +2 -0
- data/spec/ruby_specs +4 -0
- data/stdlib/deno/base.rb +28 -0
- data/stdlib/deno/file.rb +340 -0
- data/stdlib/{headless_chrome.rb → headless_browser/base.rb} +1 -1
- data/stdlib/headless_browser/file.rb +15 -0
- data/stdlib/headless_browser.rb +4 -0
- data/stdlib/native.rb +1 -1
- data/stdlib/nodejs/file.rb +5 -0
- data/stdlib/opal/platform.rb +8 -6
- data/stdlib/opal-platform.rb +14 -8
- data/stdlib/set.rb +1 -258
- data/tasks/benchmarking.rake +62 -19
- data/tasks/building.rake +6 -2
- data/tasks/performance.rake +1 -1
- data/tasks/testing.rake +5 -3
- data/test/nodejs/test_file.rb +29 -10
- data/test/opal/http_server.rb +28 -11
- data/test/opal/unsupported_and_bugs.rb +2 -1
- metadata +92 -53
- data/lib/opal/cli_runners/node_modules/ultron/LICENSE +0 -22
- data/lib/opal/cli_runners/node_modules/ultron/index.js +0 -138
- data/lib/opal/cli_runners/node_modules/ultron/package.json +0 -112
- data/lib/opal/cli_runners/node_modules/ws/SECURITY.md +0 -33
- data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.fallback.js +0 -56
- data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.js +0 -15
- data/lib/opal/cli_runners/node_modules/ws/lib/ErrorCodes.js +0 -28
- data/lib/opal/cli_runners/node_modules/ws/lib/EventTarget.js +0 -158
- data/lib/opal/cli_runners/node_modules/ws/lib/Extensions.js +0 -69
- data/lib/opal/cli_runners/node_modules/ws/lib/PerMessageDeflate.js +0 -339
- data/lib/opal/cli_runners/node_modules/ws/lib/Receiver.js +0 -520
- data/lib/opal/cli_runners/node_modules/ws/lib/Sender.js +0 -438
- data/lib/opal/cli_runners/node_modules/ws/lib/Validation.fallback.js +0 -9
- data/lib/opal/cli_runners/node_modules/ws/lib/Validation.js +0 -17
- data/lib/opal/cli_runners/node_modules/ws/lib/WebSocket.js +0 -705
- data/lib/opal/cli_runners/node_modules/ws/lib/WebSocketServer.js +0 -336
- data/spec/filters/bugs/boolean.rb +0 -3
- data/spec/filters/bugs/matrix.rb +0 -3
- data/spec/filters/unsupported/fixnum.rb +0 -15
- data/spec/filters/unsupported/freeze.rb +0 -102
- data/spec/filters/unsupported/pathname.rb +0 -4
- data/spec/filters/unsupported/proc.rb +0 -4
- data/spec/filters/unsupported/random.rb +0 -5
- data/spec/filters/unsupported/taint.rb +0 -162
data/opal/corelib/boolean.rb
CHANGED
@@ -90,13 +90,13 @@ class ::Boolean < `Boolean`
|
|
90
90
|
# the methods defined on Boolean, but our implementation doesn't allow that,
|
91
91
|
# unless you define them on Boolean and not on TrueClass/FalseClass.
|
92
92
|
def method_missing(method, *args, &block)
|
93
|
-
`var body = self.$$class.$$prototype[
|
93
|
+
`var body = self.$$class.$$prototype[Opal.jsid(#{method})]`
|
94
94
|
super unless `typeof body !== 'undefined' && !body.$$stub`
|
95
95
|
`Opal.send(self, body, #{args}, #{block})`
|
96
96
|
end
|
97
97
|
|
98
98
|
def respond_to_missing?(method, _include_all = false)
|
99
|
-
`var body = self.$$class.$$prototype[
|
99
|
+
`var body = self.$$class.$$prototype[Opal.jsid(#{method})]`
|
100
100
|
`typeof body !== 'undefined' && !body.$$stub`
|
101
101
|
end
|
102
102
|
|
data/opal/corelib/class.rb
CHANGED
@@ -83,5 +83,16 @@ class ::Class
|
|
83
83
|
}
|
84
84
|
end
|
85
85
|
|
86
|
+
def attached_object
|
87
|
+
%x{
|
88
|
+
if (self.$$singleton_of != null) {
|
89
|
+
return self.$$singleton_of;
|
90
|
+
}
|
91
|
+
else {
|
92
|
+
#{::Kernel.raise ::TypeError, "`#{self}' is not a singleton class"}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
86
97
|
alias inspect to_s
|
87
98
|
end
|
data/opal/corelib/constants.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
::RUBY_PLATFORM = 'opal'
|
2
2
|
::RUBY_ENGINE = 'opal'
|
3
|
-
::RUBY_VERSION = '3.
|
4
|
-
::RUBY_ENGINE_VERSION = '1.
|
5
|
-
::RUBY_RELEASE_DATE = '2022-
|
3
|
+
::RUBY_VERSION = '3.2.0'
|
4
|
+
::RUBY_ENGINE_VERSION = '1.7.0.rc1'
|
5
|
+
::RUBY_RELEASE_DATE = '2022-12-22'
|
6
6
|
::RUBY_PATCHLEVEL = 0
|
7
7
|
::RUBY_REVISION = '0'
|
8
8
|
::RUBY_COPYRIGHT = 'opal - Copyright (C) 2013-2022 Adam Beynon and the Opal contributors'
|
data/opal/corelib/enumerable.rb
CHANGED
data/opal/corelib/enumerator.rb
CHANGED
data/opal/corelib/hash.rb
CHANGED
@@ -1031,7 +1031,7 @@ class ::Hash
|
|
1031
1031
|
return [key, $hash_delete(self, key)];
|
1032
1032
|
}
|
1033
1033
|
|
1034
|
-
return
|
1034
|
+
return nil;
|
1035
1035
|
}
|
1036
1036
|
end
|
1037
1037
|
|
@@ -1136,7 +1136,7 @@ class ::Hash
|
|
1136
1136
|
%x{
|
1137
1137
|
$deny_frozen_access(self);
|
1138
1138
|
|
1139
|
-
var keys = Opal.slice
|
1139
|
+
var keys = Opal.slice(self.$$keys),
|
1140
1140
|
i, length = keys.length, key, value, new_key;
|
1141
1141
|
|
1142
1142
|
for (i = 0; i < length; i++) {
|
data/opal/corelib/helpers.rb
CHANGED
@@ -147,7 +147,7 @@ module ::Opal
|
|
147
147
|
var method_name, method;
|
148
148
|
for (var i = method_names.length - 1; i >= 0; i--) {
|
149
149
|
method_name = method_names[i];
|
150
|
-
method = owner_class.$$prototype[
|
150
|
+
method = owner_class.$$prototype[Opal.jsid(method_name)];
|
151
151
|
|
152
152
|
if (method && !method.$$stub) {
|
153
153
|
method.$$pristine = true;
|
data/opal/corelib/kernel.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# helpers: truthy, coerce_to, respond_to, Opal, deny_frozen_access, freeze, freeze_props
|
1
|
+
# helpers: truthy, coerce_to, respond_to, Opal, deny_frozen_access, freeze, freeze_props, jsid
|
2
2
|
# use_strict: true
|
3
3
|
|
4
4
|
module ::Kernel
|
@@ -31,7 +31,7 @@ module ::Kernel
|
|
31
31
|
|
32
32
|
def method(name)
|
33
33
|
%x{
|
34
|
-
var meth = self[
|
34
|
+
var meth = self[$jsid(name)];
|
35
35
|
|
36
36
|
if (!meth || meth.$$stub) {
|
37
37
|
#{::Kernel.raise ::NameError.new("undefined method `#{name}' for class `#{self.class}'", name)};
|
@@ -662,7 +662,7 @@ module ::Kernel
|
|
662
662
|
|
663
663
|
def respond_to?(name, include_all = false)
|
664
664
|
%x{
|
665
|
-
var body = self[
|
665
|
+
var body = self[$jsid(name)];
|
666
666
|
|
667
667
|
if (typeof(body) === "function" && !body.$$stub) {
|
668
668
|
return true;
|
data/opal/corelib/method.rb
CHANGED
@@ -53,7 +53,7 @@ class ::Method
|
|
53
53
|
var proc = self.$call.bind(self);
|
54
54
|
proc.$$unbound = #{@method};
|
55
55
|
proc.$$is_lambda = true;
|
56
|
-
proc.$$arity = #{@method}.$$arity;
|
56
|
+
proc.$$arity = #{@method}.$$arity == null ? #{@method}.length : #{@method}.$$arity;
|
57
57
|
proc.$$parameters = #{@method}.$$parameters;
|
58
58
|
return proc;
|
59
59
|
}
|
data/opal/corelib/module.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# helpers: truthy, coerce_to, const_set, Object, return_ivar, assign_ivar, ivar, deny_frozen_access, freeze, prop
|
1
|
+
# helpers: truthy, coerce_to, const_set, Object, return_ivar, assign_ivar, ivar, deny_frozen_access, freeze, prop, jsid
|
2
2
|
|
3
3
|
class ::Module
|
4
4
|
def self.allocate
|
@@ -138,7 +138,7 @@ class ::Module
|
|
138
138
|
|
139
139
|
for (var i = names.length - 1; i >= 0; i--) {
|
140
140
|
var name = names[i],
|
141
|
-
id =
|
141
|
+
id = $jsid(name),
|
142
142
|
ivar = $ivar(name);
|
143
143
|
|
144
144
|
var body = $return_ivar(ivar);
|
@@ -164,7 +164,7 @@ class ::Module
|
|
164
164
|
|
165
165
|
for (var i = names.length - 1; i >= 0; i--) {
|
166
166
|
var name = names[i],
|
167
|
-
id =
|
167
|
+
id = $jsid(name + '='),
|
168
168
|
ivar = $ivar(name);
|
169
169
|
|
170
170
|
var body = $assign_ivar(ivar)
|
@@ -200,6 +200,10 @@ class ::Module
|
|
200
200
|
}
|
201
201
|
Opal.const_cache_version++;
|
202
202
|
self.$$autoload[#{const}] = { path: #{path}, loaded: false, required: false, success: false, exception: false };
|
203
|
+
|
204
|
+
if (self.$const_added && !self.$const_added.$$pristine) {
|
205
|
+
self.$const_added(#{const});
|
206
|
+
}
|
203
207
|
}
|
204
208
|
return nil;
|
205
209
|
}
|
@@ -246,6 +250,10 @@ class ::Module
|
|
246
250
|
`Opal.class_variables(self).hasOwnProperty(name)`
|
247
251
|
end
|
248
252
|
|
253
|
+
def const_added(name)
|
254
|
+
end
|
255
|
+
::Opal.pristine self, :const_added
|
256
|
+
|
249
257
|
def remove_class_variable(name)
|
250
258
|
`$deny_frozen_access(self)`
|
251
259
|
|
@@ -424,7 +432,7 @@ class ::Module
|
|
424
432
|
block.$$def = block;
|
425
433
|
block.$$define_meth = true;
|
426
434
|
|
427
|
-
return Opal.defn(self,
|
435
|
+
return Opal.defn(self, $jsid(name), block);
|
428
436
|
}
|
429
437
|
end
|
430
438
|
|
@@ -503,7 +511,7 @@ class ::Module
|
|
503
511
|
|
504
512
|
def instance_method(name)
|
505
513
|
%x{
|
506
|
-
var meth = self.$$prototype[
|
514
|
+
var meth = self.$$prototype[$jsid(name)];
|
507
515
|
|
508
516
|
if (!meth || meth.$$stub) {
|
509
517
|
#{::Kernel.raise ::NameError.new("undefined method `#{name}' for class `#{self.name}'", name)};
|
@@ -589,7 +597,7 @@ class ::Module
|
|
589
597
|
|
590
598
|
def method_defined?(method)
|
591
599
|
%x{
|
592
|
-
var body = self.$$prototype[
|
600
|
+
var body = self.$$prototype[$jsid(method)];
|
593
601
|
return (!!body) && !body.$$stub;
|
594
602
|
}
|
595
603
|
end
|
@@ -605,7 +613,7 @@ class ::Module
|
|
605
613
|
else {
|
606
614
|
for (var i = 0, length = methods.length; i < length; i++) {
|
607
615
|
var meth = methods[i],
|
608
|
-
id =
|
616
|
+
id = $jsid(meth),
|
609
617
|
func = self.$$prototype[id];
|
610
618
|
|
611
619
|
Opal.defs(self, id, func);
|
@@ -754,7 +762,7 @@ class ::Module
|
|
754
762
|
%x{
|
755
763
|
klass_id = Opal.id(klass);
|
756
764
|
if (typeof self.$$refine_modules === "undefined") {
|
757
|
-
self.$$refine_modules =
|
765
|
+
self.$$refine_modules = Object.create(null);
|
758
766
|
}
|
759
767
|
if (typeof self.$$refine_modules[klass_id] === "undefined") {
|
760
768
|
m = self.$$refine_modules[klass_id] = #{::Refinement.new};
|
@@ -769,6 +777,17 @@ class ::Module
|
|
769
777
|
m
|
770
778
|
end
|
771
779
|
|
780
|
+
def refinements
|
781
|
+
%x{
|
782
|
+
var refine_modules = self.$$refine_modules, hash = #{{}};;
|
783
|
+
if (typeof refine_modules === "undefined") return hash;
|
784
|
+
for (var id in refine_modules) {
|
785
|
+
hash['$[]='](refine_modules[id].refined_class, refine_modules[id]);
|
786
|
+
}
|
787
|
+
return hash;
|
788
|
+
}
|
789
|
+
end
|
790
|
+
|
772
791
|
# Compiler overrides this method
|
773
792
|
def using(mod)
|
774
793
|
::Kernel.raise 'Module#using is not permitted in methods'
|
@@ -780,6 +799,8 @@ class ::Module
|
|
780
799
|
end
|
781
800
|
|
782
801
|
class ::Refinement < ::Module
|
802
|
+
attr_reader :refined_class
|
803
|
+
|
783
804
|
def inspect
|
784
805
|
if @refinement_module
|
785
806
|
"#<refinement:#{@refined_class.inspect}@#{@refinement_module.inspect}>"
|
data/opal/corelib/proc.rb
CHANGED
@@ -81,8 +81,10 @@ class ::Proc < `Function`
|
|
81
81
|
%x{
|
82
82
|
if (self.$$is_curried) {
|
83
83
|
return -1;
|
84
|
-
} else {
|
84
|
+
} else if (self.$$arity != null) {
|
85
85
|
return self.$$arity;
|
86
|
+
} else {
|
87
|
+
return self.length;
|
86
88
|
}
|
87
89
|
}
|
88
90
|
end
|
@@ -100,12 +102,12 @@ class ::Proc < `Function`
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
def parameters
|
105
|
+
def parameters(lambda: undefined)
|
104
106
|
%x{
|
105
107
|
if (self.$$is_curried) {
|
106
108
|
return #{[[:rest]]};
|
107
109
|
} else if (self.$$parameters) {
|
108
|
-
if (self.$$is_lambda) {
|
110
|
+
if (lambda == null ? self.$$is_lambda : lambda) {
|
109
111
|
return self.$$parameters;
|
110
112
|
} else {
|
111
113
|
var result = [], i, length;
|
@@ -142,7 +144,7 @@ class ::Proc < `Function`
|
|
142
144
|
}
|
143
145
|
|
144
146
|
function curried () {
|
145
|
-
var args = $slice
|
147
|
+
var args = $slice(arguments),
|
146
148
|
length = args.length,
|
147
149
|
result;
|
148
150
|
|
@@ -156,7 +158,7 @@ class ::Proc < `Function`
|
|
156
158
|
|
157
159
|
result = function () {
|
158
160
|
return curried.apply(null,
|
159
|
-
args.concat($slice
|
161
|
+
args.concat($slice(arguments)));
|
160
162
|
}
|
161
163
|
result.$$is_lambda = self.$$is_lambda;
|
162
164
|
result.$$is_curried = true;
|