opal 0.3.20 → 0.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. data/.gitignore +2 -7
  2. data/.rspec +2 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +8 -2
  5. data/LICENSE +2 -3
  6. data/README.md +106 -239
  7. data/Rakefile +58 -16
  8. data/bin/opal +1 -0
  9. data/core/array.rb +180 -160
  10. data/core/basic_object.rb +8 -4
  11. data/core/boolean.rb +6 -6
  12. data/core/class.rb +9 -15
  13. data/core/dir.rb +89 -0
  14. data/core/enumerable.rb +83 -86
  15. data/core/error.rb +9 -4
  16. data/core/file.rb +85 -0
  17. data/core/hash.rb +67 -67
  18. data/core/kernel.rb +38 -42
  19. data/core/module.rb +57 -54
  20. data/core/numeric.rb +41 -41
  21. data/core/proc.rb +1 -5
  22. data/core/range.rb +11 -11
  23. data/core/regexp.rb +27 -22
  24. data/core/runtime.js +152 -221
  25. data/core/string.rb +86 -73
  26. data/core/time.rb +22 -18
  27. data/docs/post.html +9 -0
  28. data/docs/pre.html +32 -0
  29. data/lib/opal.rb +43 -3
  30. data/lib/opal/builder.rb +9 -26
  31. data/lib/opal/grammar.rb +1 -1
  32. data/lib/opal/grammar.y +1 -1
  33. data/lib/opal/lexer.rb +21 -15
  34. data/lib/opal/parser.rb +100 -111
  35. data/lib/opal/rake_task.rb +66 -0
  36. data/lib/opal/scope.rb +13 -5
  37. data/lib/opal/version.rb +1 -1
  38. data/opal.gemspec +2 -0
  39. data/spec/browser_spec.rb +28 -0
  40. data/spec/builder/lib_name_for_spec.rb +1 -6
  41. data/spec/grammar/alias_spec.rb +1 -1
  42. data/spec/grammar/and_spec.rb +1 -1
  43. data/spec/grammar/array_spec.rb +1 -1
  44. data/spec/grammar/attrasgn_spec.rb +1 -1
  45. data/spec/grammar/begin_spec.rb +1 -1
  46. data/spec/grammar/block_spec.rb +1 -1
  47. data/spec/grammar/break_spec.rb +1 -1
  48. data/spec/grammar/call_spec.rb +1 -1
  49. data/spec/grammar/class_spec.rb +1 -1
  50. data/spec/grammar/const_spec.rb +1 -1
  51. data/spec/grammar/cvar_spec.rb +1 -1
  52. data/spec/grammar/def_spec.rb +1 -1
  53. data/spec/grammar/false_spec.rb +1 -1
  54. data/spec/grammar/file_spec.rb +1 -1
  55. data/spec/grammar/gvar_spec.rb +1 -1
  56. data/spec/grammar/hash_spec.rb +1 -1
  57. data/spec/grammar/iasgn_spec.rb +1 -1
  58. data/spec/grammar/if_spec.rb +1 -1
  59. data/spec/grammar/iter_spec.rb +1 -1
  60. data/spec/grammar/ivar_spec.rb +1 -1
  61. data/spec/grammar/lambda_spec.rb +1 -1
  62. data/spec/grammar/lasgn_spec.rb +1 -1
  63. data/spec/grammar/line_spec.rb +1 -1
  64. data/spec/grammar/lvar_spec.rb +1 -1
  65. data/spec/grammar/masgn_spec.rb +1 -1
  66. data/spec/grammar/module_spec.rb +1 -1
  67. data/spec/grammar/nil_spec.rb +1 -1
  68. data/spec/grammar/not_spec.rb +1 -1
  69. data/spec/grammar/op_asgn1_spec.rb +1 -1
  70. data/spec/grammar/op_asgn2_spec.rb +1 -1
  71. data/spec/grammar/or_spec.rb +1 -1
  72. data/spec/grammar/return_spec.rb +1 -1
  73. data/spec/grammar/sclass_spec.rb +1 -1
  74. data/spec/grammar/self_spec.rb +1 -1
  75. data/spec/grammar/str_spec.rb +1 -1
  76. data/spec/grammar/super_spec.rb +1 -1
  77. data/spec/grammar/true_spec.rb +1 -1
  78. data/spec/grammar/undef_spec.rb +1 -1
  79. data/spec/grammar/unless_spec.rb +1 -1
  80. data/spec/grammar/while_spec.rb +1 -1
  81. data/spec/grammar/xstr_spec.rb +1 -1
  82. data/spec/grammar/yield_spec.rb +1 -1
  83. data/spec/spec_helper.rb +6 -1
  84. data/test/core/array/minus_spec.rb +13 -0
  85. data/test/core/enumerable/drop_while_spec.rb +0 -5
  86. data/test/core/range/case_compare_spec.rb +0 -1
  87. data/test/index.html +1 -1
  88. data/test/index.min.html +12 -0
  89. data/test/language/alias_spec.rb +0 -4
  90. data/test/language/fixtures/next.rb +62 -0
  91. data/test/language/metaclass_spec.rb +4 -4
  92. data/test/language/next_spec.rb +0 -63
  93. data/test/language/send_spec.rb +0 -5
  94. data/test/language/singleton_class_spec.rb +4 -0
  95. data/test/opal/array/subclassing_spec.rb +1 -1
  96. data/test/opal/class/bridge_class_spec.rb +2 -2
  97. data/test/opal/runtime/class_hierarchy_spec.rb +1 -2
  98. data/test/opal/runtime/method_missing_spec.rb +17 -0
  99. data/test/spec_helper.rb +4 -1
  100. metadata +32 -28
  101. data/docs/CNAME +0 -1
  102. data/docs/Rakefile +0 -55
  103. data/docs/css/styles.css +0 -50
  104. data/docs/css/syntax.css +0 -63
  105. data/docs/layout/post.html +0 -3
  106. data/docs/layout/pre.html +0 -11
  107. data/examples/dependencies/.gitignore +0 -1
  108. data/examples/dependencies/Gemfile +0 -6
  109. data/examples/dependencies/README.md +0 -41
  110. data/examples/dependencies/Rakefile +0 -10
  111. data/examples/dependencies/app.rb +0 -19
  112. data/examples/dependencies/build/.gitkeep +0 -0
  113. data/examples/dependencies/index.html +0 -13
  114. data/examples/hello_world/.gitignore +0 -1
  115. data/examples/hello_world/Gemfile +0 -3
  116. data/examples/hello_world/README.md +0 -27
  117. data/examples/hello_world/Rakefile +0 -23
  118. data/examples/hello_world/app.rb +0 -7
  119. data/examples/hello_world/index.html +0 -12
  120. data/lib/opal/builder_task.rb +0 -91
  121. data/spec/builder/build_order_spec.rb +0 -20
  122. data/test/opal/runtime/_methods_spec.rb +0 -48
@@ -4,11 +4,11 @@ module Kernel
4
4
  end
5
5
 
6
6
  def ==(other)
7
- `this === other`
7
+ `#{self} === other`
8
8
  end
9
9
 
10
10
  def ===(other)
11
- `this == other`
11
+ `#{self} == other`
12
12
  end
13
13
 
14
14
  def Array(object)
@@ -34,7 +34,7 @@ module Kernel
34
34
  end
35
35
 
36
36
  def class
37
- `return this._real`
37
+ `return #{self}.$k`
38
38
  end
39
39
 
40
40
  def define_singleton_method(name, &body)
@@ -43,33 +43,33 @@ module Kernel
43
43
  no_block_given();
44
44
  }
45
45
 
46
- var jsid = mid_to_jsid(name);
47
- body._jsid = jsid;
48
- body._sup = this[jsid]
46
+ #{ self.singleton_class };
49
47
 
50
- // FIXME: need to donate()
51
- this.$singleton_class().prototype[jsid] = body;
48
+ body._jsid = name;
49
+ body._sup = #{self}.$m[name]
52
50
 
53
- return this;
51
+ #{self}.$m[name] = body;
52
+
53
+ return #{self};
54
54
  }
55
55
  end
56
56
 
57
57
  def equal?(other)
58
- `this === other`
58
+ `#{self} === other`
59
59
  end
60
60
 
61
61
  def extend(*mods)
62
62
  %x{
63
63
  for (var i = 0, length = mods.length; i < length; i++) {
64
- this.$singleton_class().$include(mods[i]);
64
+ #{ self.singleton_class.include `mods[i]` };
65
65
  }
66
66
 
67
- return this;
67
+ return #{self};
68
68
  }
69
69
  end
70
70
 
71
71
  def hash
72
- `this._id`
72
+ `#{self}._id`
73
73
  end
74
74
 
75
75
  def inspect
@@ -77,30 +77,30 @@ module Kernel
77
77
  end
78
78
 
79
79
  def instance_of?(klass)
80
- `this._klass === klass`
80
+ `#{self}.$k === klass`
81
81
  end
82
82
 
83
83
  def instance_variable_defined?(name)
84
- `__hasOwn.call(this, name.substr(1))`
84
+ `__hasOwn.call(#{self}, name.substr(1))`
85
85
  end
86
86
 
87
87
  def instance_variable_get(name)
88
88
  %x{
89
- var ivar = this[name.substr(1)];
89
+ var ivar = #{self}[name.substr(1)];
90
90
 
91
91
  return ivar == null ? nil : ivar;
92
92
  }
93
93
  end
94
94
 
95
95
  def instance_variable_set(name, value)
96
- `this[name.substr(1)] = value`
96
+ `#{self}[name.substr(1)] = value`
97
97
  end
98
98
 
99
99
  def instance_variables
100
100
  %x{
101
101
  var result = [];
102
102
 
103
- for (var name in this) {
103
+ for (var name in #{self}) {
104
104
  result.push(name);
105
105
  }
106
106
 
@@ -110,14 +110,14 @@ module Kernel
110
110
 
111
111
  def is_a?(klass)
112
112
  %x{
113
- var search = this._klass;
113
+ var search = #{self}.$k;
114
114
 
115
115
  while (search) {
116
116
  if (search === klass) {
117
117
  return true;
118
118
  }
119
119
 
120
- search = search._super;
120
+ search = search.$s;
121
121
  }
122
122
 
123
123
  return false;
@@ -133,15 +133,11 @@ module Kernel
133
133
  def loop(&block)
134
134
  return enum_for :loop unless block_given?
135
135
 
136
- %x{
137
- while (true) {
138
- if (block.call(__context) === __breaker) {
139
- return __breaker.$v;
140
- }
141
- }
136
+ `while (true) {`
137
+ yield
138
+ `}`
142
139
 
143
- return this;
144
- }
140
+ self
145
141
  end
146
142
 
147
143
  def nil?
@@ -149,7 +145,7 @@ module Kernel
149
145
  end
150
146
 
151
147
  def object_id
152
- `this._id || (this._id = unique_id++)`
148
+ `#{self}._id || (#{self}._id = unique_id++)`
153
149
  end
154
150
 
155
151
  def proc(&block)
@@ -191,30 +187,30 @@ module Kernel
191
187
  end
192
188
 
193
189
  def respond_to?(name)
194
- `!!this[mid_to_jsid(name)]`
190
+ `!!#{self}.$m[name]`
195
191
  end
196
192
 
197
193
  def singleton_class
198
194
  %x{
199
- if (!this._isObject) {
200
- return this._real;
195
+ if (!#{self}._isObject) {
196
+ return #{self}.$k;
201
197
  }
202
198
 
203
- if (this._klass._isSingleton) {
204
- return this._klass;
199
+ if (#{self}._singleton) {
200
+ return #{self}._singleton;
205
201
  }
202
+
206
203
  else {
207
- var orig_class = this._klass,
204
+ var orig_class = #{self}.$k,
208
205
  class_id = "#<Class:#<" + orig_class._name + ":" + orig_class._id + ">>";
209
206
 
210
- function _Singleton() {};
211
- var meta = boot_class(orig_class, _Singleton);
207
+ function Singleton() {};
208
+ var meta = boot_class(orig_class, Singleton);
212
209
  meta._name = class_id;
213
210
 
214
- meta._isSingleton = true;
215
- meta.prototype = this;
216
- this._klass = meta;
217
- meta._klass = orig_class._real;
211
+ #{self}.$m = meta.$m_tbl;
212
+ #{self}._singleton = meta;
213
+ meta.$k = orig_class.$k;
218
214
 
219
215
  return meta;
220
216
  }
@@ -237,7 +233,7 @@ module Kernel
237
233
  end
238
234
 
239
235
  def to_s
240
- `return "#<" + this._klass._real._name + ":0x" + (this._id * 400487).toString(16) + ">";`
236
+ `return "#<" + #{self}.$k._name + ":" + #{self}._id + ">";`
241
237
  end
242
238
 
243
239
  def enum_for (method = :each, *args)
@@ -1,24 +1,36 @@
1
1
  class Module
2
+ def ===(object)
3
+ %x{
4
+ if (object == null) {
5
+ return false;
6
+ }
7
+
8
+ var search = object.$k;
9
+
10
+ while (search) {
11
+ if (search === #{self}) {
12
+ return true;
13
+ }
14
+
15
+ search = search._super;
16
+ }
17
+
18
+ return false;
19
+ }
20
+ end
21
+
2
22
  def alias_method(newname, oldname)
3
- `this.prototype[mid_to_jsid(newname)] = this.prototype[mid_to_jsid(oldname)]`
23
+ `#{self}.$m_tbl[newname] = #{self}.$m_tbl[oldname]`
4
24
  self
5
25
  end
6
26
 
7
27
  def ancestors
8
28
  %x{
9
- var parent = this,
29
+ var parent = #{self},
10
30
  result = [];
11
31
 
12
32
  while (parent) {
13
- if (parent._isSingleton) {
14
- continue;
15
- }
16
- else if (parent._isIClass)
17
- result.push(parent._klass);
18
- else {
19
- result.push(parent);
20
- }
21
-
33
+ result.push(parent);
22
34
  parent = parent._super;
23
35
  }
24
36
 
@@ -28,7 +40,7 @@ class Module
28
40
 
29
41
  def append_features(klass)
30
42
  %x{
31
- var module = this;
43
+ var module = #{self};
32
44
 
33
45
  if (!klass.$included_modules) {
34
46
  klass.$included_modules = [];
@@ -48,17 +60,15 @@ class Module
48
60
 
49
61
  module.$included_in.push(klass);
50
62
 
51
- var donator = module.prototype,
52
- prototype = klass.prototype,
53
- methods = module._methods;
63
+ var donator = module.$m_tbl,
64
+ target = klass.$m_tbl;
54
65
 
55
- for (var i = 0, length = methods.length; i < length; i++) {
56
- var method = methods[i];
57
- prototype[method] = donator[method];
66
+ for (var meth in donator) {
67
+ target[meth] = donator[meth];
58
68
  }
59
69
 
60
70
  if (klass.$included_in) {
61
- klass._donate(methods.slice(), true);
71
+ // klass._donate(methods.slice(), true);
62
72
  }
63
73
  }
64
74
 
@@ -69,24 +79,20 @@ class Module
69
79
  %x{
70
80
  function define_attr(klass, name, getter, setter) {
71
81
  if (getter) {
72
- var get_jsid = mid_to_jsid(name);
73
-
74
- klass.prototype[get_jsid] = function() {
75
- var res = this[name];
82
+ klass.$m_tbl[name] = function() {
83
+ var res = #{self}[name];
76
84
  return res == null ? nil : res;
77
85
  };
78
86
 
79
- klass._donate([get_jsid]);
87
+ klass._donate([name]);
80
88
  }
81
89
 
82
90
  if (setter) {
83
- var set_jsid = mid_to_jsid(name + '=');
84
-
85
- klass.prototype[set_jsid] = function(val) {
86
- return this[name] = val;
91
+ klass.$m_tbl[name + '='] = function(val) {
92
+ return #{self}[name] = val;
87
93
  };
88
94
 
89
- klass._donate([set_jsid]);
95
+ klass._donate([name]);
90
96
  }
91
97
  }
92
98
  }
@@ -94,7 +100,7 @@ class Module
94
100
  def attr_accessor(*attrs)
95
101
  %x{
96
102
  for (var i = 0, length = attrs.length; i < length; i++) {
97
- define_attr(this, attrs[i], true, true);
103
+ define_attr(#{self}, attrs[i], true, true);
98
104
  }
99
105
 
100
106
  return nil;
@@ -104,7 +110,7 @@ class Module
104
110
  def attr_reader(*attrs)
105
111
  %x{
106
112
  for (var i = 0, length = attrs.length; i < length; i++) {
107
- define_attr(this, attrs[i], true, false);
113
+ define_attr(#{self}, attrs[i], true, false);
108
114
  }
109
115
 
110
116
  return nil;
@@ -114,7 +120,7 @@ class Module
114
120
  def attr_writer(*attrs)
115
121
  %x{
116
122
  for (var i = 0, length = attrs.length; i < length; i++) {
117
- define_attr(this, attrs[i], false, true);
123
+ define_attr(#{self}, attrs[i], false, true);
118
124
  }
119
125
 
120
126
  return nil;
@@ -122,7 +128,7 @@ class Module
122
128
  end
123
129
 
124
130
  def attr(name, setter = false)
125
- `define_attr(this, name, true, setter)`
131
+ `define_attr(#{self}, name, true, setter)`
126
132
 
127
133
  self
128
134
  end
@@ -133,12 +139,11 @@ class Module
133
139
  no_block_given();
134
140
  }
135
141
 
136
- var jsid = mid_to_jsid(name);
137
- block._jsid = jsid;
138
- block._sup = this.prototype[jsid];
142
+ block._jsid = name;
143
+ block._sup = #{self}.$m_tbl[name];
139
144
 
140
- this.prototype[jsid] = block;
141
- this._donate([jsid]);
145
+ #{self}.$m_tbl[name] = block;
146
+ #{self}._donate([name]);
142
147
 
143
148
  return nil;
144
149
  }
@@ -151,15 +156,15 @@ class Module
151
156
  mod = mods[i];
152
157
  i--;
153
158
 
154
- if (mod === this) {
159
+ if (mod === #{self}) {
155
160
  continue;
156
161
  }
157
- define_iclass(this, mod);
158
- mod.$append_features(this);
159
- mod.$included(this);
162
+
163
+ #{ `mod`.append_features self };
164
+ #{ `mod`.included self };
160
165
  }
161
166
 
162
- return this;
167
+ return #{self};
163
168
  }
164
169
  end
165
170
 
@@ -177,31 +182,29 @@ class Module
177
182
  no_block_given();
178
183
  }
179
184
 
180
- return block.call(this);
185
+ return block(#{self});
181
186
  }
182
187
  end
183
188
 
184
189
  alias class_eval module_eval
185
190
 
186
191
  def name
187
- `this._name`
192
+ `#{self}._name`
188
193
  end
189
194
 
190
195
  alias public_instance_methods instance_methods
191
196
 
192
197
  def singleton_class
193
198
  %x{
194
- if (this._klass._isSingleton) {
195
- return this._klass;
199
+ if (#{self}._singleton) {
200
+ return #{self}._singleton;
196
201
  }
197
- else {
198
- var meta = new __opal.Class;
199
- this._klass = meta;
200
- meta._isSingleton = true;
201
- meta.prototype = this;
202
202
 
203
- return meta;
204
- }
203
+ var meta = new __opal.Class;
204
+ #{self}._singleton = meta;
205
+ meta.$m_tbl = #{self}.$m;
206
+
207
+ return meta;
205
208
  }
206
209
  end
207
210
 
@@ -6,79 +6,79 @@ class Numeric < `Number`
6
6
  include Comparable
7
7
 
8
8
  def +(other)
9
- `this + other`
9
+ `#{self} + other`
10
10
  end
11
11
 
12
12
  def -(other)
13
- `this - other`
13
+ `#{self} - other`
14
14
  end
15
15
 
16
16
  def *(other)
17
- `this * other`
17
+ `#{self} * other`
18
18
  end
19
19
 
20
20
  def /(other)
21
- `this / other`
21
+ `#{self} / other`
22
22
  end
23
23
 
24
24
  def %(other)
25
- `this % other`
25
+ `#{self} % other`
26
26
  end
27
27
 
28
28
  def &(other)
29
- `this & other`
29
+ `#{self} & other`
30
30
  end
31
31
 
32
32
  def |(other)
33
- `this | other`
33
+ `#{self} | other`
34
34
  end
35
35
 
36
36
  def ^(other)
37
- `this ^ other`
37
+ `#{self} ^ other`
38
38
  end
39
39
 
40
40
  def <(other)
41
- `this < other`
41
+ `#{self} < other`
42
42
  end
43
43
 
44
44
  def <=(other)
45
- `this <= other`
45
+ `#{self} <= other`
46
46
  end
47
47
 
48
48
  def >(other)
49
- `this > other`
49
+ `#{self} > other`
50
50
  end
51
51
 
52
52
  def >=(other)
53
- `this >= other`
53
+ `#{self} >= other`
54
54
  end
55
55
 
56
56
  def <<(count)
57
- `this << count`
57
+ `#{self} << count`
58
58
  end
59
59
 
60
60
  def >>(count)
61
- `this >> count`
61
+ `#{self} >> count`
62
62
  end
63
63
 
64
64
  def +@
65
- `+this`
65
+ `+#{self}`
66
66
  end
67
67
 
68
68
  def -@
69
- `-this`
69
+ `-#{self}`
70
70
  end
71
71
 
72
72
  def ~
73
- `~this`
73
+ `~#{self}`
74
74
  end
75
75
 
76
76
  def **(other)
77
- `Math.pow(this, other)`
77
+ `Math.pow(#{self}, other)`
78
78
  end
79
79
 
80
80
  def ==(other)
81
- `this == other`
81
+ `#{self} == other`
82
82
  end
83
83
 
84
84
  def <=>(other)
@@ -87,52 +87,52 @@ class Numeric < `Number`
87
87
  return nil;
88
88
  }
89
89
 
90
- return this < other ? -1 : (this > other ? 1 : 0);
90
+ return #{self} < other ? -1 : (#{self} > other ? 1 : 0);
91
91
  }
92
92
  end
93
93
 
94
94
  def abs
95
- `Math.abs(this)`
95
+ `Math.abs(#{self})`
96
96
  end
97
97
 
98
98
  def ceil
99
- `Math.ceil(this)`
99
+ `Math.ceil(#{self})`
100
100
  end
101
101
 
102
102
  def chr
103
- `String.fromCharCode(this)`
103
+ `String.fromCharCode(#{self})`
104
104
  end
105
105
 
106
106
  def downto(finish, &block)
107
107
  return enum_for :downto, finish unless block_given?
108
108
 
109
109
  %x{
110
- for (var i = this; i >= finish; i--) {
110
+ for (var i = #{self}; i >= finish; i--) {
111
111
  if (block.call(__context, i) === __breaker) {
112
112
  return __breaker.$v;
113
113
  }
114
114
  }
115
115
 
116
- return this;
116
+ return #{self};
117
117
  }
118
118
  end
119
119
 
120
120
  alias eql? ==
121
121
 
122
122
  def even?
123
- `this % 2 === 0`
123
+ `#{self} % 2 === 0`
124
124
  end
125
125
 
126
126
  def floor
127
- `Math.floor(this)`
127
+ `Math.floor(#{self})`
128
128
  end
129
129
 
130
130
  def hash
131
- `this.toString()`
131
+ `#{self}.toString()`
132
132
  end
133
133
 
134
134
  def integer?
135
- `this % 1 === 0`
135
+ `#{self} % 1 === 0`
136
136
  end
137
137
 
138
138
  alias magnitude abs
@@ -140,15 +140,15 @@ class Numeric < `Number`
140
140
  alias modulo %
141
141
 
142
142
  def next
143
- `this + 1`
143
+ `#{self} + 1`
144
144
  end
145
145
 
146
146
  def nonzero?
147
- `this.valueOf() === 0 ? nil : this`
147
+ `#{self}.valueOf() === 0 ? nil : #{self}`
148
148
  end
149
149
 
150
150
  def odd?
151
- `this % 2 !== 0`
151
+ `#{self} % 2 !== 0`
152
152
  end
153
153
 
154
154
  def ord
@@ -156,7 +156,7 @@ class Numeric < `Number`
156
156
  end
157
157
 
158
158
  def pred
159
- `this - 1`
159
+ `#{self} - 1`
160
160
  end
161
161
 
162
162
  alias succ next
@@ -165,30 +165,30 @@ class Numeric < `Number`
165
165
  return enum_for :times unless block_given?
166
166
 
167
167
  %x{
168
- for (var i = 0; i <= this; i++) {
168
+ for (var i = 0; i <= #{self}; i++) {
169
169
  if (block.call(__context, i) === __breaker) {
170
170
  return __breaker.$v;
171
171
  }
172
172
  }
173
173
 
174
- return this;
174
+ return #{self};
175
175
  }
176
176
  end
177
177
 
178
178
  def to_f
179
- `parseFloat(this)`
179
+ `parseFloat(#{self})`
180
180
  end
181
181
 
182
182
  def to_i
183
- `parseInt(this)`
183
+ `parseInt(#{self})`
184
184
  end
185
185
 
186
186
  def to_json
187
- `this.toString()`
187
+ `#{self}.toString()`
188
188
  end
189
189
 
190
190
  def to_s(base = 10)
191
- `this.toString()`
191
+ `#{self}.toString()`
192
192
  end
193
193
 
194
194
  def upto(finish, &block)
@@ -201,11 +201,11 @@ class Numeric < `Number`
201
201
  }
202
202
  }
203
203
 
204
- return this;
204
+ return #{self};
205
205
  }
206
206
  end
207
207
 
208
208
  def zero?
209
- `this == 0`
209
+ `#{self} == 0`
210
210
  end
211
211
  end