;; -*-theme-d-*-

;; Copyright (C) 2017 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK


(define-proper-program (tests test488)

  (import (standard-library core-forms))

  (define _console-display
    (unchecked-prim-proc
     theme-prim-console-display (<object>) <none> nonpure))

  (define console-display-string
    (lambda (((str <string>)) <none> nonpure)
      (_console-display str)))

  (define console-newline
    (unchecked-prim-proc theme-console-newline () <none> nonpure))

  (define integer->string
    (prim-proc number->string (<integer>) <string> pure))

  (define-param-proc-alt vector-ref (%type)
    (unchecked-prim-proc _i_vector-ref
			 ((:vector %type) <integer>) %type pure))

  (define-param-proc-alt mutable-vector-ref (%type)
    (unchecked-prim-proc _i_mutable-vector-ref
			 ((:mutable-vector %type) <integer>)
			 %type pure))

  (define-param-proc-alt mutable-vector-set! (%type)
    (unchecked-prim-proc _i_mutable-vector-set!
			 ((:mutable-vector %type)
			  <integer> %type) <none> nonpure))

  (define-param-proc-alt value-vector-ref (%type)
    (unchecked-prim-proc _i_value-vector-ref
			 ((:value-vector %type) <integer>) %type pure))
  
  (define-param-proc-alt mutable-value-vector-ref (%type)
    (unchecked-prim-proc _i_mutable-value-vector-ref
			 ((:mutable-value-vector %type) <integer>)
			 %type pure))

  (define-simple-proc main (() <none> nonpure)
    (let ((v1 (:vector <integer>)
	      (make-vector <integer> 5 1))
	  (v2 (:mutable-vector <integer>)
	      (make-mutable-vector <integer> 10 2))
	  (v3 (:value-vector <integer>)
	      (make-value-vector <integer> 10 3))
	  (v4 (:mutable-value-vector <integer>)
	      (make-mutable-value-vector <integer> 10 4)))
      (console-display-string
       (integer->string (vector-ref v1 0)))
      (console-newline)
      (console-display-string
       (integer->string (mutable-vector-ref v2 0)))
      (console-newline)
      (console-display-string
       (integer->string (value-vector-ref v3 0)))
      (console-newline)
      (console-display-string
       (integer->string (mutable-value-vector-ref v4 0)))
      (console-newline))))
