Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 26f6149

Browse files
committedSep 5, 2014
Internals, $$ Ed.
__meta__ > $$meta __inc__ > $$inc __dep__ > $$dep __mod__ > $$mod __autoload > $$autoload __parent > $$parent _isClass > $$is_class _isSingleton > $$is_singleton _isArray > $$is_array _isRange > $$is_range _isRegexp > $$is_regexp _isBoolean > $$is_boolean _isString > $$is_string _isProc > $$is_proc _base_module > $$base_module _orig_scope > $$orig_scope _full_name > $$full_name _donated > $$donated _methods > $$methods _proto > $$proto _scope > $$scope _klass > $$class _super > $$super _name > $$name _jsid > $$jsid _def > $$def _id > $$id _p > $$p _s > $$s
1 parent c3157a7 commit 26f6149

36 files changed

+384
-384
lines changed
 

‎lib/opal/nodes/call.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def default_compile
6666

6767
if blktmp
6868
unshift "(#{blktmp} = "
69-
push ", #{blktmp}._p = ", block, ", #{blktmp})"
69+
push ", #{blktmp}.$$p = ", block, ", #{blktmp})"
7070
end
7171

7272
if splat

‎lib/opal/nodes/class.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def compile
1717

1818
in_scope do
1919
scope.name = name
20-
add_temp "#{scope.proto} = self._proto"
21-
add_temp "$scope = self._scope"
20+
add_temp "#{scope.proto} = self.$$proto"
21+
add_temp "$scope = self.$$scope"
2222

2323
body_code = self.body_code
2424
empty_line

‎lib/opal/nodes/constants.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ConstGetNode < Base
4949
def compile
5050
push "(("
5151
push expr(base)
52-
push ")._scope.get('#{name}'))"
52+
push ").$$scope.get('#{name}'))"
5353
end
5454
end
5555

‎lib/opal/nodes/def.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ def compile
7070
scope_name = scope.identity
7171

7272
if scope.uses_block?
73-
add_temp "$iter = #{scope_name}._p"
73+
add_temp "$iter = #{scope_name}.$$p"
7474
add_temp "#{yielder} = $iter || nil"
7575

76-
line "#{scope_name}._p = null;"
76+
line "#{scope_name}.$$p = null;"
7777
end
7878

7979
unshift "\n#{current_indent}", scope.to_vars
@@ -107,9 +107,9 @@ def compile
107107
elsif scope.iter?
108108
wrap "$opal.defn(self, '$#{mid}', ", ')'
109109
elsif scope.type == :sclass
110-
unshift "self._proto#{jsid} = "
110+
unshift "self.$$proto#{jsid} = "
111111
elsif scope.top?
112-
unshift "$opal.Object._proto#{jsid} = "
112+
unshift "$opal.Object.$$proto#{jsid} = "
113113
else
114114
unshift "def#{jsid} = "
115115
end

‎lib/opal/nodes/defined.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ def compile_colon2
7575
# does not raise errors is needed
7676
push "(function(){ try { return (("
7777
push expr(value)
78-
push ") != null ? 'constant' : nil); } catch (err) { if (err._klass"
78+
push ") != null ? 'constant' : nil); } catch (err) { if (err.$$class"
7979
push " === Opal.NameError) { return nil; } else { throw(err); }}; })()"
8080
end
8181

8282
def compile_colon3
83-
push "($opal.Object._scope.#{value[1]} == null ? nil : 'constant')"
83+
push "($opal.Object.$$scope.#{value[1]} == null ? nil : 'constant')"
8484
end
8585

8686
def compile_cvar

‎lib/opal/nodes/definitions.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def compile
4242
scope.methods << "$#{new_name[1]}"
4343
push "$opal.defn(self, '$#{new_name[1]}', #{scope.proto}#{old_mid})"
4444
else
45-
push "self._proto#{new_mid} = self._proto#{old_mid}"
45+
push "self.$$proto#{new_mid} = self.$$proto#{old_mid}"
4646
end
4747
end
4848
end

‎lib/opal/nodes/helpers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def js_truthy(sexp)
7676
end
7777

7878
with_temp do |tmp|
79-
[fragment("((#{tmp} = "), expr(sexp), fragment(") !== nil && (!#{tmp}._isBoolean || #{tmp} == true))")]
79+
[fragment("((#{tmp} = "), expr(sexp), fragment(") !== nil && (!#{tmp}.$$is_boolean || #{tmp} == true))")]
8080
end
8181
end
8282

@@ -90,7 +90,7 @@ def js_falsy(sexp)
9090
end
9191

9292
with_temp do |tmp|
93-
[fragment("((#{tmp} = "), expr(sexp), fragment(") === nil || (#{tmp}._isBoolean && #{tmp} == false))")]
93+
[fragment("((#{tmp} = "), expr(sexp), fragment(") === nil || (#{tmp}.$$is_boolean && #{tmp} == false))")]
9494
end
9595
end
9696

‎lib/opal/nodes/iter.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def compile
2525

2626
in_scope do
2727
identity = scope.identify!
28-
add_temp "self = #{identity}._s || this"
28+
add_temp "self = #{identity}.$$s || this"
2929

3030
compile_args(args[1..-1], opt_args, params)
3131

@@ -39,7 +39,7 @@ def compile
3939
scope.add_temp block_arg
4040
scope_name = scope.identify!
4141

42-
line "#{block_arg} = #{scope_name}._p || nil, #{scope_name}._p = null;"
42+
line "#{block_arg} = #{scope_name}.$$p || nil, #{scope_name}.$$p = null;"
4343
end
4444

4545
body_code = stmt(body)
@@ -51,7 +51,7 @@ def compile
5151
unshift to_vars
5252

5353
unshift "(#{identity} = function(#{params.join ', '}){"
54-
push "}, #{identity}._s = self, #{identity})"
54+
push "}, #{identity}.$$s = self, #{identity})"
5555
end
5656

5757
def compile_args(args, opt_args, params)

‎lib/opal/nodes/masgn.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def compile
1818
push "#{tmp} = $opal.to_ary(", expr(rhs[1]), ")"
1919
elsif rhs.type == :splat
2020
push "(#{tmp} = ", expr(rhs[1]), ")['$to_a'] ? (#{tmp} = #{tmp}['$to_a']())"
21-
push " : (#{tmp})._isArray ? #{tmp} : (#{tmp} = [#{tmp}])"
21+
push " : (#{tmp}).$$is_array ? #{tmp} : (#{tmp} = [#{tmp}])"
2222
else
2323
raise "unsupported mlhs type"
2424
end

‎lib/opal/nodes/module.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def compile
1616

1717
in_scope do
1818
scope.name = name
19-
add_temp "#{scope.proto} = self._proto"
20-
add_temp '$scope = self._scope'
19+
add_temp "#{scope.proto} = self.$$proto"
20+
add_temp '$scope = self.$$scope'
2121

2222
body_code = stmt(body || s(:nil))
2323
empty_line

‎lib/opal/nodes/singleton_class.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def compile
1111
push "(function(self) {"
1212

1313
in_scope do
14-
add_temp '$scope = self._scope'
15-
add_temp 'def = self._proto'
14+
add_temp '$scope = self.$$scope'
15+
add_temp 'def = self.$$proto'
1616

1717
line scope.to_vars
1818
line stmt(compiler.returns(body))

‎lib/opal/nodes/super.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def compile_dispatcher
1818
if scope.def?
1919
scope.uses_block!
2020
scope_name = scope.identify!
21-
class_name = scope.parent.name ? "$#{scope.parent.name}" : 'self._klass._proto'
21+
class_name = scope.parent.name ? "$#{scope.parent.name}" : 'self.$$class.$$proto'
2222

2323
if scope.defs
2424
push "$opal.find_super_dispatcher(self, '#{scope.mid.to_s}', #{scope_name}, "
@@ -31,7 +31,7 @@ def compile_dispatcher
3131
end
3232
elsif scope.iter?
3333
chain, cur_defn, mid = scope.get_super_chain
34-
trys = chain.map { |c| "#{c}._def" }.join(' || ')
34+
trys = chain.map { |c| "#{c}.$$def" }.join(' || ')
3535

3636
push "$opal.find_iter_super_dispatcher(self, #{mid}, (#{trys} || #{cur_defn}), null)"
3737
else

‎opal/corelib/array.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Array
44
include Enumerable
55

66
# Mark all javascript arrays as being valid ruby arrays
7-
`def._isArray = true`
7+
`def.$$is_array = true`
88

99
def self.[](*objects)
1010
objects
@@ -244,7 +244,7 @@ def ==(other)
244244
var a = self[i],
245245
b = other[i];
246246
247-
if (a._isArray && b._isArray && (a === self)) {
247+
if (a.$$is_array && b.$$is_array && (a === self)) {
248248
continue;
249249
}
250250
@@ -721,7 +721,7 @@ def eql?(other)
721721
var a = self[i],
722722
b = other[i];
723723
724-
if (a._isArray && b._isArray && (a === self)) {
724+
if (a.$$is_array && b.$$is_array && (a === self)) {
725725
continue;
726726
}
727727
@@ -916,7 +916,7 @@ def flatten!(level = undefined)
916916
end
917917

918918
def hash
919-
`self._id || (self._id = Opal.uid())`
919+
`self.$$id || (self.$$id = Opal.uid())`
920920
end
921921

922922
def include?(member)

‎opal/corelib/array/inheritance.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ def self.inherited(klass)
33
replace = Class.new(Array::Wrapper)
44

55
%x{
6-
klass._proto = replace._proto;
7-
klass._proto._klass = klass;
8-
klass._alloc = replace._alloc;
9-
klass.__parent = #{Array::Wrapper};
6+
klass.$$proto = replace.$$proto;
7+
klass.$$proto.$$class = klass;
8+
klass.$$alloc = replace.$$alloc;
9+
klass.$$parent = #{Array::Wrapper};
1010
1111
klass.$allocate = replace.$allocate;
1212
klass.$new = replace.$new;
@@ -79,7 +79,7 @@ def *(other)
7979
%x{
8080
var result = #{@literal * other};
8181
82-
if (result._isArray) {
82+
if (result.$$is_array) {
8383
return #{self.class.allocate(`result`)}
8484
}
8585
else {
@@ -92,7 +92,7 @@ def [](index, length = undefined)
9292
%x{
9393
var result = #{@literal.slice(index, length)};
9494
95-
if (result._isArray && (index._isRange || length !== undefined)) {
95+
if (result.$$is_array && (index.$$is_range || length !== undefined)) {
9696
return #{self.class.allocate(`result`)}
9797
}
9898
else {

‎opal/corelib/basic_object.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def ==(other)
77
end
88

99
def __id__
10-
`self._id || (self._id = Opal.uid())`
10+
`self.$$id || (self.$$id = Opal.uid())`
1111
end
1212

1313
def __send__(symbol, *args, &block)
@@ -16,14 +16,14 @@ def __send__(symbol, *args, &block)
1616
1717
if (func) {
1818
if (block !== nil) {
19-
func._p = block;
19+
func.$$p = block;
2020
}
2121
2222
return func.apply(self, args);
2323
}
2424
2525
if (block !== nil) {
26-
self.$method_missing._p = block;
26+
self.$method_missing.$$p = block;
2727
}
2828
2929
return self.$method_missing.apply(self, [symbol].concat(args));
@@ -41,12 +41,12 @@ def instance_eval(&block)
4141
Kernel.raise ArgumentError, "no block given" unless block
4242

4343
%x{
44-
var old = block._s,
44+
var old = block.$$s,
4545
result;
4646
47-
block._s = null;
47+
block.$$s = null;
4848
result = block.call(self, self);
49-
block._s = old;
49+
block.$$s = old;
5050
5151
return result;
5252
}
@@ -56,12 +56,12 @@ def instance_exec(*args, &block)
5656
Kernel.raise ArgumentError, "no block given" unless block
5757

5858
%x{
59-
var block_self = block._s,
59+
var block_self = block.$$s,
6060
result;
6161
62-
block._s = null;
62+
block.$$s = null;
6363
result = block.apply(self, args);
64-
block._s = block_self;
64+
block.$$s = block_self;
6565
6666
return result;
6767
}

‎opal/corelib/boolean.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Boolean
2-
`def._isBoolean = true`
2+
`def.$$is_boolean = true`
33

44
class << self
55
undef_method :new

‎opal/corelib/class.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
class Class
44
def self.new(sup = Object, &block)
55
%x{
6-
if (!sup._isClass || sup.__mod__) {
6+
if (!sup.$$is_class || sup.$$mod) {
77
#{raise TypeError, "superclass must be a Class"};
88
}
99
1010
function AnonClass(){};
1111
var klass = Opal.boot(sup, AnonClass)
12-
klass._name = nil;
13-
klass.__parent = sup;
12+
klass.$$name = nil;
13+
klass.$$parent = sup;
1414
1515
// inherit scope from parent
16-
$opal.create_scope(sup._scope, klass);
16+
$opal.create_scope(sup.$$scope, klass);
1717
1818
sup.$inherited(klass);
1919
2020
if (block !== nil) {
21-
var block_self = block._s;
22-
block._s = null;
21+
var block_self = block.$$s;
22+
block.$$s = null;
2323
block.call(klass);
24-
block._s = block_self;
24+
block.$$s = block_self;
2525
}
2626
2727
return klass;
@@ -30,8 +30,8 @@ def self.new(sup = Object, &block)
3030

3131
def allocate
3232
%x{
33-
var obj = new self._alloc;
34-
obj._id = Opal.uid();
33+
var obj = new self.$$alloc;
34+
obj.$$id = Opal.uid();
3535
return obj;
3636
}
3737
end
@@ -43,13 +43,13 @@ def new(*args, &block)
4343
%x{
4444
var obj = #{allocate};
4545
46-
obj.$initialize._p = block;
46+
obj.$initialize.$$p = block;
4747
obj.$initialize.apply(obj, args);
4848
return obj;
4949
}
5050
end
5151

5252
def superclass
53-
`self._super || nil`
53+
`self.$$super || nil`
5454
end
5555
end

‎opal/corelib/enumerable.rb

+42-42
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def all?(&block)
44
var result = true;
55
66
if (block !== nil) {
7-
self.$each._p = function() {
7+
self.$each.$$p = function() {
88
var value = $opal.$yieldX(block, arguments);
99
1010
if (value === $breaker) {
@@ -19,7 +19,7 @@ def all?(&block)
1919
}
2020
}
2121
else {
22-
self.$each._p = function(obj) {
22+
self.$each.$$p = function(obj) {
2323
if (arguments.length == 1 && #{Opal.falsy?(`obj`)}) {
2424
result = false;
2525
return $breaker;
@@ -38,7 +38,7 @@ def any?(&block)
3838
var result = false;
3939
4040
if (block !== nil) {
41-
self.$each._p = function() {
41+
self.$each.$$p = function() {
4242
var value = $opal.$yieldX(block, arguments);
4343
4444
if (value === $breaker) {
@@ -53,7 +53,7 @@ def any?(&block)
5353
};
5454
}
5555
else {
56-
self.$each._p = function(obj) {
56+
self.$each.$$p = function(obj) {
5757
if (arguments.length != 1 || #{Opal.truthy?(`obj`)}) {
5858
result = true;
5959
return $breaker;
@@ -77,7 +77,7 @@ def collect(&block)
7777
%x{
7878
var result = [];
7979
80-
self.$each._p = function() {
80+
self.$each.$$p = function() {
8181
var value = $opal.$yieldX(block, arguments);
8282
8383
if (value === $breaker) {
@@ -112,7 +112,7 @@ def count(object = undefined, &block)
112112
block = function() { return true; };
113113
}
114114
115-
self.$each._p = function() {
115+
self.$each.$$p = function() {
116116
var value = $opal.$yieldX(block, arguments);
117117
118118
if (value === $breaker) {
@@ -144,7 +144,7 @@ def cycle(n = nil, &block)
144144
var result,
145145
all = [];
146146
147-
self.$each._p = function() {
147+
self.$each.$$p = function() {
148148
var param = #{Opal.destructure(`arguments`)},
149149
value = $opal.$yield1(block, param);
150150
@@ -202,7 +202,7 @@ def detect(ifnone = undefined, &block)
202202
%x{
203203
var result = undefined;
204204
205-
self.$each._p = function() {
205+
self.$each.$$p = function() {
206206
var params = #{Opal.destructure(`arguments`)},
207207
value = $opal.$yield1(block, params);
208208
@@ -243,7 +243,7 @@ def drop(number)
243243
var result = [],
244244
current = 0;
245245
246-
self.$each._p = function() {
246+
self.$each.$$p = function() {
247247
if (number <= current) {
248248
result.push(#{Opal.destructure(`arguments`)});
249249
}
@@ -264,7 +264,7 @@ def drop_while(&block)
264264
var result = [],
265265
dropping = true;
266266
267-
self.$each._p = function() {
267+
self.$each.$$p = function() {
268268
var param = #{Opal.destructure(`arguments`)};
269269
270270
if (dropping) {
@@ -312,7 +312,7 @@ def each_slice(n, &block)
312312
var result,
313313
slice = []
314314
315-
self.$each._p = function() {
315+
self.$each.$$p = function() {
316316
var param = #{Opal.destructure(`arguments`)};
317317
318318
slice.push(param);
@@ -351,7 +351,7 @@ def each_with_index(*args, &block)
351351
var result,
352352
index = 0;
353353
354-
self.$each._p = function() {
354+
self.$each.$$p = function() {
355355
var param = #{Opal.destructure(`arguments`)},
356356
value = block(param, index);
357357
@@ -379,7 +379,7 @@ def each_with_object(object, &block)
379379
%x{
380380
var result;
381381
382-
self.$each._p = function() {
382+
self.$each.$$p = function() {
383383
var param = #{Opal.destructure(`arguments`)},
384384
value = block(param, object);
385385
@@ -403,7 +403,7 @@ def entries(*args)
403403
%x{
404404
var result = [];
405405
406-
self.$each._p = function() {
406+
self.$each.$$p = function() {
407407
result.push(#{Opal.destructure(`arguments`)});
408408
};
409409
@@ -421,7 +421,7 @@ def find_all(&block)
421421
%x{
422422
var result = [];
423423
424-
self.$each._p = function() {
424+
self.$each.$$p = function() {
425425
var param = #{Opal.destructure(`arguments`)},
426426
value = $opal.$yield1(block, param);
427427
@@ -449,7 +449,7 @@ def find_index(object = undefined, &block)
449449
index = 0;
450450
451451
if (object != null) {
452-
self.$each._p = function() {
452+
self.$each.$$p = function() {
453453
var param = #{Opal.destructure(`arguments`)};
454454
455455
if (#{`param` == `object`}) {
@@ -461,7 +461,7 @@ def find_index(object = undefined, &block)
461461
};
462462
}
463463
else if (block !== nil) {
464-
self.$each._p = function() {
464+
self.$each.$$p = function() {
465465
var value = $opal.$yieldX(block, arguments);
466466
467467
if (value === $breaker) {
@@ -489,7 +489,7 @@ def first(number = undefined)
489489
result = nil
490490

491491
%x{
492-
self.$each._p = function() {
492+
self.$each.$$p = function() {
493493
result = #{Opal.destructure(`arguments`)};
494494
495495
return $breaker;
@@ -513,7 +513,7 @@ def first(number = undefined)
513513
var current = 0,
514514
number = #{Opal.coerce_to number, Integer, :to_int};
515515
516-
self.$each._p = function() {
516+
self.$each.$$p = function() {
517517
result.push(#{Opal.destructure(`arguments`)});
518518
519519
if (number <= ++current) {
@@ -535,7 +535,7 @@ def grep(pattern, &block)
535535
var result = [];
536536
537537
if (block !== nil) {
538-
self.$each._p = function() {
538+
self.$each.$$p = function() {
539539
var param = #{Opal.destructure(`arguments`)},
540540
value = #{pattern === `param`};
541541
@@ -552,7 +552,7 @@ def grep(pattern, &block)
552552
};
553553
}
554554
else {
555-
self.$each._p = function() {
555+
self.$each.$$p = function() {
556556
var param = #{Opal.destructure(`arguments`)},
557557
value = #{pattern === `param`};
558558
@@ -576,7 +576,7 @@ def group_by(&block)
576576
%x{
577577
var result;
578578
579-
self.$each._p = function() {
579+
self.$each.$$p = function() {
580580
var param = #{Opal.destructure(`arguments`)},
581581
value = $opal.$yield1(block, param);
582582
@@ -602,7 +602,7 @@ def include?(obj)
602602
%x{
603603
var result = false;
604604
605-
self.$each._p = function() {
605+
self.$each.$$p = function() {
606606
var param = #{Opal.destructure(`arguments`)};
607607
608608
if (#{`param` == obj}) {
@@ -622,7 +622,7 @@ def inject(object = undefined, sym = undefined, &block)
622622
var result = object;
623623
624624
if (block !== nil && sym === undefined) {
625-
self.$each._p = function() {
625+
self.$each.$$p = function() {
626626
var value = #{Opal.destructure(`arguments`)};
627627
628628
if (result === undefined) {
@@ -650,7 +650,7 @@ def inject(object = undefined, sym = undefined, &block)
650650
result = undefined;
651651
}
652652
653-
self.$each._p = function() {
653+
self.$each.$$p = function() {
654654
var value = #{Opal.destructure(`arguments`)};
655655
656656
if (result === undefined) {
@@ -686,7 +686,7 @@ def max(&block)
686686
var result;
687687
688688
if (block !== nil) {
689-
self.$each._p = function() {
689+
self.$each.$$p = function() {
690690
var param = #{Opal.destructure(`arguments`)};
691691
692692
if (result === undefined) {
@@ -711,7 +711,7 @@ def max(&block)
711711
};
712712
}
713713
else {
714-
self.$each._p = function() {
714+
self.$each.$$p = function() {
715715
var param = #{Opal.destructure(`arguments`)};
716716
717717
if (result === undefined) {
@@ -738,7 +738,7 @@ def max_by(&block)
738738
var result,
739739
by;
740740
741-
self.$each._p = function() {
741+
self.$each.$$p = function() {
742742
var param = #{Opal.destructure(`arguments`)},
743743
value = $opal.$yield1(block, param);
744744
@@ -772,7 +772,7 @@ def min(&block)
772772
var result;
773773
774774
if (block !== nil) {
775-
self.$each._p = function() {
775+
self.$each.$$p = function() {
776776
var param = #{Opal.destructure(`arguments`)};
777777
778778
if (result === undefined) {
@@ -797,7 +797,7 @@ def min(&block)
797797
};
798798
}
799799
else {
800-
self.$each._p = function() {
800+
self.$each.$$p = function() {
801801
var param = #{Opal.destructure(`arguments`)};
802802
803803
if (result === undefined) {
@@ -824,7 +824,7 @@ def min_by(&block)
824824
var result,
825825
by;
826826
827-
self.$each._p = function() {
827+
self.$each.$$p = function() {
828828
var param = #{Opal.destructure(`arguments`)},
829829
value = $opal.$yield1(block, param);
830830
@@ -864,7 +864,7 @@ def none?(&block)
864864
var result = true;
865865
866866
if (block !== nil) {
867-
self.$each._p = function() {
867+
self.$each.$$p = function() {
868868
var value = $opal.$yieldX(block, arguments);
869869
870870
if (value === $breaker) {
@@ -879,7 +879,7 @@ def none?(&block)
879879
}
880880
}
881881
else {
882-
self.$each._p = function() {
882+
self.$each.$$p = function() {
883883
var value = #{Opal.destructure(`arguments`)};
884884
885885
if (#{Opal.truthy?(`value`)}) {
@@ -900,7 +900,7 @@ def one?(&block)
900900
var result = false;
901901
902902
if (block !== nil) {
903-
self.$each._p = function() {
903+
self.$each.$$p = function() {
904904
var value = $opal.$yieldX(block, arguments);
905905
906906
if (value === $breaker) {
@@ -919,7 +919,7 @@ def one?(&block)
919919
}
920920
}
921921
else {
922-
self.$each._p = function() {
922+
self.$each.$$p = function() {
923923
var value = #{Opal.destructure(`arguments`)};
924924
925925
if (#{Opal.truthy?(`value`)}) {
@@ -945,7 +945,7 @@ def partition(&block)
945945
%x{
946946
var truthy = [], falsy = [];
947947
948-
self.$each._p = function() {
948+
self.$each.$$p = function() {
949949
var param = #{Opal.destructure(`arguments`)},
950950
value = $opal.$yield1(block, param);
951951
@@ -976,7 +976,7 @@ def reject(&block)
976976
%x{
977977
var result = [];
978978
979-
self.$each._p = function() {
979+
self.$each.$$p = function() {
980980
var param = #{Opal.destructure(`arguments`)},
981981
value = $opal.$yield1(block, param);
982982
@@ -1002,7 +1002,7 @@ def reverse_each(&block)
10021002
%x{
10031003
var result = [];
10041004
1005-
self.$each._p = function() {
1005+
self.$each.$$p = function() {
10061006
result.push(arguments);
10071007
};
10081008
@@ -1029,7 +1029,7 @@ def slice_before(pattern = undefined, &block)
10291029
10301030
if (block !== nil) {
10311031
if (pattern === undefined) {
1032-
self.$each._p = function() {
1032+
self.$each.$$p = function() {
10331033
var param = #{Opal.destructure(`arguments`)},
10341034
value = $opal.$yield1(block, param);
10351035
@@ -1042,7 +1042,7 @@ def slice_before(pattern = undefined, &block)
10421042
};
10431043
}
10441044
else {
1045-
self.$each._p = function() {
1045+
self.$each.$$p = function() {
10461046
var param = #{Opal.destructure(`arguments`)},
10471047
value = block(param, #{pattern.dup});
10481048
@@ -1056,7 +1056,7 @@ def slice_before(pattern = undefined, &block)
10561056
}
10571057
}
10581058
else {
1059-
self.$each._p = function() {
1059+
self.$each.$$p = function() {
10601060
var param = #{Opal.destructure(`arguments`)},
10611061
value = #{pattern === `param`};
10621062
@@ -1102,7 +1102,7 @@ def take_while(&block)
11021102
%x{
11031103
var result = [];
11041104
1105-
self.$each._p = function() {
1105+
self.$each.$$p = function() {
11061106
var param = #{Opal.destructure(`arguments`)},
11071107
value = $opal.$yield1(block, param);
11081108

‎opal/corelib/enumerator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def with_index(offset = 0, &block)
6161
%x{
6262
var result
6363
64-
self.$each._p = function() {
64+
self.$each.$$p = function() {
6565
var param = #{Opal.destructure(`arguments`)},
6666
value = block(param, index);
6767

‎opal/corelib/error.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class Exception
44
def self.new(message = '')
55
%x{
66
var err = new Error(message);
7-
err._klass = self;
8-
err.name = self._name;
7+
err.$$class = self;
8+
err.name = self.$$name;
99
return err;
1010
}
1111
end

‎opal/corelib/hash.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.[](*objs)
99

1010
def self.allocate
1111
%x{
12-
var hash = new self._alloc;
12+
var hash = new self.$$alloc;
1313
1414
hash.map = {};
1515
hash.keys = [];
@@ -125,7 +125,7 @@ def clone
125125
map[key] = value;
126126
}
127127
128-
var hash = new self._klass._alloc();
128+
var hash = new self.$$class.$$alloc();
129129
130130
hash.map = map;
131131
hash.keys = keys;
@@ -313,7 +313,7 @@ def flatten(level=undefined)
313313
314314
result.push(key);
315315
316-
if (value._isArray) {
316+
if (value.$$is_array) {
317317
if (level == null || level === 1) {
318318
result.push(value);
319319
}
@@ -347,7 +347,7 @@ def has_value?(value)
347347
end
348348

349349
def hash
350-
`self._id`
350+
`self.$$id`
351351
end
352352

353353
alias include? has_key?
@@ -689,7 +689,7 @@ def to_a
689689

690690
def to_h
691691
%x{
692-
var hash = new Opal.Hash._alloc,
692+
var hash = new Opal.Hash.$$alloc,
693693
cloned = #{clone};
694694
695695
hash.map = cloned.map;

‎opal/corelib/helpers.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def self.destructure(args)
6464
if (args.length == 1) {
6565
return args[0];
6666
}
67-
else if (args._isArray) {
67+
else if (args.$$is_array) {
6868
return args;
6969
}
7070
else {
@@ -75,7 +75,7 @@ def self.destructure(args)
7575

7676
def self.respond_to?(obj, method)
7777
%x{
78-
if (obj == null || !obj._klass) {
78+
if (obj == null || !obj.$$class) {
7979
return false;
8080
}
8181
}
@@ -91,7 +91,7 @@ def self.inspect(obj)
9191
else if (obj === null) {
9292
return "null";
9393
}
94-
else if (!obj._klass) {
94+
else if (!obj.$$class) {
9595
return obj.toString();
9696
}
9797
else {

‎opal/corelib/kernel.rb

+31-31
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ def caller
7878
end
7979

8080
def class
81-
`self._klass`
81+
`self.$$class`
8282
end
8383

8484
def copy_instance_variables(other)
8585
%x{
8686
for (var name in other) {
8787
if (name.charAt(0) !== '$') {
88-
if (name !== '_id' && name !== '_klass') {
88+
if (name !== '$$id' && name !== '$$class') {
8989
self[name] = other[name];
9090
}
9191
}
@@ -113,11 +113,11 @@ def define_singleton_method(name, &body)
113113

114114
%x{
115115
var jsid = '$' + name;
116-
body._jsid = name;
117-
body._s = null;
118-
body._def = body;
116+
body.$$jsid = name;
117+
body.$$s = null;
118+
body.$$def = body;
119119
120-
#{singleton_class}._proto[jsid] = body;
120+
#{singleton_class}.$$proto[jsid] = body;
121121
122122
return self;
123123
}
@@ -204,7 +204,7 @@ def format(format, *args)
204204
switch (spec) {
205205
case 'c':
206206
obj = args[idx];
207-
if (obj._isString) {
207+
if (obj.$$is_string) {
208208
str = obj.charAt(0);
209209
} else {
210210
str = String.fromCharCode(#{`obj`.to_i});
@@ -291,7 +291,7 @@ def format(format, *args)
291291
end
292292

293293
def hash
294-
`self._id`
294+
`self.$$id`
295295
end
296296

297297
def initialize_copy(other)
@@ -302,7 +302,7 @@ def inspect
302302
end
303303

304304
def instance_of?(klass)
305-
`self._klass === klass`
305+
`self.$$class === klass`
306306
end
307307

308308
def instance_variable_defined?(name)
@@ -327,7 +327,7 @@ def instance_variables
327327
328328
for (var name in self) {
329329
if (name.charAt(0) !== '$') {
330-
if (name !== '_klass' && name !== '_id') {
330+
if (name !== '$$class' && name !== '$$id') {
331331
result.push('@' + name);
332332
}
333333
}
@@ -460,7 +460,7 @@ def raise(exception = undefined, string = undefined)
460460
if (exception == null && #$!) {
461461
exception = #$!;
462462
}
463-
else if (exception._isString) {
463+
else if (exception.$$is_string) {
464464
exception = #{RuntimeError.new exception};
465465
}
466466
else if (!#{exception.is_a? Exception}) {
@@ -479,7 +479,7 @@ def rand(max = undefined)
479479
if (max === undefined) {
480480
return Math.random();
481481
}
482-
else if (max._isRange) {
482+
else if (max.$$is_range) {
483483
var arr = #{max.to_a};
484484
485485
return arr[#{rand(`arr.length`)}];
@@ -512,43 +512,43 @@ def respond_to?(name, include_all = false)
512512

513513
def singleton_class
514514
%x{
515-
if (self.__meta__) {
516-
return self.__meta__;
515+
if (self.$$meta) {
516+
return self.$$meta;
517517
}
518518
519-
if (self._isClass) {
520-
var meta = new $opal.Class._alloc;
521-
meta._klass = $opal.Class;
519+
if (self.$$is_class) {
520+
var meta = new $opal.Class.$$alloc;
521+
meta.$$class = $opal.Class;
522522
523523
// FIXME - is this right? (probably - methods defined on
524524
// class' singleton should also go to subclasses?)
525525
//
526526
// @elia says: Actually a class' singleton inherits from its superclass'
527527
// singleton that in turn inherits from Class;
528528
529-
meta._proto = self.constructor.prototype;
529+
meta.$$proto = self.constructor.prototype;
530530
531-
meta._isSingleton = true;
532-
meta.__inc__ = [];
533-
meta._methods = [];
534-
meta._scope = self._scope;
531+
meta.$$is_singleton = true;
532+
meta.$$inc = [];
533+
meta.$$methods = [];
534+
meta.$$scope = self.$$scope;
535535
}
536536
537537
else {
538-
var orig_class = self._klass,
539-
class_id = "#<Class:#<" + orig_class._name + ":" + orig_class._id + ">>";
538+
var orig_class = self.$$class,
539+
class_id = "#<Class:#<" + orig_class.$$name + ":" + orig_class.$$id + ">>";
540540
541541
var Singleton = function () {};
542542
var meta = Opal.boot(orig_class, Singleton);
543-
meta._name = class_id;
543+
meta.$$name = class_id;
544544
545-
meta._proto = self;
546-
meta._klass = orig_class._klass;
547-
meta._scope = orig_class._scope;
548-
meta.__parent = orig_class;
545+
meta.$$proto = self;
546+
meta.$$class = orig_class.$$class;
547+
meta.$$scope = orig_class.$$scope;
548+
meta.$$parent = orig_class;
549549
}
550550
551-
return self.__meta__ = meta;
551+
return self.$$meta = meta;
552552
}
553553
end
554554

@@ -568,7 +568,7 @@ def to_proc
568568
end
569569

570570
def to_s
571-
`"#<" + #{self.class.name} + ":" + self._id + ">"`
571+
`"#<" + #{self.class.name} + ":" + self.$$id + ">"`
572572
end
573573

574574
def freeze

‎opal/corelib/method.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def arity
1414

1515
def call(*args, &block)
1616
%x{
17-
#@method._p = block;
17+
#@method.$$p = block;
1818
1919
return #@method.apply(#@receiver, args);
2020
}

‎opal/corelib/module.rb

+74-74
Large diffs are not rendered by default.

‎opal/corelib/nil_class.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def to_s
5454
end
5555

5656
def object_id
57-
`#{NilClass}._id || (#{NilClass}._id = $opal.uid())`
57+
`#{NilClass}.$$id || (#{NilClass}.$$id = $opal.uid())`
5858
end
5959
alias hash object_id
6060
end

‎opal/corelib/numeric.rb

+19-19
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
class Numeric
44
include Comparable
55

6-
`def._isNumber = true`
6+
`def.$$is_number = true`
77

88
def coerce(other, type = :operation)
99
%x{
10-
if (other._isNumber) {
10+
if (other.$$is_number) {
1111
return [self, other];
1212
}
1313
else {
@@ -39,7 +39,7 @@ def send_coerced(method, other)
3939

4040
def +(other)
4141
%x{
42-
if (other._isNumber) {
42+
if (other.$$is_number) {
4343
return self + other;
4444
}
4545
else {
@@ -50,7 +50,7 @@ def +(other)
5050

5151
def -(other)
5252
%x{
53-
if (other._isNumber) {
53+
if (other.$$is_number) {
5454
return self - other;
5555
}
5656
else {
@@ -61,7 +61,7 @@ def -(other)
6161

6262
def *(other)
6363
%x{
64-
if (other._isNumber) {
64+
if (other.$$is_number) {
6565
return self * other;
6666
}
6767
else {
@@ -72,7 +72,7 @@ def *(other)
7272

7373
def /(other)
7474
%x{
75-
if (other._isNumber) {
75+
if (other.$$is_number) {
7676
return self / other;
7777
}
7878
else {
@@ -83,7 +83,7 @@ def /(other)
8383

8484
def %(other)
8585
%x{
86-
if (other._isNumber) {
86+
if (other.$$is_number) {
8787
if (other < 0 || self < 0) {
8888
return (self % other + other) % other;
8989
}
@@ -99,7 +99,7 @@ def %(other)
9999

100100
def &(other)
101101
%x{
102-
if (other._isNumber) {
102+
if (other.$$is_number) {
103103
return self & other;
104104
}
105105
else {
@@ -110,7 +110,7 @@ def &(other)
110110

111111
def |(other)
112112
%x{
113-
if (other._isNumber) {
113+
if (other.$$is_number) {
114114
return self | other;
115115
}
116116
else {
@@ -121,7 +121,7 @@ def |(other)
121121

122122
def ^(other)
123123
%x{
124-
if (other._isNumber) {
124+
if (other.$$is_number) {
125125
return self ^ other;
126126
}
127127
else {
@@ -132,7 +132,7 @@ def ^(other)
132132

133133
def <(other)
134134
%x{
135-
if (other._isNumber) {
135+
if (other.$$is_number) {
136136
return self < other;
137137
}
138138
else {
@@ -143,7 +143,7 @@ def <(other)
143143

144144
def <=(other)
145145
%x{
146-
if (other._isNumber) {
146+
if (other.$$is_number) {
147147
return self <= other;
148148
}
149149
else {
@@ -154,7 +154,7 @@ def <=(other)
154154

155155
def >(other)
156156
%x{
157-
if (other._isNumber) {
157+
if (other.$$is_number) {
158158
return self > other;
159159
}
160160
else {
@@ -165,7 +165,7 @@ def >(other)
165165

166166
def >=(other)
167167
%x{
168-
if (other._isNumber) {
168+
if (other.$$is_number) {
169169
return self >= other;
170170
}
171171
else {
@@ -176,7 +176,7 @@ def >=(other)
176176

177177
def <=>(other)
178178
%x{
179-
if (other._isNumber) {
179+
if (other.$$is_number) {
180180
return self > other ? 1 : (self < other ? -1 : 0);
181181
}
182182
else {
@@ -217,7 +217,7 @@ def ~
217217

218218
def **(other)
219219
%x{
220-
if (other._isNumber) {
220+
if (other.$$is_number) {
221221
return Math.pow(self, other);
222222
}
223223
else {
@@ -228,7 +228,7 @@ def **(other)
228228

229229
def ==(other)
230230
%x{
231-
if (other._isNumber) {
231+
if (other.$$is_number) {
232232
return self == Number(other);
233233
}
234234
else if (#{other.respond_to? :==}) {
@@ -503,7 +503,7 @@ def negative?
503503
class Integer < Numeric
504504
def self.===(other)
505505
%x{
506-
if (!other._isNumber) {
506+
if (!other.$$is_number) {
507507
return false;
508508
}
509509
@@ -514,7 +514,7 @@ def self.===(other)
514514

515515
class Float < Numeric
516516
def self.===(other)
517-
`!!other._isNumber`
517+
`!!other.$$is_number`
518518
end
519519

520520
INFINITY = `Infinity`

‎opal/corelib/proc.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Proc
2-
`def._isProc = true`
2+
`def.$$is_proc = true`
33
`def.is_lambda = false`
44

55
def self.new(&block)
@@ -13,7 +13,7 @@ def self.new(&block)
1313
def call(*args, &block)
1414
%x{
1515
if (block !== nil) {
16-
self._p = block;
16+
self.$$p = block;
1717
}
1818
1919
var result;

‎opal/corelib/range.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Range
44
include Enumerable
55

6-
`def._isRange = true;`
6+
`def.$$is_range = true;`
77

88
attr_reader :begin, :end
99

@@ -17,7 +17,7 @@ def initialize(first, last, exclude = false)
1717

1818
def ==(other)
1919
%x{
20-
if (!other._isRange) {
20+
if (!other.$$is_range) {
2121
return false;
2222
}
2323

‎opal/corelib/regexp.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Regexp
2-
`def._isRegexp = true`
2+
`def.$$is_regexp = true`
33

44
class << self
55
def escape(string)
@@ -29,11 +29,11 @@ def ==(other)
2929

3030
def ===(str)
3131
%x{
32-
if (!str._isString && #{str.respond_to?(:to_str)}) {
32+
if (!str.$$is_string && #{str.respond_to?(:to_str)}) {
3333
#{str = str.to_str};
3434
}
3535
36-
if (!str._isString) {
36+
if (!str.$$is_string) {
3737
return false;
3838
}
3939
@@ -88,7 +88,7 @@ def match(string, pos = undefined, &block)
8888
return
8989
end
9090

91-
if `string._isString == null`
91+
if `string.$$is_string == null`
9292
unless string.respond_to? :to_str
9393
raise TypeError, "no implicit conversion of #{string.class} into String"
9494
end

‎opal/corelib/runtime.js

+124-124
Large diffs are not rendered by default.

‎opal/corelib/string.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class String
44
include Comparable
55

6-
`def._isString = true`
6+
`def.$$is_string = true`
77

88
def self.try_convert(what)
99
what.to_str
@@ -81,7 +81,7 @@ def ==(other)
8181

8282
def =~(other)
8383
%x{
84-
if (other._isString) {
84+
if (other.$$is_string) {
8585
#{raise TypeError, 'type mismatch: String given'};
8686
}
8787
@@ -93,7 +93,7 @@ def [](index, length = undefined)
9393
%x{
9494
var size = self.length;
9595
96-
if (index._isRange) {
96+
if (index.$$is_range) {
9797
var exclude = index.exclude,
9898
length = index.end,
9999
index = index.begin;
@@ -313,7 +313,7 @@ def gsub(pattern, replace = undefined, &block)
313313
options = pattern.substr(pattern.lastIndexOf('/') + 1) + 'g',
314314
regexp = pattern.substr(1, pattern.lastIndexOf('/') - 1);
315315
316-
self.$sub._p = block;
316+
self.$sub.$$p = block;
317317
return self.$sub(new RegExp(regexp, options), replace);
318318
}
319319
end
@@ -328,7 +328,7 @@ def hex
328328

329329
def include?(other)
330330
%x{
331-
if (other._isString) {
331+
if (other.$$is_string) {
332332
return self.indexOf(other) !== -1;
333333
}
334334
}
@@ -616,7 +616,7 @@ def split(pattern = $; || ' ', limit = undefined)
616616
return [self];
617617
}
618618
619-
if (pattern && pattern._isRegexp) {
619+
if (pattern && pattern.$$is_regexp) {
620620
var pattern_str = pattern.toString();
621621
622622
/* Opal and JS's repr of an empty RE. */
@@ -777,7 +777,7 @@ def strip
777777

778778
def sub(pattern, replace = undefined, &block)
779779
%x{
780-
if (typeof(pattern) !== 'string' && !pattern._isRegexp) {
780+
if (typeof(pattern) !== 'string' && !pattern.$$is_regexp) {
781781
pattern = #{Opal.coerce_to! pattern, String, :to_str};
782782
}
783783

‎opal/corelib/string/inheritance.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ def self.inherited(klass)
33
replace = Class.new(String::Wrapper)
44

55
%x{
6-
klass._proto = replace._proto;
7-
klass._proto._klass = klass;
8-
klass._alloc = replace._alloc;
9-
klass.__parent = #{String::Wrapper};
6+
klass.$$proto = replace.$$proto;
7+
klass.$$proto.$$class = klass;
8+
klass.$$alloc = replace.$$alloc;
9+
klass.$$parent = #{String::Wrapper};
1010
1111
klass.$allocate = replace.$allocate;
1212
klass.$new = replace.$new;
@@ -38,7 +38,7 @@ def initialize(string = '')
3838
def method_missing(*args, &block)
3939
result = @literal.__send__(*args, &block)
4040

41-
if `result._isString != null`
41+
if `result.$$is_string != null`
4242
if `result == #@literal`
4343
self
4444
else

‎stdlib/date.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def initialize(year = undefined, month = undefined, day = undefined)
2424

2525
def -(date)
2626
%x{
27-
if (date._isNumber) {
27+
if (date.$$is_number) {
2828
var result = #{clone};
2929
result.date.setDate(#@date.getDate() - date);
3030
return result;
@@ -40,7 +40,7 @@ def -(date)
4040

4141
def +(date)
4242
%x{
43-
if (date._isNumber) {
43+
if (date.$$is_number) {
4444
var result = #{clone};
4545
result.date.setDate(#@date.getDate() + date);
4646
return result;

‎stdlib/json.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module JSON
2020
case 'object':
2121
if (!value) return nil;
2222
23-
if (value._isArray) {
23+
if (value.$$is_array) {
2424
var arr = #{`options.array_class`.new};
2525
2626
for (var i = 0, ii = value.length; i < ii; i++) {

‎stdlib/native.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def to_n
128128

129129
module Kernel
130130
def native?(value)
131-
`value == null || !value._klass`
131+
`value == null || !value.$$class`
132132
end
133133

134134
def Native(obj)
@@ -256,11 +256,11 @@ def is_a?(klass)
256256
alias kind_of? is_a?
257257

258258
def instance_of?(klass)
259-
`self._klass === klass`
259+
`self.$$class === klass`
260260
end
261261

262262
def class
263-
`self._klass`
263+
`self.$$class`
264264
end
265265

266266
def to_a(options = {}, &block)
@@ -520,7 +520,7 @@ def native_module
520520

521521
class Class
522522
def native_alias(jsid, mid)
523-
`#{self}._proto[#{jsid}] = #{self}._proto['$' + #{mid}]`
523+
`#{self}.$$proto[#{jsid}] = #{self}.$$proto['$' + #{mid}]`
524524
end
525525

526526
alias native_class native_module

0 commit comments

Comments
 (0)
Please sign in to comment.