[svn:parrot] r49342 - trunk/compilers/pct/src/PAST

jonathan at svn.parrot.org jonathan at svn.parrot.org
Sun Sep 26 17:05:51 UTC 2010


Author: jonathan
Date: Sun Sep 26 17:05:50 2010
New Revision: 49342
URL: https://trac.parrot.org/parrot/changeset/49342

Log:
[pct] Add support for using the keyed version of get_attribute/set_attribute by supporting an optional second child in PAST::Var nodes of type attribute.

Modified:
   trunk/compilers/pct/src/PAST/Compiler.pir

Modified: trunk/compilers/pct/src/PAST/Compiler.pir
==============================================================================
--- trunk/compilers/pct/src/PAST/Compiler.pir	Sun Sep 26 14:00:33 2010	(r49341)
+++ trunk/compilers/pct/src/PAST/Compiler.pir	Sun Sep 26 17:05:50 2010	(r49342)
@@ -2391,11 +2391,19 @@
     name = node.'name'()
     name = self.'escape'(name)
 
+    # We have three cases here.
+    #   0 children = use self
+    #   1 child    = object to look up on
+    #   2 children = object to look up on + class handle
+    # In the last case, we need to generate a different form of the op that
+    # has the extra argument.
     .local pmc call_on
+    $I0 = elements node
+    if $I0 == 0 goto use_self
     call_on = node[0]
-    if null call_on goto use_self
     call_on = self.'as_post'(call_on, 'rtype'=>'P')
     ops.'push'(call_on)
+    if $I0 == 2 goto have_class_handle
     goto invocant_done
   use_self:
     call_on = box 'self'
@@ -2414,6 +2422,25 @@
     ops.'push_pirop'('setattribute', call_on, name, bindpost)
     ops.'result'(bindpost)
     .return (ops)
+
+  have_class_handle:
+    .local pmc handle
+    handle = node[1]
+    handle = self.'as_post'(handle, 'rtype'=>'P')
+    ops.'push'(handle)
+
+    if bindpost goto attribute_bind_handle
+
+    .local pmc fetchop, storeop
+    $P0 = get_hll_global ['POST'], 'Op'
+    fetchop = $P0.'new'(ops, call_on, handle, name, 'pirop'=>'getattribute')
+    storeop = $P0.'new'(call_on, handle, name, ops, 'pirop'=>'setattribute')
+    .tailcall self.'vivify'(node, ops, fetchop, storeop)
+
+  attribute_bind_handle:
+    ops.'push_pirop'('setattribute', call_on, handle, name, bindpost)
+    ops.'result'(bindpost)
+    .return (ops)
 .end
 
 


More information about the parrot-commits mailing list