From 37ca131c03bcc4b2b9e761e93bcc0e9be7ba4786 Mon Sep 17 00:00:00 2001
From: bothner <bothner@5e0a886f-7f45-49c5-bc19-40643649e37f>
Date: Thu, 16 Jun 2011 18:15:13 +0000
Subject: [PATCH 1/1] 	* CompileInvoke.java (validateApplyInvoke): Use
 ALLOCATE_ON_STACK 	instead of SlotSet.setFieldReturnObject. 	*
 SlotSet.java (returnSelf, setFieldReturnObject): Remove fields. 
 (apply3, compile) Remove support for returnSelf option. 	*
 CompileReflect.java (validateApplySlotSet): Likewise.

	* Declaration.java (load): Generalize ALLOCATE_ON_STACK to handle
	targets other than StackTarget, plus stack growth by one.
	* ReferenceExp.java (compile): Disable compileWrite optimization
	if ALLOCATE_ON_STACK is set.


git-svn-id: http://sourceware.org/svn/kawa/trunk@6990 5e0a886f-7f45-49c5-bc19-40643649e37f
---
 gnu/expr/ChangeLog                   |  7 +++++++
 gnu/expr/Declaration.java            | 23 +++++++++++++++--------
 gnu/expr/ReferenceExp.java           |  1 +
 gnu/kawa/reflect/ChangeLog           |  8 ++++++++
 gnu/kawa/reflect/CompileInvoke.java  | 22 ++++++++++++----------
 gnu/kawa/reflect/CompileReflect.java |  4 +---
 gnu/kawa/reflect/SlotSet.java        | 16 ++--------------
 7 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/gnu/kawa/reflect/CompileInvoke.java b/gnu/kawa/reflect/CompileInvoke.java
index d02386b..4e30422 100644
--- a/gnu/kawa/reflect/CompileInvoke.java
+++ b/gnu/kawa/reflect/CompileInvoke.java
@@ -283,6 +283,10 @@ public class CompileInvoke
                 Expression e = ae;
                 if (args.length > 0)
                   {
+                    comp.letStart();
+                    Declaration adecl = comp.letVariable((String) null, ctype, e);
+                    adecl.setFlag(Declaration.ALLOCATE_ON_STACK);
+                    BeginExp begin = new BeginExp();
                     for (int i = 0;  i < slots.length;  i++)
                       {
                         Object slot = slots[i];
@@ -296,20 +300,18 @@ public class CompileInvoke
                         if (stype != null)
                           stype = iproc.language.getLangTypeFor(stype);
                         Expression arg = visitor.visit(args[keywordStart + 2 * i + 1], stype);
+                        ReferenceExp aref = new ReferenceExp(adecl);
                         Expression[] sargs
-                          = { ae, new QuoteExp(slot), arg};
-                        ae = new ApplyExp(SlotSet.setFieldReturnObject, sargs);
+                          = { visitor.visit(aref, null), new QuoteExp(slot), arg};
+                        ae = new ApplyExp(SlotSet.set$Mnfield$Ex, sargs);
                         ae.setType(ctype);
+                        begin.add(ae);
                       }
                     int sargs = keywordStart == args.length ? 1
                       : 2 * slots.length + keywordStart;
                     e = ae;
                     if (sargs < args.length)
                       {
-                        comp.letStart();
-                        Declaration adecl = comp.letVariable((String) null, ctype, e);
-                        adecl.setFlag(Declaration.ALLOCATE_ON_STACK);
-                        BeginExp begin = new BeginExp();
                         for (int i = sargs;  i < args.length;  i++)
                           {
                             Expression[] iargs = {
@@ -321,11 +323,11 @@ public class CompileInvoke
                                                                  iargs),
                                                     null));
                           }
-                        ReferenceExp aref = new ReferenceExp(adecl);
-                        aref.setFlag(ReferenceExp.ALLOCATE_ON_STACK_LAST);
-                        begin.add(aref);
-                        e = comp.letDone(begin);
                       }
+                    ReferenceExp aref = new ReferenceExp(adecl);
+                    aref.setFlag(ReferenceExp.ALLOCATE_ON_STACK_LAST);
+                    begin.add(aref);
+                    e = comp.letDone(begin);
                   }
                 return visitor.checkType(e.setLine(exp), required);
               }
