;; -*-theme-d-*-

;; Copyright (C) 2015 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 test524)


  (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
    (prim-proc theme-console-newline () <none> nonpure))

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

  (define-class <a> <object> #t #f #f public ()
    ((field1 <integer> public module 0)))

  (define-generic-proc push)
  (define-generic-proc pop)

  (define-simple-method push
    (((store <a>) (item <integer>)) <none> nonpure)
    (field-set! store 'field1 item))

  (define-simple-method pop
    (((store <a>)) <integer> nonpure)
    (field-ref store 'field1))

  (define-param-signature :stack (%element) ()
    (push (this %element) <none> nonpure)
    (pop (this) %element nonpure))

  (define myproc
    (lambda (((s (:stack <integer>)) (item <integer>)) <integer> nonpure)
      (push s item)
      (pop s)))

  (define main
    (lambda (() <none> nonpure)
      (let ((mystack (make <a>)))
	(console-display-string (integer->string (myproc mystack 1)))
	(console-newline)))))
