From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Lynch Newsgroups: gmane.lisp.guile.devel Subject: [PATCH 3/4] Implement ecmascript function prototype. Date: Wed, 28 Oct 2020 00:03:33 -0400 Message-ID: <20201028040330.22051-4-sean@seanplynch.com> References: <20201028040330.22051-1-sean@seanplynch.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5698"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Sean Lynch To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Oct 28 15:28:01 2020 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXmQj-0001Lj-JZ for guile-devel@m.gmane-mx.org; Wed, 28 Oct 2020 15:28:01 +0100 Original-Received: from localhost ([::1]:54102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXmQi-0003DL-JZ for guile-devel@m.gmane-mx.org; Wed, 28 Oct 2020 10:28:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXci2-0006NS-3R for guile-devel@gnu.org; Wed, 28 Oct 2020 00:05:14 -0400 Original-Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:46721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXci0-0002JG-NK for guile-devel@gnu.org; Wed, 28 Oct 2020 00:05:13 -0400 Original-Received: by mail-qt1-x835.google.com with SMTP id r8so2701719qtp.13 for ; Tue, 27 Oct 2020 21:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seanplynch-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ly8NLJFFEkiPDmp53G8iFqyFR2gcPkHAQhY5tuUPBMA=; b=nGIMXdJEVamxcgqJPftgjDxSgBhKZfBtx3trVvS8OBLOgpHEJDEAyo9AeCxC+Q2ddG r8UE0PWcabSEKAC67HEXHer08z04OJkb0lXfZA7P9KZUYA08GoEre11uFOANT3z2exqI 4/T6SmEF5nHOq490KYa7jGYlYSQqug27Joa/FL/0ixoTlHJ34ZC/AB4YDDJ8+KVOqAdZ rBKei4E+OEX6equckDy7ujfRTTNs0uLkwxhBE2/srR2qYe/1pvOIFmhjHzHKQj9GI/D6 aVa/LLU28ZOYOa7cjwyKRlEP7qWiu9VfmijrIq83zkO60uiZXkyLEZF6jHp1X0GsFArt M+Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ly8NLJFFEkiPDmp53G8iFqyFR2gcPkHAQhY5tuUPBMA=; b=KOihcS6XJub9Wfz3WG4FoeCOQPP0UVDcyNtgs6T/a+n5yCT4LbWOhemkrDM7vx2TKN vLbq/uwtPmDWCqcS7nZC3AibCbUTIwIBwgAQwlJHKe8YNYnp02mFpWbVV0dmhU0h4S15 IrpZm/F+7PFMwiPfd+O7s7zQLg9yprNKrkZkQzeV7Lp9ANW0/yKbY/h5gMt+lWbqRFrt fY9bQAu5AF8eaid+A3qtN5krLBCIMip6CUOtj+dVuQaP43lN93+C/iZIMz0kACwXBD5/ 0jfnmJuSB9iGOD45qClwC7iU4qUZ5POPricHWyJbfl1OnDDkIL9NQPpjzbDe493aBt9T Rq8Q== X-Gm-Message-State: AOAM531Km4a5IRntb8bvPQ0B4IyKxxJkqBcQ3IMiasQIdjWgeG0AjzW1 XZrPQctRIa+hP4gY2vfzg4abOGOPZpKPVKTl X-Google-Smtp-Source: ABdhPJyK+bqiUbefX3TBlCafwpg9Hjsv8S/i5vzSaJd+vG0uVTWqMDyR+YIrpylLbQ26BE/szXCmEw== X-Received: by 2002:ac8:6f6f:: with SMTP id u15mr5432816qtv.115.1603857911594; Tue, 27 Oct 2020 21:05:11 -0700 (PDT) Original-Received: from guix.stny.rr.com (cpe-74-69-187-15.stny.res.rr.com. [74.69.187.15]) by smtp.googlemail.com with ESMTPSA id 67sm2318916qkd.14.2020.10.27.21.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 21:05:10 -0700 (PDT) X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201028040330.22051-1-sean@seanplynch.com> Received-SPF: neutral client-ip=2607:f8b0:4864:20::835; envelope-from=sean@seanplynch.com; helo=mail-qt1-x835.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 28 Oct 2020 10:27:17 -0400 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20604 Archived-At: Per section 19.2.4.3 of the 2020 ECMAScript specification, functions that can be used as a constructor must have a fresh prototype. * module/language/ecmascript/compile-tree-il.scm: Use make-js-function procedure when creating an ecmascript function. This provides the function with a fresh prototype. * module/language/ecmascript/function.scm: Adds a make-js-function procedure that given a procedure provides a program-wrapper with a fresh prototype object, and optionally a name property. --- module/language/ecmascript/compile-tree-il.scm | 12 +++++++----- module/language/ecmascript/function.scm | 7 ++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/module/language/ecmascript/compile-tree-il.scm b/module/language/ecmascript/compile-tree-il.scm index 6f6af5210..48dca3166 100644 --- a/module/language/ecmascript/compile-tree-il.scm +++ b/module/language/ecmascript/compile-tree-il.scm @@ -19,6 +19,7 @@ ;;; Code: (define-module (language ecmascript compile-tree-il) + #:use-module (language ecmascript function) #:use-module (language tree-il) #:use-module (ice-9 receive) #:use-module (system base pmatch) @@ -349,12 +350,13 @@ (let ((syms (map (lambda (x) (gensym (string-append (symbol->string x) " "))) formals))) - `(lambda () - (lambda-case - ((() ,formals #f #f ,(map (lambda (x) (@implv *undefined*)) formals) ,syms) - ,(with-return-prompt + `(call (@ (language ecmascript function) make-js-function) (lambda () - (comp-body e body formals syms)))))))) + (lambda-case + ((() ,formals #f #f ,(map (lambda (x) (@implv *undefined*)) formals) ,syms) + ,(with-return-prompt + (lambda () + (comp-body e body formals syms))))))))) ((try (block . ,body) (catch ,err (block . ,catch)) ,finally) diff --git a/module/language/ecmascript/function.scm b/module/language/ecmascript/function.scm index 72edc4e61..fd0b980b6 100644 --- a/module/language/ecmascript/function.scm +++ b/module/language/ecmascript/function.scm @@ -21,8 +21,13 @@ (define-module (language ecmascript function) #:use-module (oop goops) #:use-module (language ecmascript base) - #:export (*function-prototype* *program-wrappers*)) + #:export (*function-prototype* *program-wrappers* + make-js-function)) +(define* (make-js-function proc #:optional name) + (pput proc 'prototype (make )) + (pput proc 'name (or name "")) + proc) (define-class ()) -- 2.29.1