Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4F2D6200C1D for ; Thu, 16 Feb 2017 12:36:12 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4DBBB160B61; Thu, 16 Feb 2017 11:36:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 75100160B57 for ; Thu, 16 Feb 2017 12:36:11 +0100 (CET) Received: (qmail 36084 invoked by uid 500); 16 Feb 2017 11:36:10 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 36074 invoked by uid 99); 16 Feb 2017 11:36:10 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2017 11:36:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 03BF71A0348 for ; Thu, 16 Feb 2017 11:36:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.8 X-Spam-Level: X-Spam-Status: No, score=-0.8 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=ameritech.net Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id YXBpc-rTMD9P for ; Thu, 16 Feb 2017 11:36:08 +0000 (UTC) Received: from nm5-vm4.access.bullet.mail.bf1.yahoo.com (nm5-vm4.access.bullet.mail.bf1.yahoo.com [216.109.114.131]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id B7AF05F370 for ; Thu, 16 Feb 2017 11:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ameritech.net; s=s2048; t=1487244958; bh=tN4w/kS9IWeFKQ+HW9ZUXG/kRk2sfG5sIvF3ReVTgK4=; h=Subject:Reply-To:References:To:From:Date:In-Reply-To:From:Subject; b=jdI4Yu/pveCsqI0kH08VgF6ze8JY9/9dIlfd4Df2LI6MJFgp3Q7Cdv+shD3CYSW04VskGZoBS2ESlq0SAgwh50CB4HvswVh0329QyROqjMrMSTmVSsdE5jOAKsedoAINBxtNeXT9GX2P89AfT3d8ArH2vTp7nAJ65pw72kSGaiZ64Qz0JfShFtJoQxXxIhhUWTshEtoPlfHjVozNWINaZkYIUvWukrCfCJDrB5nTFmXH11ymkA9/9gm+Eo2qxdGiMy0uhBHXIqHRxIjQIzpd2+uAb8eSoPDDt6TER974+PAOLGoXLSSr5wRp7H53bYgWmyMGLkI7xhkatUyGMcGqlw== Received: from [66.196.81.164] by nm5.access.bullet.mail.bf1.yahoo.com with NNFMP; 16 Feb 2017 11:35:58 -0000 Received: from [98.139.244.53] by tm10.access.bullet.mail.bf1.yahoo.com with NNFMP; 16 Feb 2017 11:35:58 -0000 Received: from [127.0.0.1] by smtp115.sbc.mail.bf1.yahoo.com with NNFMP; 16 Feb 2017 11:35:58 -0000 X-Yahoo-Newman-Id: 304184.92091.bm@smtp115.sbc.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: cRLrGuoVM1nMvvsn6t0Bty.0CdnYGkhwP2NgzJMHBl9iB2g W4qe.GptYyKmswIQEoFJkxkypdC.vz5dFMEgLUQIOS5RpcicQF3yheW31muO 8hIgR8KV7JSZMKUJkptgRSHMrFPc0Ok927v2aioYhH5i0bKBZhfhOou.wBa6 F3jr_2UgbGN8jaw0U7oFpcQ1qv.vksdgz.fCJTIoEIar3Xa.oJ87JT2t3y1J jKt5vmXw4GVvBAAvjMDZCc0ej4a8r_dF1z3LQYLO27s6LIq3_PxQ_nk8OFZO vNvgmt.QRy.MTgFdXqH9uitP8wHSP1481S.4ZqKOQx3mGMTpRWbYx0i4Jkj8 rZIWMK_XRUdbjyyZ.FaXsPwrRMaKukZKtX1vBnjqfvFMXqnzNbmGrt7419Z_ MNAqS9BNec_0UIfXnLWUujWKtANHNjCxTyLwj2HH_WBTyVvth5pwFzqqx0RS t._UmF..J6O8VGV63lDh4bE05nzX9MQK0YRPUpY4movh.uCP7depsPmKzrhQ .3P2vLnDtH6_ok1dPMV5hTvptaKmTgi2MLG7hSn8dH4BROZTL.OYdSoP.z5K Yt5NJeg-- X-Yahoo-SMTP: Bq.YuS2swBAnAqrQertsUb6eYlocRqEVdq4_Cfw6KBXRHg-- Subject: Re: help with an AST Reply-To: users@groovy.apache.org References: <5866C1A8.6020809@gmx.org> <337fe01e-3af4-5345-cd5f-8836cd565a94@ameritech.net> <10564426-910c-7a84-1cdb-c6f3a75c57b1@gmx.org> <2af0d74f-d064-1bd2-d44e-830e7a49c086@ameritech.net> To: users@groovy.apache.org From: Ed Clark Message-ID: Date: Thu, 16 Feb 2017 06:35:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit archived-at: Thu, 16 Feb 2017 11:36:12 -0000 Ok, a little more headbanging and I seem to have gotten farther (maybe?). At least the error message has changed. Now I'm getting: BUG! exception in phase 'class generation' in source unit 'CtxTest2.groovy' Operation: (: "=" ) not supported Searching hasn't helped with this one. The xform-ed code looks good -- in fact, if I type the code into a separate groovyConsole, it will run. (The console AST generation works up thru the Instruction Selection phase, obviously.) I'm guessing it's still with how I'm setting up the scoping (or how I'm not setting up the scoping). Ideas, please? Thanks, Ed On 02/14/2017 12:58 PM, Ed Clark wrote: > On 02/14/2017 12:16 PM, Jochen Theodorou wrote: >> >> >> On 14.02.2017 12:41, Ed Clark wrote: >>> Hi Jochen, >>> >>> Well, I've been slowly making progress on this; kind of feels like >>> bashing my >>> head against a wall at times, but I have made a small hole in the wall >>> through >>> which I can see my goal. ;-) >> >> making holes my lead to brain damage.. then things get really hard to solve ;) > Maybe I'm too late, and that's why things aren't coming together ;) > >> >> [...] >>> Specifically, I haven't figured out how to inject a variable into the >>> scope of an outer >>> with's closure that can be used by code in an interior with's closure. >>> For example, >>> consider >>> >>> myCtx1.with { >>> __outerCtx1 = null // injected statement >>> __currCtx1 = myCtx1 // injected statement >>> .... some code ... >>> myCtx2.with { >>> __outerCtx2 = __currCtx1 // injected statement <--- doesn't >>> work >>> __currCtx2 = myCtx2 // injected statement >> >> where is __currCtx1 and __outerCtx1 coming from? Are they supposed to be new local variables? in >> that case you will have to add a DeclarationStatement, not just an assignment to a >> VariableExpression. Otherwise the compiler will thnk they are dynamic properties and tries to >> resolve them against the context. >> >> as for the logic behind __outerCtxN... with number wouldn't have to be null I would have said you >> should think of using getOwner on Closure >> > Hmmm, I'm close to that, but not quite the same. I was trying > > ExpressionStatement currCtx = new ExpressionStatement( > new DeclarationExpression ( > new VariableExpression( "__currCtx$levelcnt"), > new Token( Types.ASSIGNMENT_OPERATOR, "=", -1, -1), > new MethodCallExpression( new VariableExpression( 'this'), 'getDelegate', new > ArgumentListExpression()) > ) > ) > > Would a DeclarationStatment act differently from an ExpressionStatement with an embedded > DeclarationExpression? If my foggy memory is correct, I wrote my code after looking at the > AST displayed for a short test script in groovyConsole. > > Plus, if foggy memory serves, I tried using getOwner and it came back with the closure being > owned by the test script, not the object doing the with. Calling getDelegate gave me the object. > If foggy memory serves. > > I also tried playing around with setClosureSharedVariable( true) and putReferencedLocalVariable() > without success. But, those were somewhat blind stabs in the dark, so I might not have been > using them correctly. > > Looking at the AST generated by groovyConsole, my transform looks like it is working, but > the compiler complains about things not being in scope (in the inner closure). So, I'm doing > something wrong with setting up the scoping. > >> bye Jochen > > Thanks, > > Ed >