-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdriver_nqp.pir
78 lines (62 loc) · 1.78 KB
/
driver_nqp.pir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# for devel
.namespace ['Eclectus']
.sub '__onload' :init
load_bytecode "dumper.pbc"
load_bytecode 'PGE.pbc'
load_bytecode 'PGE/Text.pbc'
load_bytecode 'PGE/Util.pbc'
load_bytecode 'PGE/Dumper.pbc'
load_bytecode 'PCT.pbc'
load_bytecode 'languages/eclectus/src/builtins/all.pbc'
# The dynamics PMCs used by Eclectus are loaded
loadlib $P1, 'pair'
#_dumper( 'p1', $P1 )
loadlib $P1, 'eclectus_group'
#_dumper( 'p1', $P1 )
.end
.sub drive :main
.param pmc argv
.local string program_name, nqp_fn
program_name = 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()
# compile and evaluate the PAST returned from scheme_entry()
.local pmc past_compiler
past_compiler = new [ 'PCT';'HLLCompiler' ]
$P0 = split ' ', 'post pir'
past_compiler.'stages'( $P0 )
$P1 = past_compiler.'eval'(stmts)
#_dumper ($P1)
$P0 = split ' ', 'evalpmc'
past_compiler.'stages'( $P0 )
past_compiler.'eval'( $P1 )
.end
.sub '__initconst' :init
$P0 = new 'EclectusBoolean'
$P0 = 1
set_root_global ['_eclectus'], '#t', $P0
$P0 = new 'EclectusBoolean'
set_root_global ['_eclectus'], '#f', $P0
$P0 = new 'EclectusEmptyList'
set_root_global ['_eclectus'], '()', $P0
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: