Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[pct]: Add 'signature' attribute to PAST::Node, to explicitly request…

… a particular signature for evaluating children.
  • Loading branch information...
commit c89970666355580f44775200daa23bff948d1175 1 parent 8352b99
Patrick R. Michaud pmichaud authored
25 compilers/pct/src/PAST/Compiler.pir
View
@@ -758,15 +758,28 @@ nodes of type C<PAST::Stmts>.
.param pmc options :slurpy :named
.local pmc ops
- .local string rtype
+ .local string rtype, signature
rtype = options['rtype']
+
+ signature = node.'signature'()
+ if signature goto have_signature
$P0 = node.'list'()
$I0 = elements $P0
- $S0 = repeat 'v', $I0
- $S0 = concat $S0, rtype
- ops = self.'post_children'(node, 'signature'=>$S0)
- $P0 = ops[-1]
- ops.'result'($P0)
+ signature = repeat 'v', $I0
+ signature = concat signature, rtype
+ have_signature:
+ ops = self.'post_children'(node, 'signature'=>signature)
+ .local pmc result
+ result = ops[-1]
+ $S0 = substr signature, 0, 1
+ $I0 = index '0123456789', $S0
+ if $I0 < 0 goto have_result
+ result = ops[$I0]
+ have_result:
+ ops.'result'(result)
+ unless rtype goto rtype_done
+ ops = self.'coerce'(ops, rtype)
+ rtype_done:
.local pmc eh
eh = node.'handlers'()
unless eh, no_eh
14 compilers/pct/src/PAST/Node.pir
View
@@ -125,6 +125,20 @@ variable is being used in an lvalue context.
.end
+=item signature([signature])
+
+Get/set the signature to be used for evaluating any
+children nodes.
+
+=cut
+
+.sub 'signature' :method
+ .param pmc value :optional
+ .param int has_value :opt_flag
+ .tailcall self.'attr'('signature', value, has_value)
+.end
+
+
=item childorder([order])
Get/set the order in which children nodes should be evaluated
Please sign in to comment.
Something went wrong with that request. Please try again.