;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2023 Ludovic Courtès ;;; Copyright © 2014, 2016 Mark H Weaver ;;; Copyright © 2015, 2017 Leo Famulari ;;; Copyright © 2016 Nikita ;;; Copyright © 2016 Efraim Flashner ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; Copyright © 2017, 2019, 2020, 2021 Marius Bakke ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice ;;; Copyright © 2020 Michael Rohleder ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages ncurses) #:use-module (gnu packages) #:use-module (guix licenses) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix build-system gnu) #:use-module (guix build-system perl) #:use-module (gnu packages) #:use-module (gnu packages perl) #:use-module (gnu packages pkg-config) #:use-module (gnu packages swig) #:use-module (gnu packages linux) #:use-module (guix utils) #:use-module ((guix memoization) #:select (mlambda)) #:use-module (ice-9 match)) (define ncurses-rollup-patch (mlambda (version) (origin (method url-fetch) (uri (match (string-split (version-major+minor+point version) #\.) ((major minor point) (string-append "https://invisible-mirror.net/archives" "/ncurses/" major "." minor "/ncurses-" major "." minor "-" point "-patch.sh.bz2")))) (sha256 (base32 "1b6522cvi4066bgh9lp93q8lk93zcjjssvnw1512z447xvazy2y6"))))) (define-public ncurses (package (name "ncurses") (version "6.2.20210619") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/ncurses/ncurses-" (version-major+minor version) ".tar.gz")) (sha256 (base32 "17bcm2z1rdx5gmzj5fb8cp7f28aw5b4g2z4qvvqg3yg0fq66wc1h")))) (build-system gnu-build-system) (outputs '("out" "doc")) ;1 MiB of man pages (arguments (let ((patch-makefile-phase #~(lambda _ (for-each patch-makefile-SHELL (find-files "." "Makefile.in")))) (configure-phase ;; The 'configure' script does not understand '--docdir', so we must ;; override that and use '--mandir' instead. #~(lambda* (#:key build target outputs configure-flags #:allow-other-keys) (let ((out (assoc-ref outputs "out")) (doc (assoc-ref outputs "doc"))) (apply invoke "./configure" (string-append "SHELL=" (which "sh")) (string-append "--build=" build) (string-append "--prefix=" out) (string-append "--mandir=" doc "/share/man") (if target (cons (string-append "--host=" target) configure-flags) configure-flags))))) (apply-rollup-patch-phase ;; Ncurses distributes "stable" patchsets to be applied on top ;; of the release tarball. These are only available as shell ;; scripts(!) so we decompress and apply them in a phase. ;; See . #~(lambda* (#:key inputs native-inputs #:allow-other-keys) (let ((rollup-patch #$(ncurses-rollup-patch (package-version this-package)))) (copy-file rollup-patch (string-append (getcwd) "/rollup-patch.sh.bz2")) (invoke "bzip2" "-d" "rollup-patch.sh.bz2") (invoke "sh" "rollup-patch.sh")))) (remove-shebang-phase #~(lambda _ ;; To avoid retaining a reference to the bootstrap Bash via the ;; shebang of the 'ncursesw6-config' script, simply remove that ;; shebang: it'll work just as well without it. Likewise, do not ;; retain a reference to the "doc" output. (substitute* "misc/ncurses-config.in" (("#!@SHELL@") "# No shebang here, use /bin/sh!\n") (("@SHELL@ \\$0") "$0") (("mandir=.*$") "mandir=share/man")))) (post-install-phase #~(lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) ;; When building a wide-character (Unicode) build, create backward ;; compatibility links from the the "normal" libraries to the ;; wide-character ones (e.g. libncurses.so to libncursesw.so). #$@(if (target-mingw?) '( ;; TODO: create .la files to -rw-r--r--lib/compress.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js
index cf138377..005768b7 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4638,7 +4638,7 @@ merge(Compressor.prototype, {
if (self.name && self.name.definition() === fn.definition()) break;
fn = fn.fixed_value();
}
- if (!(fn instanceof AST_Lambda)) break;
+ if (!(fn instanceof AST_Defun || fn instanceof AST_Function)) break;
if (fn.uses_arguments) break;
if (fn === call.expression) {
if (fn.parent_scope !== self) break;
@@ -7776,7 +7776,9 @@ merge(Compressor.prototype, {
var_assigned = true;
if (stat) return false;
}
- } else if (line instanceof AST_Defun || line instanceof AST_EmptyStatement) {
+ } else if (line instanceof AST_AsyncDefun
+ || line instanceof AST_Defun
+ || line instanceof AST_EmptyStatement) {
continue;
} else if (stat) {
return false;
@@ -7803,6 +7805,7 @@ merge(Compressor.prototype, {
var begin;
var in_order = [];
var side_effects = false;
+ var verify_await = true;
value.walk(new TreeWalker(function(node, descend) {
if (abort) return true;
if (node instanceof AST_Binary && lazy_op[node.operator]
@@ -7811,13 +7814,18 @@ merge(Compressor.prototype, {
return;
}
if (node instanceof AST_Scope) return abort = true;
+ if (verify_await && node instanceof AST_Symbol && node.name == "await") {
+ var scope = compressor.find_parent(AST_Scope);
+ if (scope instanceof AST_AsyncDefun || scope instanceof AST_AsyncFunction) return abort = true;
+ verify_await = false;
+ }
if (node instanceof AST_SymbolRef) {
var def = node.definition();
if (fn.variables.get(node.name) !== def) {
in_order = null;
return;
}
- if (def.init instanceof AST_Defun) return abort = true;
+ if (def.init instanceof AST_AsyncDefun || def.init instanceof AST_Defun) return abort = true;
if (is_lhs(node, this.parent())) return abort = true;
var index = resolve_index(def);
if (!(begin < index)) begin = index;
@@ -7868,7 +7876,7 @@ merge(Compressor.prototype, {
function can_inject_vars(defined, used, safe_to_inject) {
for (var i = 0; i < fn.body.length; i++) {
var stat = fn.body[i];
- if (stat instanceof AST_Defun) {
+ if (stat instanceof AST_AsyncDefun || stat instanceof AST_Defun) {
if (!safe_to_inject || var_exists(used, stat.name.name)) return false;
if (!all(stat.enclosed, function(def) {
return def.scope === stat || !defined[def.name];
@@ -7890,7 +7898,7 @@ merge(Compressor.prototype, {
var defined = Object.create(null);
var level = 0, child;
scope = compressor.self();
- while (!(scope instanceof AST_Scope)) {
+ do {
if (scope.variables) scope.variables.each(function(def) {
defined[def.name] = true;
});
@@ -7908,11 +7916,25 @@ merge(Compressor.prototype, {
} else if (scope instanceof AST_SymbolRef) {
if (scope.fixed_value() instanceof AST_Scope) return false;
}
- }
+ } while (!(scope instanceof AST_Scope));
insert = scope.body.indexOf(child) + 1;
if (!insert) return false;
+ if (scope instanceof AST_AsyncDefun || scope instanceof AST_AsyncFunction) {
+ var found = false;
+ fn.walk(new TreeWalker(function(node) {
+ if (found) return true;
+ if (node instanceof AST_Scope && node !== fn) {
+ if (node instanceof AST_AsyncDefun || node instanceof AST_Defun) {
+ if (node.name.name == "await") found = true;
+ }
+ return true;
+ }
+ if (node instanceof AST_Symbol && node.name == "await" && node !== fn.name) return found = true;
+ }));
+ if (found) return false;
+ }
var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars)
- && (exp !== fn || fn.parent_scope.resolve() === compressor.find_parent(AST_Scope));
+ && (exp !== fn || fn.parent_scope.resolve() === scope);
var inline = compressor.option("inline");
var used = Object.create(defined);
if (!can_inject_args(defined, used, inline >= 2 && safe_to_inject)) return false;
@@ -8004,7 +8026,7 @@ merge(Compressor.prototype, {
flatten_vars(decls, expressions);
expressions.push(value);
var args = fn.body.filter(function(stat) {
- if (stat instanceof AST_Defun) {
+ if (stat instanceof AST_AsyncDefun || stat instanceof AST_Defun) {
var def = stat.name.definition();
scope.functions.set(def.name, def);
scope.variables.set(def.name, def);
is the interface between Perl and the curses library of your system.") (license perl-license))) (define-public stfl (package (name "stfl") (version "0.24") (source (origin (method url-fetch) (uri (string-append "http://www.clifford.at/stfl/stfl-" version ".tar.gz")) (sha256 (base32 "1460d5lc780p3q38l3wc9jfr2a7zlyrcra0li65aynj738cam9yl")))) (build-system gnu-build-system) (arguments '(#:tests? #f ; no test target #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out"))) #:phases (modify-phases %standard-phases (delete 'configure) ; there is no configure script ;; in our ncurses, the headers are in /include (add-before 'build 'patch-ncursesw (lambda _ (substitute* "stfl_internals.h" (("ncursesw/") "")) #t)) (add-after 'install 'install-missing-symlink (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (lib (string-append out "/lib"))) ;; Some programs look for libstfl.so.0. (symlink "libstfl.so" (string-append lib "/libstfl.so.0")))))))) (inputs (list ncurses)) (native-inputs (list swig)) (home-page "https://www.clifford.at/stfl/") (synopsis "Structured terminal forms library") (description "Stfl is a library which implements a curses-based widget set for text terminals.") (license lgpl3+)))