opal 0.9.0.beta2 → 0.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.jshintrc +2 -1
  3. data/.travis.yml +8 -4
  4. data/CHANGELOG.md +270 -251
  5. data/CONTRIBUTING.md +41 -0
  6. data/README.md +8 -8
  7. data/Rakefile +1 -1
  8. data/lib/opal/cli.rb +1 -0
  9. data/lib/opal/cli_options.rb +2 -2
  10. data/lib/opal/cli_runners.rb +1 -0
  11. data/lib/opal/cli_runners/nashorn.rb +58 -0
  12. data/lib/opal/cli_runners/phantom.js +11 -9
  13. data/lib/opal/compiler.rb +2 -0
  14. data/lib/opal/erb.rb +2 -1
  15. data/lib/opal/nodes/def.rb +15 -6
  16. data/lib/opal/nodes/helpers.rb +1 -1
  17. data/lib/opal/nodes/literal.rb +1 -1
  18. data/lib/opal/nodes/masgn.rb +79 -29
  19. data/lib/opal/nodes/module.rb +1 -1
  20. data/lib/opal/nodes/top.rb +6 -2
  21. data/lib/opal/parser.rb +1 -0
  22. data/lib/opal/parser/grammar.rb +3160 -3083
  23. data/lib/opal/parser/grammar.y +39 -11
  24. data/lib/opal/parser/lexer.rb +15 -13
  25. data/lib/opal/parser/sexp.rb +5 -0
  26. data/lib/opal/version.rb +1 -1
  27. data/opal/corelib/array.rb +21 -6
  28. data/opal/corelib/basic_object.rb +17 -4
  29. data/opal/corelib/class.rb +1 -1
  30. data/opal/corelib/constants.rb +2 -2
  31. data/opal/corelib/enumerator.rb +2 -0
  32. data/opal/corelib/hash.rb +50 -50
  33. data/opal/corelib/helpers.rb +1 -1
  34. data/opal/corelib/io.rb +9 -6
  35. data/opal/corelib/kernel.rb +37 -9
  36. data/opal/corelib/module.rb +6 -17
  37. data/opal/corelib/nil.rb +4 -0
  38. data/opal/corelib/number.rb +0 -4
  39. data/opal/corelib/runtime.js +637 -662
  40. data/opal/corelib/struct.rb +7 -3
  41. data/spec/filters/bugs/array.rb +4 -9
  42. data/spec/filters/bugs/basicobject.rb +1 -15
  43. data/spec/filters/bugs/date.rb +4 -26
  44. data/spec/filters/bugs/enumerable.rb +26 -1
  45. data/spec/filters/bugs/enumerator.rb +4 -4
  46. data/spec/filters/bugs/exception.rb +1 -7
  47. data/spec/filters/bugs/float.rb +14 -0
  48. data/spec/filters/bugs/hash.rb +0 -2
  49. data/spec/filters/bugs/integer.rb +1 -1
  50. data/spec/filters/bugs/kernel.rb +47 -66
  51. data/spec/filters/bugs/language.rb +1 -2
  52. data/spec/filters/bugs/module.rb +11 -14
  53. data/spec/filters/bugs/numeric.rb +3 -3
  54. data/spec/filters/bugs/proc.rb +0 -1
  55. data/spec/filters/bugs/range.rb +2 -3
  56. data/spec/filters/bugs/regexp.rb +15 -17
  57. data/spec/filters/bugs/set.rb +2 -2
  58. data/spec/filters/bugs/string.rb +29 -5
  59. data/spec/filters/bugs/{strscan.rb → stringscanner.rb} +9 -10
  60. data/spec/filters/bugs/struct.rb +0 -4
  61. data/spec/filters/bugs/time.rb +2 -3
  62. data/spec/filters/bugs/unboundmethod.rb +3 -0
  63. data/spec/filters/unsupported/freeze.rb +2 -1
  64. data/spec/filters/unsupported/taint.rb +2 -0
  65. data/spec/lib/parser/aref_spec.rb +10 -0
  66. data/spec/lib/parser/lambda_spec.rb +14 -0
  67. data/spec/lib/parser/op_asgn_spec.rb +17 -0
  68. data/spec/lib/parser/return_spec.rb +5 -0
  69. data/spec/lib/parser/unary_spec.rb +4 -0
  70. data/spec/lib/sprockets/erb_spec.rb +1 -1
  71. data/spec/mspec/opal/formatters.rb +159 -0
  72. data/{lib → spec}/mspec/opal/runner.rb +0 -160
  73. data/spec/opal/core/hash/internals_spec.rb +162 -162
  74. data/spec/opal/core/kernel/at_exit_spec.rb +70 -0
  75. data/spec/opal/core/kernel/extend_spec.rb +1 -1
  76. data/spec/opal/core/kernel/instance_variables_spec.rb +56 -0
  77. data/spec/opal/core/language/equal_spec.rb +8 -0
  78. data/spec/opal/core/language/predefined_spec.rb +1 -1
  79. data/spec/opal/core/language/ternary_operator_spec.rb +14 -0
  80. data/spec/opal/core/language/versions/{hash_1.9.rb → hash_1_9_spec.rb} +5 -0
  81. data/spec/opal/core/module/fixtures/classes.rb +11 -1
  82. data/spec/opal/core/module/method_lookup_spec.rb +13 -0
  83. data/spec/opal/core/runtime/super_spec.rb +10 -0
  84. data/spec/opal/stdlib/native/new_spec.rb +84 -0
  85. data/spec/opal/stdlib/strscan/scan_spec.rb +11 -0
  86. data/spec/rubyspecs +6 -9
  87. data/spec/spec_helper.rb +9 -21
  88. data/stdlib/date.rb +121 -1
  89. data/stdlib/js.rb +13 -5
  90. data/stdlib/json.rb +3 -3
  91. data/stdlib/nashorn.rb +5 -0
  92. data/stdlib/nashorn/file.rb +13 -0
  93. data/stdlib/nashorn/io.rb +2 -0
  94. data/stdlib/native.rb +12 -4
  95. data/stdlib/nodejs/io.rb +5 -2
  96. data/stdlib/opal/platform.rb +19 -0
  97. data/stdlib/phantomjs.rb +4 -0
  98. data/stdlib/strscan.rb +1 -1
  99. data/tasks/building.rake +2 -1
  100. data/tasks/testing.rake +29 -34
  101. data/tasks/testing/{phantomjs1-sprockets.js → sprockets-phantomjs.js} +2 -20
  102. data/vendored-minitest/minitest/test.rb +7 -15
  103. metadata +32 -9
  104. data/lib/mspec/opal/main.rb.erb +0 -9
@@ -5,22 +5,22 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
5
5
  kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
6
6
  kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
8
+ k__FILE__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
9
  tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP
10
+ tREGEXP_END tUPLUS tUMINUS tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP
11
11
  tOROP tMATCH tNMATCH tJSDOT tDOT tDOT2 tDOT3 tAREF tASET tLSHFT tRSHFT
12
12
  tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN tLPAREN2 tRPAREN tLPAREN_ARG
13
- ARRAY_BEG tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2
13
+ tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2
14
14
  tTILDE tPERCENT tDIVIDE tPLUS tMINUS tLT tGT tPIPE tBANG tCARET
15
15
  tLCURLY tRCURLY tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
16
16
  tWORDS_BEG tAWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END tSTRING
17
17
  tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG
18
- tLBRACK2 tLBRACK tJSLBRACK tDSTAR
18
+ tLBRACK2 tLBRACK tJSLBRACK tDSTAR tLABEL_END tEQL
19
19
 
20
20
  prechigh
21
21
  right tBANG tTILDE tUPLUS
22
22
  right tPOW
23
- right tUMINUS_NUM tUMINUS
23
+ right tUMINUS
24
24
  left tSTAR2 tDIVIDE tPERCENT
25
25
  left tPLUS tMINUS
26
26
  left tLSHFT tRSHFT
@@ -275,20 +275,33 @@ rule
275
275
  result = val[0] << s(:splat, val[2])
276
276
  }
277
277
  | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
278
+ {
279
+ result = (val[0] << s(:splat, val[2])).concat(val[4].children)
280
+ }
278
281
  | mlhs_head tSTAR
279
282
  {
280
283
  result = val[0] << s(:splat)
281
284
  }
282
285
  | mlhs_head tSTAR tCOMMA mlhs_post
286
+ {
287
+ result = (val[0] << s(:splat)).concat(val[3].children)
288
+ }
283
289
  | tSTAR mlhs_node
284
290
  {
285
291
  result = s(:array, s(:splat, val[1]))
286
292
  }
293
+ | tSTAR mlhs_node tCOMMA mlhs_post
294
+ {
295
+ result = s(:array, s(:splat, val[1])).concat(val[3].children)
296
+ }
287
297
  | tSTAR
288
298
  {
289
299
  result = s(:array, s(:splat))
290
300
  }
291
301
  | tSTAR tCOMMA mlhs_post
302
+ {
303
+ result = s(:array, s(:splat)).concat(val[2].children)
304
+ }
292
305
 
293
306
  mlhs_item: mlhs_node
294
307
  {
@@ -309,7 +322,13 @@ rule
309
322
  }
310
323
 
311
324
  mlhs_post: mlhs_item
325
+ {
326
+ result = s(:array, val[0])
327
+ }
312
328
  | mlhs_post tCOMMA mlhs_item
329
+ {
330
+ result = val[0] << val[2]
331
+ }
313
332
 
314
333
  mlhs_node: variable
315
334
  {
@@ -590,9 +609,9 @@ rule
590
609
  {
591
610
  result = s(:defined, val[2])
592
611
  }
593
- | arg tEH arg tCOLON arg
612
+ | arg tEH { lexer.cond_push 1 } arg tCOLON { lexer.cond_pop } arg
594
613
  {
595
- result = new_if(val[1], val[0], val[2], val[4])
614
+ result = new_if(val[1], val[0], val[3], val[6])
596
615
  }
597
616
  | primary
598
617
 
@@ -619,6 +638,11 @@ rule
619
638
  {
620
639
  result = [s(:hash, *val[0])]
621
640
  }
641
+ | args tCOMMA block_arg
642
+ {
643
+ result = val[0] << val[2]
644
+ }
645
+
622
646
 
623
647
  paren_args: tLPAREN2 opt_call_args rparen
624
648
  {
@@ -1397,19 +1421,19 @@ xstring_contents: none
1397
1421
  {
1398
1422
  result = new_float(val[0])
1399
1423
  }
1400
- | '-@NUM' tINTEGER =tLOWEST
1424
+ | '-@NUM' tINTEGER =tUMINUS
1401
1425
  {
1402
1426
  result = negate_num(new_int(val[1]))
1403
1427
  }
1404
- | '-@NUM' tFLOAT =tLOWEST
1428
+ | '-@NUM' tFLOAT =tUMINUS
1405
1429
  {
1406
1430
  result = negate_num(new_float(val[1]))
1407
1431
  }
1408
- | '+@NUM' tINTEGER =tLOWEST
1432
+ | '+@NUM' tINTEGER
1409
1433
  {
1410
1434
  result = new_int(val[1])
1411
1435
  }
1412
- | '+@NUM' tFLOAT =tLOWEST
1436
+ | '+@NUM' tFLOAT
1413
1437
  {
1414
1438
  result = new_float(val[1])
1415
1439
  }
@@ -1745,6 +1769,10 @@ xstring_contents: none
1745
1769
  {
1746
1770
  result = [new_sym(val[0]), val[1]]
1747
1771
  }
1772
+ | tSTRING_BEG string_contents tLABEL_END arg_value
1773
+ {
1774
+ result = [s(:sym, source(val[1]).to_sym), val[3]]
1775
+ }
1748
1776
 
1749
1777
  operation: tIDENTIFIER
1750
1778
  | tCONSTANT
@@ -206,6 +206,7 @@ module Opal
206
206
 
207
207
  def new_op_asgn(value)
208
208
  self.yylval = value
209
+ @lex_state = :expr_beg
209
210
  :tOP_ASGN
210
211
  end
211
212
 
@@ -360,7 +361,7 @@ module Opal
360
361
  self.yylval = scan(/\w+/)
361
362
  return :tREGEXP_END
362
363
  end
363
- return :tSTRING_END
364
+ return !cond? && scan(/:[^:]/) ? :tLABEL_END : :tSTRING_END
364
365
  else
365
366
  str_buffer << scanner.matched
366
367
  str_parse[:nesting] -= 1
@@ -376,7 +377,7 @@ module Opal
376
377
  @scanner = str_parse[:scanner]
377
378
  end
378
379
 
379
- return :tSTRING_END
380
+ return !cond? && scan(/:[^:]/) ? :tLABEL_END : :tSTRING_END
380
381
  end
381
382
  end
382
383
 
@@ -645,7 +646,7 @@ module Opal
645
646
  token = parse_string
646
647
  end
647
648
 
648
- if token == :tSTRING_END or token == :tREGEXP_END
649
+ if token == :tSTRING_END or token == :tREGEXP_END or token == :tLABEL_END
649
650
  self.strterm = nil
650
651
  @lex_state = :expr_end
651
652
  end
@@ -692,13 +693,11 @@ module Opal
692
693
 
693
694
  elsif check(/\*/)
694
695
  if scan(/\*\*\=/)
695
- @lex_state = :expr_beg
696
696
  return new_op_asgn('**')
697
697
  elsif scan(/\*\*/)
698
698
  self.set_arg_state
699
699
  return :tPOW
700
700
  elsif scan(/\*\=/)
701
- @lex_state = :expr_beg
702
701
  return new_op_asgn('*')
703
702
  else
704
703
  scan(/\*/)
@@ -803,7 +802,6 @@ module Opal
803
802
  return :tANDOP
804
803
 
805
804
  elsif scan(/\=/)
806
- @lex_state = :expr_beg
807
805
  return new_op_asgn('&')
808
806
  end
809
807
 
@@ -823,6 +821,7 @@ module Opal
823
821
  elsif scan(/\|/)
824
822
  if scan(/\|/)
825
823
  @lex_state = :expr_beg
824
+
826
825
  if scan(/\=/)
827
826
  return new_op_asgn('||')
828
827
  end
@@ -875,7 +874,6 @@ module Opal
875
874
  self.strterm = new_strterm(STR_REGEXP, '/', '/')
876
875
  return :tREGEXP_BEG
877
876
  elsif scan(/\=/)
878
- @lex_state = :expr_beg
879
877
  return new_op_asgn('/')
880
878
  end
881
879
 
@@ -896,10 +894,11 @@ module Opal
896
894
 
897
895
  elsif scan(/\%/)
898
896
  if scan(/\=/)
899
- @lex_state = :expr_beg
900
897
  return new_op_asgn('%')
901
898
  elsif check(/[^\s]/)
902
- if @lex_state == :expr_beg or (@lex_state == :expr_arg && @space_seen)
899
+ if @lex_state == :expr_beg or
900
+ (@lex_state == :expr_arg && @space_seen) or
901
+ @lex_state == :expr_mid
903
902
  start_word = scan(/./)
904
903
  end_word = { '(' => ')', '[' => ']', '{' => '}' }[start_word] || start_word
905
904
  self.strterm = new_strterm2(STR_DQUOTE, end_word, start_word)
@@ -1034,7 +1033,6 @@ module Opal
1034
1033
  return :tSYMBEG
1035
1034
 
1036
1035
  elsif scan(/\^\=/)
1037
- @lex_state = :expr_beg
1038
1036
  return new_op_asgn('^')
1039
1037
 
1040
1038
  elsif scan(/\^/)
@@ -1043,7 +1041,6 @@ module Opal
1043
1041
 
1044
1042
  elsif check(/</)
1045
1043
  if scan(/<<\=/)
1046
- @lex_state = :expr_beg
1047
1044
  return new_op_asgn('<<')
1048
1045
 
1049
1046
  elsif scan(/<</)
@@ -1132,14 +1129,17 @@ module Opal
1132
1129
  end
1133
1130
 
1134
1131
  if scan(/\=/)
1135
- @lex_state = :expr_beg
1136
1132
  return new_op_asgn(matched)
1137
1133
  end
1138
1134
 
1139
1135
  if spcarg?
1140
1136
  @lex_state = :expr_mid
1141
1137
  self.yylval = matched
1142
- return utype
1138
+ if scanner.peek(1) =~ /\d/ and
1139
+ return utype == :tUMINUS ? '-@NUM' : '+@NUM'
1140
+ else
1141
+ return utype
1142
+ end
1143
1143
  end
1144
1144
 
1145
1145
  @lex_state = :expr_beg
@@ -1209,6 +1209,8 @@ module Opal
1209
1209
  if @start_of_lambda
1210
1210
  @start_of_lambda = false
1211
1211
  @lex_state = :expr_beg
1212
+ cond_push 0
1213
+ cmdarg_push 0
1212
1214
  return :tLAMBEG
1213
1215
 
1214
1216
  elsif arg? or @lex_state == :expr_end
@@ -42,6 +42,11 @@ module Opal
42
42
  self
43
43
  end
44
44
 
45
+ def concat(children)
46
+ @array.concat(children)
47
+ self
48
+ end
49
+
45
50
  def to_ary
46
51
  @array
47
52
  end
data/lib/opal/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  # WHEN RELEASING:
3
3
  # Remember to update RUBY_ENGINE_VERSION in opal/corelib/constants.rb too!
4
- VERSION = '0.9.0.beta2'
4
+ VERSION = '0.9.0.rc1'
5
5
  end
@@ -220,6 +220,9 @@ class Array < `Array`
220
220
  function _eqeq(array, other) {
221
221
  var i, length, a, b;
222
222
 
223
+ if (array === other)
224
+ return true;
225
+
223
226
  if (!other.$$is_array) {
224
227
  if (#{Opal.respond_to? `other`, :to_ary}) {
225
228
  return #{`other` == `array`};
@@ -228,7 +231,10 @@ class Array < `Array`
228
231
  }
229
232
  }
230
233
 
231
- other = #{other.to_a};
234
+ if (array.constructor !== Array)
235
+ array = array.literal;
236
+ if (other.constructor !== Array)
237
+ other = other.literal;
232
238
 
233
239
  if (array.length !== other.length) {
234
240
  return false;
@@ -2099,12 +2105,21 @@ class Array < `Array`
2099
2105
 
2100
2106
  for (j = 0, jj = others.length; j < jj; j++) {
2101
2107
  o = others[j];
2102
- if (!o.$$is_array) {
2103
- others[j] = #{(
2104
- Opal.coerce_to?(`o`, Array, :to_ary) ||
2105
- Opal.coerce_to!(`o`, Enumerator, :each)
2106
- ).to_a};
2108
+ if (o.$$is_array) {
2109
+ continue;
2110
+ }
2111
+ if (o.$$is_enumerator) {
2112
+ if (o.$size() === Infinity) {
2113
+ others[j] = o.$take(size);
2114
+ } else {
2115
+ others[j] = o.$to_a();
2116
+ }
2117
+ continue;
2107
2118
  }
2119
+ others[j] = #{(
2120
+ Opal.coerce_to?(`o`, Array, :to_ary) ||
2121
+ Opal.coerce_to!(`o`, Enumerator, :each)
2122
+ ).to_a};
2108
2123
  }
2109
2124
 
2110
2125
  for (i = 0; i < size; i++) {
@@ -10,6 +10,8 @@ class BasicObject
10
10
  self == other
11
11
  end
12
12
 
13
+ alias equal? ==
14
+
13
15
  def __id__
14
16
  `self.$$id || (self.$$id = Opal.uid())`
15
17
  end
@@ -44,8 +46,18 @@ class BasicObject
44
46
 
45
47
  alias equal? ==
46
48
 
47
- def instance_eval(&block)
48
- Kernel.raise ArgumentError, "no block given" unless block
49
+ def instance_eval(*args, &block)
50
+ if block.nil? && `!!Opal.compile`
51
+ Kernel.raise ArgumentError, "wrong number of arguments (0 for 1..3)" unless (1..3).cover? args.size
52
+
53
+ string, file, _lineno = *args
54
+ compiled = Opal.compile string, file: (file || '(eval)'), eval: true
55
+ wrapper = `function() {return eval(compiled)}`
56
+
57
+ block = Kernel.lambda { `wrapper.call(#{self})` }
58
+ elsif args.size > 0
59
+ Kernel.raise ArgumentError, "wrong number of arguments (#{args.size} for 0)"
60
+ end
49
61
 
50
62
  %x{
51
63
  var old = block.$$s,
@@ -53,8 +65,9 @@ class BasicObject
53
65
 
54
66
  block.$$s = null;
55
67
 
56
- // need to pass $$eval so that method definitions know if this is being done on a class/module. Cannot be compiler driven since
57
- // send(:instance_eval) needs to work
68
+ // Need to pass $$eval so that method definitions know if this is
69
+ // being done on a class/module. Cannot be compiler driven since
70
+ // send(:instance_eval) needs to work.
58
71
  if (self.$$is_class || self.$$is_module) {
59
72
  self.$$eval = true;
60
73
  try {
@@ -8,7 +8,7 @@ class Class
8
8
  }
9
9
 
10
10
  function AnonClass(){};
11
- var klass = Opal.boot(sup, AnonClass)
11
+ var klass = Opal.boot_class(sup, AnonClass)
12
12
  klass.$$name = nil;
13
13
  klass.$$parent = sup;
14
14
  klass.$$is_class = true;
@@ -1,7 +1,7 @@
1
1
  RUBY_PLATFORM = 'opal'
2
2
  RUBY_ENGINE = 'opal'
3
- RUBY_VERSION = '2.1.5'
4
- RUBY_ENGINE_VERSION = '0.9.0.beta2'
3
+ RUBY_VERSION = '2.2.3'
4
+ RUBY_ENGINE_VERSION = '0.9.0.rc1'
5
5
  RUBY_RELEASE_DATE = '2015-11-06'
6
6
  RUBY_PATCHLEVEL = 0
7
7
  RUBY_REVISION = 0
@@ -3,6 +3,8 @@ require 'corelib/enumerable'
3
3
  class Enumerator
4
4
  include Enumerable
5
5
 
6
+ `def.$$is_enumerator = true`
7
+
6
8
  def self.for(object, method = :each, *args, &block)
7
9
  %x{
8
10
  var obj = #{allocate};
data/opal/corelib/hash.rb CHANGED
@@ -93,16 +93,16 @@ class Hash
93
93
  return false;
94
94
  }
95
95
 
96
- if (self.keys.length !== other.keys.length) {
96
+ if (self.$$keys.length !== other.$$keys.length) {
97
97
  return false;
98
98
  }
99
99
 
100
- for (var i = 0, keys = self.keys, length = keys.length, key, value, other_value; i < length; i++) {
100
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, other_value; i < length; i++) {
101
101
  key = keys[i];
102
102
 
103
103
  if (key.$$is_string) {
104
- value = self.smap[key];
105
- other_value = other.smap[key];
104
+ value = self.$$smap[key];
105
+ other_value = other.$$smap[key];
106
106
  } else {
107
107
  value = key.value;
108
108
  other_value = Opal.hash_get(other, key.key);
@@ -138,12 +138,12 @@ class Hash
138
138
 
139
139
  def assoc(object)
140
140
  %x{
141
- for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) {
141
+ for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) {
142
142
  key = keys[i];
143
143
 
144
144
  if (key.$$is_string) {
145
145
  if (#{`key` == object}) {
146
- return [key, self.smap[key]];
146
+ return [key, self.$$smap[key]];
147
147
  }
148
148
  } else {
149
149
  if (#{`key.key` == object}) {
@@ -233,11 +233,11 @@ class Hash
233
233
  return enum_for(:delete_if){self.size} unless block
234
234
 
235
235
  %x{
236
- for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) {
236
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) {
237
237
  key = keys[i];
238
238
 
239
239
  if (key.$$is_string) {
240
- value = self.smap[key];
240
+ value = self.$$smap[key];
241
241
  } else {
242
242
  value = key.value;
243
243
  key = key.key;
@@ -267,11 +267,11 @@ class Hash
267
267
  return enum_for(:each){self.size} unless block
268
268
 
269
269
  %x{
270
- for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) {
270
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) {
271
271
  key = keys[i];
272
272
 
273
273
  if (key.$$is_string) {
274
- value = self.smap[key];
274
+ value = self.$$smap[key];
275
275
  } else {
276
276
  value = key.value;
277
277
  key = key.key;
@@ -292,7 +292,7 @@ class Hash
292
292
  return enum_for(:each_key){self.size} unless block
293
293
 
294
294
  %x{
295
- for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) {
295
+ for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) {
296
296
  key = keys[i];
297
297
 
298
298
  if (block(key.$$is_string ? key : key.key) === $breaker) {
@@ -310,10 +310,10 @@ class Hash
310
310
  return enum_for(:each_value){self.size} unless block
311
311
 
312
312
  %x{
313
- for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) {
313
+ for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) {
314
314
  key = keys[i];
315
315
 
316
- if (block(key.$$is_string ? self.smap[key] : key.value) === $breaker) {
316
+ if (block(key.$$is_string ? self.$$smap[key] : key.value) === $breaker) {
317
317
  return $breaker.$v;
318
318
  }
319
319
  }
@@ -323,7 +323,7 @@ class Hash
323
323
  end
324
324
 
325
325
  def empty?
326
- `self.keys.length === 0`
326
+ `self.$$keys.length === 0`
327
327
  end
328
328
 
329
329
  alias eql? ==
@@ -360,11 +360,11 @@ class Hash
360
360
  %x{
361
361
  var result = [];
362
362
 
363
- for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) {
363
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) {
364
364
  key = keys[i];
365
365
 
366
366
  if (key.$$is_string) {
367
- value = self.smap[key];
367
+ value = self.$$smap[key];
368
368
  } else {
369
369
  value = key.value;
370
370
  key = key.key;
@@ -395,10 +395,10 @@ class Hash
395
395
 
396
396
  def has_value?(value)
397
397
  %x{
398
- for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) {
398
+ for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) {
399
399
  key = keys[i];
400
400
 
401
- if (#{`(key.$$is_string ? self.smap[key] : key.value)` == value}) {
401
+ if (#{`(key.$$is_string ? self.$$smap[key] : key.value)` == value}) {
402
402
  return true;
403
403
  }
404
404
  }
@@ -434,11 +434,11 @@ class Hash
434
434
 
435
435
  Opal.hash_ids[hash_id] = self;
436
436
 
437
- for (var i = 0, keys = self.keys, length = keys.length; i < length; i++) {
437
+ for (var i = 0, keys = self.$$keys, length = keys.length; i < length; i++) {
438
438
  key = keys[i];
439
439
 
440
440
  if (key.$$is_string) {
441
- result.push([key, self.smap[key].$hash()]);
441
+ result.push([key, self.$$smap[key].$hash()]);
442
442
  } else {
443
443
  result.push([key.key_hash, key.value.$hash()]);
444
444
  }
@@ -458,11 +458,11 @@ class Hash
458
458
 
459
459
  def index(object)
460
460
  %x{
461
- for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) {
461
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) {
462
462
  key = keys[i];
463
463
 
464
464
  if (key.$$is_string) {
465
- value = self.smap[key];
465
+ value = self.$$smap[key];
466
466
  } else {
467
467
  value = key.value;
468
468
  key = key.key;
@@ -518,11 +518,11 @@ class Hash
518
518
 
519
519
  inspect_ids[hash_id] = true;
520
520
 
521
- for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) {
521
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) {
522
522
  key = keys[i];
523
523
 
524
524
  if (key.$$is_string) {
525
- value = self.smap[key];
525
+ value = self.$$smap[key];
526
526
  } else {
527
527
  value = key.value;
528
528
  key = key.key;
@@ -545,11 +545,11 @@ class Hash
545
545
  %x{
546
546
  var hash = Opal.hash();
547
547
 
548
- for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) {
548
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) {
549
549
  key = keys[i];
550
550
 
551
551
  if (key.$$is_string) {
552
- value = self.smap[key];
552
+ value = self.$$smap[key];
553
553
  } else {
554
554
  value = key.value;
555
555
  key = key.key;
@@ -566,11 +566,11 @@ class Hash
566
566
  return enum_for(:keep_if){self.size} unless block
567
567
 
568
568
  %x{
569
- for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) {
569
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) {
570
570
  key = keys[i];
571
571
 
572
572
  if (key.$$is_string) {
573
- value = self.smap[key];
573
+ value = self.$$smap[key];
574
574
  } else {
575
575
  value = key.value;
576
576
  key = key.key;
@@ -602,7 +602,7 @@ class Hash
602
602
  %x{
603
603
  var result = [];
604
604
 
605
- for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) {
605
+ for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) {
606
606
  key = keys[i];
607
607
 
608
608
  if (key.$$is_string) {
@@ -617,7 +617,7 @@ class Hash
617
617
  end
618
618
 
619
619
  def length
620
- `self.keys.length`
620
+ `self.$$keys.length`
621
621
  end
622
622
 
623
623
  alias member? has_key?
@@ -632,14 +632,14 @@ class Hash
632
632
  other = #{Opal.coerce_to!(other, Hash, :to_hash)};
633
633
  }
634
634
 
635
- var i, other_keys = other.keys, length = other_keys.length, key, value, other_value;
635
+ var i, other_keys = other.$$keys, length = other_keys.length, key, value, other_value;
636
636
 
637
637
  if (block === nil) {
638
638
  for (i = 0; i < length; i++) {
639
639
  key = other_keys[i];
640
640
 
641
641
  if (key.$$is_string) {
642
- other_value = other.smap[key];
642
+ other_value = other.$$smap[key];
643
643
  } else {
644
644
  other_value = key.value;
645
645
  key = key.key;
@@ -655,7 +655,7 @@ class Hash
655
655
  key = other_keys[i];
656
656
 
657
657
  if (key.$$is_string) {
658
- other_value = other.smap[key];
658
+ other_value = other.$$smap[key];
659
659
  } else {
660
660
  other_value = key.value;
661
661
  key = key.key;
@@ -677,11 +677,11 @@ class Hash
677
677
 
678
678
  def rassoc(object)
679
679
  %x{
680
- for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) {
680
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) {
681
681
  key = keys[i];
682
682
 
683
683
  if (key.$$is_string) {
684
- value = self.smap[key];
684
+ value = self.$$smap[key];
685
685
  } else {
686
686
  value = key.value;
687
687
  key = key.key;
@@ -709,11 +709,11 @@ class Hash
709
709
  %x{
710
710
  var hash = Opal.hash();
711
711
 
712
- for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) {
712
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) {
713
713
  key = keys[i];
714
714
 
715
715
  if (key.$$is_string) {
716
- value = self.smap[key];
716
+ value = self.$$smap[key];
717
717
  } else {
718
718
  value = key.value;
719
719
  key = key.key;
@@ -740,11 +740,11 @@ class Hash
740
740
  %x{
741
741
  var changes_were_made = false;
742
742
 
743
- for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) {
743
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) {
744
744
  key = keys[i];
745
745
 
746
746
  if (key.$$is_string) {
747
- value = self.smap[key];
747
+ value = self.$$smap[key];
748
748
  } else {
749
749
  value = key.value;
750
750
  key = key.key;
@@ -775,11 +775,11 @@ class Hash
775
775
  %x{
776
776
  Opal.hash_init(self);
777
777
 
778
- for (var i = 0, other_keys = other.keys, length = other_keys.length, key, value, other_value; i < length; i++) {
778
+ for (var i = 0, other_keys = other.$$keys, length = other_keys.length, key, value, other_value; i < length; i++) {
779
779
  key = other_keys[i];
780
780
 
781
781
  if (key.$$is_string) {
782
- other_value = other.smap[key];
782
+ other_value = other.$$smap[key];
783
783
  } else {
784
784
  other_value = key.value;
785
785
  key = key.key;
@@ -804,11 +804,11 @@ class Hash
804
804
  %x{
805
805
  var hash = Opal.hash();
806
806
 
807
- for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) {
807
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) {
808
808
  key = keys[i];
809
809
 
810
810
  if (key.$$is_string) {
811
- value = self.smap[key];
811
+ value = self.$$smap[key];
812
812
  } else {
813
813
  value = key.value;
814
814
  key = key.key;
@@ -835,11 +835,11 @@ class Hash
835
835
  %x{
836
836
  var result = nil;
837
837
 
838
- for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) {
838
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) {
839
839
  key = keys[i];
840
840
 
841
841
  if (key.$$is_string) {
842
- value = self.smap[key];
842
+ value = self.$$smap[key];
843
843
  } else {
844
844
  value = key.value;
845
845
  key = key.key;
@@ -866,7 +866,7 @@ class Hash
866
866
 
867
867
  def shift
868
868
  %x{
869
- var keys = self.keys,
869
+ var keys = self.$$keys,
870
870
  key;
871
871
 
872
872
  if (keys.length > 0) {
@@ -889,11 +889,11 @@ class Hash
889
889
  %x{
890
890
  var result = [];
891
891
 
892
- for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) {
892
+ for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) {
893
893
  key = keys[i];
894
894
 
895
895
  if (key.$$is_string) {
896
- value = self.smap[key];
896
+ value = self.$$smap[key];
897
897
  } else {
898
898
  value = key.value;
899
899
  key = key.key;
@@ -937,11 +937,11 @@ class Hash
937
937
  %x{
938
938
  var result = [];
939
939
 
940
- for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) {
940
+ for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) {
941
941
  key = keys[i];
942
942
 
943
943
  if (key.$$is_string) {
944
- result.push(self.smap[key]);
944
+ result.push(self.$$smap[key]);
945
945
  } else {
946
946
  result.push(key.value);
947
947
  }