Permalink
Browse files

bugfixes

  • Loading branch information...
1 parent a5d40cf commit 5f50f245d8604e4b50c344af1139e5ca294cdad3 @jlongster committed Apr 14, 2012
Showing with 94 additions and 47 deletions.
  1. +25 −12 backends/js.js
  2. +7 −0 backends/js.ol
  3. +14 −10 compiler.js
  4. +6 −0 compiler.ol
  5. +23 −11 runtime.js
  6. +19 −14 runtime.ol
View
@@ -151,7 +151,21 @@ return fold((function(el,acc){
return (acc + 1);
}),0,lst);
});
-var list_dash_append = (function(lst1,lst2){
+var list_dash_append = (function(){
+var lsts = vector_dash__gt_list(Array.prototype.slice.call(arguments, 0));
+var l_star_ = (function() {if(null_p_(lsts)) {return _emptylst;
+} else {return lsts;
+}})()
+;
+return (function() {if(null_p_(l_star_)) {return _emptylst;
+} else {return (function() {if(null_p_(cdr(l_star_))) {return car(l_star_);
+} else {return _list_dash_append(car(l_star_),apply(list_dash_append,cdr(l_star_)));
+}})()
+;
+}})()
+;
+});
+var _list_dash_append = (function(lst1,lst2){
return ((function() {var loop = (function(lst){
return (function() {if(null_p_(lst)) {return lst2;
} else {return cons(car(lst),loop(cdr(lst)));
@@ -468,24 +482,22 @@ var o38 = obj2;
return loop(o37,o38);
}))();
}))();
-} else {return (function() {if((vector_p_(obj1) && vector_p_(obj2))) {return ((function() {return ((function() {var loop = (function(i){
-return (function() {if(((i < obj1["length"]) && (i < obj2["length"]))) {return ((function() {return true;
-}))();
-} else {return (function() {if(((i < obj1["length"]) || (i < obj2["length"]))) {return ((function() {return false;
-}))();
-} else {return ((function() {return (function() {if(equal_p_(vector_dash_ref(obj1,i),vector_dash_ref(obj2,i))) {return loop((i + 1));
+} else {return (function() {if((vector_p_(obj1) && vector_p_(obj2))) {return ((function() {return (function() {if(not(_eq_(obj1["length"],obj2["length"]))) {return false;
+} else {return ((function() {var loop = (function(i){
+return (function() {if((i < obj1["length"])) {return (function() {if(_eq_(vector_dash_ref(obj1,i),vector_dash_ref(obj2,i))) {return vector("__tco_call",(function() {return loop((i + 1));
+}));
} else {return false;
}})()
;
-}))();
-}})()
-;
+} else {return true;
}})()
;
});
var o39 = 0;
-return loop(o39);
+return trampoline(loop(o39));
}))();
+}})()
+;
}))();
} else {return (function() {if((dict_p_(obj1) && dict_p_(obj2))) {return ((function() {return ((function() {var o40 = (function(keys1,keys2){
return (eq_p_(length(keys1),length(keys2)) && ((function() {var loop = (function(lst){
@@ -821,6 +833,7 @@ name = name["replace"](RegExp(">","g"),"_gt_");
name = name["replace"](RegExp("<","g"),"_lt_");
name = name["replace"](RegExp("%","g"),"_per_");
name = name["replace"](RegExp("=","g"),"_eq_");
+name = name["replace"](RegExp("\\/","g"),"_slash_");
name = name["replace"](RegExp("\\*","g"),"_star_");
name = name["replace"](RegExp("\\+","g"),"_plus_");
return write(name);
@@ -995,7 +1008,7 @@ write_dash_string(cadr(el));
return write(");");
}),args);
});
-return dict("\uFDD1write-runtime",write_dash_runtime,"\uFDD1write-number",write_dash_number,"\uFDD1write-string",write_dash_string,"\uFDD1write-boolean",write_dash_boolean,"\uFDD1write-term",write_dash_term,"\uFDD1write-symbol",write_dash_symbol,"\uFDD1write-empty-list",write_dash_empty_dash_list,"\uFDD1write-set",write_dash_set,"\uFDD1write-set!",write_dash_set_excl_,"\uFDD1write-if",write_dash_if,"\uFDD1write-lambda",write_dash_lambda,"\uFDD1write-func-call",write_dash_func_dash_call,"\uFDD1write-raw-code",write_dash_raw_dash_code,"\uFDD1write-require",write_dash_require,"\uFDD1write-and",make_dash_op_dash_writer("&&"),"\uFDD1write-or",make_dash_op_dash_writer("||"),"\uFDD1write-add",make_dash_op_dash_writer("+"),"\uFDD1write-subtract",make_dash_op_dash_writer("-"),"\uFDD1write-multiply",make_dash_op_dash_writer("*"),"\uFDD1write-divide",make_dash_op_dash_writer("/"),"\uFDD1write-gt",make_dash_op_dash_writer(">"),"\uFDD1write-lt",make_dash_op_dash_writer("<"),"\uFDD1write-mod",make_dash_op_dash_writer("%"),"\uFDD1make-fresh",make_dash_fresh,"\uFDD1get-code",(function() {return code["join"]("");
+return dict("\uFDD1write-runtime",write_dash_runtime,"\uFDD1write-number",write_dash_number,"\uFDD1write-string",write_dash_string,"\uFDD1write-boolean",write_dash_boolean,"\uFDD1write-term",write_dash_term,"\uFDD1write-symbol",write_dash_symbol,"\uFDD1write-empty-list",write_dash_empty_dash_list,"\uFDD1write-set",write_dash_set,"\uFDD1write-set!",write_dash_set_excl_,"\uFDD1write-if",write_dash_if,"\uFDD1write-lambda",write_dash_lambda,"\uFDD1write-func-call",write_dash_func_dash_call,"\uFDD1write-raw-code",write_dash_raw_dash_code,"\uFDD1write-require",write_dash_require,"\uFDD1write-and",make_dash_op_dash_writer("&&"),"\uFDD1write-or",make_dash_op_dash_writer("||"),"\uFDD1write-add",make_dash_op_dash_writer("+"),"\uFDD1write-subtract",make_dash_op_dash_writer("-"),"\uFDD1write-multiply",make_dash_op_dash_writer("*"),"\uFDD1write-divide",make_dash_op_dash_writer("/"),"\uFDD1write-gt",make_dash_op_dash_writer(">"),"\uFDD1write-lt",make_dash_op_dash_writer("<"),"\uFDD1write-gteq",make_dash_op_dash_writer(">="),"\uFDD1write-lteq",make_dash_op_dash_writer("<="),"\uFDD1write-mod",make_dash_op_dash_writer("%"),"\uFDD1write-rshift",make_dash_op_dash_writer(">>"),"\uFDD1write-lshift",make_dash_op_dash_writer("<<"),"\uFDD1write-bitwise-or",make_dash_op_dash_writer("|"),"\uFDD1write-bitwise-and",make_dash_op_dash_writer("&"),"\uFDD1make-fresh",make_dash_fresh,"\uFDD1get-code",(function() {return code["join"]("");
}));
});
module["exports"] = generator;
View
@@ -92,6 +92,7 @@
(set! name (name.replace (RegExp "<" "g") "_lt_"))
(set! name (name.replace (RegExp "%" "g") "_per_"))
(set! name (name.replace (RegExp "=" "g") "_eq_"))
+ (set! name (name.replace (RegExp "\\/" "g") "_slash_"))
(set! name (name.replace (RegExp "\\*" "g") "_star_"))
(set! name (name.replace (RegExp "\\+" "g") "_plus_"))
(write name))
@@ -270,7 +271,13 @@
:write-divide (make-op-writer "/")
:write-gt (make-op-writer ">")
:write-lt (make-op-writer "<")
+ :write-gteq (make-op-writer ">=")
+ :write-lteq (make-op-writer "<=")
:write-mod (make-op-writer "%")
+ :write-rshift (make-op-writer ">>")
+ :write-lshift (make-op-writer "<<")
+ :write-bitwise-or (make-op-writer "|")
+ :write-bitwise-and (make-op-writer "&")
:make-fresh make-fresh
:get-code (lambda () (code.join ""))})
View
@@ -468,24 +468,22 @@ var o38 = obj2;
return loop(o37,o38);
}))();
}))();
-} else {return (function() {if((vector_p_(obj1) && vector_p_(obj2))) {return ((function() {return ((function() {var loop = (function(i){
-return (function() {if(((i < obj1["length"]) && (i < obj2["length"]))) {return ((function() {return true;
-}))();
-} else {return (function() {if(((i < obj1["length"]) || (i < obj2["length"]))) {return ((function() {return false;
-}))();
-} else {return ((function() {return (function() {if(equal_p_(vector_dash_ref(obj1,i),vector_dash_ref(obj2,i))) {return loop((i + 1));
+} else {return (function() {if((vector_p_(obj1) && vector_p_(obj2))) {return ((function() {return (function() {if(not(_eq_(obj1["length"],obj2["length"]))) {return false;
+} else {return ((function() {var loop = (function(i){
+return (function() {if((i < obj1["length"])) {return (function() {if(_eq_(vector_dash_ref(obj1,i),vector_dash_ref(obj2,i))) {return vector("__tco_call",(function() {return loop((i + 1));
+}));
} else {return false;
}})()
;
-}))();
-}})()
-;
+} else {return true;
}})()
;
});
var o39 = 0;
-return loop(o39);
+return trampoline(loop(o39));
}))();
+}})()
+;
}))();
} else {return (function() {if((dict_p_(obj1) && dict_p_(obj2))) {return ((function() {return ((function() {var o40 = (function(keys1,keys2){
return (eq_p_(length(keys1),length(keys2)) && ((function() {var loop = (function(lst){
@@ -1340,6 +1338,12 @@ install_dash_native("\uFDD1*","\uFDD1write-multiply",verify_dash_not_dash_single
install_dash_native("\uFDD1/","\uFDD1write-divide",verify_dash_not_dash_single);
install_dash_native("\uFDD1>","\uFDD1write-gt",verify_dash_not_dash_single);
install_dash_native("\uFDD1<","\uFDD1write-lt",verify_dash_not_dash_single);
+install_dash_native("\uFDD1<=","\uFDD1write-lteq",verify_dash_not_dash_single);
+install_dash_native("\uFDD1>=","\uFDD1write-gteq",verify_dash_not_dash_single);
+install_dash_native("\uFDD1>>","\uFDD1write-rshift",verify_dash_not_dash_single);
+install_dash_native("\uFDD1<<","\uFDD1write-lshift",verify_dash_not_dash_single);
+install_dash_native("\uFDD1bitwise-or","\uFDD1write-bitwise-or",verify_dash_not_dash_single);
+install_dash_native("\uFDD1bitwise-and","\uFDD1write-bitwise-and",verify_dash_not_dash_single);
install_dash_native("\uFDD1%","\uFDD1write-mod",verify_dash_not_dash_single);
install_dash_native("\uFDD1require","\uFDD1write-require",(function(form){
verify_dash_not_dash_single(form);
View
@@ -452,6 +452,12 @@
(install-native '/ 'write-divide verify-not-single)
(install-native '> 'write-gt verify-not-single)
(install-native '< 'write-lt verify-not-single)
+(install-native '<= 'write-lteq verify-not-single)
+(install-native '>= 'write-gteq verify-not-single)
+(install-native '>> 'write-rshift verify-not-single)
+(install-native '<< 'write-lshift verify-not-single)
+(install-native 'bitwise-or 'write-bitwise-or verify-not-single)
+(install-native 'bitwise-and 'write-bitwise-and verify-not-single)
(install-native '% 'write-mod verify-not-single)
(install-native 'require 'write-require
View
@@ -151,7 +151,21 @@ return fold((function(el,acc){
return (acc + 1);
}),0,lst);
});
-var list_dash_append = (function(lst1,lst2){
+var list_dash_append = (function(){
+var lsts = vector_dash__gt_list(Array.prototype.slice.call(arguments, 0));
+var l_star_ = (function() {if(null_p_(lsts)) {return _emptylst;
+} else {return lsts;
+}})()
+;
+return (function() {if(null_p_(l_star_)) {return _emptylst;
+} else {return (function() {if(null_p_(cdr(l_star_))) {return car(l_star_);
+} else {return _list_dash_append(car(l_star_),apply(list_dash_append,cdr(l_star_)));
+}})()
+;
+}})()
+;
+});
+var _list_dash_append = (function(lst1,lst2){
return ((function() {var loop = (function(lst){
return (function() {if(null_p_(lst)) {return lst2;
} else {return cons(car(lst),loop(cdr(lst)));
@@ -468,24 +482,22 @@ var o38 = obj2;
return loop(o37,o38);
}))();
}))();
-} else {return (function() {if((vector_p_(obj1) && vector_p_(obj2))) {return ((function() {return ((function() {var loop = (function(i){
-return (function() {if(((i < obj1["length"]) && (i < obj2["length"]))) {return ((function() {return true;
-}))();
-} else {return (function() {if(((i < obj1["length"]) || (i < obj2["length"]))) {return ((function() {return false;
-}))();
-} else {return ((function() {return (function() {if(equal_p_(vector_dash_ref(obj1,i),vector_dash_ref(obj2,i))) {return loop((i + 1));
+} else {return (function() {if((vector_p_(obj1) && vector_p_(obj2))) {return ((function() {return (function() {if(not(_eq_(obj1["length"],obj2["length"]))) {return false;
+} else {return ((function() {var loop = (function(i){
+return (function() {if((i < obj1["length"])) {return (function() {if(_eq_(vector_dash_ref(obj1,i),vector_dash_ref(obj2,i))) {return vector("__tco_call",(function() {return loop((i + 1));
+}));
} else {return false;
}})()
;
-}))();
-}})()
-;
+} else {return true;
}})()
;
});
var o39 = 0;
-return loop(o39);
+return trampoline(loop(o39));
}))();
+}})()
+;
}))();
} else {return (function() {if((dict_p_(obj1) && dict_p_(obj2))) {return ((function() {return ((function() {var o40 = (function(keys1,keys2){
return (eq_p_(length(keys1),length(keys2)) && ((function() {var loop = (function(lst){
View
@@ -136,7 +136,16 @@
0
lst))
-(define (list-append lst1 lst2)
+(define (list-append . lsts)
+ (define l* (if (null? lsts) '() lsts))
+ (if (null? l*)
+ '()
+ (if (null? (cdr l*))
+ (car l*)
+ (_list-append (car l*)
+ (apply list-append (cdr l*))))))
+
+(define (_list-append lst1 lst2)
(let loop ((lst lst1))
(if (null? lst)
lst2
@@ -357,19 +366,15 @@
#f)))))
((and (vector? obj1)
(vector? obj2))
- (let loop ((i 0))
- (cond
- ((and (< i obj1.length)
- (< i obj2.length))
- #t)
- ((or (< i obj1.length)
- (< i obj2.length))
- #f)
- (else
- (if (equal? (vector-ref obj1 i)
- (vector-ref obj2 i))
- (loop (+ i 1))
- #f)))))
+ (if (not (= obj1.length obj2.length))
+ #f
+ (let loop ((i 0))
+ (if (< i obj1.length)
+ (if (= (vector-ref obj1 i)
+ (vector-ref obj2 i))
+ (loop (+ i 1))
+ #f)
+ #t))))
((and (dict? obj1)
(dict? obj2))
(let ((keys1 (keys obj1))

0 comments on commit 5f50f24

Please sign in to comment.