( define (compile-program x)
  (emit ".sub main :main")
  (emit "say ~a" x)
  (emit ".end"))

; $Id$
; PAST-Generator for Eclectus

( define (compile-program x)

  (emit ".namespace")

  (emit ".sub '__onload' :init")
  (emit "    load_bytecode 'PGE.pbc'")
  (emit "    load_bytecode 'PGE/Text.pbc'")
  (emit "    load_bytecode 'PGE/Util.pbc'")
  (emit "    load_bytecode 'PGE/Dumper.pbc'")
  (emit "    load_bytecode 'PCT.pbc'")
  (emit ".end")
  (emit "")
  (emit ".sub main :main")
  (emit "")
  (emit "    .local pmc val_x")
  (emit "    val_x = new 'PAST::Val'")
  (emit "    val_x.init( 'value' => '~a', 'returns' => 'Integer' )" x )
  (emit "")
  (emit "    .local pmc var_last")
  (emit "    var_last = new 'PAST::Var'")
  (emit "    var_last.init( 'name' => 'last', 'scope' => 'package', 'lvalue' => 1 )")
  (emit "               ")
  (emit "    .local pmc op_bind")
  (emit "    op_bind = new 'PAST::Op'")
  (emit "    op_bind.init( var_last, val_x, 'pasttype' => 'bind' )")
  (emit "           ")
  (emit "    .local pmc op_say")
  (emit "    op_say = new 'PAST::Op'")
  (emit "    op_say.init( op_bind, 'name' => 'say', 'pasttype' => 'call' )")
  (emit "")
  (emit "    .local pmc stmts")
  (emit "    stmts = new 'PAST::Stmts'")
  (emit "    stmts.'init'( op_say, 'name'=>'stmts' )")
  (emit "")
  (emit "    # compile to PIR and display")
  (emit "    .local pmc astcompiler")
  (emit "    astcompiler = new [ 'PCT::HLLCompiler' ]")
  (emit "    astcompiler.'removestage'('parse')")
  (emit "    astcompiler.'removestage'('past')")
  (emit "")
  (emit "    astcompiler.'eval'(stmts)")
  (emit "")
  (emit ".end")
  (emit "")
  (emit "")
  (emit ".sub 'say'")
  (emit "    .param pmc args :slurpy")
  (emit "    if null args goto end")
  (emit "    .local pmc iter")
  (emit "    iter = new 'Iterator', args")
  (emit "  loop:")
  (emit "    unless iter goto end")
  (emit "    $P0 = shift iter")
  (emit "    print $P0")
  (emit "    goto loop")
  (emit "  end:")
  (emit "    say ''")
  (emit "    .return ()")
  (emit ".end"))


Use PCT-PAST in generated PIR.
[Eclectus]
Use PCT-PAST in generated PIR.


git-svn-id: 25691d43496b77c53f0b494379003863a981bfc4@23216 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
