Cut cons over to new expr-safe code

Want to ensure cons can be used safely as part of a Cyc-seq. This cannot happen if the cons used the previous make_pair macro as that can only be called at the top of a function as part of a declaration.
This commit is contained in:
Justin Ethier 2018-12-03 13:17:17 -05:00
parent f9d03342f2
commit 01a73839ac

View file

@ -463,7 +463,7 @@
use-alloca? use-alloca?
(member (member
p p
'(cons '(;cons
Cyc-fast-list-1 Cyc-fast-list-1
Cyc-fast-list-2 Cyc-fast-list-2
Cyc-fast-list-3 Cyc-fast-list-3
@ -481,7 +481,7 @@
;; created via alloca or such, and cannot be declared as stack vars. ;; created via alloca or such, and cannot be declared as stack vars.
;; This is to support C loops in place of recursion. ;; This is to support C loops in place of recursion.
(cond (cond
((eq? p 'cons) "alloca_pair") ;((eq? p 'cons) "alloca_pair")
((eq? p 'Cyc-fast-list-1) "alloca_list_1") ((eq? p 'Cyc-fast-list-1) "alloca_list_1")
((eq? p 'Cyc-fast-list-2) "alloca_list_2") ((eq? p 'Cyc-fast-list-2) "alloca_list_2")
((eq? p 'Cyc-fast-list-3) "alloca_list_3") ((eq? p 'Cyc-fast-list-3) "alloca_list_3")
@ -640,8 +640,8 @@
((eq? p 'string?) "Cyc_is_string") ((eq? p 'string?) "Cyc_is_string")
((eq? p 'eof-object?) "Cyc_is_eof_object") ((eq? p 'eof-object?) "Cyc_is_eof_object")
((eq? p 'symbol?) "Cyc_is_symbol") ((eq? p 'symbol?) "Cyc_is_symbol")
((eq? p 'cons) "make_pair") ;((eq? p 'cons) "make_pair")
;((eq? p 'cons) "set_pair_as_expr") ((eq? p 'cons) "set_pair_as_expr")
((eq? p 'Cyc-fast-list-1) "make_list_1") ((eq? p 'Cyc-fast-list-1) "make_list_1")
((eq? p 'Cyc-fast-list-2) "make_list_2") ((eq? p 'Cyc-fast-list-2) "make_list_2")
((eq? p 'Cyc-fast-list-3) "make_list_3") ((eq? p 'Cyc-fast-list-3) "make_list_3")
@ -753,7 +753,7 @@
;; Determine if primitive receives a pointer to a local C variable ;; Determine if primitive receives a pointer to a local C variable
(define (prim/c-var-pointer p) (define (prim/c-var-pointer p)
(cond (cond
;((eq? p 'cons) "pair_type") ((eq? p 'cons) "pair_type")
((eq? p 'Cyc-fast-plus) "complex_num_type") ((eq? p 'Cyc-fast-plus) "complex_num_type")
((eq? p 'Cyc-fast-sub) "complex_num_type") ((eq? p 'Cyc-fast-sub) "complex_num_type")
((eq? p 'Cyc-fast-mul) "complex_num_type") ((eq? p 'Cyc-fast-mul) "complex_num_type")
@ -871,7 +871,7 @@
Cyc-fast-list-2 Cyc-fast-list-2
Cyc-fast-list-3 Cyc-fast-list-3
Cyc-fast-list-4 Cyc-fast-list-4
cons ;cons
cell)) cell))
(member exp *udf-prims*)))) (member exp *udf-prims*))))
@ -923,7 +923,10 @@
(define (prim:allocates-object? exp use-alloca?) (define (prim:allocates-object? exp use-alloca?)
(and (prim? exp) (and (prim? exp)
use-alloca? use-alloca?
(member exp '(cons)))) (member exp
'(
;cons
))))
;; Does the primitive only accept/return immutable objects? ;; Does the primitive only accept/return immutable objects?
;; This is useful during optimization ;; This is useful during optimization