
Hello. I'm working on the translation of GHC's STG language to JavaScript. I've started my implementation, but I've got stuck with the STG case statements. The problem is the binder in case expression. StgCase expr livevars liverhsvars bndr srt alttype alts Operationally, I need to save continuation and evaluate expr expression, but I have no idea what to do with the bndr. It seems to me that I need to build a closure binded by bndr with the body of expr evaluate it, update it, and use it in RHSs of alternatives. But It seems that this behavior isn't intended by GHC. Can you explain briefly how GHC implements this binder and what this binder points to. Here are some notes about Dmitries last year activity and my activity: http://haskell.org/haskellwiki/STG_in_Javascript -- vir http://vir.comtv.ru/

Hi
Are you aware that Dimitry is still working on ycr2js - and has made
great progress. There are details available in The Monad Reader, issue
7 (http://www.haskell.org/haskellwiki/The_Monad.Reader)
Thanks
Neil
On 9/17/07, Victor Nazarov
Hello. I'm working on the translation of GHC's STG language to JavaScript. I've started my implementation, but I've got stuck with the STG case statements. The problem is the binder in case expression.
StgCase expr livevars liverhsvars bndr srt alttype alts
Operationally, I need to save continuation and evaluate expr expression, but I have no idea what to do with the bndr. It seems to me that I need to build a closure binded by bndr with the body of expr evaluate it, update it, and use it in RHSs of alternatives. But It seems that this behavior isn't intended by GHC. Can you explain briefly how GHC implements this binder and what this binder points to.
Here are some notes about Dmitries last year activity and my activity: http://haskell.org/haskellwiki/STG_in_Javascript
-- vir http://vir.comtv.ru/ _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Victor Nazarov wrote:
Hello. I'm working on the translation of GHC's STG language to JavaScript. I've started my implementation, but I've got stuck with the STG case statements. The problem is the binder in case expression.
StgCase expr livevars liverhsvars bndr srt alttype alts
Operationally, I need to save continuation and evaluate expr expression, but I have no idea what to do with the bndr. It seems to me that I need to build a closure binded by bndr with the body of expr evaluate it, update it, and use it in RHSs of alternatives. But It seems that this behavior isn't intended by GHC. Can you explain briefly how GHC implements this binder and what this binder points to.
It should be easy to implement: the value of expr is bound to bndr within the alternatives. Cheers, Simon

case e of b { pati -> rhsi } * evaluates 'e', * binds the resulting value to 'b', * performs case analysis on the result to find which alternative to choose * binds the variables of the pattern to the components of the value This is described in the GHC commentary: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType does that help? Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org] On | Behalf Of Victor Nazarov | Sent: 17 September 2007 11:48 | To: glasgow-haskell-users@haskell.org | Subject: STG to JavaScript translation | | Hello. | I'm working on the translation of GHC's STG language to | JavaScript. I've started my implementation, but I've got stuck with | the STG case statements. The problem is the binder in case expression. | | StgCase expr livevars liverhsvars bndr srt alttype alts | | Operationally, I need to save continuation and evaluate expr | expression, but I have no idea what to do with the bndr. It seems to | me that I need to build a closure binded by bndr with the body of | expr evaluate it, update it, and use it in RHSs of alternatives. | But It seems that this behavior isn't intended by GHC. Can you explain briefly | how GHC implements this binder and what this binder points to. | | Here are some notes about Dmitries last year activity and my activity: | http://haskell.org/haskellwiki/STG_in_Javascript | | -- | vir | http://vir.comtv.ru/ | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Hi
case e of b { pati -> rhsi }
* evaluates 'e', * binds the resulting value to 'b', * performs case analysis on the result to find which alternative to choose * binds the variables of the pattern to the components of the value
The Yhc.Core translator converts this to: let b = e in case b of { pati -> rhsi } I'm not sure if that would be a clearer form for you to work with, as it is closer to standard Haskell. Thanks Neil

On Mon, 17 Sep 2007, Neil Mitchell wrote:
Hi
case e of b { pati -> rhsi }
* evaluates 'e', * binds the resulting value to 'b', * performs case analysis on the result to find which alternative to choose * binds the variables of the pattern to the components of the value
The Yhc.Core translator converts this to:
let b = e in case b of { pati -> rhsi }
I'm not sure if that would be a clearer form for you to work with, as it is closer to standard Haskell.
Definitely not, let allocates. -- flippa@flippac.org There is no magic bullet. There are, however, plenty of bullets that magically home in on feet when not used in exactly the right circumstances.
participants (5)
-
Neil Mitchell
-
Philippa Cowderoy
-
Simon Marlow
-
Simon Peyton-Jones
-
Victor Nazarov