[svn:parrot] r49325 - in trunk/compilers/pct/src: PAST POST
jonathan at svn.parrot.org
jonathan at svn.parrot.org
Sat Sep 25 22:46:44 UTC 2010
Author: jonathan
Date: Sat Sep 25 22:46:43 2010
New Revision: 49325
URL: https://trac.parrot.org/parrot/changeset/49325
Log:
[pct] Add a way to tag a block with libs that it requires, which are compiled to .loadlib directives.
Modified:
trunk/compilers/pct/src/PAST/Compiler.pir
trunk/compilers/pct/src/PAST/Node.pir
trunk/compilers/pct/src/POST/Compiler.pir
trunk/compilers/pct/src/POST/Node.pir
Modified: trunk/compilers/pct/src/PAST/Compiler.pir
==============================================================================
--- trunk/compilers/pct/src/PAST/Compiler.pir Sat Sep 25 13:02:25 2010 (r49324)
+++ trunk/compilers/pct/src/PAST/Compiler.pir Sat Sep 25 22:46:43 2010 (r49325)
@@ -812,7 +812,7 @@
unshift blockpast, node
.local string name, pirflags, blocktype
- .local pmc nsentry, subid, ns, hll, multi
+ .local pmc nsentry, subid, ns, hll, multi, loadlibs
name = node.'name'()
pirflags = node.'pirflags'()
blocktype = node.'blocktype'()
@@ -821,6 +821,7 @@
ns = node.'namespace'()
hll = node.'hll'()
multi = node.'multi'()
+ loadlibs = node.'loadlibs'()
## handle nsentry attribute
$I0 = defined nsentry
@@ -846,7 +847,7 @@
## create a POST::Sub node for this block
.local pmc bpost
$P0 = get_hll_global ['POST'], 'Sub'
- bpost = $P0.'new'('node'=>node, 'name'=>name, 'blocktype'=>blocktype, 'namespace'=>ns, 'hll'=>hll, 'subid'=>subid, 'multi'=>multi)
+ bpost = $P0.'new'('node'=>node, 'name'=>name, 'blocktype'=>blocktype, 'namespace'=>ns, 'hll'=>hll, 'subid'=>subid, 'multi'=>multi, 'loadlibs'=>loadlibs)
unless pirflags goto pirflags_done
bpost.'pirflags'(pirflags)
pirflags_done:
@@ -931,8 +932,9 @@
$S0 = self.'unique'('control_')
ctrllabel = $P0.'new'('result'=>$S0)
$S0 = self.'uniquereg'('P')
- bpost.'push_pirop'('new', $S0, "['ExceptionHandler']", '.CONTROL_RETURN')
+ bpost.'push_pirop'('new', $S0, "'ExceptionHandler'")
bpost.'push_pirop'('set_addr', $S0, ctrllabel)
+ bpost.'push_pirop'('callmethod', '"handle_types"', $S0, '.CONTROL_RETURN')
bpost.'push_pirop'('push_eh', $S0)
bpost.'add_directive'('.include "except_types.pasm"')
@@ -2086,7 +2088,7 @@
$S0 = files
sourceline = concat ' (', $S0
concat sourceline, ':'
- $I0 = self.'lineof'(source, pos)
+ $I0 = source.'lineof'(pos)
inc $I0
$S0 = $I0
concat sourceline, $S0
Modified: trunk/compilers/pct/src/PAST/Node.pir
==============================================================================
--- trunk/compilers/pct/src/PAST/Node.pir Sat Sep 25 13:02:25 2010 (r49324)
+++ trunk/compilers/pct/src/PAST/Node.pir Sat Sep 25 22:46:43 2010 (r49325)
@@ -601,6 +601,21 @@
.end
+=item loadlibs([lib1, lib2, ...])
+
+Get/set the libraries to be loaded at startup. EXPERIMENTAL (not subject to
+deprecation policy, yet).
+
+=cut
+
+.sub 'loadlibs' :method
+ .param pmc libs :slurpy
+ .local int has_value
+ has_value = elements libs
+ .tailcall self.'attr'('loadlibs', libs, has_value)
+.end
+
+
=item nsentry([nsentry])
Get/set the C<nsentry> for this block.
Modified: trunk/compilers/pct/src/POST/Compiler.pir
==============================================================================
--- trunk/compilers/pct/src/POST/Compiler.pir Sat Sep 25 13:02:25 2010 (r49324)
+++ trunk/compilers/pct/src/POST/Compiler.pir Sat Sep 25 22:46:43 2010 (r49325)
@@ -130,8 +130,9 @@
pos = cpost['pos']
if null pos goto done_subline
source = cpost['source']
- if null source goto done_subline
- line = self.'lineof'(source, pos, 'cache'=>1)
+ $I0 = can source, 'lineof'
+ unless $I0 goto done_subline
+ line = source.'lineof'(pos)
inc line
done_subline:
self.'pir'(cpost)
@@ -362,9 +363,20 @@
goto subpir_done
subpir_post:
- unless hll goto subpir_ns
+ unless hll goto subpir_loadlibs
$P0 = self.'escape'(hll)
subpir.'append_format'("\n.HLL %0\n", $P0)
+ subpir_loadlibs:
+ $P0 = node.'loadlibs'()
+ if null $P0 goto subpir_ns
+ unless $P0 goto subpir_ns
+ $P1 = iter $P0
+ subpir_loadlibs_loop:
+ unless $P1 goto subpir_ns
+ $P2 = shift $P1
+ $P2 = self.'escape'($P2)
+ subpir.'append_format'("\n.loadlib %0\n", $P2)
+ goto subpir_loadlibs_loop
subpir_ns:
subpir.'append_format'("\n.namespace %0\n", nskey)
subpir_directives:
Modified: trunk/compilers/pct/src/POST/Node.pir
==============================================================================
--- trunk/compilers/pct/src/POST/Node.pir Sat Sep 25 13:02:25 2010 (r49324)
+++ trunk/compilers/pct/src/POST/Node.pir Sat Sep 25 22:46:43 2010 (r49325)
@@ -194,6 +194,13 @@
.end
+.sub 'loadlibs' :method
+ .param pmc value :optional
+ .param int has_value :opt_flag
+ .tailcall self.'attr'('loadlibs', value, has_value)
+.end
+
+
.sub 'outer' :method
.param pmc value :optional
.param int has_value :opt_flag
More information about the parrot-commits
mailing list