;; -*-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 test629)


  (import (standard-library core)
	  (standard-library console-io))


  (define-param-class :a (%element) <object> #t #f #f public ()
    ((field1 %element public module 0)))

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

  (define-param-method push 
      (%element)
      (((store (:a %element)) (item %element)) <none> nonpure)
    (field-set! store 'field1 item))

  (define-param-method pop
      (%element)
      (((store (:a %element))) <integer> nonpure)
    (field-ref store 'field1))

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

  (define-param-method myproc (%type)
		       (((s (:stack %type)) (item %type)) %type nonpure)
    (push s item)
    (pop s))

  (define main
    (lambda (() <none> nonpure)
      (let ((mystack (make (:a <integer>))))
	(console-display-line (myproc (static-cast (:stack <integer>) mystack)
				      1))))))
