opal 0.7.0.beta1 → 0.7.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitmodules +1 -1
  4. data/.inch.yml +19 -0
  5. data/.travis.yml +10 -7
  6. data/CHANGELOG.md +23 -0
  7. data/README.md +2 -2
  8. data/Rakefile +43 -1
  9. data/bin/opal +6 -1
  10. data/lib/mspec/opal/rake_task.rb +10 -31
  11. data/lib/mspec/opal/runner.rb +44 -1
  12. data/lib/mspec/opal/special_calls.rb +25 -0
  13. data/lib/opal/builder.rb +1 -1
  14. data/lib/opal/builder_processors.rb +4 -23
  15. data/lib/opal/cli.rb +17 -11
  16. data/lib/opal/cli_options.rb +1 -1
  17. data/lib/opal/cli_runners.rb +1 -0
  18. data/lib/opal/cli_runners/apple_script.rb +65 -0
  19. data/lib/opal/cli_runners/nodejs.rb +9 -3
  20. data/lib/opal/cli_runners/phantomjs.rb +2 -2
  21. data/lib/opal/cli_runners/server.rb +7 -5
  22. data/lib/opal/compiler.rb +1 -1
  23. data/lib/opal/nodes/call.rb +3 -2
  24. data/lib/opal/nodes/constants.rb +3 -3
  25. data/lib/opal/nodes/def.rb +7 -7
  26. data/lib/opal/nodes/defined.rb +2 -2
  27. data/lib/opal/nodes/definitions.rb +1 -1
  28. data/lib/opal/nodes/literal.rb +1 -1
  29. data/lib/opal/nodes/logic.rb +1 -1
  30. data/lib/opal/nodes/masgn.rb +1 -1
  31. data/lib/opal/nodes/module.rb +1 -1
  32. data/lib/opal/nodes/rescue.rb +1 -1
  33. data/lib/opal/nodes/scope.rb +1 -1
  34. data/lib/opal/nodes/super.rb +3 -3
  35. data/lib/opal/nodes/top.rb +11 -9
  36. data/lib/opal/nodes/variables.rb +39 -6
  37. data/lib/opal/nodes/yield.rb +3 -3
  38. data/lib/opal/parser.rb +3 -1
  39. data/lib/opal/parser/lexer.rb +8 -2
  40. data/lib/opal/paths.rb +13 -3
  41. data/lib/opal/sprockets/server.rb +1 -1
  42. data/lib/opal/version.rb +1 -1
  43. data/opal.gemspec +1 -1
  44. data/opal/corelib/array.rb +29 -20
  45. data/opal/corelib/array/inheritance.rb +3 -3
  46. data/opal/corelib/basic_object.rb +3 -1
  47. data/opal/corelib/class.rb +1 -1
  48. data/opal/corelib/comparable.rb +6 -5
  49. data/opal/corelib/dir.rb +4 -4
  50. data/opal/corelib/enumerable.rb +25 -25
  51. data/opal/corelib/enumerator.rb +16 -14
  52. data/opal/corelib/error.rb +13 -4
  53. data/opal/corelib/hash.rb +511 -162
  54. data/opal/corelib/helpers.rb +1 -1
  55. data/opal/corelib/kernel.rb +60 -44
  56. data/opal/corelib/match_data.rb +1 -10
  57. data/opal/corelib/method.rb +1 -1
  58. data/opal/corelib/module.rb +62 -32
  59. data/opal/corelib/nil_class.rb +1 -6
  60. data/opal/corelib/numeric.rb +6 -3
  61. data/opal/corelib/proc.rb +1 -1
  62. data/opal/corelib/regexp.rb +15 -6
  63. data/opal/corelib/runtime.js +57 -36
  64. data/opal/corelib/string.rb +38 -2
  65. data/opal/corelib/string/inheritance.rb +3 -3
  66. data/opal/corelib/struct.rb +1 -1
  67. data/opal/corelib/time.rb +46 -3
  68. data/spec/filters/bugs/date.rb +15 -0
  69. data/spec/filters/bugs/enumerator.rb +7 -0
  70. data/spec/filters/bugs/exception.rb +12 -0
  71. data/spec/filters/bugs/hash.rb +0 -18
  72. data/spec/filters/bugs/match_data.rb +13 -0
  73. data/spec/filters/bugs/module.rb +13 -0
  74. data/spec/filters/bugs/numeric.rb +2 -0
  75. data/spec/filters/bugs/regexp.rb +0 -2
  76. data/spec/filters/bugs/stringscanner.rb +8 -0
  77. data/spec/filters/bugs/time.rb +1 -1
  78. data/spec/filters/unsupported/float.rb +1 -0
  79. data/spec/filters/unsupported/symbols.rb +10 -0
  80. data/spec/filters/unsupported/tainted.rb +3 -0
  81. data/spec/filters/unsupported/trusted.rb +3 -0
  82. data/spec/lib/compiler_spec.rb +2 -2
  83. data/spec/lib/parser/call_spec.rb +7 -0
  84. data/spec/opal/core/date_spec.rb +49 -8
  85. data/spec/opal/core/exception_spec.rb +13 -0
  86. data/spec/opal/core/fixtures/require_tree_files/nested/nested 1.rb +1 -0
  87. data/spec/opal/core/fixtures/require_tree_files/nested/nested 2.rb +1 -0
  88. data/spec/opal/core/fixtures/require_tree_files/other/other 1.rb +1 -0
  89. data/spec/opal/core/kernel/require_tree_spec.rb +3 -1
  90. data/spec/opal/core/language/predefined_spec.rb +43 -0
  91. data/spec/opal/stdlib/promise/rescue_spec.rb +9 -0
  92. data/spec/opal/stdlib/promise/then_spec.rb +9 -0
  93. data/spec/opal/stdlib/promise/trace_spec.rb +9 -0
  94. data/spec/rubyspecs +40 -19
  95. data/spec/spec_helper.rb +10 -5
  96. data/stdlib/date.rb +68 -8
  97. data/stdlib/fileutils.rb +0 -0
  98. data/stdlib/iconv.rb +0 -0
  99. data/stdlib/json.rb +16 -3
  100. data/stdlib/native.rb +36 -17
  101. data/stdlib/nodejs.rb +3 -0
  102. data/stdlib/nodejs/dir.rb +1 -1
  103. data/stdlib/nodejs/file.rb +2 -2
  104. data/stdlib/nodejs/io.rb +1 -1
  105. data/stdlib/nodejs/process.rb +2 -2
  106. data/stdlib/nodejs/require.rb +5 -7
  107. data/stdlib/nodejs/runtime.rb +3 -2
  108. data/stdlib/pathname.rb +25 -1
  109. data/stdlib/promise.rb +16 -0
  110. data/stdlib/set.rb +48 -4
  111. data/stdlib/strscan.rb +12 -1
  112. data/stdlib/yaml.rb +1 -0
  113. metadata +27 -7
  114. data/spec/opal/core/language/symbol_spec.rb +0 -40
@@ -32,4 +32,13 @@ describe 'Promise#rescue' do
32
32
  Promise.error(23).rescue { |v| x = v }.rescue { x = 42 }
33
33
  x.should == 23
34
34
  end
35
+
36
+ it 'raises an exception when the promise has already been chained' do
37
+ p = Promise.value(2)
38
+ p.then {}
39
+
40
+ proc {
41
+ p.rescue {}
42
+ }.should raise_error(ArgumentError)
43
+ end
35
44
  end
@@ -51,4 +51,13 @@ describe 'Promise#then' do
51
51
 
52
52
  x.should be_kind_of(RuntimeError)
53
53
  end
54
+
55
+ it 'raises an exception when the promise has already been chained' do
56
+ p = Promise.value(2)
57
+ p.then {}
58
+
59
+ proc {
60
+ p.then {}
61
+ }.should raise_error(ArgumentError)
62
+ end
54
63
  end
@@ -32,4 +32,13 @@ describe 'Promise#trace' do
32
32
 
33
33
  x.should == 6
34
34
  end
35
+
36
+ it 'raises an exception when the promise has already been chained' do
37
+ p = Promise.value(2)
38
+ p.then {}
39
+
40
+ proc {
41
+ p.trace {}
42
+ }.should raise_error(ArgumentError)
43
+ end
35
44
  end
@@ -31,11 +31,22 @@ corelib/core/fixnum/to_s_spec
31
31
  corelib/core/fixnum/zero_spec
32
32
 
33
33
  corelib/core/integer/downto_spec
34
+ corelib/core/integer/even_spec
35
+ corelib/core/integer/upto_spec
34
36
 
35
37
  corelib/core/enumerator/each_spec
36
38
  corelib/core/enumerator/new_spec
37
39
  corelib/core/enumerator/next_spec
38
40
  corelib/core/enumerator/rewind_spec
41
+ corelib/core/enumerator/with_index_spec
42
+
43
+ corelib/core/exception/initialize_spec
44
+ corelib/core/exception/inspect_spec
45
+ corelib/core/exception/message_spec
46
+ corelib/core/exception/name_spec
47
+ corelib/core/exception/new_spec
48
+ corelib/core/exception/reason_spec
49
+ corelib/core/exception/to_s_spec
39
50
 
40
51
  corelib/core/kernel/comparison_spec
41
52
  corelib/core/kernel/eql_spec
@@ -46,8 +57,11 @@ corelib/core/kernel/to_s_spec
46
57
  corelib/core/kernel/warn_spec
47
58
 
48
59
  corelib/core/matchdata/captures_spec
60
+ corelib/core/matchdata/element_reference_spec
49
61
  corelib/core/matchdata/inspect_spec
50
62
  corelib/core/matchdata/length_spec
63
+ corelib/core/matchdata/post_match_spec
64
+ corelib/core/matchdata/pre_match_spec
51
65
  corelib/core/matchdata/regexp_spec
52
66
  corelib/core/matchdata/size_spec
53
67
  corelib/core/matchdata/string_spec
@@ -55,6 +69,8 @@ corelib/core/matchdata/to_a_spec
55
69
  corelib/core/matchdata/to_s_spec
56
70
  corelib/core/matchdata/values_at_spec
57
71
 
72
+ corelib/core/module/module_function_spec
73
+
58
74
  corelib/core/range/begin_spec
59
75
  corelib/core/range/case_compare_spec
60
76
  corelib/core/range/end_spec
@@ -197,6 +213,7 @@ corelib/core/regexp/case_compare_spec
197
213
  corelib/core/regexp/eql_spec
198
214
  corelib/core/regexp/equal_value_spec
199
215
  corelib/core/regexp/escape_spec
216
+ corelib/core/regexp/last_match_spec
200
217
  corelib/core/regexp/match_spec
201
218
  corelib/core/regexp/quote_spec
202
219
 
@@ -245,7 +262,7 @@ corelib/language/singleton_class_spec
245
262
  # corelib/language/splat_spec - can't parse all splats
246
263
  # corelib/language/string_spec - can't parse strings using control-characters
247
264
  corelib/language/super_spec
248
- # corelib/language/symbol_spec - lots fail
265
+ corelib/language/symbol_spec
249
266
  # corelib/language/throw_spec - unsupported
250
267
  corelib/language/undef_spec
251
268
  corelib/language/unless_spec
@@ -254,44 +271,55 @@ corelib/language/until_spec
254
271
  corelib/language/while_spec
255
272
  # corelib/language/yield_spec - can't parse destructuring argument list, see block_spec
256
273
 
257
- stdlib/rubysl-singleton/spec/
258
- stdlib/rubysl-observer/spec/
274
+ stdlib/rubysl-singleton/spec
275
+ stdlib/rubysl-observer/spec
276
+ stdlib/rubysl-pathname/spec
259
277
 
278
+ stdlib/rubysl-strscan/spec/beginning_of_line_spec
260
279
  stdlib/rubysl-strscan/spec/bol_spec
261
280
  stdlib/rubysl-strscan/spec/check_spec
262
281
  stdlib/rubysl-strscan/spec/element_reference_spec
282
+ stdlib/rubysl-strscan/spec/eos_spec
263
283
  stdlib/rubysl-strscan/spec/get_byte_spec
284
+ stdlib/rubysl-strscan/spec/peek_spec
264
285
  stdlib/rubysl-strscan/spec/pos_spec
286
+ stdlib/rubysl-strscan/spec/reset_spec
287
+ stdlib/rubysl-strscan/spec/rest_spec
265
288
  stdlib/rubysl-strscan/spec/scan_spec
266
289
  stdlib/rubysl-strscan/spec/skip_spec
267
290
  stdlib/rubysl-strscan/spec/terminate_spec
268
291
 
269
292
  stdlib/rubysl-delegate/spec/delegator/send_spec
270
293
 
294
+ stdlib/rubysl-erb/spec/util/h_spec
271
295
  stdlib/rubysl-erb/spec/util/html_escape_spec
272
296
 
273
297
  stdlib/rubysl-set/spec/add_spec
274
298
  stdlib/rubysl-set/spec/append_spec
299
+ stdlib/rubysl-set/spec/classify_spec
275
300
  stdlib/rubysl-set/spec/clear_spec
301
+ stdlib/rubysl-set/spec/collect_spec
276
302
  stdlib/rubysl-set/spec/constructor_spec
277
303
  stdlib/rubysl-set/spec/delete_if_spec
278
304
  stdlib/rubysl-set/spec/delete_spec
305
+ stdlib/rubysl-set/spec/difference_spec
279
306
  stdlib/rubysl-set/spec/each_spec
280
307
  stdlib/rubysl-set/spec/empty_spec
281
308
  stdlib/rubysl-set/spec/enumerable/to_set_spec
309
+ stdlib/rubysl-set/spec/eql_spec
282
310
  stdlib/rubysl-set/spec/equal_value_spec
283
311
  stdlib/rubysl-set/spec/include_spec
284
312
  stdlib/rubysl-set/spec/initialize_spec
285
313
  stdlib/rubysl-set/spec/length_spec
314
+ stdlib/rubysl-set/spec/map_spec
286
315
  stdlib/rubysl-set/spec/member_spec
287
316
  stdlib/rubysl-set/spec/merge_spec
317
+ stdlib/rubysl-set/spec/minus_spec
318
+ stdlib/rubysl-set/spec/replace_spec
288
319
  stdlib/rubysl-set/spec/size_spec
320
+ stdlib/rubysl-set/spec/subtract_spec
289
321
  stdlib/rubysl-set/spec/to_a_spec
290
- # stdlib/rubysl-set/spec/classify_spec
291
- # stdlib/rubysl-set/spec/collect_spec
292
- # stdlib/rubysl-set/spec/difference_spec
293
322
  # stdlib/rubysl-set/spec/divide_spec
294
- # stdlib/rubysl-set/spec/eql_spec
295
323
  # stdlib/rubysl-set/spec/exclusion_spec
296
324
  # stdlib/rubysl-set/spec/flatten_merge_spec
297
325
  # stdlib/rubysl-set/spec/flatten_spec
@@ -300,30 +328,23 @@ stdlib/rubysl-set/spec/to_a_spec
300
328
  # stdlib/rubysl-set/spec/inspect_spec
301
329
  # stdlib/rubysl-set/spec/intersection_spec
302
330
  # stdlib/rubysl-set/spec/keep_if_spec
303
- # stdlib/rubysl-set/spec/map_spec
304
- # stdlib/rubysl-set/spec/minus_spec
305
331
  # stdlib/rubysl-set/spec/plus_spec
306
332
  # stdlib/rubysl-set/spec/pretty_print_cycle_spec
307
333
  # stdlib/rubysl-set/spec/pretty_print_spec
308
334
  # stdlib/rubysl-set/spec/proper_subset_spec
309
335
  # stdlib/rubysl-set/spec/proper_superset_spec
310
336
  # stdlib/rubysl-set/spec/reject_spec
311
- # stdlib/rubysl-set/spec/replace_spec
312
337
  # stdlib/rubysl-set/spec/select_spec
313
338
  # stdlib/rubysl-set/spec/subset_spec
314
- # stdlib/rubysl-set/spec/subtract_spec
315
339
  # stdlib/rubysl-set/spec/superset_spec
316
340
  # stdlib/rubysl-set/spec/union_spec
317
341
 
318
-
319
-
320
-
321
- stdlib/rubysl-pathname/spec/new_spec
322
- stdlib/rubysl-pathname/spec/equal_value_spec
323
- stdlib/rubysl-pathname/spec/absolute_spec
324
- stdlib/rubysl-pathname/spec/relative_spec
325
-
342
+ stdlib/rubysl-date/spec/date/add_month_spec
326
343
  stdlib/rubysl-date/spec/date/add_spec
344
+ stdlib/rubysl-date/spec/date/append_spec
345
+ stdlib/rubysl-date/spec/date/case_compare_spec
327
346
  stdlib/rubysl-date/spec/date/eql_spec
347
+ stdlib/rubysl-date/spec/date/minus_month_spec
328
348
  stdlib/rubysl-date/spec/date/minus_spec
329
349
  stdlib/rubysl-date/spec/date/plus_spec
350
+ stdlib/rubysl-date/spec/date/strftime_spec
@@ -26,11 +26,16 @@ module Kernel
26
26
  end
27
27
  end
28
28
 
29
- if `!!window.OPAL_SPEC_PHANTOM`
30
- require 'phantomjs'
31
- formatter_class = PhantomFormatter
32
- else
33
- formatter_class = BrowserFormatter
29
+ case
30
+ when defined?(NodeJS)
31
+ formatter_class = NodeJSFormatter
32
+ when `(typeof(window) !== 'undefined')`
33
+ if `!!window.OPAL_SPEC_PHANTOM`
34
+ require 'phantomjs'
35
+ formatter_class = PhantomFormatter
36
+ else
37
+ formatter_class = BrowserFormatter
38
+ end
34
39
  end
35
40
 
36
41
  # Uncomment the following to see example titles when they're executed.
@@ -94,6 +94,30 @@ class Date
94
94
  }
95
95
  end
96
96
 
97
+ def >>(n)
98
+ %x{
99
+ if (!n.$$is_number) {
100
+ #{raise TypeError};
101
+ }
102
+
103
+ var result = #{clone}, date = result.date, cur = date.getDate();
104
+ date.setDate(1);
105
+ date.setMonth(date.getMonth() + n);
106
+ date.setDate(Math.min(cur, days_in_month(date.getFullYear(), date.getMonth())));
107
+ return result;
108
+ }
109
+ end
110
+
111
+ def <<(n)
112
+ %x{
113
+ if (!n.$$is_number) {
114
+ #{raise TypeError};
115
+ }
116
+
117
+ return #{self >> `-n`};
118
+ }
119
+ end
120
+
97
121
  alias eql? ==
98
122
 
99
123
  def clone
@@ -104,14 +128,24 @@ class Date
104
128
  `#@date.getDate()`
105
129
  end
106
130
 
131
+ def friday?
132
+ wday == 5
133
+ end
134
+
135
+ def monday?
136
+ wday == 1
137
+ end
138
+
107
139
  def month
108
140
  `#@date.getMonth() + 1`
109
141
  end
110
142
 
111
143
  def next
112
- res = self.clone
113
- `res.date.setDate(#@date.getDate() + 1)`
114
- res
144
+ self + 1
145
+ end
146
+
147
+ def next_day(n=1)
148
+ self + n
115
149
  end
116
150
 
117
151
  def next_month
@@ -124,10 +158,8 @@ class Date
124
158
  }
125
159
  end
126
160
 
127
- def prev
128
- res = self.clone
129
- `res.date.setDate(#@date.getDate() - 1)`
130
- res
161
+ def prev_day(n=1)
162
+ self - n
131
163
  end
132
164
 
133
165
  def prev_month
@@ -140,8 +172,28 @@ class Date
140
172
  }
141
173
  end
142
174
 
175
+ def saturday?
176
+ wday == 6
177
+ end
178
+
143
179
  def strftime(format = '')
144
- `#@date.$strftime(#{format})`
180
+ %x{
181
+ if (format == '') {
182
+ return #{to_s};
183
+ }
184
+
185
+ return #@date.$strftime(#{format});
186
+ }
187
+ end
188
+
189
+ alias_method :succ, :next
190
+
191
+ def sunday?
192
+ wday == 0
193
+ end
194
+
195
+ def thursday?
196
+ wday == 4
145
197
  end
146
198
 
147
199
  def to_s
@@ -153,10 +205,18 @@ class Date
153
205
  }
154
206
  end
155
207
 
208
+ def tuesday?
209
+ wday == 2
210
+ end
211
+
156
212
  def wday
157
213
  `#@date.getDay()`
158
214
  end
159
215
 
216
+ def wednesday?
217
+ wday == 3
218
+ end
219
+
160
220
  def year
161
221
  `#@date.getFullYear()`
162
222
  end
File without changes
File without changes
@@ -78,7 +78,7 @@ module JSON
78
78
  options[:object_class] ||= Hash
79
79
  options[:array_class] ||= Array
80
80
 
81
- `to_opal(js_object, options.map)`
81
+ `to_opal(js_object, options.smap)`
82
82
  end
83
83
 
84
84
  def self.generate(obj, options = {})
@@ -136,11 +136,24 @@ end
136
136
  class Hash
137
137
  def to_json
138
138
  %x{
139
- var inspect = [], keys = self.keys, map = self.map;
139
+ var inspect = [],
140
+ keys = self.keys,
141
+ _map = self.map,
142
+ smap = self.smap,
143
+ map, khash;
140
144
 
141
145
  for (var i = 0, length = keys.length; i < length; i++) {
142
146
  var key = keys[i];
143
- inspect.push(#{`key`.to_s.to_json} + ':' + #{`map[key]`.to_json});
147
+
148
+ if (key.$$is_string) {
149
+ map = smap;
150
+ khash = key;
151
+ } else {
152
+ map = _map;
153
+ khash = key.$hash();
154
+ }
155
+
156
+ inspect.push(#{`key`.to_s.to_json} + ':' + #{`map[khash]`.to_json});
144
157
  }
145
158
 
146
159
  return '{' + inspect.join(', ') + '}';
@@ -170,7 +170,7 @@ class Native::Object < BasicObject
170
170
  end
171
171
 
172
172
  def has_key?(name)
173
- `$opal.hasOwnProperty.call(#@native, #{name})`
173
+ `Opal.hasOwnProperty.call(#@native, #{name})`
174
174
  end
175
175
 
176
176
  alias key? has_key?
@@ -231,7 +231,7 @@ class Native::Object < BasicObject
231
231
  end
232
232
 
233
233
  def respond_to_missing?(name)
234
- `$opal.hasOwnProperty.call(#@native, #{name})`
234
+ `Opal.hasOwnProperty.call(#@native, #{name})`
235
235
  end
236
236
 
237
237
  def method_missing(mid, *args, &block)
@@ -250,7 +250,7 @@ class Native::Object < BasicObject
250
250
  end
251
251
 
252
252
  def is_a?(klass)
253
- `$opal.is_a(self, klass)`
253
+ `Opal.is_a(self, klass)`
254
254
  end
255
255
 
256
256
  alias kind_of? is_a?
@@ -295,7 +295,7 @@ class Native::Array
295
295
 
296
296
  %x{
297
297
  for (var i = 0, length = #{length}; i < length; i++) {
298
- var value = $opal.$yield1(block, #{self[`i`]});
298
+ var value = Opal.yield1(block, #{self[`i`]});
299
299
 
300
300
  if (value === $breaker) {
301
301
  return $breaker.$v;
@@ -459,17 +459,27 @@ class Hash
459
459
  %x{
460
460
  if (defaults != null) {
461
461
  if (defaults.constructor === Object) {
462
- var map = self.map,
463
- keys = self.keys;
462
+ var _map = self.map,
463
+ smap = self.smap,
464
+ keys = self.keys,
465
+ map, khash, value;
464
466
 
465
467
  for (var key in defaults) {
466
- var value = defaults[key];
468
+ value = defaults[key];
469
+
470
+ if (key.$$is_string) {
471
+ map = smap;
472
+ khash = key;
473
+ } else {
474
+ map = _map;
475
+ khash = key.$hash();
476
+ }
467
477
 
468
478
  if (value && value.constructor === Object) {
469
- map[key] = #{Hash.new(`value`)};
479
+ map[khash] = #{Hash.new(`value`)};
470
480
  }
471
481
  else {
472
- map[key] = #{Native(`defaults[key]`)};
482
+ map[khash] = #{Native(`value`)};
473
483
  }
474
484
 
475
485
  keys.push(key);
@@ -491,19 +501,28 @@ class Hash
491
501
  %x{
492
502
  var result = {},
493
503
  keys = self.keys,
494
- map = self.map,
495
- bucket,
496
- value;
504
+ _map = self.map,
505
+ smap = self.smap,
506
+ map, khash, value;
497
507
 
498
508
  for (var i = 0, length = keys.length; i < length; i++) {
499
- var key = keys[i],
500
- obj = map[key];
509
+ key = keys[i];
510
+
511
+ if (key.$$is_string) {
512
+ map = smap;
513
+ khash = key;
514
+ } else {
515
+ map = _map;
516
+ khash = key.$hash();
517
+ }
501
518
 
502
- if (#{`obj`.respond_to? :to_n}) {
503
- result[key] = #{`obj`.to_n};
519
+ value = map[khash];
520
+
521
+ if (#{`value`.respond_to? :to_n}) {
522
+ result[key] = #{`value`.to_n};
504
523
  }
505
524
  else {
506
- result[key] = obj;
525
+ result[key] = value;
507
526
  }
508
527
  }
509
528