From 720bff3437e31a456086bee8f3ea3de44870ac47 Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Sun, 20 Sep 2026 15:40:29 +0300 Subject: [PATCH] semen: add and use fn core prototype getter --- semen.scm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/semen.scm b/semen.scm index 21fc965..71ddb1e 100644 --- a/semen.scm +++ b/semen.scm @@ -147,6 +147,12 @@ (define (fn-header-length fn-form) (if (memq (first fn-form) '(pub extern)) 5 4)) +(define (fn-core form) + ;; The (fn name args rettype . body) list, without pub/extern + (if (memq (first form) '(pub extern)) + (cdr form) + form)) + (define (strip-fn-header-comments fn-form) ;; Remove comment forms from the function header ;; ([pub|extern] fn name arglist rettype) so the positional accessors @@ -241,28 +247,22 @@ Returns #f if the form is not a function, returns the form otherwise" (else #f))) (define (sex-fn-public? fn-form) - (eq? (car fn-form) 'pub)) - -(define (sex-fn-return-type fn-form) - (assert (sex-fn? fn-form) - (fmt #f "Form " fn-form " is not a function")) - (if (sex-fn-public? fn-form) - (third fn-form) - (second fn-form))) + (eq? (first fn-form) 'pub)) (define (sex-fn-name fn-form) (assert (sex-fn? fn-form) (fmt #f "Form " fn-form " is not a function")) - (if (sex-fn-public? fn-form) - (fourth fn-form) - (third fn-form))) + (second (fn-core fn-form))) (define (sex-fn-arglist fn-form) (assert (sex-fn? fn-form) (fmt #f "Form " fn-form " is not a function")) - (if (sex-fn-public? fn-form) - (fifth fn-form) - (fourth fn-form))) + (third (fn-core fn-form))) + +(define (sex-fn-return-type fn-form) + (assert (sex-fn? fn-form) + (fmt #f "Form " fn-form " is not a function")) + (fourth (fn-core fn-form))) (define (sex-fn-prototype fn-form) "Returns all except body"