Changeset 2991
- Timestamp:
- 12/10/07 17:59:32 (5 years ago)
- Location:
- lang/javascript/jsruby/trunk
- Files:
-
- 2 modified
-
src/interpreter.js (modified) (3 diffs)
-
tests/array.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/jsruby/trunk/src/interpreter.js
r2989 r2991 2 2 3 3 RubyEngine.Scope = function(){ this.clear(); } 4 RubyEngine.Scope.copy = function(scope, src) {5 for(var i in src) scope[i] = src[i];6 return scope;7 }8 4 9 5 RubyEngine.Scope.prototype.clear = function(){ 10 6 this.level = [{}] 11 7 this.stack = [] 12 this.global = RubyEngine.Scope.copy({}, RubyEngine.Interpreter.KernelMethod) 8 this.global = {} 9 for(var i in RubyEngine.Interpreter.KernelMethod) { 10 if (i.match(/^[a-z_]/)) this.global[i] = RubyEngine.Interpreter.KernelMethod[i]; 11 } 12 for(var i in RubyEngine.RubyObject) { 13 if (i.match(/^[A-Z\$]/)) this.global[i] = RubyEngine.RubyObject[i]; 14 } 13 15 } 14 16 RubyEngine.Scope.prototype.substitute = function(name, value){ … … 51 53 52 54 RubyEngine.Interpreter.prototype.run = function(node){ 53 //console.log( args[idx].toSource());console.trace();if(!confirm("continue?")) exit();55 //console.log(node.toSource());console.trace();if(!confirm("continue?")) exit(); 54 56 var ret = null; 55 57 if (Array.prototype.isPrototypeOf(node)) { … … 146 148 } 147 149 RubyEngine.Interpreter.prototype.objectMethod = function(node){ 148 //console.log(node.toSource());console.trace();if(!confirm("continue?")) exit(); 149 var obj = this.run(node.target); 150 //console.log(node.toSource());console.dir(node);console.trace();if(!confirm("continue?")) exit(); 151 var obj; 152 if (RubyEngine.Node.Ref.prototype.isPrototypeOf(node.target)) { 153 obj = this.scope.reference(node.target.name); 154 } else { 155 obj = this.run(node.target); 156 } 150 157 var method = obj.clz.methods[node.name]; 151 158 if (method) { -
lang/javascript/jsruby/trunk/tests/array.html
r2474 r2991 25 25 } 26 26 27 function testArrayNew() { 28 assertArrayEquals("array new 1", ruby.exec(" Array.new() "), []); 29 assertArrayEquals("array new 2", ruby.exec(" Array.new(1) "), [1]); 30 assertArrayEquals("array new 3", ruby.exec(" Array.new(1, 2, 3) "), [1, 2, 3]); 31 assertArrayEquals("array new 4", ruby.exec(" Array.new([1, 2], Array.new(3, 4)) "), [[1, 2], [3, 4]]); 32 assertArrayEquals("array new 5", ruby.exec(" Array.new(1, '2', 3) "), [1, '2', 3]); 33 } 34 27 35 function testBrackett() { 28 36 ruby.exec(' a=["x", "y", "z"] ')
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)