mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-30 06:50:31 +02:00
resolve-primitives tweaks
* module/ice-9/boot-9.scm (make-struct/no-tail): Define a version of this function. Because during optimization we resolve make-struct to make-struct/no-tail, we need an implemented make-struct/no-tail if we are to be able to run scheme made from tree-il->scheme. * module/language/tree-il/compile-glil.scm (*primcall-ops*): Remove variable-set case, as there is no "variable-set!" primitive. (flatten): Add a special hack for variable-set!. Ugly, I know. * module/language/tree-il/primitives.scm (*effect-free-primitives*): Add make-struct/no-tail. (*effect+exception-free-primitives*): Remove make-struct, as it could raise an exception. (variable-set!): Remove expansion to variable-set.
This commit is contained in:
parent
0f2b9f6252
commit
9b3cc65965
3 changed files with 22 additions and 8 deletions
|
@ -254,6 +254,14 @@ If there is no handler at all, Guile prints an error and then exits."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;; {Structs}
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define (make-struct/no-tail vtable . args)
|
||||||
|
(apply make-struct vtable 0 args))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; {and-map and or-map}
|
;;; {and-map and or-map}
|
||||||
;;;
|
;;;
|
||||||
;;; (and-map fn lst) is like (and (fn (car lst)) (fn (cadr lst)) (fn...) ...)
|
;;; (and-map fn lst) is like (and (fn (car lst)) (fn (cadr lst)) (fn...) ...)
|
||||||
|
|
|
@ -114,7 +114,6 @@
|
||||||
((vector-set! . 3) . vector-set)
|
((vector-set! . 3) . vector-set)
|
||||||
((variable-ref . 1) . variable-ref)
|
((variable-ref . 1) . variable-ref)
|
||||||
;; nb, *not* variable-set! -- the args are switched
|
;; nb, *not* variable-set! -- the args are switched
|
||||||
((variable-set . 2) . variable-set)
|
|
||||||
((variable-bound? . 1) . variable-bound?)
|
((variable-bound? . 1) . variable-bound?)
|
||||||
((struct? . 1) . struct?)
|
((struct? . 1) . struct?)
|
||||||
((struct-vtable . 1) . struct-vtable)
|
((struct-vtable . 1) . struct-vtable)
|
||||||
|
@ -385,6 +384,18 @@
|
||||||
args))
|
args))
|
||||||
(maybe-emit-return))))
|
(maybe-emit-return))))
|
||||||
|
|
||||||
|
;; A hack for variable-set, the opcode for which takes its args
|
||||||
|
;; reversed, relative to the variable-set! function
|
||||||
|
((and (primitive-ref? proc)
|
||||||
|
(eq? (primitive-ref-name proc) 'variable-set!)
|
||||||
|
(= (length args) 2))
|
||||||
|
(comp-push (cadr args))
|
||||||
|
(comp-push (car args))
|
||||||
|
(emit-code src (make-glil-call 'variable-set 2))
|
||||||
|
(case context
|
||||||
|
((tail push vals) (emit-code #f (make-glil-void))))
|
||||||
|
(maybe-emit-return))
|
||||||
|
|
||||||
((and (primitive-ref? proc)
|
((and (primitive-ref? proc)
|
||||||
(or (hash-ref *primcall-ops*
|
(or (hash-ref *primcall-ops*
|
||||||
(cons (primitive-ref-name proc) (length args)))
|
(cons (primitive-ref-name proc) (length args)))
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
vector-ref vector-set!
|
vector-ref vector-set!
|
||||||
variable-ref variable-set!
|
variable-ref variable-set!
|
||||||
variable-bound?
|
variable-bound?
|
||||||
;; args of variable-set are switched; it needs special help
|
|
||||||
|
|
||||||
fluid-ref fluid-set!
|
fluid-ref fluid-set!
|
||||||
|
|
||||||
|
@ -121,7 +120,7 @@
|
||||||
caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
|
caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
|
||||||
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
|
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
|
||||||
vector-ref
|
vector-ref
|
||||||
struct? struct-vtable make-struct struct-ref
|
struct? struct-vtable make-struct make-struct/no-tail struct-ref
|
||||||
bytevector-u8-ref bytevector-s8-ref
|
bytevector-u8-ref bytevector-s8-ref
|
||||||
bytevector-u16-ref bytevector-u16-native-ref
|
bytevector-u16-ref bytevector-u16-native-ref
|
||||||
bytevector-s16-ref bytevector-s16-native-ref
|
bytevector-s16-ref bytevector-s16-native-ref
|
||||||
|
@ -140,7 +139,7 @@
|
||||||
not
|
not
|
||||||
pair? null? list? acons cons cons*
|
pair? null? list? acons cons cons*
|
||||||
list vector
|
list vector
|
||||||
struct? make-struct))
|
struct?))
|
||||||
|
|
||||||
(define *effect-free-primitive-table* (make-hash-table))
|
(define *effect-free-primitive-table* (make-hash-table))
|
||||||
(define *effect+exceptions-free-primitive-table* (make-hash-table))
|
(define *effect+exceptions-free-primitive-table* (make-hash-table))
|
||||||
|
@ -334,10 +333,6 @@
|
||||||
|
|
||||||
(define-primitive-expander values (x) x)
|
(define-primitive-expander values (x) x)
|
||||||
|
|
||||||
;; swap args
|
|
||||||
(define-primitive-expander variable-set! (var val)
|
|
||||||
(variable-set val var))
|
|
||||||
|
|
||||||
(define-primitive-expander make-struct (vtable tail-size . args)
|
(define-primitive-expander make-struct (vtable tail-size . args)
|
||||||
(if (and (const? tail-size)
|
(if (and (const? tail-size)
|
||||||
(let ((n (const-exp tail-size)))
|
(let ((n (const-exp tail-size)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue