red 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,108 +0,0 @@
1
- == 4.0.2 2008-10-14
2
-
3
- * 2 bug fixes:
4
- * Fixed the newly introduced namespacing issue.
5
- * Adjusted send, and attr and similar methods to properly cache their referred-to methods.
6
-
7
- == 4.0.1 2008-10-13
8
-
9
- * 1 major enhancement:
10
- * Improved flexibility for platforming Red into browsers.
11
-
12
- * 2 bug fixes:
13
- * Fixed a namespacing issue for Constants.
14
- * Added a few more essential internally-referenced methods.
15
-
16
- == 4.0.0 2008-10-12
17
-
18
- * New version released.
19
-
20
- == 3.5.0 2008-08-13
21
-
22
- * 2 major enhancements:
23
- * Added support for child classes.
24
- * Updated method for "call to returned function"; now use "_".
25
-
26
- * 3 bug fixes:
27
- * Fixed Prototype library's handling of class_variables; now separated out into an Object.extend declaration.
28
- * String quoting is now properly handled in foo["eval#{string}"]-type calls.
29
- * Added parentheses wrapping to sugared operators ('+', '*', '||', '&&', etc) in order to solve chained method problems.
30
-
31
- == 3.4.2 2008-08-12
32
-
33
- * 1 major enhancement:
34
- * Added Prototype support for constructible class definition.
35
-
36
- * 1 bug fix:
37
- * @instance_variable no longer initializes with reduplicated "this". Bug was introduced with addition of incremental operators.
38
-
39
- == 3.4.1 2008-08-09
40
-
41
- * 1 major enhancement:
42
- * Edited output messages for -r and -u executable options.
43
-
44
- == 3.4.0 2008-08-09
45
-
46
- * 2 major enhancements:
47
- * Added functionality to "obj" of "class << obj" construct.
48
- * Souped up -r and -u options for the Red executable.
49
-
50
- * 3 bug fixes:
51
- * Added <= and >= to the list of sugared Ruby operators.
52
- * Fixed nested ternary operators.
53
- * Fixed camelcasing of all_CAPS sections in identifiers.
54
-
55
- == 3.3.0 2008-08-08
56
-
57
- * 1 major enhancement:
58
- * Added -u option, which installs unobtrusive JavaScript scaffolding.
59
-
60
- == 3.2.1 2008-08-08
61
-
62
- * 1 bug fix:
63
- * Adjusted the way class variables are handled within standard class definitions.
64
-
65
- == 3.2.0 2008-08-07
66
-
67
- * 1 major enhancement:
68
- * Added Rails support.
69
-
70
- * 1 bug fix:
71
- * Added commenting to the error messages produced inline with the JavaScript output.
72
-
73
- == 3.1.2 2008-08-06
74
-
75
- * 2 bug fixes:
76
- * Added gem dependency for ParseTree.
77
- * Rescued the error thrown when no argument is given for -s option flag.
78
-
79
- == 3.1.1 2008-08-06
80
-
81
- * 1 major enhancement:
82
- * Added -s option to allow conversion of Ruby strings from the command line
83
-
84
- * 1 bug fix:
85
- * Rescued the error thrown when using an unknown option flag.
86
-
87
- == 3.1.0 2008-08-06
88
-
89
- * 1 major enhancement:
90
- * Removed rake task and added "red" executable
91
-
92
- == 3.0.0 2008-08-06
93
-
94
- * 1 major enhancement:
95
- * Initial Rubyforge release
96
-
97
- == 2.0.0 2008-07-13
98
-
99
- * 1 major enhancement:
100
- * Version 2 stable
101
-
102
- * 1 bug fix:
103
- * Removed buggy whitespace
104
-
105
- == 1.0.0 2008-07-04
106
-
107
- * 1 major enhancement:
108
- * Stable working prototype
data/lib/red.rb CHANGED
@@ -204,6 +204,7 @@ module Red # :nodoc:
204
204
  is_a?
205
205
  join
206
206
  new
207
+ raise
207
208
  sprintf
208
209
  to_proc
209
210
  to_s
@@ -55,7 +55,7 @@ module Red
55
55
  block = (block_sexp.is_sexp?(:block) ? block_sexp : [:block, block_sexp]).red!(:force_return => options[:force_return])
56
56
  rescue_body = "else{%s;}" % rescue_body_sexp.red!(:force_return => options[:force_return]) if rescue_body_sexp
57
57
 
58
- self << "%sif($eType(_e,%s)){_eRescued=true;%s;}%s" % [exception_variable, exception_types_array, block, rescue_body]
58
+ self << "%sif(Red.LoopError.isA(_e,%s)){_eRescued=true;%s;}%s" % [exception_variable, exception_types_array, block, rescue_body]
59
59
  end
60
60
  end
61
61
 
@@ -33,7 +33,7 @@ module Red
33
33
 
34
34
  scope = scope_sexp.red!(:as_class_eval => true)
35
35
 
36
- self << "\n\n$class('%s',%s,function(){ var _=%s.prototype;\n %s;\n})" % [namespaced_class.gsub("c$",""), superclass, namespaced_class, scope]
36
+ self << "\n\nRed.class('%s',%s,function(){ var _=%s.prototype;\n %s;\n})" % [namespaced_class.gsub("c$",""), superclass, namespaced_class, scope]
37
37
 
38
38
  old_namespace_stack.nil? ? @@namespace_stack.pop : @@namespace_stack = old_namespace_stack
39
39
  end
@@ -61,7 +61,7 @@ module Red
61
61
 
62
62
  scope = scope_sexp.red!(:as_class_eval => true)
63
63
 
64
- self << "\n\n$module('%s',function(){ var _=%s.prototype;\n %s;\n})" % [namespaced_module.gsub("c$",""), namespaced_module, scope]
64
+ self << "\n\nRed.module('%s',function(){ var _=%s.prototype;\n %s;\n})" % [namespaced_module.gsub("c$",""), namespaced_module, scope]
65
65
 
66
66
  @@namespace_stack.pop
67
67
  end
data/lib/red/version.rb CHANGED
@@ -2,7 +2,7 @@ module Red
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 4
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/source/ruby.rb CHANGED
@@ -1,19 +1,135 @@
1
- `
2
- var $u=undefined,$objectId=100,nil=null,$_argTemp=undefined;
1
+ `Red = {
2
+ id: 100,
3
+
4
+ conferInheritance: function(newClass,superclass) {
5
+ newClass.__superclass__=superclass;
6
+ Red.donateMethodsToSingleton(superclass,newClass,true);
7
+ Red.donateMethodsToClass(superclass.prototype,newClass.prototype,true);
8
+ if(newClass==c$Module){delete(newClass.prototype.m$initialize);};
9
+ if(newClass!==Number&&newClass!==Array){newClass.prototype.toString==superclass.prototype.toString;};
10
+ },
11
+
12
+ donateMethodsToSingleton: function(donor,recipient,overwrite) {
13
+ for(var x in donor) {
14
+ if(x.slice(0,2)==='m$' && (overwrite || recipient[x]===undefined)) {
15
+ var f = function() { var m=arguments.callee;return m.__methodSource__[m.__methodName__].apply(m.__methodReceiver__,arguments); };
16
+ f.__methodName__=x;f.__methodSource__=donor;f.__methodReceiver__=recipient;
17
+ recipient[x]=f;
18
+ };
19
+ };
20
+ },
21
+
22
+ donateMethodsToClass: function(donor,recipient,overwrite) {
23
+ for(var x in donor) {
24
+ if(x.slice(0,2)==='m$' && (overwrite || recipient[x]===undefined)) {
25
+ var f = function() { var m=arguments.callee;return m.__methodSource__[m.__methodName__].apply(this,arguments); };
26
+ f.__methodName__=x;f.__methodSource__=donor;
27
+ recipient[x]=f;
28
+ };
29
+ };
30
+ },
31
+
32
+ updateChildren: function(parentClass) {
33
+ for(var x in parentClass.__children__) {
34
+ var childClass=Red.inferConstantFromString(x);
35
+ Red.donateMethodsToSingleton(parentClass,childClass,false);
36
+ Red.donateMethodsToClass(parentClass.prototype,childClass.prototype,false);
37
+ Red.updateChildren(childClass);
38
+ };
39
+ },
40
+
41
+ updateIncluders: function(module) {
42
+ for(var x in module.__includers__) {
43
+ var includer=Red.inferConstantFromString(x);
44
+ Red.donateMethodsToSingleton(module,includer,false);
45
+ Red.donateMethodsToClass(module.prototype,includer.prototype,false);
46
+ switch(includer.m$class().__name__){case 'Module':Red.updateIncluders(includer);break;case 'Class':Red.updateChildren(includer);break;};
47
+ };
48
+ },
49
+
50
+ initializeClass: function(longName,newClass) {
51
+ newClass.__name__ = longName;
52
+ newClass.__id__ = Red.id++;
53
+ newClass.__modules__ = {};
54
+ newClass.__children__ = {};
55
+ newClass.prototype.__class__=newClass;
56
+ Red.donateMethodsToSingleton(c$Class.prototype,newClass,true)
57
+ },
58
+
59
+ interpretNamespace: function(longName) {
60
+ var ary=longName.split('.'),name=ary.pop(),namespace=window;
61
+ while(ary.length>0){namespace=namespace['c$'+ary.shift()];};
62
+ return [namespace,name];
63
+ },
64
+
65
+ inferConstantFromString: function(longName) {
66
+ if(longName=='window'){return window;}
67
+ var context=Red.interpretNamespace(longName);
68
+ return context[0]['c$'+context[1]];
69
+ },
70
+
71
+ module: function(longName,block){
72
+ var newModule,context=Red.interpretNamespace(longName),namespace=context[0],name=context[1];
73
+ if(namespace['c$'+name]) {
74
+ newModule = namespace['c$'+name];
75
+ } else {
76
+ newModule = c$Module.m$new(longName);
77
+ namespace['c$'+name] = newModule;
78
+ newModule.__includers__={};
79
+ };
80
+ if(typeof(block)=='function') { block.call(newModule); };
81
+ },
82
+
83
+ class: function(longName,superclass,block){
84
+ var newClass,context=Red.interpretNamespace(longName),namespace=context[0],name=context[1];
85
+ if(namespace['c$'+name]) {
86
+ if(name!=='Object' && superclass!==namespace['c$'+name].__superclass__){m$raise(c$TypeError,$q('superclass mismatch for class '+longName));};
87
+ newClass = namespace['c$'+name];
88
+ if(name=='Module'&&!(newClass.__superclass__.__children__[name])){Red.conferInheritance(c$Module,c$Object);}
89
+ if(name=='Class'&&!(newClass.__superclass__.__children__[name])){Red.conferInheritance(c$Class,c$Module);}
90
+ } else {
91
+ switch(name){
92
+ case 'Array':newClass=Array;break;case 'Numeric':newClass=Number;break;
93
+ default: newClass = function() { this.__id__ = Red.id++ };
94
+ };
95
+ Red.conferInheritance(newClass,superclass);
96
+ Red.initializeClass(longName,newClass);
97
+ superclass.__children__[newClass.__name__]=true;
98
+ superclass.m$inherited && superclass.m$inherited(newClass);
99
+ namespace['c$'+name] = newClass;
100
+ };
101
+ if(name == 'Object' || superclass == c$Object){
102
+ newClass.cvset = function(var_name,object) { return newClass['v$'+var_name] = object; };
103
+ newClass.cvget = function(var_name) { return newClass['v$'+var_name]; };
104
+ } else {
105
+ newClass.cvset = function() { return superclass.cvset.apply(null,arguments); };
106
+ newClass.cvget = function() { return superclass.cvget.apply(null,arguments); };
107
+ };
108
+ if(typeof(block)=='function') { block.call(newClass); };
109
+ Red.updateChildren(newClass);
110
+ if((typeof(c$TrueClass)!='undefined'&&newClass==c$TrueClass)||(typeof(c$FalseClass)!='undefined'&&newClass==c$FalseClass)) { Red.donateMethodsToClass(newClass.prototype,Boolean.prototype); };
111
+ },
112
+
113
+ LoopError: {
114
+ break:function(value){var e=new(Error);e.__keyword__='break';e._value=value==null?nil:value;throw(e);},
115
+ next:function(value){var e=new(Error);e.__keyword__='next';e._value=value==null?nil:value;throw(e);},
116
+ redo:function(){var e=new(Error);e.__keyword__='redo';throw(e);},
117
+ isA:function(e,ary){for(var i=0,l=ary.length;i<l;++i){if(e.m$isABool(ary[i])){return true;};};return false;}
118
+ }
119
+ };
3
120
 
4
- function $break(value){var e=new(Error);e._name='break';e._value=value==null?nil:value;throw(e);};
5
- function $next(value){var e=new(Error);e._name='next';e._value=value==null?nil:value;throw(e);};
6
- function $redo(){var e=new(Error);e._name='redo';throw(e);};
7
- function $return(value){var e=new(Error);e._name='return';e._value=value==null?nil:value;throw(e);};
8
- function $eType(e,ary){for(var i=0,l=ary.length;i<l;++i){if(e.m$isABool(ary[i])){return true;};};return false;};
121
+ var $u=undefined,nil=null;
9
122
 
10
- c$Object = function(){this._objectId=$objectId++};
11
- c$Module = function(){this._objectId=$objectId++};
12
- c$Class = function(){this._objectId=$objectId++};
123
+ c$Class = function(){this.__id__=Red.id++};c$Class.__name__='Class';c$Class.__children__={};
124
+ c$Module = function(){this.__id__=Red.id++};c$Module.__name__='Module';c$Module.__children__={};c$Class.__superclass__=c$Module;
125
+ c$Object = function(){this.__id__=Red.id++};c$Object.__name__='Object';c$Object.__children__={};c$Module.__superclass__=c$Object;
13
126
 
14
- c$Object.prototype.toString=function(){return '#<'+this.m$class()._name+':0x'+(this._objectId*999^4000000).toString(16)+'>'};
15
- Function.prototype.m$=function(o){var f=this;var p=function(){return f.apply(o,arguments);};p._arity=f.arity;p._objectId=$objectId++;return p;};
16
- window.m$include=function(){for(var i=0,modules=arguments,l=modules.length;i<l;++i){var mp=modules[i].prototype;for(var x in mp){if(x.slice(0,2)=='m$'){var f=function(){return arguments.callee._source[arguments.callee._name].apply(window,arguments) };f._source=mp;f._name=x;window[x]=f;};};modules[i].m$included(window);};return window;};
127
+ c$Object.prototype.toString=function(){return '#<'+this.m$class().__name__.replace(/\\./g,'::')+':0x'+(this.__id__*999^4000000).toString(16)+'>'};
128
+ Function.prototype.m$=function(o){var f=this;var p=function(){return f.apply(o,arguments);};p._arity=f.arity;p.__id__=Red.id++;return p;};
129
+ window.__name__='window';
130
+ window.prototype=window;
131
+ window.__children__={'Object':true};
132
+ window.m$include=function(){for(var i=0,modules=arguments,l=modules.length;i<l;++i){var mp=modules[i].prototype;for(var x in mp){if(x.slice(0,2)=='m$'){var f=function(){return arguments.callee._source[arguments.callee._name].apply(window,arguments) };f._source=mp;f._name=x;window[x]=f;};};modules[i].m$included(window);modules[i].__includers__['window']=true;};if(modules[0]!=c$Kernel){Red.donateMethodsToClass(window,c$Object.prototype);Red.updateChildren(c$Object);};return window;};
17
133
  window.m$blockGivenBool=function(){typeof(arguments[0])=='function'}
18
134
 
19
135
  function $Q(){for(var i=1,s=arguments[0],l=arguments.length;i<l;++i){s+=$q(arguments[i]).m$toS()._value;};return $q(s);};
@@ -22,98 +138,6 @@ function $r(value,options){return c$Regexp.m$new(value,options);};
22
138
  function $s(value){return(c$Symbol._table[value]||c$Symbol.m$new(value));};
23
139
  function $T(x){return x!==false&&x!==nil&&x!=undefined;};
24
140
 
25
- function $inheritance(newClass,superclass) {
26
- newClass._superclass = superclass;
27
- for(var x in superclass) {
28
- if(x.slice(0,2)==='m$' && x!=='m$class') {
29
- var f = function() { return arguments.callee._source[arguments.callee._name].apply(newClass,arguments) };
30
- f._source = superclass;
31
- f._name = x
32
- newClass[x] = f;
33
- };
34
- };
35
- var sp=superclass.prototype,np=newClass.prototype;
36
- for(var x in sp) {
37
- if(x.slice(0,2)==='m$' && !(x=='m$initialize' && newClass==c$Module) && x!=='m$class' || (x=='toString'&&newClass!==Number&&newClass!==Array)) {
38
- var f = function() { return arguments.callee._source[''+arguments.callee._name].apply(this,arguments) };
39
- f._source = sp;
40
- f._name = x;
41
- np[x] = f;
42
- };
43
- };
44
- };
45
-
46
- function $classlike(name,newClass) {
47
- newClass._name = name;
48
- newClass._objectId = $objectId++;
49
- newClass._modules = {};
50
- for(var x in c$Class.prototype) {
51
- if(x.slice(0,2)==='m$' && !(newClass == c$Class && x==='m$new')) {
52
- var f = function() { return c$Class.prototype[arguments.callee._name].apply(newClass,arguments) };
53
- f._name = x;
54
- newClass[x] = f;
55
- };
56
- };
57
- };
58
-
59
- function $booleanClass(newClass) {
60
- for(var x in newClass.prototype){
61
- if(x.slice(0,2)==='m$'){
62
- var f=function(){return arguments.callee._source[arguments.callee._name].apply(this,arguments)};
63
- f._source=newClass.prototype;
64
- f._name=x;
65
- Boolean.prototype[x]=f;
66
- };
67
- };
68
- }
69
-
70
- function $context(name){
71
- var ary=name.split('.'),name=ary.pop(),namespace=window;
72
- while(ary.length>0){
73
- namespace=namespace['c$'+ary.shift()]
74
- };
75
- return [namespace,name];
76
- };
77
-
78
- function $module(name,block){
79
- var newModule,context=$context(name),namespace=context[0],name=context[1];
80
- if(namespace['c$'+name]) {
81
- newModule = namespace['c$'+name];
82
- } else {
83
- newModule = c$Module.m$new(name);
84
- namespace['c$'+name] = newModule;
85
- };
86
- if(typeof(block)=='function') { block.call(namespace['c$'+name]); };
87
- };
88
-
89
- function $class(name,superclass,block){
90
- var newClass,context=$context(name),namespace=context[0],name=context[1];
91
- if(namespace['c$'+name]) {
92
- if(name !== 'Object' && name !== 'Class' && name !== 'Module' && superclass !== namespace['c$'+name]._superclass){throw('TypeError: superclass mismatch for class '+name);};
93
- newClass = namespace['c$'+name];
94
- if(name=='Module'){$inheritance(c$Module,c$Object);}
95
- if(name=='Class'){$inheritance(c$Class,c$Module);}
96
- } else {
97
- switch(name){
98
- case 'Array':newClass=Array;break;case 'Numeric':newClass=Number;break;
99
- default: newClass = function() { this._objectId = $objectId++ };
100
- };
101
- $inheritance(newClass,superclass);
102
- $classlike(name,newClass);
103
- superclass.m$inherited && superclass.m$inherited(newClass);
104
- namespace['c$'+name] = newClass;
105
- };
106
- if(name == 'Object' || superclass == c$Object){
107
- newClass.cvset = function(var_name,object) { return newClass['v$'+var_name] = object; };
108
- newClass.cvget = function(var_name) { return newClass['v$'+var_name]; };
109
- } else {
110
- newClass.cvset = function() { return superclass.cvset.apply(null,arguments); };
111
- newClass.cvget = function() { return superclass.cvget.apply(null,arguments); };
112
- };
113
- newClass.prototype.m$class = function() { return newClass; };
114
- if(typeof(block)=='function') { block.call(namespace['c$'+name]); };
115
- if((typeof(c$TrueClass)!='undefined'&&newClass==c$TrueClass)||(typeof(c$FalseClass)!='undefined'&&newClass==c$FalseClass)) { $booleanClass(newClass); };
116
- }
117
141
  `
118
142
 
119
143
  # +Object+ is the parent class of all classes in Red. Its methods are
@@ -145,7 +169,7 @@ class Object
145
169
  # may override this behavior.
146
170
  #
147
171
  def ==(other)
148
- `this._objectId==other._objectId`
172
+ `this.__id__==other.__id__`
149
173
  end
150
174
 
151
175
  # call-seq:
@@ -156,7 +180,7 @@ class Object
156
180
  # semantics in case statements.
157
181
  #
158
182
  def ===(other)
159
- `this._objectId==other._objectId`
183
+ `this.__id__==other.__id__`
160
184
  end
161
185
 
162
186
  # call-seq:
@@ -178,7 +202,7 @@ class Object
178
202
  # will share an id.
179
203
  #
180
204
  def __id__
181
- `this._objectId`
205
+ `this.__id__`
182
206
  end
183
207
 
184
208
  # call-seq:
@@ -212,7 +236,7 @@ class Object
212
236
  # self.class #=> Object
213
237
  #
214
238
  def class
215
- return `c$Object`
239
+ `this.__class__`
216
240
  end
217
241
 
218
242
  # call-seq:
@@ -238,8 +262,8 @@ class Object
238
262
  #
239
263
  def clone
240
264
  `var result={}`
241
- `for(var x in this){if(x!='_objectId'){result[x]=this[x];};}`
242
- `result._objectId=$objectId++`
265
+ `for(var x in this){if(x!='__id__'){result[x]=this[x];};}`
266
+ `result.__id__=Red.id++`
243
267
  return `result`
244
268
  end
245
269
 
@@ -258,8 +282,8 @@ class Object
258
282
  #
259
283
  def dup
260
284
  `var result=this.m$class.m$new()`
261
- `for(var x in this){if(x!='_objectId'&&x.slice(0,2)!='i$'){result[x]=this[x];};}`
262
- `result._objectId=$objectId++`
285
+ `for(var x in this){if(x!='__id__'&&x.slice(0,2)!='i$'){result[x]=this[x];};}`
286
+ `result.__id__=Red.id++`
263
287
  return `result`
264
288
  end
265
289
 
@@ -286,7 +310,7 @@ class Object
286
310
  # may override this behavior.
287
311
  #
288
312
  def eql?(other)
289
- `this._objectId==other._objectId`
313
+ `this.__id__==other.__id__`
290
314
  end
291
315
 
292
316
  # call-seq:
@@ -308,7 +332,7 @@ class Object
308
332
  # may override this behavior.
309
333
  #
310
334
  def equal?(other)
311
- `this._objectId==other._objectId`
335
+ `this.__id__==other.__id__`
312
336
  end
313
337
 
314
338
  # call-seq:
@@ -350,7 +374,7 @@ class Object
350
374
  # <tt>a.hash == b.hash</tt>, and is typically overridden in child classes.
351
375
  #
352
376
  def hash
353
- `'o_'+this._objectId`
377
+ `'o_'+this.__id__`
354
378
  end
355
379
 
356
380
  # call-seq:
@@ -506,7 +530,7 @@ class Object
506
530
  `if(this.m$class()._modules[klass]){return true;}` # true if klass is included in obj's class
507
531
  `if(this.m$class()==c$Object){return false;}` # false if module check fails and obj is Object
508
532
  `var bubble=this.m$class(),result=false`
509
- `while(bubble!=c$Object){if(klass==bubble||bubble._modules[klass]!=null){result=true;};if(result){break;};bubble=bubble._superclass;}`
533
+ `while(bubble!=c$Object){if(klass==bubble||bubble._modules[klass]!=null){result=true;};if(result){break;};bubble=bubble.__superclass__;}`
510
534
  return `result`
511
535
  end
512
536
 
@@ -539,7 +563,7 @@ class Object
539
563
  `if(this.m$class()._modules[klass]){return true;}` # true if klass is included in obj's class
540
564
  `if(this.m$class()==c$Object){return false;}` # false if module check fails and obj is Object
541
565
  `var bubble=this.m$class(),result=false`
542
- `while(bubble!=c$Object){if(klass==bubble||bubble._modules[klass]!=null){result=true;};if(result){break;};bubble=bubble._superclass;}`
566
+ `while(bubble!=c$Object){if(klass==bubble||bubble._modules[klass]!=null){result=true;};if(result){break;};bubble=bubble.__superclass__;}`
543
567
  return `result`
544
568
  end
545
569
 
@@ -613,7 +637,7 @@ class Object
613
637
  # will share an id.
614
638
  #
615
639
  def object_id
616
- `this._objectId`
640
+ `this.__id__`
617
641
  end
618
642
 
619
643
  # call-seq:
@@ -696,7 +720,7 @@ class Object
696
720
  # 6-digit hex memory representation.
697
721
  #
698
722
  def to_s
699
- `$q('#<'+this.m$class()._name+':0x'+(this._objectId*999^4000000).toString(16)+'>')`
723
+ `$q('#<'+this.m$class().__name__.replace(/\\./g,'::')+':0x'+(this.__id__*999^4000000).toString(16)+'>')`
700
724
  end
701
725
  end
702
726
 
@@ -749,7 +773,7 @@ class Module
749
773
  # a.say_bye #=> "goodbye"
750
774
  #
751
775
  def initialize(module_name, &block)
752
- `this._name=moduleName._value||moduleName`
776
+ `this.__name__=moduleName._value||moduleName`
753
777
  `this.prototype={}`
754
778
  end
755
779
 
@@ -789,20 +813,9 @@ class Module
789
813
  # FIX: Incomplete
790
814
  def append_features(mod)
791
815
  `var tp=this.prototype,mp=mod.prototype`
792
- `for(var x in tp){
793
- if(x.slice(0,2)=='m$'){
794
- var f=function(){return arguments.callee._source[arguments.callee._name].apply(this,arguments) };
795
- f._source=tp;
796
- f._name=x;
797
- mp[x]=f;
798
- };
799
- }`
816
+ `Red.donateMethodsToSingleton(mod,this)`
817
+ `Red.donateMethodsToClass(mod.prototype,this.prototype)`
800
818
  return `mod`
801
-
802
-
803
- #`for(x in this.prototype){#{other_module}.prototype[x]=this.prototype[x];}`
804
- #`for(#{x} in #{self}){if(x.slice(0,2)=='');}` # FIGURE THIS OUT
805
- #return other_module
806
819
  end
807
820
 
808
821
  def attr(attribute, writer = false)
@@ -815,10 +828,8 @@ class Module
815
828
  def attr_accessor(*symbols)
816
829
  `for(var i=0,l=symbols.length;i<l;++i){
817
830
  var a=symbols[i]._value;
818
- f1=this.prototype['m$'+a]=function(){return this['i$'+arguments.callee._name];};
819
- f2=this.prototype['m$'+a+'Eql']=function(x){return this['i$'+arguments.callee._name]=x;};
820
- f1._name = a
821
- f2._name = a
831
+ f1=this.prototype['m$'+a]=function(){return this['i$'+arguments.callee._name];};f1._name=a;
832
+ f2=this.prototype['m$'+a+'Eql']=function(x){return this['i$'+arguments.callee._name]=x;};f2._name=a;
822
833
  }`
823
834
  return nil
824
835
  end
@@ -826,8 +837,7 @@ class Module
826
837
  def attr_reader(*symbols)
827
838
  `for(var i=0,l=symbols.length;i<l;++i){
828
839
  var a=symbols[i]._value;
829
- f = this.prototype['m$'+a]=function(){return this['i$'+arguments.callee._name];};
830
- f._name = a
840
+ f=this.prototype['m$'+a]=function(){return this['i$'+arguments.callee._name];};f._name=a;
831
841
  }`
832
842
  return nil
833
843
  end
@@ -835,8 +845,7 @@ class Module
835
845
  def attr_writer(*symbols)
836
846
  `for(var i=0,l=symbols.length;i<l;++i){
837
847
  var a=symbols[i]._value;
838
- f = this.prototype['m$'+a+'Eql']=function(x){return this['i$'+arguments.callee._name]=x;};
839
- f._name = a
848
+ f=this.prototype['m$'+a+'Eql']=function(x){return this['i$'+arguments.callee._name]=x;};f._name=a;
840
849
  }`
841
850
  return nil
842
851
  end
@@ -898,11 +907,11 @@ class Module
898
907
  # Picky won't give its methods to a String
899
908
  #
900
909
  def extend_object(obj)
901
- `for(var x in this.prototype){
910
+ `var tp=this.prototype`
911
+ `for(var x in tp){
902
912
  if(x.slice(0,2)=='m$'){
903
- var f=function(){return arguments.callee._source[arguments.callee._name].apply(obj,arguments) };
904
- f._source=this.prototype;
905
- f._name=x;
913
+ var f=function(){var m=arguments.callee;return m.__methodSource__[m.__methodName__].apply(m.__methodReceiver__,arguments) };
914
+ f.__methodName__=x;f.__methodSource__=tp;f.__methodReceiver__=obj;
906
915
  obj[x]=f;
907
916
  };
908
917
  }`
@@ -961,7 +970,7 @@ class Module
961
970
  # k.hello #=> "Hello from Mod"
962
971
  #
963
972
  def include(*modules)
964
- `for(var i=0,l=modules.length;i<l;++i){modules[i].m$appendFeatures(this);modules[i].m$included(this);}`
973
+ `for(var i=0,l=modules.length;i<l;++i){var mod=modules[i];mod.m$appendFeatures(this);mod.m$included(this);mod.__includers__[this.__name__]=true;}`
965
974
  return self
966
975
  end
967
976
 
@@ -1008,7 +1017,7 @@ class Module
1008
1017
  end
1009
1018
 
1010
1019
  def name
1011
- `$q(this._name)`
1020
+ `$q(this.__name__.replace(/\\./g,'::'))`
1012
1021
  end
1013
1022
 
1014
1023
  def remove_class_variable(sym)
@@ -1022,7 +1031,7 @@ class Module
1022
1031
 
1023
1032
  # Return a string representing this module or class.
1024
1033
  def to_s
1025
- `$q(this._name)`
1034
+ `$q(this.__name__.replace(/\\./g,'::'))`
1026
1035
  end
1027
1036
  end
1028
1037
 
@@ -1056,14 +1065,14 @@ class Class < Module
1056
1065
  # call-seq:
1057
1066
  # Class.new(class_name, superclass = Object) -> class
1058
1067
  #
1059
- # Creates a new class with the given _superclass_ (or +Object+ if no
1068
+ # Creates a new class with the given __superclass___ (or +Object+ if no
1060
1069
  # superclass is given). Unlike in Ruby, where you need only assign the
1061
1070
  # class object to a constant in order to give it a name, in Red you must
1062
1071
  # also pass the class name as a string argument.
1063
1072
  #
1064
1073
  # FIX: Incomplete
1065
1074
  def self.new(class_name, superclass = Object)
1066
- `$class(className._value,superclass,function(){})`
1075
+ `Red.class(className._value,superclass,function(){})`
1067
1076
  return `window['c$'+className._value]`
1068
1077
  end
1069
1078
 
@@ -1139,14 +1148,14 @@ class Class < Module
1139
1148
  # Object.superclass #=> nil
1140
1149
  #
1141
1150
  def superclass
1142
- `this._superclass`
1151
+ `this.__superclass__`
1143
1152
  end
1144
1153
  end
1145
1154
 
1146
1155
  `
1147
- $classlike('Object',c$Object);
1148
- $classlike('Module',c$Module);
1149
- $classlike('Class',c$Class)
1156
+ Red.initializeClass('Object',c$Object);c$Object.__children__={'Module':true};
1157
+ Red.initializeClass('Module',c$Module);c$Module.__children__={'Class':true};
1158
+ Red.initializeClass('Class',c$Class)
1150
1159
  `
1151
1160
 
1152
1161
  # The +Comparable+ mixin is used by classes whose objects may be ordered. The
@@ -1214,7 +1223,7 @@ module Comparable
1214
1223
  # and _other_ are the same object.
1215
1224
  #
1216
1225
  def ==(obj)
1217
- `(this._objectId&&obj._objectId&&this._objectId==obj._objectId)||this.m$_ltgt(obj)==0`
1226
+ `(this.__id__&&obj.__id__&&this.__id__==obj.__id__)||this.m$_ltgt(obj)==0`
1218
1227
  end
1219
1228
 
1220
1229
  # call-seq:
@@ -1967,7 +1976,7 @@ class Array
1967
1976
  # a #=> [1, 2, 3, 4]
1968
1977
  #
1969
1978
  def collect
1970
- `for(var i=0,l=this.length,result=[];i<l;++i){try{result[i]=#{yield `this[i]`};}catch(e){switch(e._name){case 'next':result[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
1979
+ `for(var i=0,l=this.length,result=[];i<l;++i){try{result[i]=#{yield `this[i]`};}catch(e){switch(e.__keyword__){case 'next':result[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
1971
1980
  return `result`
1972
1981
  end
1973
1982
 
@@ -1985,7 +1994,7 @@ class Array
1985
1994
  # a.collect! {|x| x + 100 } #=> [201, 202, 203, 204]
1986
1995
  #
1987
1996
  def collect!
1988
- `for(var i=0,l=this.length;i<l;++i){try{this[i]=#{yield `this[i]`};}catch(e){switch(e._name){case 'next':this[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
1997
+ `for(var i=0,l=this.length;i<l;++i){try{this[i]=#{yield `this[i]`};}catch(e){switch(e.__keyword__){case 'next':this[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
1989
1998
  return self
1990
1999
  end
1991
2000
 
@@ -2084,7 +2093,7 @@ class Array
2084
2093
  # a.delete_if {|element| element >= 'b' } #=> ["a"]
2085
2094
  #
2086
2095
  def delete_if
2087
- `for(var temp=[],i=0,l=this.length;i<l;++i){try{if(!$T(#{yield `this[i]`})){temp.push(this[i]);};}catch(e){switch(e._name){case 'next':if(!$T(e._value)){temp.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2096
+ `for(var temp=[],i=0,l=this.length;i<l;++i){try{if(!$T(#{yield `this[i]`})){temp.push(this[i]);};}catch(e){switch(e.__keyword__){case 'next':if(!$T(e._value)){temp.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2088
2097
  `this._replace(temp)`
2089
2098
  end
2090
2099
 
@@ -2102,7 +2111,7 @@ class Array
2102
2111
  # C
2103
2112
  #
2104
2113
  def each
2105
- `for(var i=0,l=this.length;i<l;++i){try{#{yield `this[i]`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2114
+ `for(var i=0,l=this.length;i<l;++i){try{#{yield `this[i]`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2106
2115
  return self
2107
2116
  end
2108
2117
 
@@ -2120,7 +2129,7 @@ class Array
2120
2129
  # 102
2121
2130
  #
2122
2131
  def each_index
2123
- `for(var i=0,l=this.length;i<l;++i){try{#{yield `i`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2132
+ `for(var i=0,l=this.length;i<l;++i){try{#{yield `i`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2124
2133
  return self
2125
2134
  end
2126
2135
 
@@ -2388,7 +2397,7 @@ class Array
2388
2397
  # a #=> [1, 2, 3, 4]
2389
2398
  #
2390
2399
  def map
2391
- `for(var i=0,l=this.length,result=[];i<l;++i){try{result[i]=#{yield `this[i]`};}catch(e){switch(e._name){case 'next':result[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2400
+ `for(var i=0,l=this.length,result=[];i<l;++i){try{result[i]=#{yield `this[i]`};}catch(e){switch(e.__keyword__){case 'next':result[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2392
2401
  return `result`
2393
2402
  end
2394
2403
 
@@ -2406,7 +2415,7 @@ class Array
2406
2415
  # a.map! {|x| x + 100 } #=> [201, 202, 203, 204]
2407
2416
  #
2408
2417
  def map!
2409
- `for(var i=0,l=this.length;i<l;++i){try{this[i]=#{yield `this[i]`};}catch(e){switch(e._name){case 'next':this[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2418
+ `for(var i=0,l=this.length;i<l;++i){try{this[i]=#{yield `this[i]`};}catch(e){switch(e.__keyword__){case 'next':this[i]=e._value;break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2410
2419
  return self
2411
2420
  end
2412
2421
 
@@ -2484,7 +2493,7 @@ class Array
2484
2493
  # a #=> [1, 2, 3, 4, 5]
2485
2494
  #
2486
2495
  def reject
2487
- `for(var i=0,l=this.length,result=[];i<l;++i){try{if(!$T(#{yield `this[i]`})){result.push(this[i]);};}catch(e){switch(e._name){case 'next':if(!$T(e._value)){result.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2496
+ `for(var i=0,l=this.length,result=[];i<l;++i){try{if(!$T(#{yield `this[i]`})){result.push(this[i]);};}catch(e){switch(e.__keyword__){case 'next':if(!$T(e._value)){result.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2488
2497
  return `result`
2489
2498
  end
2490
2499
 
@@ -2501,7 +2510,7 @@ class Array
2501
2510
  # a #=> [1, 2, 3]
2502
2511
  #
2503
2512
  def reject!
2504
- `for(var i=0,l=this.length,temp=[];i<l;++i){try{if(!$T(#{yield `this[i]`})){temp.push(this[i]);};}catch(e){switch(e._name){case 'next':if(!$T(e._value)){temp.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2513
+ `for(var i=0,l=this.length,temp=[];i<l;++i){try{if(!$T(#{yield `this[i]`})){temp.push(this[i]);};}catch(e){switch(e.__keyword__){case 'next':if(!$T(e._value)){temp.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2505
2514
  return `temp.length==l?nil:this._replace(temp)`
2506
2515
  end
2507
2516
 
@@ -2564,7 +2573,7 @@ class Array
2564
2573
  # A
2565
2574
  #
2566
2575
  def reverse_each
2567
- `for(var i=this.length;i>0;){try{#{yield `this[--i]`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':++i;break;default:throw(e);};};}`
2576
+ `for(var i=this.length;i>0;){try{#{yield `this[--i]`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':++i;break;default:throw(e);};};}`
2568
2577
  return self
2569
2578
  end
2570
2579
 
@@ -2593,7 +2602,7 @@ class Array
2593
2602
  # [1,2,3,4,5].select {|x| x > 3 } #=> [4, 5]
2594
2603
  #
2595
2604
  def select
2596
- `for(var i=0,l=this.length,result=[];i<l;++i){try{if($T(#{yield `this[i]`})){result.push(this[i]);};}catch(e){switch(e._name){case 'next':if($T(e._value)){result.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2605
+ `for(var i=0,l=this.length,result=[];i<l;++i){try{if($T(#{yield `this[i]`})){result.push(this[i]);};}catch(e){switch(e.__keyword__){case 'next':if($T(e._value)){result.push(this[i]);};break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
2597
2606
  return `result`
2598
2607
  end
2599
2608
 
@@ -2730,7 +2739,7 @@ class Array
2730
2739
  # [1,2,3].to_a #=> [1, 2, 3]
2731
2740
  #
2732
2741
  def to_a
2733
- `if(self.m$class()==c$Array){return this;}`
2742
+ `if(this.m$class()==c$Array){return this;}`
2734
2743
  return `c$Array.apply(nil,this)`
2735
2744
  end
2736
2745
 
@@ -2888,7 +2897,7 @@ class Exception
2888
2897
  # Returns _exc_'s class name and message.
2889
2898
  #
2890
2899
  def inspect
2891
- `var class_name=this.m$class()._name`
2900
+ `var class_name=this.m$class().__name__.replace(/\\./g,'::')`
2892
2901
  `this._message==''?$q(class_name):$q('#<'+class_name+': '+(this._message||class_name)+'>')`
2893
2902
  end
2894
2903
 
@@ -2901,7 +2910,7 @@ class Exception
2901
2910
  # is set).
2902
2911
  #
2903
2912
  def message
2904
- `this._message==null?$q(this.m$class()._name):$q(this._message)`
2913
+ `this._message==null?$q(this.m$class().__name__.replace(/\\./g,'::')):$q(this._message)`
2905
2914
  end
2906
2915
 
2907
2916
  # call-seq:
@@ -2925,7 +2934,7 @@ class Exception
2925
2934
  # is set).
2926
2935
  #
2927
2936
  def to_s
2928
- `this._message==null?$q(this.m$class()._name):$q(this._message)`
2937
+ `this._message==null?$q(this.m$class().__name__.replace(/\\./g,'::')):$q(this._message)`
2929
2938
  end
2930
2939
 
2931
2940
  # call-seq:
@@ -2937,7 +2946,7 @@ class Exception
2937
2946
  # is set).
2938
2947
  #
2939
2948
  def to_str
2940
- `this._message==null?$q(this.m$class()._name):$q(this._message)`
2949
+ `this._message==null?$q(this.m$class().__name__.replace(/\\./g,'::')):$q(this._message)`
2941
2950
  end
2942
2951
  end
2943
2952
 
@@ -3243,7 +3252,7 @@ class Hash
3243
3252
  #
3244
3253
  def delete_if
3245
3254
  `var c=this._contents`
3246
- `for(var x in c){try{if(x.slice(1,2)=='_'&&$T(#{yield(`c[x][0]`,`c[x][1]`)})){delete(c[x]);};}catch(e){switch(e._name){case 'next':if($T(e._value)){delete(c[x]);};break;case 'break':return e._value;break;default:throw(e);};};}`
3255
+ `for(var x in c){try{if(x.slice(1,2)=='_'&&$T(#{yield(`c[x][0]`,`c[x][1]`)})){delete(c[x]);};}catch(e){switch(e.__keyword__){case 'next':if($T(e._value)){delete(c[x]);};break;case 'break':return e._value;break;default:throw(e);};};}`
3247
3256
  return self
3248
3257
  end
3249
3258
 
@@ -3270,7 +3279,7 @@ class Hash
3270
3279
  #
3271
3280
  def each
3272
3281
  `var c=this._contents`
3273
- `for(var x in c){try{if(x.slice(1,2)=='_'){var kv=c[x];_block._arity==1?#{yield(`[kv[0],kv[1]]`)}:#{yield(`kv[0],kv[1]`)}};}catch(e){switch(e._name){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3282
+ `for(var x in c){try{if(x.slice(1,2)=='_'){var kv=c[x];_block._arity==1?#{yield(`[kv[0],kv[1]]`)}:#{yield(`kv[0],kv[1]`)}};}catch(e){switch(e.__keyword__){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3274
3283
  return self
3275
3284
  end
3276
3285
 
@@ -3290,7 +3299,7 @@ class Hash
3290
3299
  #
3291
3300
  def each_key
3292
3301
  `var c=this._contents`
3293
- `for(var x in c){try{if(x.slice(1,2)=='_'){#{yield `c[x][0]`}};}catch(e){switch(e._name){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3302
+ `for(var x in c){try{if(x.slice(1,2)=='_'){#{yield `c[x][0]`}};}catch(e){switch(e.__keyword__){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3294
3303
  return self
3295
3304
  end
3296
3305
 
@@ -3311,7 +3320,7 @@ class Hash
3311
3320
  #
3312
3321
  def each_pair
3313
3322
  `var c=this._contents`
3314
- `for(var x in c){try{if(x.slice(1,2)=='_'){var kv=c[x];#{yield(`kv[0]`,`kv[1]`)}};}catch(e){switch(e._name){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3323
+ `for(var x in c){try{if(x.slice(1,2)=='_'){var kv=c[x];#{yield(`kv[0]`,`kv[1]`)}};}catch(e){switch(e.__keyword__){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3315
3324
  return self
3316
3325
  end
3317
3326
 
@@ -3332,7 +3341,7 @@ class Hash
3332
3341
  #
3333
3342
  def each_value
3334
3343
  `var c=this._contents`
3335
- `for(var x in c){try{if(x.slice(1,2)=='_'){#{yield `c[x][1]`}};}catch(e){switch(e._name){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3344
+ `for(var x in c){try{if(x.slice(1,2)=='_'){#{yield `c[x][1]`}};}catch(e){switch(e.__keyword__){case 'next':;break;case 'break':return e._value;break;default:throw(e);};};}`
3336
3345
  return self
3337
3346
  end
3338
3347
 
@@ -3597,7 +3606,7 @@ class Hash
3597
3606
  #
3598
3607
  def reject
3599
3608
  `var c=this._contents,result=c$Hash.m$new()`
3600
- `for(var x in c){try{var kv=c[x];if(x.slice(1,2)=='_'&&!$T(#{yield(`kv[0]`,`kv[1]`)})){result._contents[x]=kv;};}catch(e){switch(e._name){case 'next':if(!$T(e._value)){result._contents[x]=kv;};break;case 'break':return e._value;break;default:throw(e);};};}`
3609
+ `for(var x in c){try{var kv=c[x];if(x.slice(1,2)=='_'&&!$T(#{yield(`kv[0]`,`kv[1]`)})){result._contents[x]=kv;};}catch(e){switch(e.__keyword__){case 'next':if(!$T(e._value)){result._contents[x]=kv;};break;case 'break':return e._value;break;default:throw(e);};};}`
3601
3610
  return `result`
3602
3611
  end
3603
3612
 
@@ -3616,7 +3625,7 @@ class Hash
3616
3625
  #
3617
3626
  def reject!
3618
3627
  `var c=this._contents,u=true`
3619
- `for(var x in c){try{var kv=c[x];if(x.slice(1,2)=='_'&&$T(#{yield(`kv[0]`,`kv[1]`)})){u=false;delete(c[x]);};}catch(e){switch(e._name){case 'next':if($T(e._value)){u=false;delete(c[x]);};break;case 'break':return e._value;break;default:throw(e);};};}`
3628
+ `for(var x in c){try{var kv=c[x];if(x.slice(1,2)=='_'&&$T(#{yield(`kv[0]`,`kv[1]`)})){u=false;delete(c[x]);};}catch(e){switch(e.__keyword__){case 'next':if($T(e._value)){u=false;delete(c[x]);};break;case 'break':return e._value;break;default:throw(e);};};}`
3620
3629
  return `u?nil:this`
3621
3630
  end
3622
3631
 
@@ -3650,7 +3659,7 @@ class Hash
3650
3659
  #
3651
3660
  def select
3652
3661
  `var c=this._contents,result=[]`
3653
- `for(var x in c){try{var kv=c[x];if(x.slice(1,2)=='_'&&$T(#{yield(`kv[0]`,`kv[1]`)})){result.push(kv);};}catch(e){switch(e._name){case 'next':if($T(e._value)){result.push(kv);};break;case 'break':return e._value;break;default:throw(e);};};}`
3662
+ `for(var x in c){try{var kv=c[x];if(x.slice(1,2)=='_'&&$T(#{yield(`kv[0]`,`kv[1]`)})){result.push(kv);};}catch(e){switch(e.__keyword__){case 'next':if($T(e._value)){result.push(kv);};break;case 'break':return e._value;break;default:throw(e);};};}`
3654
3663
  return `result`
3655
3664
  end
3656
3665
 
@@ -4011,7 +4020,7 @@ end
4011
4020
  #
4012
4021
  class NilClass
4013
4022
  def initialize # :nodoc:
4014
- `this._objectId=4`
4023
+ `this.__id__=4`
4015
4024
  end
4016
4025
 
4017
4026
  # call-seq:
@@ -4096,7 +4105,7 @@ class NilClass
4096
4105
  end
4097
4106
 
4098
4107
  `nil=c$NilClass.m$new()`
4099
- `c$Object._superclass=nil`
4108
+ `c$Object.__superclass__=nil`
4100
4109
 
4101
4110
  undef initialize
4102
4111
  end
@@ -4364,7 +4373,7 @@ class Numeric
4364
4373
  # 1..
4365
4374
  #
4366
4375
  def downto(limit)
4367
- `for(var i=this.valueOf();i>=limit;--i){try{#{yield `i`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':++i;break;default:throw(e);};};}`
4376
+ `for(var i=this.valueOf();i>=limit;--i){try{#{yield `i`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':++i;break;default:throw(e);};};}`
4368
4377
  return self
4369
4378
  end
4370
4379
 
@@ -4524,7 +4533,7 @@ class Numeric
4524
4533
  #
4525
4534
  def step(limit, step)
4526
4535
  `var i=this.valueOf()`
4527
- `if(step>0){if(i<limit){for(;limit>=i;i+=step){try{#{yield `i`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':i-=step;break;default:throw(e);};};};};}else{if(i>limit){for(;limit<=i;i+=step){try{#{yield `i`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':i-=step;break;default:throw(e);};}};;};}`
4536
+ `if(step>0){if(i<limit){for(;limit>=i;i+=step){try{#{yield `i`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':i-=step;break;default:throw(e);};};};};}else{if(i>limit){for(;limit<=i;i+=step){try{#{yield `i`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':i-=step;break;default:throw(e);};}};;};}`
4528
4537
  return self
4529
4538
  end
4530
4539
 
@@ -4561,7 +4570,7 @@ class Numeric
4561
4570
  # 4
4562
4571
  #
4563
4572
  def times
4564
- `for(var i=0,l=this.valueOf();i<l;++i){try{#{yield `i`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};}}`
4573
+ `for(var i=0,l=this.valueOf();i<l;++i){try{#{yield `i`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};}}`
4565
4574
  return self
4566
4575
  end
4567
4576
 
@@ -4643,7 +4652,7 @@ class Numeric
4643
4652
  # 100..
4644
4653
  #
4645
4654
  def upto(limit)
4646
- `for(var i=this.valueOf();i<=limit;++i){try{#{yield `i`};}catch(e){switch(e._name){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
4655
+ `for(var i=this.valueOf();i<=limit;++i){try{#{yield `i`};}catch(e){switch(e.__keyword__){case 'next':break;case 'break':return e._value;break;case 'redo':--i;break;default:throw(e);};};}`
4647
4656
  return self
4648
4657
  end
4649
4658
 
@@ -6210,7 +6219,7 @@ class Symbol
6210
6219
  # :foo.to_i #=> 2019
6211
6220
  #
6212
6221
  def to_i
6213
- `this._objectId`
6222
+ `this.__id__`
6214
6223
  end
6215
6224
 
6216
6225
  # call-seq:
@@ -6757,7 +6766,7 @@ end
6757
6766
 
6758
6767
  `
6759
6768
 
6760
- c$Exception.prototype.toString=function(){var class_name=this.m$class()._name,str=class_name+': '+(this._message||class_name);console.log(str+(this._stack!=null?'\\n from '+this.m$backtrace().join('\\n from '):''));return '#<'+str+'>';}
6769
+ c$Exception.prototype.toString=function(){var class_name=this.m$class().__name__.replace(/\\./g,'::'),str=class_name+': '+(this._message||class_name);console.log(str+(this._stack!=null?'\\n from '+this.m$backtrace().join('\\n from '):''));return '#<'+str+'>';}
6761
6770
  c$NilClass.prototype.toString=function(){return 'nil';};
6762
6771
  c$Range.prototype.toString=function(){return ''+this._start+(this._exclusive?'...':'..')+this._end;};
6763
6772
  c$Regexp.prototype.toString=function(){return '/'+this._source+'/'+(/s/.test(this._options)?'m':'')+(/i/.test(this._options)?'i':'')+(/x/.test(this._options)?'x':'');};
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Sielaff
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-14 00:00:00 -04:00
12
+ date: 2008-10-16 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency