Skip to content

Commit de93e51

Browse files
committed
clean up array type property
1 parent efea2f7 commit de93e51

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

src/array.lisp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131

3232
(defun upgraded-array-element-type (typespec &optional environment)
3333
(declare (ignore environment))
34-
(if (eq typespec 'character)
35-
'character
36-
t))
34+
(case typespec
35+
(character 'character)
36+
((nil) (error "NIL array element type unimplemented"))
37+
(t t)))
3738

3839
(defun %array-to-lists (array)
3940
(let ((index 0))
@@ -65,7 +66,7 @@ in which case ARRAY might be partially filled from CONTENTS."
6566
(process (array-dimensions array) contents)
6667
array)))
6768

68-
(defun make-array (dimensions &key element-type
69+
(defun make-array (dimensions &key (element-type t)
6970
(initial-element nil initial-element-p)
7071
(initial-contents nil initial-contents-p)
7172
adjustable
@@ -80,21 +81,20 @@ in which case ARRAY might be partially filled from CONTENTS."
8081
(error "make-array - invalid FILL-POINTER ~a." fill-pointer)))
8182
(t (error "make-array - bad FILL-POINTER ~s type ~a." fill-pointer (type-of fill-pointer))))
8283
;; Upgrade type
83-
(if (eq element-type 'character)
84-
(progn
85-
(oset 1 array "stringp")
86-
(setf element-type 'character
87-
initial-element (or initial-element #\space)))
88-
(setf element-type t))
84+
(setq element-type (upgraded-array-element-type element-type))
85+
(case element-type
86+
(character
87+
(oset 1 array "stringp")
88+
(unless initial-element-p
89+
(setq initial-element #\space))))
8990
(when (and (listp dimensions)
9091
(not (null (cdr dimensions)))
9192
fill-pointer)
9293
(error "make-array - FILL-POINTER cannot be specified on multidimensional arrays."))
9394
;; Record metadata
9495
(when (or (null dimensions) (cdr dimensions))
9596
(setf (oget array "dimensions") dimensions))
96-
(setf (oget array "type") element-type
97-
(oget array "fillpointer") fill-pointer)
97+
(setf (oget array "fillpointer") fill-pointer)
9898
;; Initialize array
9999
(when (and initial-element-p initial-contents-p)
100100
(error "make-array - INITIAL-ELEMENT and INITIAL-CONTENTS cannot both be provided"))
@@ -114,9 +114,8 @@ in which case ARRAY might be partially filled from CONTENTS."
114114
(defun array-element-type (array)
115115
(unless (arrayp array)
116116
(error "~S is not an array." array))
117-
(if (eq (oget array "stringp") 1)
118-
'character
119-
(oget array "type")))
117+
(cond ((eq (oget array "stringp") 1) 'character)
118+
(t t)))
120119

121120
(defun array-dimensions (array)
122121
(unless (arrayp array)

src/compiler/compiler.lisp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,6 @@
586586
(var (gvarname 'array)))
587587
`(selfcall
588588
(var (,var ,(list-to-vector (mapcar #'literal elements))))
589-
(= (get ,var "type")
590-
(call-internal |lisp_to_js| ,(literal (array-element-type array))))
591589
,(unless (vectorp array)
592590
`(= (get ,var "dimensions")
593591
(call-internal |lisp_to_js| ,(literal (array-dimensions array)))))
@@ -1385,7 +1383,6 @@
13851383
`(selfcall
13861384
(var (sv1 ,sv1))
13871385
(var (r (method-call sv1 "concat" ,sv2)))
1388-
(= (get r "type") (get sv1 "type"))
13891386
(= (get r "stringp") (get sv1 "stringp"))
13901387
(return r)))
13911388

0 commit comments

Comments
 (0)