Day 188 (r6230): Perl 6 compiled to Perl 5 data structures.

autrijus on 2005-08-13T19:39:38

This may not be exciting as compiling Perl 6 into Perl 5 programs, but it's exciting news nevertheless. With help from the amazingly flexible DrIFT, pugs -CPerl5 can now serialize the compiled PIL1 tree into a Perl 5 expression:

% ./pugs -CPerl5 -e "say 42"
bless({
    pilMain => bless({
        pStmt => 'PNoop',
        pStmts => bless({
            pStmt => bless({
                pPos => bless({
                    posName => "-e",
                    posBeginLine => 1,
                    posBeginColumn => 1,
                    posEndLine => 1,
                    posEndColumn => 7
                } => 'MkPos'),
                pExp => (undef),
                pNode => bless({
                    pExpr => bless({
                        pLV => bless({
                            pCxt => bless(['TCxtVoid'] => 'TTailCall'),
                            pFun => bless({
                                pLV => bless({
                                    pVarName => "&say"
                                } => 'PVar')
                            } => 'PExp'),
                            pInv => (undef),
                            pArgs => [
                                bless({
                                    pLit => bless({
                                        pVal => bless([42] => 'VInt')
                                    } => 'PVal')
                                } => 'PLit')
                            ]
                        } => 'PApp')
                    } => 'PExp')
                } => 'PStmt')
            } => 'PPos'),
            pStmts => 'PNil'
        } => 'PStmts')
    } => 'PStmts'),
    pilGlob => [
        bless({
            pSubName => "&*END",
            pSubType => "SubPrim",
            pSubParams => [],
            pSubBody => 'PNil'
        } => 'PSub')
    ]
} => 'PIL::Environment')

iblech expects PIL2JS compilation to be several times faster, once he switches it to use this representation. Furthermore, as the derive Perl5 works for any Haskell data type, we can load in PIL2 and their support structure in Perl 5 with no extra effort, which will greatly simplify the true Perl6-on-perl5 effort.

Tomorrow I'd like to work on -CYAML, -CXML and/or -CBinary, just to make sure that everybody can play with Pugs's internal structures, so we can have macros and refactoring browsers written in non-Haskell languages.