Ticket #584: define-external-no-optimization.patch

File define-external-no-optimization.patch, 1.6 KB (added by sjamaan, 13 years ago)

Insert module-qualified names into callback-names db

  • compiler.scm

    diff --git a/compiler.scm b/compiler.scm
    index a3fa620..629881f 100644
    a b  
    11401140                        ((##core#foreign-callback-wrapper)
    11411141                         (let-values ([(args lam) (split-at (cdr x) 4)])
    11421142                           (let* ([lam (car lam)]
    1143                                   [name (cadr (first args))]
     1143                                  [raw-c-name (cadr (first args))]
     1144                                  [name (##sys#alias-global-hook raw-c-name #t dest)]
    11441145                                  [rtype (cadr (third args))]
    11451146                                  [atypes (cadr (fourth args))]
    11461147                                  [vars (second lam)] )
    1147                              (if (valid-c-identifier? name)
     1148                             (if (valid-c-identifier? raw-c-name)
    11481149                                 (set! callback-names (cons name callback-names))
    11491150                                 (quit "name `~S' of external definition is not a valid C identifier"
    1150                                        name) )
     1151                                       raw-c-name) )
    11511152                             (when (or (not (proper-list? vars))
    11521153                                       (not (proper-list? atypes))
    11531154                                       (not (= (length vars) (length atypes))) )
  • tests/compiler-tests.scm

    diff --git a/tests/compiler-tests.scm b/tests/compiler-tests.scm
    index f4feb01..78bcb0e 100644
    a b  
    137137((foreign-safe-lambda* void ()
    138138   "print_foo(\"bar\");"))
    139139
     140;; Unused arguments in foreign callback wrappers are not optimized away
     141(module bla (foo)
     142
     143(import chicken scheme foreign)
     144
     145(define-external
     146  (blabla (int a) (c-string b) (int c) (int d) (c-string e) (int f))
     147  int
     148  f)
     149
     150(define (foo) ((foreign-safe-lambda* int () "C_return(blabla(1, \"2\", 3, 4, \"5\", 6));")))
     151)
     152
     153(import bla)
     154(assert (= (foo) 6))
    140155
    141156;;; compiler-syntax for map/for-each must be careful when the
    142157;   operator may have side-effects (currently only lambda exprs and symbols