]> gitweb.factorcode.org Git - factor.git/commitdiff
fjsc: remove 'world' parameter
authorchris.double <chris.double@double.co.nz>
Sat, 16 Dec 2006 23:32:34 +0000 (23:32 +0000)
committerchris.double <chris.double@double.co.nz>
Sat, 16 Dec 2006 23:32:34 +0000 (23:32 +0000)
apps/furnace-fjsc/resources/bootstrap.js
libs/fjsc/fjsc.factor

index f4c5fb6da1e14235dd6a2589bf982dd89ad831df..a6a27185aad503a0bc97fc6dfde17f7c097a0528 100644 (file)
@@ -4,8 +4,8 @@ function Word(name, source, func) {
   this.func = func;
 }
 
-Word.prototype.execute = function(world, next) {
-  this.func(world,next);
+Word.prototype.execute = function(next) {
+  this.func(next);
 }
 
 function Continuation() {
@@ -29,188 +29,187 @@ function Factor() {
 
 var factor = new Factor();
 
-factor.words["dup"] = new Word("dup", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["dup"] = new Word("dup", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   stack[stack.length] = stack[stack.length-1];
-  next(world);
+  next();
 });
 
-factor.words["drop"] = new Word("drop", "primitive", function(world, next) {
-  world.cont.data_stack.pop();
-  next(world);
+factor.words["drop"] = new Word("drop", "primitive", function(next) {
+  factor.cont.data_stack.pop();
+  next();
 });
 
-factor.words["nip"] = new Word("nip", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["nip"] = new Word("nip", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   stack[stack.length-2] = stack[stack.length-1];
   stack.pop();
-  next(world);
+  next();
 });
 
-factor.words["over"] = new Word("over", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["over"] = new Word("over", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   stack[stack.length] = stack[stack.length-2];
-  next(world);
+  next();
 });
 
-factor.words["swap"] = new Word("swap", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["swap"] = new Word("swap", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   var temp = stack[stack.length-2];
   stack[stack.length-2] = stack[stack.length-1];
   stack[stack.length-1] = temp;
-  next(world);
+  next();
 });
 
-factor.words[">r"] = new Word(">r", "primitive", function(world, next) {
-  var data_stack = world.cont.data_stack;
-  var retain_stack = world.cont.retain_stack;
+factor.words[">r"] = new Word(">r", "primitive", function(next) {
+  var data_stack = factor.cont.data_stack;
+  var retain_stack = factor.cont.retain_stack;
   retain_stack.push(data_stack.pop());
-  next(world);
+  next();
 });
 
-factor.words["r>"] = new Word("r>", "primitive", function(world, next) {
-  var data_stack = world.cont.data_stack;
-  var retain_stack = world.cont.retain_stack;
+factor.words["r>"] = new Word("r>", "primitive", function(next) {
+  var data_stack = factor.cont.data_stack;
+  var retain_stack = factor.cont.retain_stack;
   data_stack.push(retain_stack.pop());
-  next(world);
+  next();
 });
 
-factor.words["*"] = new Word("*", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["*"] = new Word("*", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   stack.push(stack.pop() * stack.pop());
-  next(world);
+  next();
 });
 
-factor.words["+"] = new Word("+", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["+"] = new Word("+", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   stack.push(stack.pop() + stack.pop());
-  next(world);
+  next();
 });
 
-factor.words["-"] = new Word("-", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["-"] = new Word("-", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   var v1 = stack.pop();
   var v2 = stack.pop();
   stack.push(v2 - v1);
-  next(world);
+  next();
 });
 
-factor.words["/"] = new Word("/", "primitive", function(world, next) {
-  var stack = world.cont.data_stack;
+factor.words["/"] = new Word("/", "primitive", function(next) {
+  var stack = factor.cont.data_stack;
   var v1 = stack.pop();
   var v2 = stack.pop();
   stack.push(v2 / v1);
-  next(world);
+  next();
 });
 
-factor.words["."] = new Word(".", "primitive", function(world, next) {
-  alert(world.cont.data_stack.pop());
-  next(world);
+factor.words["."] = new Word(".", "primitive", function(next) {
+  alert(factor.cont.data_stack.pop());
+  next();
 });
 
-factor.words["call"] = new Word("call", "primitive", function(world, next) {
-  var quot = world.cont.data_stack.pop();
-  quot.execute(world, next);
+factor.words["call"] = new Word("call", "primitive", function(next) {
+  var quot = factor.cont.data_stack.pop();
+  quot.execute(next);
 });
 
-factor.words["execute"] = new Word("execute", "primitive", function(world, next) {
-  var quot = world.cont.data_stack.pop();
-  quot.execute(world, next);
+factor.words["execute"] = new Word("execute", "primitive", function(next) {
+  var quot = factor.cont.data_stack.pop();
+  quot.execute(next);
 });
 
-factor.words["clear"] = new Word("clear", "primitive", function(world, next) {
-  world.cont.data_stack = [];
-  world.cont.retain_stack = [];
-  next(world);
+factor.words["clear"] = new Word("clear", "primitive", function(next) {
+  factor.cont.data_stack = [];
+  factor.cont.retain_stack = [];
+  next();
 });
 
-factor.words["square"] = new Word("square", "primitive", function(world, next) {  
-  var stack = world.cont.data_stack;
+factor.words["square"] = new Word("square", "primitive", function(next) {  
+  var stack = factor.cont.data_stack;
   stack[stack.length-1] = stack[stack.length-1] * stack[stack.length-1];
-  next(world);
+  next();
 });
 
-factor.words["if"] = new Word("if", "primitive", function(world, next) {  
-  var stack = world.cont.data_stack;
+factor.words["if"] = new Word("if", "primitive", function(next) {  
+  var stack = factor.cont.data_stack;
   var else_quot = stack.pop();
   var then_quot = stack.pop();
   var condition = stack.pop();
   if(condition) {
-    then_quot.execute(world, next);
+    then_quot.execute(next);
   } else {
-    else_quot.execute(world, next);
+    else_quot.execute(next);
   }
 });
 
-factor.words["f"] = new Word("f", "primitive", function(world, next) {  
-  world.cont.data_stack.push(false);
-  next(world);
+factor.words["f"] = new Word("f", "primitive", function(next) {  
+  factor.cont.data_stack.push(false);
+  next();
 });
 
-factor.words["t"] = new Word("t", "primitive", function(world, next) {  
-  world.cont.data_stack.push(true);
-  next(world);
+factor.words["t"] = new Word("t", "primitive", function(next) {  
+  factor.cont.data_stack.push(true);
+  next();
 });
 
-factor.words["="] = new Word("=", "primitive", function(world, next) {   
-  var stack = world.cont.data_stack;
+factor.words["="] = new Word("=", "primitive", function(next) {   
+  var stack = factor.cont.data_stack;
   stack.push(stack.pop()==stack.pop());
-  next(world);
+  next();
 });
 
-factor.words["window"] = new Word("window", "primitive", function(world, next) {  
-  world.cont.data_stack.push(window);
-  next(world);
+factor.words["window"] = new Word("window", "primitive", function(next) {  
+  factor.cont.data_stack.push(window);
+  next();
 });
 
-factor.words["bootstrap"] = new Word("bootstrap", "primitive", function(world, next) {  
-  world.cont.data_stack.push("/responder/fjsc-resources/bootstrap.factor");
-  world.words["run-file"].execute(world, next);
+factor.words["bootstrap"] = new Word("bootstrap", "primitive", function(next) {  
+  factor.cont.data_stack.push("/responder/fjsc-resources/bootstrap.factor");
+  factor.words["run-file"].execute(next);
 });
 
-factor.words["run-file"] = new Word("run-file", "primitive", function(world, next) {  
-  var stack = world.cont.data_stack;
+factor.words["run-file"] = new Word("run-file", "primitive", function(next) {  
+  var stack = factor.cont.data_stack;
   var url = stack.pop();
   var callback = {
     success: function(o) {
       var result = o.responseText;
-      world.server_eval(result, world, next);
+      factor.server_eval(result, next);
     },
     failure: function(o) {
       alert('run-file failed');
-      next(world);
+      next();
     }
   };
   YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
 });
 
-factor.words["callcc0"] = new Word("callcc0", "primitive", function(world, next) {  
-  var data_stack = world.cont.data_stack;
+factor.words["callcc0"] = new Word("callcc0", "primitive", function(next) {  
+  var data_stack = factor.cont.data_stack;
   var quot = data_stack.pop();
-  var new_cont = world.cont.clone();  
-  var old_next = world.next;
+  var new_cont = factor.cont.clone();  
+  var old_next = factor.next;
   var cont = {
-    world: world,
-    next: function(world) {
-      world.next = old_next;
-      next(world);
+    next: function() {
+      factor.next = old_next;
+      next();
     },
-    cont: world.cont
+    cont: factor.cont
   };
   new_cont.data_stack.push(cont);
-  world.cont = new_cont;;
-  quot.execute(world, next);  
+  factor.cont = new_cont;;
+  quot.execute(next);  
 });
 
-factor.words["continue"] = new Word("continue", "primitive", function(world, next) {  
-  var data_stack = world.cont.data_stack;
+factor.words["continue"] = new Word("continue", "primitive", function(next) {  
+  var data_stack = factor.cont.data_stack;
   var cont = data_stack.pop(); 
-  world.cont = cont.cont.clone();
-  (cont.next)(world);
+  factor.cont = cont.cont.clone();
+  (cont.next)();
 });
 
-factor.words["alien-invoke"] = new Word("alien-invoke", "primitive", function(world, next) {  
-  var stack = world.cont.data_stack;
+factor.words["alien-invoke"] = new Word("alien-invoke", "primitive", function(next) {  
+  var stack = factor.cont.data_stack;
   var arg_types = stack.pop();
   var method_name = stack.pop();
   var library_name = stack.pop();
@@ -223,38 +222,38 @@ factor.words["alien-invoke"] = new Word("alien-invoke", "primitive", function(wo
   var v = obj[method_name].apply(obj, args);
   if(return_values.length > 0)
     stack.push(v);
-  next(world);
+  next();
 });
 
-Factor.prototype.push_data = function(v, world, next) {
-  world.cont.data_stack.push(v);
-  next(world);
+Factor.prototype.push_data = function(v, next) {
+  factor.cont.data_stack.push(v);
+  next();
 }
 
-Factor.prototype.define_word = function(name, source, func, world, next) {
-  factor.words[name] = new Word(name, source, function(world, next) {
-    var old = world.next;
-    world.next = function(world) {
-      world.next = old;
-      next(world);
+Factor.prototype.define_word = function(name, source, func, next) {
+  factor.words[name] = new Word(name, source, function(next) {
+    var old = factor.next;
+    factor.next = function() {
+      factor.next = old;
+      next();
     }
-    func(world);
+    func();
   });
-  next(world);
+  next();
 }
 
 Factor.prototype.make_quotation = function(source, func) {
-  return new Word("quotation", source, function(world, next) {
-    var old = world.next;
-    world.next = function(world) {
-      world.next = old;
-      next(world);
+  return new Word("quotation", source, function(next) {
+    var old = factor.next;
+    factor.next = function() {
+      factor.next = old;
+      next();
     }
-    func(world);
+    func();
   });
 }
 
-Factor.prototype.server_eval = function(text, world, next) {
+Factor.prototype.server_eval = function(text, next) {
    var self = this;
    var callback = {
       success: function(o) {
@@ -264,8 +263,8 @@ Factor.prototype.server_eval = function(text, world, next) {
         var func = eval(v);
          factor.next = function() { self.display_datastack(); } 
         func(factor);
-         if(world && next) 
-           next(world);
+         if(next) 
+           next();
       }
    };
    this.form.code.value=text;
index 9785aeebdb96df0723666113507e76aa33305829..367edb02fbc1006fdb81fe6c7feceff83ec10b1e 100644 (file)
@@ -122,9 +122,9 @@ M: ast-number (literal)
   ast-number-value number>string , ;
 
 M: ast-number (compile) 
-  "world.push_data(" ,
+  "factor.push_data(" ,
   (literal)  
-  ",world," , ;
+  "," , ;
 
 M: ast-string (literal) 
   "'" ,
@@ -134,26 +134,26 @@ M: ast-string (literal)
 M: ast-string (compile) 
   "factor.push_data(" ,
   (literal)
-  ",world," , ;
+  "," , ;
 
 M: ast-identifier (literal) 
-  "world.words[\"" , ast-identifier-value , "\"]" ,  ;
+  "factor.words[\"" , ast-identifier-value , "\"]" ,  ;
 
 M: ast-identifier (compile) 
-  (literal) ".execute(world, " ,  ;
+  (literal) ".execute(" ,  ;
 
 M: ast-define (compile) 
-  "world.define_word(\"" , 
+  "factor.define_word(\"" , 
   dup ast-define-name , 
   "\",\"source\"," ,
   ast-define-expression (compile)
-  ",world," , ;
+  "," , ;
 
 : do-expressions ( seq -- )
   dup empty? not [
     unclip
     dup ast-comment? not [
-      "function(world) {" ,
+      "function() {" ,
       (compile) 
       do-expressions
       ")}" ,
@@ -161,18 +161,18 @@ M: ast-define (compile)
       drop do-expressions
     ] if
   ] [
-    drop "world.next" ,
+    drop "factor.next" ,
   ] if  ;
 
 M: ast-quotation (literal)   
-  "world.make_quotation(\"source\"," ,
+  "factor.make_quotation(\"source\"," ,
   ast-quotation-values do-expressions
   ")" , ;
 
 M: ast-quotation (compile)   
-  "world.push_data(world.make_quotation(\"source\"," ,
+  "factor.push_data(factor.make_quotation(\"source\"," ,
   ast-quotation-values do-expressions
-  "),world," , ;
+  ")," , ;
 
 M: ast-array (literal)   
   "[" ,  
@@ -180,7 +180,7 @@ M: ast-array (literal)
   "]" , ;
 
 M: ast-array (compile)   
-  "world.push_data(" , (literal) ",world," , ;
+  "factor.push_data(" , (literal) "," , ;
 
 
 M: ast-expression (literal)
@@ -199,7 +199,7 @@ M: ast-word (literal)
 M: ast-word (compile)
   "factor.push_data(" ,
   (literal)
-  ",world," , ;
+  "," , ;
   
 M: ast-comment (compile)
   drop ;