impc:ir:compiler:tuple-set   scheme

Defined in:


;; indexing into structures is limited to i32 indexes!!
(define impc:ir:compiler:tuple-set
  (lambda (ast types)
    ;; (println 'ast ast 'type types)
    ;; arg 1 for tuples must be a symbol
    ;; arg 2 for tuples must be a number
    ;; this should make it easy for us!
    (let* ((os (make-string 0))
           (var-str (impc:ir:compiler (cadr ast) types))
           (var (impc:ir:gname))
           ;;(tuple-type (impc:ir:get-type-from-str (cadr var)))
           (tuple-type (or (impc:ti:get-namedtype-type (cadr var))
                           (impc:ir:get-type-from-str (cadr var))))
           (element-type (list-ref (cdr tuple-type) (caddr ast)))
           (index-str (impc:ir:compiler (caddr ast) types))
           (idx (impc:ir:gname))
           (val-str (impc:ir:compiler (cadddr ast) types element-type))
           (val (impc:ir:gname)))
      ;;(println 'var: var 'idx: idx 'val: val 'elementtype: element-type)
      ;; type tests
      (if (not (impc:ir:tuple? (impc:ir:get-type-from-str (cadr var))))
          (impc:compiler:print-bad-type-error-with-ast (cadr var) "tuple must be a pointer" ast))
      (if (not (impc:ir:fixed-point? (impc:ir:get-type-from-str (cadr idx))))
          (impc:compiler:print-bad-type-error-with-ast (cadr idx) "index must be an integer" ast))

Back to Index

Similar Entries