From e18c809e53c0342e9fadcf5277771423093877e8 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Fri, 31 Mar 2017 12:01:07 +0200 Subject: [PATCH 01/11] Methods are also available as functions whose identifier is ($ class-name "-" method-name). --- NEWS | 2 ++ environment/transpiler/targets/javascript/class.lisp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 363184da..bb4a8800 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ Changes of tre-0.7 relative to tre-0.6: * (%NEW): Accidentally converted to (%NEW NIL) – fixed. * PHP: Debugged property and associative array functions. + * JS: Methods are also available as functions whose + identifier is ($ class-name "-" method-name). Changes of tre-0.6 relative to tre-0.5: * PHP: PROPERTY-NAMES fixed for associative arrays. diff --git a/environment/transpiler/targets/javascript/class.lisp b/environment/transpiler/targets/javascript/class.lisp index c20aec20..03432910 100644 --- a/environment/transpiler/targets/javascript/class.lisp +++ b/environment/transpiler/targets/javascript/class.lisp @@ -26,7 +26,7 @@ (apply #'generic-defmember class-name names)) (fn js-emit-method (class-name x) - (!= ($ '~meth- class-name '- x.) + (!= ($ class-name '- x.) (. `((%%native ,x.) #',!) `(fn ,! ,.x. (%thisify ,class-name From 33412ea68c483e0a557fde448f4bbb273a50e58a Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Fri, 31 Mar 2017 12:06:50 +0200 Subject: [PATCH 02/11] PHP: AREF returns NIL for undefined indexes instead of breaking with an error message. --- NEWS | 2 ++ environment/transpiler/targets/php/core/array.lisp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index bb4a8800..21f0b0c9 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ Changes of tre-0.7 relative to tre-0.6: * (%NEW): Accidentally converted to (%NEW NIL) – fixed. * PHP: Debugged property and associative array functions. + * PHP: AREF returns NIL for undefined indexes instead of breaking with an + error message. * JS: Methods are also available as functions whose identifier is ($ class-name "-" method-name). diff --git a/environment/transpiler/targets/php/core/array.lisp b/environment/transpiler/targets/php/core/array.lisp index 5c88bb6a..f2aebf85 100644 --- a/environment/transpiler/targets/php/core/array.lisp +++ b/environment/transpiler/targets/php/core/array.lisp @@ -25,7 +25,8 @@ (fn aref (a k) (? (is_array a) - (%aref a k) + (& (%aref-defined? a k) + (%aref a k)) (href a k))) (fn (= aref) (v a k) From 6b91bb323ce9b29af58f89a877ff876ea56686dc Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sat, 1 Apr 2017 19:52:27 +0200 Subject: [PATCH 03/11] WITHOUT-HEAD, WITHOUT-TAIL: New functions. --- NEWS | 1 + environment/stage4/{head-p.lisp => head.lisp} | 5 +++++ environment/stage4/main.lisp | 4 ++-- environment/stage4/{tail-p.lisp => tail.lisp} | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) rename environment/stage4/{head-p.lisp => head.lisp} (50%) rename environment/stage4/{tail-p.lisp => tail.lisp} (62%) diff --git a/NEWS b/NEWS index 21f0b0c9..40440b0e 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Changes of tre-0.7 relative to tre-0.6: error message. * JS: Methods are also available as functions whose identifier is ($ class-name "-" method-name). + * WITHOUT-HEAD, WITHOUT-TAIL: New functions. Changes of tre-0.6 relative to tre-0.5: * PHP: PROPERTY-NAMES fixed for associative arrays. diff --git a/environment/stage4/head-p.lisp b/environment/stage4/head.lisp similarity index 50% rename from environment/stage4/head-p.lisp rename to environment/stage4/head.lisp index 049b1e3f..9fc448c7 100644 --- a/environment/stage4/head-p.lisp +++ b/environment/stage4/head.lisp @@ -1,2 +1,7 @@ (fn head? (x head &key (test #'equal)) (funcall test head (subseq x 0 (length head)))) + +(fn without-head (x head) + (? (head? x head) + (subseq x (length head)) + x)) diff --git a/environment/stage4/main.lisp b/environment/stage4/main.lisp index 5dd88f9c..0e56f924 100644 --- a/environment/stage4/main.lisp +++ b/environment/stage4/main.lisp @@ -7,7 +7,8 @@ (env-load "stage4/define-tree-filter.lisp") (env-load "stage4/destructive-arith.lisp") (env-load "stage4/intersect.lisp") -(env-load "stage4/tail-p.lisp") +(env-load "stage4/head.lisp") +(env-load "stage4/tail.lisp") (env-load "stage4/repeat-while-changes.lisp") (env-load "stage4/expander.lisp") (env-load "stage4/macrolet.lisp") @@ -26,7 +27,6 @@ (env-load "stage4/sort.lisp") (env-load "stage4/split.lisp" :cl) (env-load "stage4/split.tests.lisp") -(env-load "stage4/head-p.lisp") (env-load "stage4/trim.lisp") (env-load "stage4/trim.tests.lisp") (env-load "stage4/define-slot-setter.lisp") diff --git a/environment/stage4/tail-p.lisp b/environment/stage4/tail.lisp similarity index 62% rename from environment/stage4/tail-p.lisp rename to environment/stage4/tail.lisp index 00d6149e..ae2c6f1c 100644 --- a/environment/stage4/tail-p.lisp +++ b/environment/stage4/tail.lisp @@ -3,3 +3,8 @@ tlen (length tail)) (unless (< xlen tlen) (funcall test tail (subseq x (- xlen tlen)))))) + +(fn without-tail (x tail) + (? (tail? x tail) + (subseq x 0 (- (length x) (length tail))) + x)) From d2a6d911e2cda83d90477e5295bc1b72a4377172 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sun, 2 Apr 2017 21:40:53 +0200 Subject: [PATCH 04/11] Widened to column 78. --- NEWS | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 40440b0e..2b6c636f 100644 --- a/NEWS +++ b/NEWS @@ -3,27 +3,26 @@ Changes of tre-0.7 relative to tre-0.6: * PHP: Debugged property and associative array functions. * PHP: AREF returns NIL for undefined indexes instead of breaking with an error message. - * JS: Methods are also available as functions whose - identifier is ($ class-name "-" method-name). + * JS: Methods are also available as functions whose identifier is + ($ class-name "-" method-name). * WITHOUT-HEAD, WITHOUT-TAIL: New functions. Changes of tre-0.6 relative to tre-0.5: * PHP: PROPERTY-NAMES fixed for associative arrays. * PHP: ASSOC-ARRAY? test if first key is a string. - * Curly brackets {} denote MAKE-OBJECT if the first element - is a string or keyword. - * MAKE-OBJECT, NEW, {}: Also takes keywords whose symbol names - are converted to downcase as property names. - * JS/PHP: COPY-PROPERTIES, MERGE-PROPERTIES, UPDATE-PROPERTIES: - New functions. + * Curly brackets {} denote MAKE-OBJECT if the first element is a string or + keyword. + * MAKE-OBJECT, NEW, {}: Also takes keywords whose symbol names are converted + to downcase as property names. + * JS/PHP: COPY-PROPERTIES, MERGE-PROPERTIES, UPDATE-PROPERTIES: New + functions. Changes of tre-0.5 relative to tre-0.4: - * LOG-MESSAGE returns its argument if logging has been - switched off. + * LOG-MESSAGE returns its argument if logging has been switched off. * LML: Attribute names must be keywords. * PHP: NEW create a native object when used witout arguments. - * PHP: PROPERTY-NAME, PROPERTY-ALIST, ALIST-PROPERTIES, - MAKE-OBJECT: New core functions. + * PHP: PROPERTY-NAME, PROPERTY-ALIST, ALIST-PROPERTIES, MAKE-OBJECT: New + core functions. * PHP: ARRAY? returns T for indexed arrays only. * JS/PHP: ASSOC-ARRAY?: New predicate. * JS/PHP: JSON-ENCODE, JSON-DECODE added. @@ -37,8 +36,7 @@ Changes of tre-0.4 relative to tre-0.3: RELEASES: Changes of tre-0.3 relative to tre-0.2: - * JS: PROPERTY-NAME, PROPERTY-ALIST, ALIST-PROPERTIES: New - core functions. + * JS: PROPERTY-NAME, PROPERTY-ALIST, ALIST-PROPERTIES: New core functions. * JS: PROPERTY-REMOVE: New core codegen macro. * JS: NEW returns an empty object when used without arguments. From 30dae95c72f38284cdd5a9e4975f886aaa374202 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sun, 2 Apr 2017 21:42:24 +0200 Subject: [PATCH 05/11] Latter changes were for upcoming v0.8. --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2b6c636f..c26338ae 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Changes of tre-0.8 relative to tre-0.7: + * WITHOUT-HEAD, WITHOUT-TAIL: New functions. + Changes of tre-0.7 relative to tre-0.6: * (%NEW): Accidentally converted to (%NEW NIL) – fixed. * PHP: Debugged property and associative array functions. @@ -5,7 +8,6 @@ Changes of tre-0.7 relative to tre-0.6: error message. * JS: Methods are also available as functions whose identifier is ($ class-name "-" method-name). - * WITHOUT-HEAD, WITHOUT-TAIL: New functions. Changes of tre-0.6 relative to tre-0.5: * PHP: PROPERTY-NAMES fixed for associative arrays. From 972e58af0bc14af84134b568364865c95866e524 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Sun, 2 Apr 2017 21:43:16 +0200 Subject: [PATCH 06/11] Updated PHP-AREF also in v0.8. --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index c26338ae..f6587be8 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,11 @@ Changes of tre-0.8 relative to tre-0.7: * WITHOUT-HEAD, WITHOUT-TAIL: New functions. + * PHP: AREF returns NIL for undefined indexes instead of breaking with an + error message. Changes of tre-0.7 relative to tre-0.6: * (%NEW): Accidentally converted to (%NEW NIL) – fixed. * PHP: Debugged property and associative array functions. - * PHP: AREF returns NIL for undefined indexes instead of breaking with an - error message. * JS: Methods are also available as functions whose identifier is ($ class-name "-" method-name). From f5f3d1029b7d1851ebd8c946af9bab6f579d9900 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Tue, 18 Apr 2017 09:47:27 +0200 Subject: [PATCH 07/11] STRING?: Removed outdated test. --- environment/transpiler/targets/javascript/core/string.lisp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/environment/transpiler/targets/javascript/core/string.lisp b/environment/transpiler/targets/javascript/core/string.lisp index 580417c5..a8053b65 100644 --- a/environment/transpiler/targets/javascript/core/string.lisp +++ b/environment/transpiler/targets/javascript/core/string.lisp @@ -1,8 +1,7 @@ (js-type-predicate %string? "string") (fn string? (x) - (| (%string? x) - (instanceof x (%%native "String")))) + (%string? x)) (fn string-concat (&rest x) (alet (make-array) From 546f2a2b3dd0fd01fd20a570bbe4de929181ba47 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Tue, 18 Apr 2017 09:48:17 +0200 Subject: [PATCH 08/11] TODO added. --- environment/transpiler/targets/shared/macroexpand/class.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment/transpiler/targets/shared/macroexpand/class.lisp b/environment/transpiler/targets/shared/macroexpand/class.lisp index ae7579d2..5a8d6140 100644 --- a/environment/transpiler/targets/shared/macroexpand/class.lisp +++ b/environment/transpiler/targets/shared/macroexpand/class.lisp @@ -1,6 +1,6 @@ (defvar *delayed-constructors* nil) -(fn generic-defclass (constructor-maker class-name args &body body) +(fn generic-defclass (constructor-maker class-name args &body body) ; TODO: Check if base classes are defined. (with (cname (? (cons? class-name) class-name. class-name) From e0f8a6a613f8fc945af554aa1ac0fb1fdd4ea942 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Fri, 21 Apr 2017 15:46:48 +0200 Subject: [PATCH 09/11] Moved native PHP code, which removes magically added slashes from posted values, into its own file. --- environment/transpiler/targets/php/core.lisp | 3 ++- .../php/core/native/remove-magic-quotes.php | 16 ++++++++++++++++ .../transpiler/targets/php/toplevel.lisp | 19 +------------------ 3 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 environment/transpiler/targets/php/core/native/remove-magic-quotes.php diff --git a/environment/transpiler/targets/php/core.lisp b/environment/transpiler/targets/php/core.lisp index c906efdb..21651a2b 100644 --- a/environment/transpiler/targets/php/core.lisp +++ b/environment/transpiler/targets/php/core.lisp @@ -2,7 +2,8 @@ (defvar *php-core-native* ,(apply #'+ (@ [fetch-file (+ "environment/transpiler/targets/php/core/native/" _ ".php")] - '("settings" + '("remove-magic-quotes" + "settings" "error" "character" "cons" diff --git a/environment/transpiler/targets/php/core/native/remove-magic-quotes.php b/environment/transpiler/targets/php/core/native/remove-magic-quotes.php new file mode 100644 index 00000000..823972e1 --- /dev/null +++ b/environment/transpiler/targets/php/core/native/remove-magic-quotes.php @@ -0,0 +1,16 @@ +# From somewhere in the official PHP documentation comments. +if (get_magic_quotes_gpc ()) { + $vars = array (&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); + while (list ($key, $val) = each ($vars)) { + foreach ($val as $k => $v) { + unset ($vars[$key][$k]); + $sk = stripslashes ($k); + if (is_array ($v)) { + $vars[$key][$sk] = $v; + $vars[] = &$vars[$key][$sk]; + } else + $vars[$key][$sk] = stripslashes ($v); + } + } + unset ($vars); +} diff --git a/environment/transpiler/targets/php/toplevel.lisp b/environment/transpiler/targets/php/toplevel.lisp index 69f94cab..e5a622f6 100644 --- a/environment/transpiler/targets/php/toplevel.lisp +++ b/environment/transpiler/targets/php/toplevel.lisp @@ -1,22 +1,5 @@ (fn php-prologue () - (with-string-stream out - (format out " $v) {~%" - " unset ($vars[$key][$k]);~%" - " $sk = stripslashes ($k);~%" - " if (is_array ($v)) {~%" - " $vars[$key][$sk] = $v;~%" - " $vars[] = &$vars[$key][$sk];~%" - " } else~%" - " $vars[$key][$sk] = stripslashes ($v);~%" - " }~%" - " }~%" - " unset ($vars);~%" - "}~%")) - (php-print-native-core out))) + (format nil "~%")) From 465be5d07761add485488aafc04182702c352c3f Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Fri, 21 Apr 2017 15:55:58 +0200 Subject: [PATCH 10/11] Target 'clean': Remove compiled/. --- make.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/make.sh b/make.sh index f2a99bc3..56e2077f 100755 --- a/make.sh +++ b/make.sh @@ -15,9 +15,11 @@ BINDIR="/usr/local/bin/" basic_clean () { echo "Cleaning..." - rm -vf *.core compiled environment/transpiler/targets/c/native/$COMPILED_ENV image files.lisp + rm -rv compiled + rm -vf *.core environment/transpiler/targets/c/native/$COMPILED_ENV image files.lisp rm -vf environment/_current-version - rm -vrf _nodejstests.log _phptests.log + rm -vf environment/_release-date + rm -vf _nodejstests.log _phptests.log echo "Checking out last working core..." git checkout -- boot-common.lisp } From 941de00c8134420ace4a8b36e9291ec3d286b508 Mon Sep 17 00:00:00 2001 From: Sven Michael Klose Date: Fri, 21 Apr 2017 16:28:04 +0200 Subject: [PATCH 11/11] Fixed last commit. --- environment/transpiler/targets/php/toplevel.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment/transpiler/targets/php/toplevel.lisp b/environment/transpiler/targets/php/toplevel.lisp index e5a622f6..6d48ab79 100644 --- a/environment/transpiler/targets/php/toplevel.lisp +++ b/environment/transpiler/targets/php/toplevel.lisp @@ -1,5 +1,5 @@ (fn php-prologue () - (format nil "~%"))