|
|
Author: pmichaud
Date: Fri Jun 29 18:40:28 2007
New Revision: 19501
Modified:
trunk/compilers/past-pm/PAST/Node.pir
trunk/compilers/past-pm/POST/Grammar.tg
trunk/compilers/past-pm/POST/Node.pir
Log:
[past-pm]:
* Add 'namespace' attribute to PAST::Block and POST::Sub nodes.
Modified: trunk/compilers/past-pm/PAST/Node.pir
==============================================================================
--- trunk/compilers/past-pm/PAST/Node.pir (original)
+++ trunk/compilers/past-pm/PAST/Node.pir Fri Jun 29 18:40:28 2007
@@ -645,6 +645,20 @@
.end
+=item namespace([STRING type])
+
+Set the namespace for this block. If no namespace is given,
+then this block will inherit the namespace of any outer block.
+
+=cut
+
+.sub 'namespace' :method
+ .param pmc value :optional
+ .param int has_value :opt_flag
+ .return self.'attr'('namespace', value, has_value)
+.end
+
+
=item symtable([value])
Get/set the symbol table for the block. In the current implementation,
Modified: trunk/compilers/past-pm/POST/Grammar.tg
==============================================================================
--- trunk/compilers/past-pm/POST/Grammar.tg (original)
+++ trunk/compilers/past-pm/POST/Grammar.tg Fri Jun 29 18:40:28 2007
@@ -13,18 +13,19 @@
transform post (PAST::Block) :language('PIR') {
- .local string name, pragma, blocktype
+ .local string name, pragma, blocktype, namespace
name = node.'name'()
if name != '' goto with_name
name = node.unique('_block')
with_name:
pragma = node.'pragma'()
blocktype = node.'blocktype'()
+ namespace = node.'namespace'()
.local pmc outerpost
outerpost = get_hll_global ['POST'], '$?SUB'
.local pmc post
post = new 'POST::Sub'
- post.'init'('node'=>node, 'name'=>name, 'outer'=>outerpost,
'pragma'=>pragma, 'blocktype'=>blocktype)
+ post.'init'('node'=>node, 'name'=>name, 'outer'=>outerpost,
'pragma'=>pragma, 'blocktype'=>blocktype, 'namespace'=>namespace)
set_hll_global ['POST'], '$?SUB', post
.local string compiler
compiler = node.'compiler'()
Modified: trunk/compilers/past-pm/POST/Node.pir
==============================================================================
--- trunk/compilers/past-pm/POST/Node.pir (original)
+++ trunk/compilers/past-pm/POST/Node.pir Fri Jun 29 18:40:28 2007
@@ -318,6 +318,11 @@
pragma = self.'pragma'()
.local pmc code
code = new 'PGE::CodeString'
+ .local string namespace
+ namespace = self.'namespace'()
+ unless namespace goto have_namespace
+ code.'emit'("\n.namespace [ '%0' ]", namespace)
+ have_namespace:
code.'emit'("\n.sub %0 %1 %2", name, outer, pragma)
$P0 = self.'paramcode'()
code .= $P0
@@ -433,6 +438,29 @@
.end
+=item namespace([name])
+
+Get/set the namespace for this sub. If called to retrieve the namespace,
+use any outer namespace if it exists.
+
+=cut
+
+.sub 'namespace' :method
+ .param pmc value :optional
+ .param int has_value :opt_flag
+ .local string namespace
+ namespace = self.'attr'('namespace', value, has_value)
+ if namespace goto end
+ if has_value goto end
+ .local pmc outer
+ outer = self.'outer'()
+ if null outer goto end
+ unless outer goto end
+ namespace = outer.'namespace'()
+ end:
+ .return (namespace)
+.end
+
=item paramcode([paramcode])
Get/set
|
|