Author: bernhard
Date: Sat May 3 04:47:35 2008
New Revision: 27306
Modified:
trunk/languages/eclectus/driver_nqp.pir
trunk/languages/eclectus/tests-driver.scm
Log:
[Eclectus]
Move the NQP->PIR step from tests-driver.scm to driver_nqp.pir
Modified: trunk/languages/eclectus/driver_nqp.pir
==============================================================================
--- trunk/languages/eclectus/driver_nqp.pir (original)
+++ trunk/languages/eclectus/driver_nqp.pir Sat May 3 04:47:35 2008
@@ -23,18 +23,30 @@
.param pmc argv
- .local string program_name, pir_fn
+ .local string program_name, nqp_fn
program_name = shift argv
- pir_fn = shift argv
+ nqp_fn = shift argv
+ # compile NQP to PIR
+ .local string pir_fn, cmd
+ .local int ret
+ clone pir_fn, nqp_fn
+ substr pir_fn, -3, 3, 'pir'
+ cmd = "../../parrot ../../compilers/nqp/nqp.pbc --target=pir --output="
+ concat cmd, pir_fn
+ concat cmd, " "
+ concat cmd, nqp_fn
+ # say cmd
+ ret = spawnw cmd
+
+ # load the generated PIR
$S1 = concat "languages/eclectus/", pir_fn
load_bytecode $S1
.local pmc stmts
( stmts ) = scheme_entry()
- # _dumper( stmts, 'stmts' )
- # compile and evaluate
+ # compile and evaluate the PAST returned from scheme_entry()
.local pmc past_compiler
past_compiler = new [ 'PCT::HLLCompiler' ]
$P0 = split ' ', 'post pir'
Modified: trunk/languages/eclectus/tests-driver.scm
==============================================================================
--- trunk/languages/eclectus/tests-driver.scm (original)
+++ trunk/languages/eclectus/tests-driver.scm Sat May 3 04:47:35 2008
@@ -56,17 +56,16 @@
(error 'compile-port "not an output port ~s" p))
p)))
-(define (run-compile expr nqp-fn pir-fn)
+(define (run-compile expr nqp-fn)
(cond
( (string=? implementation "gauche")
(with-output-to-file "stst.scm" (lambda () (write expr))))
(else
+ ; compile to NQP
(let ((nqp-port (open-output-file nqp-fn 'replace)))
(parameterize ((compile-port nqp-port))
(compile-program expr))
- (close-output-port nqp-port))
- (unless (zero? (system (string-append *path-to-parrot* "
../../compilers/nqp/nqp.pbc --output=" pir-fn " --target=pir " nqp-fn)))
- (error 'execute "produced program exited abnormally")))))
+ (close-output-port nqp-port)))))
; TODO: can I use (directory-separator) in gauche?
(define *path-to-parrot*
@@ -74,13 +73,14 @@
"../../parrot"
"..\\..\\parrot"))
-(define (execute pir-fn)
+(define (execute nqp-fn)
(cond
( (string=? implementation "gauche")
(unless (zero? (system "gosh -fcase-fold -I . -l gauche/prelude.scm
stst.scm > stst.out"))
(error 'execute "produced program exited abnormally")))
(else
- (unless (zero? (system (string-append *path-to-parrot* " driver_nqp.pbc
" pir-fn " > stst.out")))
+ ; run NQP with driver_nqp.pbc
+ (unless (zero? (system (string-append *path-to-parrot* " driver_nqp.pbc
" nqp-fn " > stst.out")))
(error 'execute "produced program exited abnormally")))))
(define (get-string)
@@ -96,9 +96,9 @@
(f))))))))))
(define (test-with-string-output test-id expr expected-output test-name)
- (let ((base-fn (string-append "t/" test-name "_" (number->string test-id) )))
- (run-compile expr (string-append base-fn ".nqp") (string-append base-fn
".pir"))
- (execute (string-append base-fn ".pir")))
+ (let ((nqp-fn (string-append "t/" test-name "_" (number->string test-id)
".nqp" )))
+ (run-compile expr nqp-fn)
+ (execute nqp-fn))
(let ((actual-output (get-string)))
(if (string=? expected-output actual-output)
(pass ( + test-id 1 ) (format #f "~a: ~a" test-name expr))